diff options
Diffstat (limited to 'source4/torture/basic/charset.c')
-rw-r--r-- | source4/torture/basic/charset.c | 58 |
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; } |