From ae274c84d734165f6af8356a15d38c56b7d07406 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 11 Aug 2004 21:11:37 +0000 Subject: r1740: fixed the torture suite for ASCII-only servers (This used to be commit c3bce90be745db3e7cbf8273c1c8496920332f5e) --- source4/torture/raw/notify.c | 2 +- source4/torture/raw/qfileinfo.c | 6 +++--- source4/torture/raw/qfsinfo.c | 2 +- source4/torture/raw/search.c | 4 ++-- source4/torture/torture_util.c | 11 +++++++++-- 5 files changed, 16 insertions(+), 9 deletions(-) (limited to 'source4') diff --git a/source4/torture/raw/notify.c b/source4/torture/raw/notify.c index 6e7cf218ea..aec92bf641 100644 --- a/source4/torture/raw/notify.c +++ b/source4/torture/raw/notify.c @@ -40,7 +40,7 @@ }} while (0) #define CHECK_WSTR(field, value, flags) do { \ - if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags)) { \ + if (!field.s || strcmp(field.s, value) || wire_bad_flags(&field, flags, cli)) { \ printf("(%d) %s [%s] != %s\n", __LINE__, #field, field.s, value); \ ret = False; \ goto done; \ diff --git a/source4/torture/raw/qfileinfo.c b/source4/torture/raw/qfileinfo.c index 251a2de85d..951769d4da 100644 --- a/source4/torture/raw/qfileinfo.c +++ b/source4/torture/raw/qfileinfo.c @@ -503,14 +503,14 @@ BOOL torture_raw_qfileinfo(int dummy) #define NAME_CHECK(sname, stype, tfield, flags) do { \ s1 = fnum_find(sname); \ if (s1 && (strcmp(s1->stype.out.tfield.s, correct_name) != 0 || \ - wire_bad_flags(&s1->stype.out.tfield, flags))) { \ + wire_bad_flags(&s1->stype.out.tfield, flags, cli))) { \ printf("(%d) handle %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ ret = False; \ } \ s1 = fname_find(sname); \ if (s1 && (strcmp(s1->stype.out.tfield.s, correct_name) != 0 || \ - wire_bad_flags(&s1->stype.out.tfield, flags))) { \ + wire_bad_flags(&s1->stype.out.tfield, flags, cli))) { \ printf("(%d) path %s/%s incorrect - '%s/%d'\n", __LINE__, #stype, #tfield, \ s1->stype.out.tfield.s, s1->stype.out.tfield.private_length); \ ret = False; \ @@ -538,7 +538,7 @@ BOOL torture_raw_qfileinfo(int dummy) ret = False; } } - if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE)) { + if (wire_bad_flags(&s1->all_info.out.fname, STR_UNICODE, cli)) { printf("Should not null terminate all_info/fname\n"); ret = False; } diff --git a/source4/torture/raw/qfsinfo.c b/source4/torture/raw/qfsinfo.c index 41bc09f94e..10b9605147 100644 --- a/source4/torture/raw/qfsinfo.c +++ b/source4/torture/raw/qfsinfo.c @@ -275,7 +275,7 @@ BOOL torture_raw_qfsinfo(int dummy) #define STR_CHECK(sname, stype, field, flags) do { \ s1 = find(sname); \ if (s1) { \ - if (wire_bad_flags(&s1->stype.out.field, flags)) { \ + if (wire_bad_flags(&s1->stype.out.field, flags, cli)) { \ printf("(%d) incorrect string termination in %s/%s\n", \ __LINE__, #stype, #field); \ ret = False; \ diff --git a/source4/torture/raw/search.c b/source4/torture/raw/search.c index 55dd732e6a..f91c8083a5 100644 --- a/source4/torture/raw/search.c +++ b/source4/torture/raw/search.c @@ -235,7 +235,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (s) { \ if (!s->sname1.field1.s || \ strcmp(s->sname1.field1.s, v.sname2.out.field2.s) || \ - wire_bad_flags(&s->sname1.field1, flags)) { \ + wire_bad_flags(&s->sname1.field1, flags, cli)) { \ printf("(%d) %s/%s [%s] != %s/%s [%s]\n", \ __LINE__, \ #sname1, #field1, s->sname1.field1.s, \ @@ -249,7 +249,7 @@ static BOOL test_one_file(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) if (s) { \ if (!s->sname1.field1.s || \ strcmp(s->sname1.field1.s, fname) || \ - wire_bad_flags(&s->sname1.field1, flags)) { \ + wire_bad_flags(&s->sname1.field1, flags, cli)) { \ printf("(%d) %s/%s [%s] != %s\n", \ __LINE__, \ #sname1, #field1, s->sname1.field1.s, \ diff --git a/source4/torture/torture_util.c b/source4/torture/torture_util.c index bb7f6eb4c2..c39aa0ad5e 100644 --- a/source4/torture/torture_util.c +++ b/source4/torture/torture_util.c @@ -193,13 +193,20 @@ void *shm_setup(int size) check that a wire string matches the flags specified not 100% accurate, but close enough for testing */ -BOOL wire_bad_flags(WIRE_STRING *str, int flags) +BOOL wire_bad_flags(WIRE_STRING *str, int flags, struct smbcli_state *cli) { + BOOL server_unicode; int len; if (!str || !str->s) return True; len = strlen(str->s); if (flags & STR_TERMINATE) len++; - if ((flags & STR_UNICODE) || !getenv("CLI_FORCE_ASCII")) { + + server_unicode = (cli->transport->negotiate.capabilities&CAP_UNICODE)?True:False; + if (getenv("CLI_FORCE_ASCII") || !lp_unicode()) { + server_unicode = False; + } + + if ((flags & STR_UNICODE) || server_unicode) { len *= 2; } else if (flags & STR_TERMINATE_ASCII) { len++; -- cgit