summaryrefslogtreecommitdiff
path: root/source4/torture/basic/charset.c
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2006-10-16 13:06:41 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:21:12 -0500
commit8773e743c518578584d07d35ffdafdd598af88b0 (patch)
tree89726232dd6ae9eca1c219e21729a9b2336ddaa9 /source4/torture/basic/charset.c
parent0f2347e417dec4a50f95d64353b260cd53a44a2b (diff)
downloadsamba-8773e743c518578584d07d35ffdafdd598af88b0.tar.gz
samba-8773e743c518578584d07d35ffdafdd598af88b0.tar.bz2
samba-8773e743c518578584d07d35ffdafdd598af88b0.zip
r19339: Merge my 4.0-unittest branch. This adds an API for more fine-grained
output in the testsuite rather than just True or False for a set of tests. The aim is to use this for: * known failure lists (run all tests and detect tests that started working or started failing). This would allow us to get rid of the RPC-SAMBA3-* tests * nicer torture output * simplification of the testsuite system * compatibility with other unit testing systems * easier usage of smbtorture (being able to run one test and automatically set up the environment for that) This is still a work-in-progress; expect more updates over the next couple of days. (This used to be commit 0eb6097305776325c75081356309115f445a7218)
Diffstat (limited to 'source4/torture/basic/charset.c')
-rw-r--r--source4/torture/basic/charset.c58
1 files changed, 28 insertions, 30 deletions
diff --git a/source4/torture/basic/charset.c b/source4/torture/basic/charset.c
index d7e53ae92a..d7172e9cec 100644
--- a/source4/torture/basic/charset.c
+++ b/source4/torture/basic/charset.c
@@ -26,14 +26,15 @@
#include "libcli/libcli.h"
#include "torture/util.h"
-#define BASEDIR "\\chartest"
+#define BASEDIR "\\chartest\\"
/*
open a file using a set of unicode code points for the name
the prefix BASEDIR is added before the name
*/
-static NTSTATUS unicode_open(struct smbcli_tree *tree,
+static NTSTATUS unicode_open(struct torture_context *tctx,
+ struct smbcli_tree *tree,
TALLOC_CTX *mem_ctx,
uint32_t open_disposition,
const uint32_t *u_name,
@@ -57,12 +58,12 @@ static NTSTATUS unicode_open(struct smbcli_tree *tree,
i = convert_string_talloc(ucs_name, CH_UTF16, CH_UNIX, ucs_name, (1+u_name_len)*2, (void **)&fname);
if (i == -1) {
- printf("Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
+ torture_comment(tctx, "Failed to convert UCS2 Name into unix - convert_string_talloc() failure\n");
talloc_free(ucs_name);
return NT_STATUS_NO_MEMORY;
}
- fname2 = talloc_asprintf(ucs_name, "%s\\%s", BASEDIR, fname);
+ fname2 = talloc_asprintf(ucs_name, "%s%s", BASEDIR, fname);
if (!fname2) {
talloc_free(ucs_name);
return NT_STATUS_NO_MEMORY;
@@ -93,7 +94,8 @@ static NTSTATUS unicode_open(struct smbcli_tree *tree,
/*
see if the server recognises composed characters
*/
-static BOOL test_composed(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_composed(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0x61, 0x308};
const uint32_t name2[] = {0xe4};
@@ -101,14 +103,14 @@ static BOOL test_composed(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Testing composite character (a umlaut)\n");
- status1 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2);
+ status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 2);
if (!NT_STATUS_IS_OK(status1)) {
printf("Failed to create composed name - %s\n",
nt_errstr(status1));
return False;
}
- status2 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
if (!NT_STATUS_IS_OK(status2)) {
printf("Failed to create accented character - %s\n",
@@ -122,7 +124,8 @@ static BOOL test_composed(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/*
see if the server recognises a naked diacritical
*/
-static BOOL test_diacritical(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_diacritical(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0x308};
const uint32_t name2[] = {0x308, 0x308};
@@ -130,7 +133,7 @@ static BOOL test_diacritical(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Testing naked diacritical (umlaut)\n");
- status1 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ status1 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
if (!NT_STATUS_IS_OK(status1)) {
printf("Failed to create naked diacritical - %s\n",
@@ -139,7 +142,7 @@ static BOOL test_diacritical(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
}
/* try a double diacritical */
- status2 = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2);
+ status2 = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 2);
if (!NT_STATUS_IS_OK(status2)) {
printf("Failed to create double naked diacritical - %s\n",
@@ -153,7 +156,8 @@ static BOOL test_diacritical(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/*
see if the server recognises a partial surrogate pair
*/
-static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_surrogate(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {0xd800};
const uint32_t name2[] = {0xdc00};
@@ -162,7 +166,7 @@ static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Testing partial surrogate\n");
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to create partial surrogate 1 - %s\n",
@@ -170,7 +174,7 @@ static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return False;
}
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to create partial surrogate 2 - %s\n",
@@ -178,7 +182,7 @@ static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return False;
}
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 2);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to create full surrogate - %s\n",
@@ -192,7 +196,8 @@ static BOOL test_surrogate(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
/*
see if the server recognises wide-a characters
*/
-static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
+static BOOL test_widea(struct torture_context *tctx,
+ struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
{
const uint32_t name1[] = {'a'};
const uint32_t name2[] = {0xff41};
@@ -201,7 +206,7 @@ static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
printf("Testing wide-a\n");
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name1, 1);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to create 'a' - %s\n",
@@ -209,7 +214,7 @@ static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return False;
}
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name2, 1);
if (!NT_STATUS_IS_OK(status)) {
printf("Failed to create wide-a - %s\n",
@@ -217,7 +222,7 @@ static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return False;
}
- status = unicode_open(cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1);
+ status = unicode_open(tctx, cli->tree, mem_ctx, NTCREATEX_DISP_CREATE, name3, 1);
if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) {
printf("Expected %s creating wide-A - %s\n",
@@ -229,37 +234,30 @@ static BOOL test_widea(struct smbcli_state *cli, TALLOC_CTX *mem_ctx)
return True;
}
-BOOL torture_charset(struct torture_context *torture)
+BOOL torture_charset(struct torture_context *tctx, struct smbcli_state *cli)
{
- static struct smbcli_state *cli;
BOOL ret = True;
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init("torture_charset");
- if (!torture_open_connection(&cli, 0)) {
- return False;
- }
-
- printf("Starting charset tests\n");
-
if (!torture_setup_dir(cli, BASEDIR)) {
return False;
}
- if (!test_composed(cli, mem_ctx)) {
+ if (!test_composed(tctx, cli, mem_ctx)) {
ret = False;
}
- if (!test_diacritical(cli, mem_ctx)) {
+ if (!test_diacritical(tctx, cli, mem_ctx)) {
ret = False;
}
- if (!test_surrogate(cli, mem_ctx)) {
+ if (!test_surrogate(tctx, cli, mem_ctx)) {
ret = False;
}
- if (!test_widea(cli, mem_ctx)) {
+ if (!test_widea(tctx, cli, mem_ctx)) {
ret = False;
}