From 8773e743c518578584d07d35ffdafdd598af88b0 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 16 Oct 2006 13:06:41 +0000 Subject: 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) --- source4/auth/gensec/cyrus_sasl.c | 2 +- source4/lib/appweb/mpr/var.h | 2 +- source4/lib/crypto/sha1test.c | 54 +- source4/lib/talloc/testsuite.c | 499 ++--- source4/rpc_server/echo/rpc_echo.c | 2 +- source4/script/tests/test_nbt.sh | 3 +- source4/script/tests/test_posix.sh | 4 +- source4/script/tests/test_w2k3_file.sh | 4 +- source4/scripting/ejs/smbscript.c | 2 +- source4/torture/auth/ntlmssp.c | 46 +- source4/torture/auth/pac.c | 281 ++- source4/torture/basic/aliases.c | 197 +- source4/torture/basic/attr.c | 66 +- source4/torture/basic/base.c | 923 ++++------ source4/torture/basic/charset.c | 58 +- source4/torture/basic/delaywrite.c | 209 +-- source4/torture/basic/delete.c | 1118 ++++-------- source4/torture/basic/denytest.c | 157 +- source4/torture/basic/dir.c | 56 +- source4/torture/basic/disconnect.c | 3 +- source4/torture/basic/locking.c | 751 +++----- source4/torture/basic/mangle_test.c | 13 +- source4/torture/basic/misc.c | 855 +++++++++ source4/torture/basic/properties.c | 16 +- source4/torture/basic/rename.c | 96 +- source4/torture/basic/scanner.c | 23 +- source4/torture/basic/secleak.c | 9 +- source4/torture/basic/unlink.c | 60 +- source4/torture/basic/utable.c | 72 +- source4/torture/config.mk | 7 +- source4/torture/ldap/common.c | 17 +- source4/torture/libnet/libnet.c | 57 +- source4/torture/local/binding_string.c | 50 +- source4/torture/local/config.mk | 2 +- source4/torture/local/dbspeed.c | 18 +- source4/torture/local/event.c | 25 +- source4/torture/local/iconv.c | 137 +- source4/torture/local/idtree.c | 47 +- source4/torture/local/irpc.c | 75 +- source4/torture/local/local.c | 35 +- source4/torture/local/messaging.c | 57 +- source4/torture/local/ndr.c | 37 +- source4/torture/local/registry.c | 35 +- source4/torture/local/resolve.c | 39 +- source4/torture/local/sddl.c | 34 +- source4/torture/local/socket.c | 164 +- source4/torture/local/torture.c | 35 +- source4/torture/local/util_file.c | 51 +- source4/torture/local/util_strlist.c | 23 +- source4/torture/misc.c | 893 --------- source4/torture/nbench/nbench.c | 16 +- source4/torture/nbt/dgram.c | 180 +- source4/torture/nbt/nbt.c | 43 +- source4/torture/nbt/query.c | 61 +- source4/torture/nbt/register.c | 176 +- source4/torture/nbt/wins.c | 330 ++-- source4/torture/nbt/winsbench.c | 73 +- source4/torture/nbt/winsreplication.c | 3131 ++++++++++++++++---------------- source4/torture/rap/rap.c | 13 +- source4/torture/raw/raw.c | 65 +- source4/torture/rpc/atsvc.c | 102 +- source4/torture/rpc/dfs.c | 122 +- source4/torture/rpc/echo.c | 379 ++-- source4/torture/rpc/eventlog.c | 255 ++- source4/torture/rpc/rpc.c | 173 +- source4/torture/rpc/rpc.h | 1 + source4/torture/rpc/unixinfo.c | 65 +- source4/torture/rpc/wkssvc.c | 77 +- source4/torture/smb2/config.mk | 2 - source4/torture/smb2/connect.c | 9 +- source4/torture/smb2/smb2.c | 30 +- source4/torture/smbtorture.c | 149 +- source4/torture/torture.c | 27 +- source4/torture/ui.c | 173 +- source4/torture/ui.h | 230 ++- source4/torture/util_smb.c | 175 +- 76 files changed, 6146 insertions(+), 7330 deletions(-) create mode 100644 source4/torture/basic/misc.c delete mode 100644 source4/torture/misc.c (limited to 'source4') diff --git a/source4/auth/gensec/cyrus_sasl.c b/source4/auth/gensec/cyrus_sasl.c index f61de439f2..17a0162e8d 100644 --- a/source4/auth/gensec/cyrus_sasl.c +++ b/source4/auth/gensec/cyrus_sasl.c @@ -399,7 +399,7 @@ NTSTATUS gensec_sasl_init(void) if (oldmech) { continue; } - newmech = talloc(NULL, struct gensec_security_ops); + newmech = talloc(talloc_autofree_context(), struct gensec_security_ops); if (!newmech) { return NT_STATUS_NO_MEMORY; } diff --git a/source4/lib/appweb/mpr/var.h b/source4/lib/appweb/mpr/var.h index 1f142d604d..98313c0476 100644 --- a/source4/lib/appweb/mpr/var.h +++ b/source4/lib/appweb/mpr/var.h @@ -299,7 +299,7 @@ typedef struct MprVar { #if 0 && !BLD_DEBUG && !LINUX && !VXWORKS union { #endif - int boolean; /* Use int for speed */ + bool boolean; #if BLD_FEATURE_FLOATING_POINT double floating; #endif diff --git a/source4/lib/crypto/sha1test.c b/source4/lib/crypto/sha1test.c index c3b4506dec..a37328e328 100644 --- a/source4/lib/crypto/sha1test.c +++ b/source4/lib/crypto/sha1test.c @@ -17,6 +17,7 @@ */ #include "includes.h" +#include "torture/ui.h" #include "lib/crypto/crypto.h" @@ -50,7 +51,8 @@ static const char *resultarray[4] = "DE A3 56 A2 CD DD 90 C7 A7 EC ED C5 EB B5 63 93 4F 46 04 52 " }; -BOOL torture_local_crypto_sha1(struct torture_context *torture) + +bool torture_local_crypto_sha1(struct torture_context *tctx) { struct SHA1Context sha; int i, j, err; @@ -64,52 +66,33 @@ BOOL torture_local_crypto_sha1(struct torture_context *torture) for(j = 0; j < 4; ++j) { ZERO_STRUCT(tmp); - printf( "\nTest %d: %d, '%s'\n", + torture_comment(tctx, "Test %d: %d, '%s'\n", j+1, repeatcount[j], testarray[j]); err = SHA1Init(&sha); - if (err) - { - fprintf(stderr, "SHA1Init Error %d.\n", err ); - ret = False; - break; /* out of for j loop */ - } + torture_assert_int_equal(tctx, err, 0, "SHA1Init Error"); for(i = 0; i < repeatcount[j]; ++i) { err = SHA1Update(&sha, (const unsigned char *) testarray[j], strlen(testarray[j])); - if (err) - { - fprintf(stderr, "SHA1Update Error %d.\n", err ); - ret = False; - break; /* out of for i loop */ - } + torture_assert_int_equal(tctx, err, 0, "SHA1Update Error"); } err = SHA1Final(Message_Digest, &sha); - if (err) - { - fprintf(stderr, - "SHA1Result Error %d, could not compute message digest.\n", - err ); - ret = False; - } - else + torture_assert_int_equal(tctx, err, 0, + "SHA1Result Error, could not compute message digest."); + torture_comment(tctx, "\t"); + for(i = 0; i < 20 ; ++i) { - printf("\t"); - for(i = 0; i < 20 ; ++i) - { snprintf(tmp+(i*3), sizeof(tmp) - (i*3),"%02X ", Message_Digest[i]); - printf("%02X ", Message_Digest[i]); - } - printf("\n"); + torture_comment(tctx, "%02X ", Message_Digest[i]); } - printf("Should match:\n"); - printf("\t%s\n", resultarray[j]); + torture_comment(tctx, "\n"); + torture_comment(tctx, "Should match:\n\t%s\n", resultarray[j]); if (strcmp(resultarray[j], tmp) != 0) { ret = False; } @@ -117,10 +100,11 @@ BOOL torture_local_crypto_sha1(struct torture_context *torture) /* Test some error returns */ err = SHA1Update(&sha,(const unsigned char *) testarray[1], 1); - if (err != shaStateError) ret = False; - printf ("\nError %d. Should be %d.\n", err, shaStateError ); + torture_assert_int_equal(tctx, err, shaStateError, "SHA1Update failed"); err = SHA1Init(0); - if (err != shaNull) ret = False; - printf ("\nError %d. Should be %d.\n", err, shaNull ); - return ret; + torture_assert_int_equal(tctx, err, shaNull, "SHA1Init failed"); + + return true; } + + diff --git a/source4/lib/talloc/testsuite.c b/source4/lib/talloc/testsuite.c index 1a2a60a3a3..f2e61157e4 100644 --- a/source4/lib/talloc/testsuite.c +++ b/source4/lib/talloc/testsuite.c @@ -27,8 +27,17 @@ #include "replace.h" #include "system/time.h" #include "talloc.h" +#ifdef _SAMBA_BUILD_ +#include "includes.h" +#include "torture/ui.h" +#else +#define torture_comment printf +#define torture_assert(tctx, expr, str) if (!(expr)) { printf str; return false; } +#define torture_suite_add_simple_tcase(suite,name,fn) \ + ret &= printf("TESTING %s\n", name), fn(); +#define torture_out stdout -struct torture_context; +struct torture_suite; static struct timeval timeval_current(void) { @@ -43,6 +52,7 @@ static double timeval_elapsed(struct timeval *tv) return (tv2.tv_sec - tv->tv_sec) + (tv2.tv_usec - tv->tv_usec)*1.0e-6; } +#endif /* _SAMBA_BUILD_ */ #if _SAMBA_BUILD_==3 #ifdef malloc @@ -55,10 +65,10 @@ static double timeval_elapsed(struct timeval *tv) #define CHECK_SIZE(ptr, tsize) do { \ if (talloc_total_size(ptr) != (tsize)) { \ - printf(__location__ " failed: wrong '%s' tree size: got %u expected %u\n", \ + torture_comment(tctx, talloc_asprintf(tctx, "failed: wrong '%s' tree size: got %u expected %u\n", \ #ptr, \ (unsigned)talloc_total_size(ptr), \ - (unsigned)tsize); \ + (unsigned)tsize)); \ talloc_report_full(ptr, stdout); \ return false; \ } \ @@ -66,10 +76,10 @@ static double timeval_elapsed(struct timeval *tv) #define CHECK_BLOCKS(ptr, tblocks) do { \ if (talloc_total_blocks(ptr) != (tblocks)) { \ - printf(__location__ " failed: wrong '%s' tree blocks: got %u expected %u\n", \ + torture_comment(tctx, talloc_asprintf(tctx, "failed: wrong '%s' tree blocks: got %u expected %u\n", \ #ptr, \ (unsigned)talloc_total_blocks(ptr), \ - (unsigned)tblocks); \ + (unsigned)tblocks)); \ talloc_report_full(ptr, stdout); \ return false; \ } \ @@ -77,10 +87,10 @@ static double timeval_elapsed(struct timeval *tv) #define CHECK_PARENT(ptr, parent) do { \ if (talloc_parent(ptr) != (parent)) { \ - printf(__location__ " failed: '%s' has wrong parent: got %p expected %p\n", \ + torture_comment(tctx, talloc_asprintf(tctx, "failed: '%s' has wrong parent: got %p expected %p\n", \ #ptr, \ talloc_parent(ptr), \ - (parent)); \ + (parent))); \ talloc_report_full(ptr, stdout); \ talloc_report_full(parent, stdout); \ talloc_report_full(NULL, stdout); \ @@ -92,12 +102,10 @@ static double timeval_elapsed(struct timeval *tv) /* test references */ -static bool test_ref1(void) +static bool test_ref1(struct torture_context *tctx) { void *root, *p1, *p2, *ref, *r1; - printf("TESTING SINGLE REFERENCE FREE\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "p1"); p2 = talloc_named_const(p1, 1, "p2"); @@ -107,31 +115,31 @@ static bool test_ref1(void) r1 = talloc_named_const(root, 1, "r1"); ref = talloc_reference(r1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 2); - printf("Freeing p2\n"); + torture_comment(tctx, "Freeing p2\n"); talloc_free(p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 1); - printf("Freeing p1\n"); + torture_comment(tctx, "Freeing p1\n"); talloc_free(p1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(r1, 1); - printf("Freeing r1\n"); + torture_comment(tctx, "Freeing r1\n"); talloc_free(r1); - talloc_report_full(NULL, stdout); + talloc_report_full(NULL, torture_out); - printf("Testing NULL\n"); + torture_comment(tctx, "Testing NULL\n"); if (talloc_reference(root, NULL)) { return false; } @@ -141,19 +149,16 @@ static bool test_ref1(void) CHECK_SIZE(root, 0); talloc_free(root); - return true; } /* test references */ -static bool test_ref2(void) +static bool test_ref2(struct torture_context *tctx) { void *root, *p1, *p2, *ref, *r1; - printf("TESTING DOUBLE REFERENCE FREE\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "p1"); talloc_named_const(p1, 1, "x1"); @@ -163,91 +168,85 @@ static bool test_ref2(void) r1 = talloc_named_const(root, 1, "r1"); ref = talloc_reference(r1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 2); - printf("Freeing ref\n"); + torture_comment(tctx, "Freeing ref\n"); talloc_free(ref); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 1); - printf("Freeing p2\n"); + torture_comment(tctx, "Freeing p2\n"); talloc_free(p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 4); CHECK_BLOCKS(r1, 1); - printf("Freeing p1\n"); + torture_comment(tctx, "Freeing p1\n"); talloc_free(p1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(r1, 1); - printf("Freeing r1\n"); + torture_comment(tctx, "Freeing r1\n"); talloc_free(r1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_SIZE(root, 0); talloc_free(root); - return true; } /* test references */ -static bool test_ref3(void) +static bool test_ref3(struct torture_context *tctx) { void *root, *p1, *p2, *ref, *r1; - printf("TESTING PARENT REFERENCE FREE\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "p1"); p2 = talloc_named_const(root, 1, "p2"); r1 = talloc_named_const(p1, 1, "r1"); ref = talloc_reference(p2, r1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 2); CHECK_BLOCKS(p2, 2); CHECK_BLOCKS(r1, 1); - printf("Freeing p1\n"); + torture_comment(tctx, "Freeing p1\n"); talloc_free(p1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p2, 2); CHECK_BLOCKS(r1, 1); - printf("Freeing p2\n"); + torture_comment(tctx, "Freeing p2\n"); talloc_free(p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_SIZE(root, 0); talloc_free(root); - return true; } /* test references */ -static bool test_ref4(void) +static bool test_ref4(struct torture_context *tctx) { void *root, *p1, *p2, *ref, *r1; - printf("TESTING REFERRER REFERENCE FREE\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "p1"); talloc_named_const(p1, 1, "x1"); @@ -257,33 +256,32 @@ static bool test_ref4(void) r1 = talloc_named_const(root, 1, "r1"); ref = talloc_reference(r1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 2); - printf("Freeing r1\n"); + torture_comment(tctx, "Freeing r1\n"); talloc_free(r1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 5); CHECK_BLOCKS(p2, 1); - printf("Freeing p2\n"); + torture_comment(tctx, "Freeing p2\n"); talloc_free(p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 4); - printf("Freeing p1\n"); + torture_comment(tctx, "Freeing p1\n"); talloc_free(p1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_SIZE(root, 0); talloc_free(root); - return true; } @@ -291,12 +289,10 @@ static bool test_ref4(void) /* test references */ -static bool test_unlink1(void) +static bool test_unlink1(struct torture_context *tctx) { void *root, *p1, *p2, *ref, *r1; - printf("TESTING UNLINK\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "p1"); talloc_named_const(p1, 1, "x1"); @@ -306,28 +302,27 @@ static bool test_unlink1(void) r1 = talloc_named_const(p1, 1, "r1"); ref = talloc_reference(r1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 7); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 2); - printf("Unreferencing r1\n"); + torture_comment(tctx, "Unreferencing r1\n"); talloc_unlink(r1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p1, 6); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(r1, 1); - printf("Freeing p1\n"); + torture_comment(tctx, "Freeing p1\n"); talloc_free(p1); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_SIZE(root, 0); talloc_free(root); - return true; } @@ -339,22 +334,17 @@ static int fail_destructor(void *ptr) /* miscellaneous tests to try to get a higher test coverage percentage */ -static bool test_misc(void) +static bool test_misc(struct torture_context *tctx) { void *root, *p1; char *p2; double *d; const char *name; - printf("TESTING MISCELLANEOUS\n"); - root = talloc_new(NULL); p1 = talloc_size(root, 0x7fffffff); - if (p1) { - printf("failed: large talloc allowed\n"); - return false; - } + torture_assert(tctx, !p1, "failed: large talloc allowed\n"); p1 = talloc_strdup(root, "foo"); talloc_increase_ref_count(p1); @@ -369,97 +359,65 @@ static bool test_misc(void) CHECK_BLOCKS(p1, 1); CHECK_BLOCKS(root, 2); p2 = talloc_strdup(p1, "foo"); - if (talloc_unlink(root, p2) != -1) { - printf("failed: talloc_unlink() of non-reference context should return -1\n"); - return false; - } - if (talloc_unlink(p1, p2) != 0) { - printf("failed: talloc_unlink() of parent should succeed\n"); - return false; - } + torture_assert(tctx, talloc_unlink(root, p2) == -1, + "failed: talloc_unlink() of non-reference context should return -1\n"); + torture_assert(tctx, talloc_unlink(p1, p2) == 0, + "failed: talloc_unlink() of parent should succeed\n"); talloc_free(p1); CHECK_BLOCKS(p1, 1); CHECK_BLOCKS(root, 2); name = talloc_set_name(p1, "my name is %s", "foo"); - if (strcmp(talloc_get_name(p1), "my name is foo") != 0) { - printf("failed: wrong name after talloc_set_name(my name is foo) - '%s'=>'%s'\n", - (name?name:"NULL"), talloc_get_name(p1)); - return false; - } + torture_assert_str_equal(tctx, talloc_get_name(p1), "my name is foo", + "failed: wrong name after talloc_set_name(my name is foo)"); CHECK_BLOCKS(p1, 2); CHECK_BLOCKS(root, 3); talloc_set_name_const(p1, NULL); - if (strcmp(talloc_get_name(p1), "UNNAMED") != 0) { - printf("failed: wrong name after talloc_set_name(NULL) - '%s'\n", - talloc_get_name(p1)); - return false; - } + torture_assert_str_equal (tctx, talloc_get_name(p1), "UNNAMED", + "failed: wrong name after talloc_set_name(NULL)"); CHECK_BLOCKS(p1, 2); CHECK_BLOCKS(root, 3); - if (talloc_free(NULL) != -1) { - printf("talloc_free(NULL) should give -1\n"); - return false; - } + torture_assert(tctx, talloc_free(NULL) == -1, + "talloc_free(NULL) should give -1\n"); talloc_set_destructor(p1, fail_destructor); - if (talloc_free(p1) != -1) { - printf("Failed destructor should cause talloc_free to fail\n"); - return false; - } + torture_assert(tctx, talloc_free(p1) == -1, + "Failed destructor should cause talloc_free to fail\n"); talloc_set_destructor(p1, NULL); - talloc_report(root, stdout); + talloc_report(root, torture_out); p2 = (char *)talloc_zero_size(p1, 20); - if (p2[19] != 0) { - printf("Failed to give zero memory\n"); - return false; - } + torture_assert(tctx, p2[19] == 0, "Failed to give zero memory\n"); talloc_free(p2); - if (talloc_strdup(root, NULL) != NULL) { - printf("failed: strdup on NULL should give NULL\n"); - return false; - } + torture_assert(tctx, talloc_strdup(root, NULL) == NULL, + "failed: strdup on NULL should give NULL\n"); p2 = talloc_strndup(p1, "foo", 2); - if (strcmp("fo", p2) != 0) { - printf("failed: strndup doesn't work\n"); - return false; - } + torture_assert(tctx, strcmp("fo", p2) == 0, "failed: strndup doesn't work\n"); p2 = talloc_asprintf_append(p2, "o%c", 'd'); - if (strcmp("food", p2) != 0) { - printf("failed: talloc_asprintf_append doesn't work\n"); - return false; - } + torture_assert(tctx, strcmp("food", p2) == 0, + "failed: talloc_asprintf_append doesn't work\n"); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(p1, 3); p2 = talloc_asprintf_append(NULL, "hello %s", "world"); - if (strcmp("hello world", p2) != 0) { - printf("failed: talloc_asprintf_append doesn't work\n"); - return false; - } + torture_assert(tctx, strcmp("hello world", p2) == 0, + "failed: talloc_asprintf_append doesn't work\n"); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(p1, 3); talloc_free(p2); d = talloc_array(p1, double, 0x20000000); - if (d) { - printf("failed: integer overflow not detected\n"); - return false; - } + torture_assert(tctx, !d, "failed: integer overflow not detected\n"); d = talloc_realloc(p1, d, double, 0x20000000); - if (d) { - printf("failed: integer overflow not detected\n"); - return false; - } + torture_assert(tctx, !d, "failed: integer overflow not detected\n"); talloc_free(p1); CHECK_BLOCKS(root, 1); @@ -471,10 +429,8 @@ static bool test_misc(void) p1 = talloc_init("%d bytes", 200); p2 = talloc_asprintf(p1, "my test '%s'", "string"); - if (strcmp(p2, "my test 'string'") != 0) { - printf("failed: talloc_asprintf(\"my test '%%s'\", \"string\") gave: \"%s\"\n", p2); - return false; - } + torture_assert_str_equal(tctx, p2, "my test 'string'", + "failed: talloc_asprintf(\"my test '%%s'\", \"string\") gave: \"%s\""); CHECK_BLOCKS(p1, 3); CHECK_SIZE(p2, 17); CHECK_BLOCKS(root, 1); @@ -483,9 +439,9 @@ static bool test_misc(void) p1 = talloc_named_const(root, 10, "p1"); p2 = (char *)talloc_named_const(root, 20, "p2"); (void)talloc_reference(p1, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); talloc_unlink(root, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(p1, 2); CHECK_BLOCKS(root, 3); @@ -495,9 +451,9 @@ static bool test_misc(void) p1 = talloc_named_const(root, 10, "p1"); p2 = (char *)talloc_named_const(root, 20, "p2"); (void)talloc_reference(NULL, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); talloc_unlink(root, p2); - talloc_report_full(root, stdout); + talloc_report_full(root, torture_out); CHECK_BLOCKS(p2, 1); CHECK_BLOCKS(p1, 1); CHECK_BLOCKS(root, 2); @@ -506,13 +462,11 @@ static bool test_misc(void) /* Test that talloc_unlink is a no-op */ - if (talloc_unlink(root, NULL) != -1) { - printf("failed: talloc_unlink(root, NULL) == -1\n"); - return false; - } + torture_assert(tctx, talloc_unlink(root, NULL) == -1, + "failed: talloc_unlink(root, NULL) == -1\n"); - talloc_report(root, stdout); - talloc_report(NULL, stdout); + talloc_report(root, torture_out); + talloc_report(NULL, torture_out); CHECK_SIZE(root, 0); @@ -522,7 +476,6 @@ static bool test_misc(void) talloc_enable_leak_report(); talloc_enable_leak_report_full(); - return true; } @@ -530,12 +483,10 @@ static bool test_misc(void) /* test realloc */ -static bool test_realloc(void) +static bool test_realloc(struct torture_context *tctx) { void *root, *p1, *p2; - printf("TESTING REALLOC\n"); - root = talloc_new(NULL); p1 = talloc_size(root, 10); @@ -560,20 +511,16 @@ static bool test_realloc(void) CHECK_SIZE(p1, 60); talloc_increase_ref_count(p2); - if (talloc_realloc_size(NULL, p2, 5) != NULL) { - printf("failed: talloc_realloc() on a referenced pointer should fail\n"); - return false; - } + torture_assert(tctx, talloc_realloc_size(NULL, p2, 5) == NULL, + "failed: talloc_realloc() on a referenced pointer should fail\n"); CHECK_BLOCKS(p1, 4); talloc_realloc_size(NULL, p2, 0); talloc_realloc_size(NULL, p2, 0); CHECK_BLOCKS(p1, 3); - if (talloc_realloc_size(NULL, p1, 0x7fffffff) != NULL) { - printf("failed: oversize talloc should fail\n"); - return false; - } + torture_assert(tctx, talloc_realloc_size(NULL, p1, 0x7fffffff) == NULL, + "failed: oversize talloc should fail\n"); talloc_realloc_size(NULL, p1, 0); @@ -581,14 +528,13 @@ static bool test_realloc(void) CHECK_SIZE(root, 0); talloc_free(root); - return true; } /* test realloc with a child */ -static bool test_realloc_child(void) +static bool test_realloc_child(struct torture_context *tctx) { void *root; struct el2 { @@ -599,8 +545,6 @@ static bool test_realloc_child(void) struct el2 **list, **list2, **list3; } *el1; - printf("TESTING REALLOC WITH CHILD\n"); - root = talloc_new(NULL); el1 = talloc(root, struct el1); @@ -625,15 +569,13 @@ static bool test_realloc_child(void) el1->list3 = talloc_realloc(el1, el1->list3, struct el2 *, 300); talloc_free(root); - return true; } - /* test type checking */ -static bool test_type(void) +static bool test_type(struct torture_context *tctx) { void *root; struct el1 { @@ -644,42 +586,31 @@ static bool test_type(void) }; struct el1 *el1; - printf("TESTING talloc type checking\n"); - root = talloc_new(NULL); el1 = talloc(root, struct el1); el1->count = 1; - if (talloc_get_type(el1, struct el1) != el1) { - printf("type check failed on el1\n"); - return false; - } - if (talloc_get_type(el1, struct el2) != NULL) { - printf("type check failed on el1 with el2\n"); - return false; - } + torture_assert(tctx, talloc_get_type(el1, struct el1) == el1, + "type check failed on el1\n"); + torture_assert(tctx, talloc_get_type(el1, struct el2) == NULL, + "type check failed on el1 with el2\n"); talloc_set_type(el1, struct el2); - if (talloc_get_type(el1, struct el2) != (struct el2 *)el1) { - printf("type set failed on el1 with el2\n"); - return false; - } + torture_assert(tctx, talloc_get_type(el1, struct el2) == (struct el2 *)el1, + "type set failed on el1 with el2\n"); talloc_free(root); - return true; } /* test steal */ -static bool test_steal(void) +static bool test_steal(struct torture_context *tctx) { void *root, *p1, *p2; - printf("TESTING STEAL\n"); - root = talloc_new(NULL); p1 = talloc_array(root, char, 10); @@ -689,15 +620,11 @@ static bool test_steal(void) CHECK_SIZE(p1, 10); CHECK_SIZE(root, 30); - if (talloc_steal(p1, NULL) != NULL) { - printf("failed: stealing NULL should give NULL\n"); - return false; - } + torture_assert(tctx, talloc_steal(p1, NULL) == NULL, + "failed: stealing NULL should give NULL\n"); - if (talloc_steal(p1, p1) != p1) { - printf("failed: stealing to ourselves is a nop\n"); - return false; - } + torture_assert(tctx, talloc_steal(p1, p1) == p1, + "failed: stealing to ourselves is a nop\n"); CHECK_BLOCKS(root, 3); CHECK_SIZE(root, 30); @@ -719,24 +646,22 @@ static bool test_steal(void) talloc_free(root); p1 = talloc_size(NULL, 3); - talloc_report_full(NULL, stdout); + talloc_report_full(NULL, torture_out); CHECK_SIZE(NULL, 3); talloc_free(p1); - return true; } /* test move */ -static bool test_move(void) +static bool test_move(struct torture_context *tctx) { void *root; struct t_move { char *p; int *x; } *t1, *t2; - printf("TESTING MOVE\n"); root = talloc_new(NULL); @@ -748,12 +673,9 @@ static bool test_move(void) t2->p = talloc_move(t2, &t1->p); t2->x = talloc_move(t2, &t1->x); - if (t1->p != NULL || t1->x != NULL || - strcmp(t2->p, "foo") || - *t2->x != 42) { - printf("talloc move failed\n"); - return false; - } + torture_assert(tctx, t1->p == NULL && t1->x == NULL && + strcmp(t2->p, "foo") == 0 && *t2->x == 42, + "talloc move failed"); talloc_free(root); @@ -763,12 +685,10 @@ static bool test_move(void) /* test talloc_realloc_fn */ -static bool test_realloc_fn(void) +static bool test_realloc_fn(struct torture_context *tctx) { void *root, *p1; - printf("TESTING talloc_realloc_fn\n"); - root = talloc_new(NULL); p1 = talloc_realloc_fn(root, NULL, 10); @@ -782,18 +702,14 @@ static bool test_realloc_fn(void) CHECK_SIZE(root, 0); talloc_free(root); - - return true; } -static bool test_unref_reparent(void) +static bool test_unref_reparent(struct torture_context *tctx) { void *root, *p1, *p2, *c1; - printf("TESTING UNREFERENCE AFTER PARENT FREED\n"); - root = talloc_named_const(NULL, 0, "root"); p1 = talloc_named_const(root, 1, "orig parent"); p2 = talloc_named_const(root, 1, "parent by reference"); @@ -813,21 +729,18 @@ static bool test_unref_reparent(void) talloc_free(p2); talloc_free(root); - return true; } /* measure the speed of talloc versus malloc */ -static bool test_speed(void) +static bool test_speed(struct torture_context *tctx) { void *ctx = talloc_new(NULL); unsigned count; struct timeval tv; - printf("MEASURING TALLOC VS MALLOC SPEED\n"); - tv = timeval_current(); count = 0; do { @@ -839,7 +752,7 @@ static bool test_speed(void) count += 3; } while (timeval_elapsed(&tv) < 5.0); - printf("talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv)); + torture_comment(tctx, talloc_asprintf(tctx, "talloc: %.0f ops/sec\n", count/timeval_elapsed(&tv))); talloc_free(ctx); @@ -856,32 +769,27 @@ static bool test_speed(void) count += 3; } while (timeval_elapsed(&tv) < 5.0); - printf("malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv)); - - return true; + torture_comment(tctx, talloc_asprintf(tctx, "malloc: %.0f ops/sec\n", count/timeval_elapsed(&tv))); + return true; } - -static bool test_lifeless(void) +static bool test_lifeless(struct torture_context *tctx) { void *top = talloc_new(NULL); char *parent, *child; void *child_owner = talloc_new(NULL); - printf("TESTING TALLOC_UNLINK LOOP\n"); - parent = talloc_strdup(top, "parent"); child = talloc_strdup(parent, "child"); (void)talloc_reference(child, parent); (void)talloc_reference(child_owner, child); - talloc_report_full(top, stdout); + talloc_report_full(top, torture_out); talloc_unlink(top, parent); talloc_free(child); - talloc_report_full(top, stdout); + talloc_report_full(top, torture_out); talloc_free(top); talloc_free(child_owner); talloc_free(child); - return true; } @@ -889,12 +797,11 @@ static int loop_destructor_count; static int test_loop_destructor(char *ptr) { - printf("loop destructor\n"); loop_destructor_count++; return 0; } -static bool test_loop(void) +static bool test_loop(struct torture_context *tctx) { void *top = talloc_new(NULL); char *parent; @@ -902,25 +809,21 @@ static bool test_loop(void) char *req2, *req3; } *req1; - printf("TESTING TALLOC LOOP DESTRUCTION\n"); parent = talloc_strdup(top, "parent"); req1 = talloc(parent, struct req1); req1->req2 = talloc_strdup(req1, "req2"); talloc_set_destructor(req1->req2, test_loop_destructor); req1->req3 = talloc_strdup(req1, "req3"); (void)talloc_reference(req1->req3, req1); - talloc_report_full(top, stdout); + talloc_report_full(top, torture_out); talloc_free(parent); - talloc_report_full(top, stdout); - talloc_report_full(NULL, stdout); + talloc_report_full(top, torture_out); + talloc_report_full(NULL, torture_out); talloc_free(top); - if (loop_destructor_count != 1) { - printf("FAILED TO FIRE LOOP DESTRUCTOR\n"); - return false; - } + torture_assert(tctx, loop_destructor_count == 1, + "FAILED TO FIRE LOOP DESTRUCTOR\n"); loop_destructor_count = 0; - return true; } @@ -929,14 +832,13 @@ static int fail_destructor_str(char *ptr) return -1; } -static bool test_free_parent_deny_child(void) +static bool test_free_parent_deny_child(struct torture_context *tctx) { void *top = talloc_new(NULL); char *level1; char *level2; char *level3; - printf("TESTING TALLOC FREE PARENT DENY CHILD\n"); level1 = talloc_strdup(top, "level1"); level2 = talloc_strdup(level1, "level2"); level3 = talloc_strdup(level2, "level3"); @@ -948,13 +850,11 @@ static bool test_free_parent_deny_child(void) CHECK_PARENT(level3, top); talloc_free(top); - return true; } -static bool test_talloc_ptrtype(void) +static bool test_talloc_ptrtype(struct torture_context *tctx) { - bool ret = true; void *top = talloc_new(NULL); struct struct1 { int foo; @@ -965,90 +865,73 @@ static bool test_talloc_ptrtype(void) const char *location3; const char *location4; - printf("TESTING TALLOC PTRTYPE\n"); s1 = talloc_ptrtype(top, s1);location1 = __location__; - if (talloc_get_size(s1) != sizeof(struct struct1)) { - printf("%s: talloc_ptrtype() allocated the wrong size %lu " - "(should be %lu)\n", - __location__, (unsigned long)talloc_get_size(s1), - (unsigned long)sizeof(struct struct1)); - ret = false; - } + torture_assert(tctx, talloc_get_size(s1) == sizeof(struct struct1), + talloc_asprintf(tctx, + "talloc_ptrtype() allocated the wrong size %lu " + "(should be %lu)\n", (unsigned long)talloc_get_size(s1), + (unsigned long)sizeof(struct struct1))); - if (strcmp(location1, talloc_get_name(s1)) != 0) { - printf("%s: talloc_ptrtype() sets the wrong name '%s' (should be '%s')\n", - __location__, talloc_get_name(s1), location1); - ret = false; - } + torture_assert(tctx, strcmp(location1, talloc_get_name(s1)) == 0, + talloc_asprintf(tctx, + "talloc_ptrtype() sets the wrong name '%s' (should be '%s')\n", + talloc_get_name(s1), location1)); s2 = talloc_array_ptrtype(top, s2, 10);location2 = __location__; - if (talloc_get_size(s2) != (sizeof(struct struct1) * 10)) { - printf("%s: talloc_array_ptrtype() allocated the wrong size " + torture_assert(tctx, talloc_get_size(s2) == (sizeof(struct struct1) * 10), + talloc_asprintf(tctx, + "talloc_array_ptrtype() allocated the wrong size " "%lu (should be %lu)\n", - __location__, (unsigned long)talloc_get_size(s2), - (unsigned long)(sizeof(struct struct1)*10)); - ret = false; - } + (unsigned long)talloc_get_size(s2), + (unsigned long)(sizeof(struct struct1)*10))); - if (strcmp(location2, talloc_get_name(s2)) != 0) { - printf("%s: talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n", - __location__, talloc_get_name(s2), - location2); - ret = false; - } + torture_assert(tctx, strcmp(location2, talloc_get_name(s2)) == 0, + talloc_asprintf(tctx, + "talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n", + talloc_get_name(s2), location2)); s3 = talloc_array_ptrtype(top, s3, 10);location3 = __location__; - if (talloc_get_size(s3) != (sizeof(struct struct1 *) * 10)) { - printf("%s: talloc_array_ptrtype() allocated the wrong size " + torture_assert(tctx, talloc_get_size(s3) == (sizeof(struct struct1 *) * 10), + talloc_asprintf(tctx, + "talloc_array_ptrtype() allocated the wrong size " "%lu (should be %lu)\n", - __location__, (unsigned long)talloc_get_size(s3), - (unsigned long)(sizeof(struct struct1 *)*10)); - ret = false; - } + (unsigned long)talloc_get_size(s3), + (unsigned long)(sizeof(struct struct1 *)*10))); - if (strcmp(location3, talloc_get_name(s3)) != 0) { - printf("%s: talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n", - __location__, talloc_get_name(s3), location3); - ret = false; - } + torture_assert_str_equal(tctx, location3, talloc_get_name(s3), + "talloc_array_ptrtype() sets the wrong name"); s4 = talloc_array_ptrtype(top, s4, 10);location4 = __location__; - if (talloc_get_size(s4) != (sizeof(struct struct1 **) * 10)) { - printf("%s: talloc_array_ptrtype() allocated the wrong size " + torture_assert(tctx, talloc_get_size(s4) == (sizeof(struct struct1 **) * 10), + talloc_asprintf(tctx, + "talloc_array_ptrtype() allocated the wrong size " "%lu (should be %lu)\n", - __location__, (unsigned long)talloc_get_size(s4), - (unsigned long)(sizeof(struct struct1 **)*10)); - ret = false; - } + (unsigned long)talloc_get_size(s4), + (unsigned long)(sizeof(struct struct1 **)*10))); - if (strcmp(location4, talloc_get_name(s4)) != 0) { - printf("%s: talloc_array_ptrtype() sets the wrong name '%s' (should be '%s')\n", - __location__, talloc_get_name(s4), location4); - ret = false; - } + torture_assert_str_equal(tctx, location4, talloc_get_name(s4), + "talloc_array_ptrtype() sets the wrong name"); talloc_free(top); - - return ret; + return true; } -static bool test_autofree(void) +static bool test_autofree(struct torture_context *tctx) { #if _SAMBA_BUILD_>=4 /* * we can't run this inside smbtorture in samba4 * as smbtorture uses talloc_autofree_context() */ - printf("SKIPPING TALLOC AUTOFREE CONTEXT (not supported from smbtorture)\n"); + torture_skip(tctx, + "SKIPPING TALLOC AUTOFREE CONTEXT (not supported from smbtorture)"); #else void *p; - printf("TESTING TALLOC AUTOFREE CONTEXT\n"); - p = talloc_autofree_context(); talloc_free(p); @@ -1058,34 +941,42 @@ static bool test_autofree(void) return true; } -bool torture_local_talloc(struct torture_context *torture) +bool torture_local_talloc(struct torture_suite *tsuite) { bool ret = true; talloc_disable_null_tracking(); talloc_enable_null_tracking(); - ret = ret && test_ref1(); - ret = ret && test_ref2(); - ret = ret && test_ref3(); - ret = ret && test_ref4(); - ret = ret && test_unlink1(); - ret = ret && test_misc(); - ret = ret && test_realloc(); - ret = ret && test_realloc_child(); - ret = ret && test_steal(); - ret = ret && test_move(); - ret = ret && test_unref_reparent(); - ret = ret && test_realloc_fn(); - ret = ret && test_type(); - ret = ret && test_lifeless(); - ret = ret && test_loop(); - ret = ret && test_free_parent_deny_child(); - ret = ret && test_talloc_ptrtype(); + torture_suite_add_simple_test(tsuite, "SINGLE REFERENCE FREE", test_ref1); + torture_suite_add_simple_test(tsuite, "DOUBLE REFERENCE FREE", test_ref2); + torture_suite_add_simple_test(tsuite, "PARENT REFERENCE FREE", test_ref3); + torture_suite_add_simple_test(tsuite, "REFERRER REFERENCE FREE", test_ref4); + torture_suite_add_simple_test(tsuite, "UNLINK", test_unlink1); + torture_suite_add_simple_test(tsuite, "MISCELLANEOUS", test_misc); + torture_suite_add_simple_test(tsuite, "REALLOC", test_realloc); + torture_suite_add_simple_test(tsuite, "REALLOC WITH CHILD", + test_realloc_child); + torture_suite_add_simple_test(tsuite, "STEAL", test_steal); + torture_suite_add_simple_test(tsuite, "MOVE", test_move); + torture_suite_add_simple_test(tsuite, "UNREFERENCE AFTER PARENT FREED", + test_unref_reparent); + torture_suite_add_simple_test(tsuite, "talloc_realloc_fn", + test_realloc_fn); + torture_suite_add_simple_test(tsuite, "talloc type checking", test_type); + torture_suite_add_simple_test(tsuite, "TALLOC_UNLINK LOOP", test_lifeless); + torture_suite_add_simple_test(tsuite, "TALLOC LOOP DESTRUCTION", test_loop); + torture_suite_add_simple_test(tsuite, "TALLOC FREE PARENT DENY CHILD", + test_free_parent_deny_child); + torture_suite_add_simple_test(tsuite, "TALLOC PTRTYPE", + test_talloc_ptrtype); + if (ret) { - ret = ret && test_speed(); + torture_suite_add_simple_test(tsuite, "TALLOC VS MALLOC SPEED", + test_speed); } - ret = ret && test_autofree(); + torture_suite_add_simple_test(tsuite, "TALLOC AUTOFREE CONTEXT", + test_autofree); return ret; } diff --git a/source4/rpc_server/echo/rpc_echo.c b/source4/rpc_server/echo/rpc_echo.c index 3de24fb366..460c866c49 100644 --- a/source4/rpc_server/echo/rpc_echo.c +++ b/source4/rpc_server/echo/rpc_echo.c @@ -68,7 +68,7 @@ static NTSTATUS echo_SourceData(struct dcesrv_call_state *dce_call, TALLOC_CTX * static NTSTATUS echo_TestCall(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct echo_TestCall *r) { - *r->out.s2 = talloc_strdup(mem_ctx, "this is a test string"); + *r->out.s2 = talloc_strdup(mem_ctx, r->in.s1); return NT_STATUS_OK; } diff --git a/source4/script/tests/test_nbt.sh b/source4/script/tests/test_nbt.sh index 45e1e49e5d..1cb5b97ac5 100755 --- a/source4/script/tests/test_nbt.sh +++ b/source4/script/tests/test_nbt.sh @@ -22,8 +22,7 @@ testit "nmblookup -U $SERVER $SERVER" bin/nmblookup $TORTURE_OPTIONS -U $SERVER testit "nmblookup $SERVER" bin/nmblookup $TORTURE_OPTIONS $SERVER || failed=`expr $failed + 1` NBT_TESTS="NBT-REGISTER NBT-WINS" -NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-SIMPLE" -NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-REPLICA" +NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION" # if [ "$TORTURE_QUICK"x != "yes"x ]; then # NBT_TESTS="$NBT_TESTS NBT-WINSREPLICATION-OWNED" # fi diff --git a/source4/script/tests/test_posix.sh b/source4/script/tests/test_posix.sh index 016cfeaff7..81e7268c2d 100755 --- a/source4/script/tests/test_posix.sh +++ b/source4/script/tests/test_posix.sh @@ -27,8 +27,8 @@ incdir=`dirname $0` # base="BASE-ATTR BASE-CHARSET BASE-CHKPATH BASE-DEFER_OPEN BASE-DELAYWRITE BASE-DELETE" base="$base BASE-DENY1 BASE-DENY2 BASE-DENY3 BASE-DENYDOS BASE-DIR1 BASE-DIR2" -base="$base BASE-DISCONNECT BASE-FDPASS BASE-LOCK1 BASE-LOCK2 BASE-LOCK3 BASE-LOCK4" -base="$base BASE-LOCK5 BASE-LOCK6 BASE-LOCK7 BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1" +base="$base BASE-DISCONNECT BASE-FDPASS BASE-LOCK " +base="$base BASE-MANGLE BASE-NEGNOWAIT BASE-NTDENY1" base="$base BASE-NTDENY2 BASE-OPEN BASE-OPENATTR BASE-PROPERTIES BASE-RENAME BASE-RW1" base="$base BASE-SECLEAK BASE-TCON BASE-TCONDEV BASE-TRANS2 BASE-UNLINK BASE-VUID" base="$base BASE-XCOPY" diff --git a/source4/script/tests/test_w2k3_file.sh b/source4/script/tests/test_w2k3_file.sh index 16819dd205..e57fb7c2bd 100755 --- a/source4/script/tests/test_w2k3_file.sh +++ b/source4/script/tests/test_w2k3_file.sh @@ -19,8 +19,8 @@ ADDARGS="$*" incdir=`dirname $0` . $incdir/test_functions.sh -tests="BASE-FDPASS BASE-LOCK1 BASE-LOCK2 BASE-LOCK3 BASE-LOCK4" -tests="$tests BASE-LOCK5 BASE-LOCK6 BASE-LOCK7 BASE-UNLINK BASE-ATTR" +tests="BASE-FDPASS BASE-LOCK " +tests="$tests BASE-UNLINK BASE-ATTR" tests="$tests BASE-DIR1 BASE-DIR2 BASE-VUID" tests="$tests BASE-TCON BASE-TCONDEV BASE-RW1" tests="$tests BASE-DENY3 BASE-XCOPY BASE-OPEN BASE-DENYDOS" diff --git a/source4/scripting/ejs/smbscript.c b/source4/scripting/ejs/smbscript.c index d602a7733b..23e2fe2d52 100644 --- a/source4/scripting/ejs/smbscript.c +++ b/source4/scripting/ejs/smbscript.c @@ -68,7 +68,7 @@ int main(int argc, const char **argv) if (ejsOpen(NULL, NULL, NULL) != 0) { fprintf(stderr, "smbscript: ejsOpen(): unable to initialise " - "EJ subsystem\n"); + "EJS subsystem\n"); exit(127); } diff --git a/source4/torture/auth/ntlmssp.c b/source4/torture/auth/ntlmssp.c index 978610ec51..ff111faf85 100644 --- a/source4/torture/auth/ntlmssp.c +++ b/source4/torture/auth/ntlmssp.c @@ -24,16 +24,16 @@ #include "lib/cmdline/popt_common.h" #include "torture/torture.h" -static BOOL torture_ntlmssp_self_check(struct torture_context *test, - const void *_data) +static bool torture_ntlmssp_self_check(struct torture_context *tctx) { struct gensec_security *gensec_security; struct gensec_ntlmssp_state *gensec_ntlmssp_state; DATA_BLOB data; DATA_BLOB sig, expected_sig; + TALLOC_CTX *mem_ctx = tctx; - torture_assert_ntstatus_ok(test, - gensec_client_start(test, &gensec_security, NULL), + torture_assert_ntstatus_ok(tctx, + gensec_client_start(mem_ctx, &gensec_security, NULL), "gensec client start"); gensec_set_credentials(gensec_security, cmdline_credentials); @@ -41,7 +41,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, gensec_want_feature(gensec_security, GENSEC_FEATURE_SIGN); gensec_want_feature(gensec_security, GENSEC_FEATURE_SEAL); - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP), "Failed to start GENSEC for NTLMSSP"); @@ -54,7 +54,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, gensec_ntlmssp_state->neg_flags = NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_128 | NTLMSSP_NEGOTIATE_KEY_EXCH | NTLMSSP_NEGOTIATE_NTLM2; - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); @@ -67,19 +67,15 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); - if (sig.length != expected_sig.length) { - torture_fail(test, "Wrong sig length: %d != %d", - (int)sig.length, (int)expected_sig.length); - return False; - } + torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length"); - torture_assert(test, 0 == memcmp(sig.data, expected_sig.data, sig.length), + torture_assert(tctx, 0 == memcmp(sig.data, expected_sig.data, sig.length), "data mismatch"); talloc_free(gensec_security); - torture_assert_ntstatus_ok(test, - gensec_client_start(test, &gensec_security, NULL), + torture_assert_ntstatus_ok(tctx, + gensec_client_start(mem_ctx, &gensec_security, NULL), "Failed to start GENSEC for NTLMSSP"); gensec_set_credentials(gensec_security, cmdline_credentials); @@ -87,7 +83,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, gensec_want_feature(gensec_security, GENSEC_FEATURE_SIGN); gensec_want_feature(gensec_security, GENSEC_FEATURE_SEAL); - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, gensec_start_mech_by_oid(gensec_security, GENSEC_OID_NTLMSSP), "GENSEC start mech by oid"); @@ -100,7 +96,7 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, gensec_ntlmssp_state->neg_flags = NTLMSSP_NEGOTIATE_SIGN | NTLMSSP_NEGOTIATE_UNICODE | NTLMSSP_NEGOTIATE_KEY_EXCH; - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, ntlmssp_sign_init(gensec_ntlmssp_state), "Failed to sign_init"); @@ -113,28 +109,22 @@ static BOOL torture_ntlmssp_self_check(struct torture_context *test, dump_data_pw("NTLMSSP calc sig: ", sig.data, sig.length); dump_data_pw("NTLMSSP expected sig: ", expected_sig.data, expected_sig.length); - if (sig.length != expected_sig.length) { - torture_fail(test, "Wrong sig length: %d != %d", - (int)sig.length, (int)expected_sig.length); - return False; - } + torture_assert_int_equal(tctx, sig.length, expected_sig.length, "Wrong sig length"); - torture_assert(test, - 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8), + torture_assert(tctx, 0 == memcmp(sig.data+8, expected_sig.data+8, sig.length-8), "data mismatch"); talloc_free(gensec_security); - - return True; + return true; } struct torture_suite *torture_ntlmssp(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-NTLMSSP"); + "NTLMSSP"); - torture_suite_add_simple_tcase(suite, "NTLMSSP self check", - torture_ntlmssp_self_check, NULL); + torture_suite_add_simple_test(suite, "NTLMSSP self check", + torture_ntlmssp_self_check); return suite; } diff --git a/source4/torture/auth/pac.c b/source4/torture/auth/pac.c index d922d5d1e9..fffec86c0d 100644 --- a/source4/torture/auth/pac.c +++ b/source4/torture/auth/pac.c @@ -30,8 +30,7 @@ #include "libcli/security/security.h" #include "torture/torture.h" -static BOOL torture_pac_self_check(struct torture_context *test, - const void *_data) +static bool torture_pac_self_check(struct torture_context *tctx) { NTSTATUS nt_status; DATA_BLOB tmp_blob; @@ -55,7 +54,9 @@ static BOOL torture_pac_self_check(struct torture_context *test, krb5_principal client_principal; time_t logon_time = time(NULL); - torture_assert(test, 0 == smb_krb5_init_context(test, &smb_krb5_context), + TALLOC_CTX *mem_ctx = tctx; + + torture_assert(tctx, 0 == smb_krb5_init_context(mem_ctx, &smb_krb5_context), "smb_krb5_init_context"); generate_random_buffer(server_bytes, 16); @@ -65,52 +66,49 @@ static BOOL torture_pac_self_check(struct torture_context *test, ENCTYPE_ARCFOUR_HMAC, server_bytes, sizeof(server_bytes), &server_keyblock); - if (ret) { - torture_fail(test, "(self test) Server Keyblock encoding failed: %s", - smb_get_krb5_error_message(smb_krb5_context->krb5_context, - ret, test)); - - return False; - } + torture_assert(tctx, !ret, talloc_asprintf(tctx, + "(self test) Server Keyblock encoding failed: %s", + smb_get_krb5_error_message(smb_krb5_context->krb5_context, + ret, mem_ctx))); ret = krb5_keyblock_init(smb_krb5_context->krb5_context, ENCTYPE_ARCFOUR_HMAC, krbtgt_bytes, sizeof(krbtgt_bytes), &krbtgt_keyblock); if (ret) { - torture_fail(test, "(self test) KRBTGT Keyblock encoding failed: %s", - smb_get_krb5_error_message(smb_krb5_context->krb5_context, - ret, test)); + char *err = smb_get_krb5_error_message(smb_krb5_context->krb5_context, + ret, mem_ctx); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + + torture_fail(tctx, talloc_asprintf(tctx, + "(self test) KRBTGT Keyblock encoding failed: %s", err)); } /* We need an input, and this one requires no underlying database */ - nt_status = auth_anonymous_server_info(test, &server_info); + nt_status = auth_anonymous_server_info(mem_ctx, &server_info); if (!NT_STATUS_IS_OK(nt_status)) { krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); - return False; + torture_fail(tctx, "auth_anonymous_server_info"); } ret = krb5_parse_name_norealm(smb_krb5_context->krb5_context, server_info->account_name, &client_principal); if (ret) { - torture_fail(test, "krb5_parse_name_norealm"); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); - return False; + torture_fail(tctx, "krb5_parse_name_norealm"); } /* OK, go ahead and make a PAC */ - ret = kerberos_create_pac(test, server_info, + ret = kerberos_create_pac(mem_ctx, server_info, smb_krb5_context->krb5_context, &krbtgt_keyblock, &server_keyblock, @@ -119,23 +117,23 @@ static BOOL torture_pac_self_check(struct torture_context *test, &tmp_blob); if (ret) { - torture_fail(test, "(self test) PAC encoding failed: %s", - smb_get_krb5_error_message(smb_krb5_context->krb5_context, - ret, test)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - return False; + + torture_fail(tctx, talloc_asprintf(tctx, + "(self test) PAC encoding failed: %s", + smb_get_krb5_error_message(smb_krb5_context->krb5_context, + ret, mem_ctx))); } dump_data(10,tmp_blob.data,tmp_blob.length); /* Now check that we can read it back */ - nt_status = kerberos_decode_pac(test, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -144,9 +142,6 @@ static BOOL torture_pac_self_check(struct torture_context *test, logon_time, NULL); if (!NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, "(self test) PAC decoding failed: %s", - nt_errstr(nt_status)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, @@ -154,11 +149,13 @@ static BOOL torture_pac_self_check(struct torture_context *test, krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - return False; + torture_fail(tctx, talloc_asprintf(tctx, + "(self test) PAC decoding failed: %s", + nt_errstr(nt_status))); } /* Now check that we can read it back */ - nt_status = kerberos_pac_logon_info(test, &logon_info, + nt_status = kerberos_pac_logon_info(mem_ctx, &logon_info, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -168,10 +165,6 @@ static BOOL torture_pac_self_check(struct torture_context *test, NULL); if (!NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, - "(self test) PAC decoding (for logon info) failed: %s", - nt_errstr(nt_status)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, @@ -179,7 +172,10 @@ static BOOL torture_pac_self_check(struct torture_context *test, krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - return False; + torture_fail(tctx, + talloc_asprintf(tctx, + "(self test) PAC decoding (for logon info) failed: %s", + nt_errstr(nt_status))); } krb5_free_keyblock_contents(smb_krb5_context->krb5_context, @@ -190,28 +186,26 @@ static BOOL torture_pac_self_check(struct torture_context *test, client_principal); validation.sam3 = &logon_info->info3; - nt_status = make_server_info_netlogon_validation(test, + nt_status = make_server_info_netlogon_validation(mem_ctx, "", 3, &validation, &server_info_out); if (!NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(self test) PAC decoding (make server info) failed: %s", - nt_errstr(nt_status)); - - return False; + nt_errstr(nt_status))); } if (!dom_sid_equal(server_info->account_sid, server_info_out->account_sid)) { - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(self test) PAC Decode resulted in *different* domain SID: %s != %s", - dom_sid_string(test, server_info->account_sid), - dom_sid_string(test, server_info_out->account_sid)); - return False; + dom_sid_string(mem_ctx, server_info->account_sid), + dom_sid_string(mem_ctx, server_info_out->account_sid))); } - - return True; + return true; } @@ -262,8 +256,7 @@ static const uint8_t saved_pac[] = { }; /* Check with a known 'well formed' PAC, from my test server */ -static BOOL torture_pac_saved_check(struct torture_context *test, - const void *_data) +static bool torture_pac_saved_check(struct torture_context *tctx) { NTSTATUS nt_status; DATA_BLOB tmp_blob, validate_blob; @@ -284,125 +277,108 @@ static BOOL torture_pac_saved_check(struct torture_context *test, krb5_principal client_principal; const char *authtime_string; time_t authtime; + TALLOC_CTX *mem_ctx = tctx; - torture_assert(test, 0 == smb_krb5_init_context(test, &smb_krb5_context), + torture_assert(tctx, 0 == smb_krb5_init_context(mem_ctx, &smb_krb5_context), "smb_krb5_init_context"); - pac_kdc_key = lp_parm_string(-1,"torture","pac_kdc_key"); - if (pac_kdc_key == NULL) { - pac_kdc_key = "B286757148AF7FD252C53603A150B7E7"; - } + pac_kdc_key = torture_setting_string(tctx, "pac_kdc_key", + "B286757148AF7FD252C53603A150B7E7"); - pac_member_key = lp_parm_string(-1,"torture","pac_member_key"); - if (pac_member_key == NULL) { - pac_member_key = "D217FAEAE5E6B5F95CCC94077AB8A5FC"; - } + pac_member_key = torture_setting_string(tctx, "pac_member_key", + "D217FAEAE5E6B5F95CCC94077AB8A5FC"); - torture_comment(test, "Using pac_kdc_key '%s'", pac_kdc_key); - torture_comment(test, "Using pac_member_key '%s'", pac_member_key); + torture_comment(tctx, "Using pac_kdc_key '%s'\n", pac_kdc_key); + torture_comment(tctx, "Using pac_member_key '%s'\n", pac_member_key); /* The krbtgt key in use when the above PAC was generated. * This is an arcfour-hmac-md5 key, extracted with our 'net * samdump' tool. */ - krbtgt_bytes = smbpasswd_gethexpwd(test, pac_kdc_key); + krbtgt_bytes = smbpasswd_gethexpwd(mem_ctx, pac_kdc_key); if (!krbtgt_bytes) { - torture_fail(test, "(saved test) Could not interpret krbtgt key"); - return False; + torture_fail(tctx, "(saved test) Could not interpret krbtgt key"); } - krbsrv_bytes = smbpasswd_gethexpwd(test, pac_member_key); + krbsrv_bytes = smbpasswd_gethexpwd(mem_ctx, pac_member_key); if (!krbsrv_bytes) { - torture_fail(test, "(saved test) Could not interpret krbsrv key"); - return False; + torture_fail(tctx, "(saved test) Could not interpret krbsrv key"); } ret = krb5_keyblock_init(smb_krb5_context->krb5_context, ENCTYPE_ARCFOUR_HMAC, krbsrv_bytes->hash, sizeof(krbsrv_bytes->hash), &server_keyblock); - if (ret) { - torture_fail(test, - "(saved test) Server Keyblock encoding failed: %s", + torture_assert(tctx, !ret, + talloc_asprintf(tctx, + "(saved test) Server Keyblock encoding failed: %s", smb_get_krb5_error_message(smb_krb5_context->krb5_context, - ret, test)); - - return False; - } + ret, mem_ctx))); ret = krb5_keyblock_init(smb_krb5_context->krb5_context, ENCTYPE_ARCFOUR_HMAC, krbtgt_bytes->hash, sizeof(krbtgt_bytes->hash), &krbtgt_keyblock); if (ret) { - torture_fail(test, - "(saved test) Server Keyblock encoding failed: %s", - smb_get_krb5_error_message(smb_krb5_context->krb5_context, - ret, test)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + torture_fail(tctx, + talloc_asprintf(tctx, + "(saved test) Server Keyblock encoding failed: %s", + smb_get_krb5_error_message(smb_krb5_context->krb5_context, + ret, mem_ctx))); } - pac_file = lp_parm_string(-1,"torture","pac_file"); + pac_file = torture_setting_string(tctx, "pac_file", NULL); if (pac_file) { - tmp_blob.data = (uint8_t *)file_load(pac_file, &tmp_blob.length, test); - torture_comment(test, "(saved test) Loaded pac of size %ld from %s", (long)tmp_blob.length, pac_file); + tmp_blob.data = (uint8_t *)file_load(pac_file, &tmp_blob.length, mem_ctx); + torture_comment(tctx, "(saved test) Loaded pac of size %ld from %s\n", (long)tmp_blob.length, pac_file); } else { - tmp_blob = data_blob_talloc(test, saved_pac, sizeof(saved_pac)); + tmp_blob = data_blob_talloc(mem_ctx, saved_pac, sizeof(saved_pac)); } dump_data(10,tmp_blob.data,tmp_blob.length); - principal_string = lp_parm_string(-1,"torture","pac_client_principal"); - if (!principal_string) { - principal_string = "w2003final$@WIN2K3.THINKER.LOCAL"; - } + principal_string = torture_setting_string(tctx, "pac_client_principal", + "w2003final$@WIN2K3.THINKER.LOCAL"); - authtime_string = lp_parm_string(-1,"torture","pac_authtime"); - if (!authtime_string) { - authtime = 1120440609; - } else { - authtime = strtoull(authtime_string, NULL, 0); - } + authtime_string = torture_setting_string(tctx, "pac_authtime", "1120440609"); + authtime = strtoull(authtime_string, NULL, 0); ret = krb5_parse_name(smb_krb5_context->krb5_context, principal_string, &client_principal); if (ret) { - torture_fail(test, - "(saved test) parsing of client principal [%s] failed: %s", - principal_string, - smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, test)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + torture_fail(tctx, + talloc_asprintf(tctx, + "(saved test) parsing of client principal [%s] failed: %s", + principal_string, + smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, mem_ctx))); } /* Decode and verify the signaure on the PAC */ - nt_status = kerberos_decode_pac(test, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, &server_keyblock, client_principal, authtime, NULL); if (!NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, "(saved test) PAC decoding failed: %s", - nt_errstr(nt_status)); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - return False; + torture_fail(tctx, talloc_asprintf(tctx, + "(saved test) PAC decoding failed: %s", + nt_errstr(nt_status))); } /* Parse the PAC again, for the logon info this time */ - nt_status = kerberos_pac_logon_info(test, &logon_info, + nt_status = kerberos_pac_logon_info(mem_ctx, &logon_info, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -416,15 +392,14 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(saved test) PAC decoding (for logon info) failed: %s", - nt_errstr(nt_status)); - - return False; + nt_errstr(nt_status))); } validation.sam3 = &logon_info->info3; - nt_status = make_server_info_netlogon_validation(test, + nt_status = make_server_info_netlogon_validation(mem_ctx, "", 3, &validation, &server_info_out); @@ -435,15 +410,14 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(saved test) PAC decoding (make server info) failed: %s", - nt_errstr(nt_status)); - - return False; + nt_errstr(nt_status))); } if (!pac_file && - !dom_sid_equal(dom_sid_parse_talloc(test, + !dom_sid_equal(dom_sid_parse_talloc(mem_ctx, "S-1-5-21-3048156945-3961193616-3706469200-1005"), server_info_out->account_sid)) { krb5_free_keyblock_contents(smb_krb5_context->krb5_context, @@ -452,14 +426,14 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(saved test) PAC Decode resulted in *different* domain SID: %s != %s", "S-1-5-21-3048156945-3961193616-3706469200-1005", - dom_sid_string(test, server_info_out->account_sid)); - return False; + dom_sid_string(mem_ctx, server_info_out->account_sid))); } - ret = kerberos_encode_pac(test, + ret = kerberos_encode_pac(mem_ctx, pac_data, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -473,8 +447,7 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, "(saved test) PAC push failed"); - return False; + torture_fail(tctx, "(saved test) PAC push failed"); } dump_data(10, validate_blob.data, validate_blob.length); @@ -490,10 +463,10 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, + torture_fail(tctx, + talloc_asprintf(tctx, "(saved test) PAC push failed: original buffer length[%u] != created buffer length[%u]", - (unsigned)tmp_blob.length, (unsigned)validate_blob.length); - return False; + (unsigned)tmp_blob.length, (unsigned)validate_blob.length)); } if (memcmp(tmp_blob.data, validate_blob.data, tmp_blob.length) != 0) { @@ -503,16 +476,15 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, "(saved test) PAC push failed: length[%u] matches, but data does not", (unsigned)tmp_blob.length); DEBUG(0, ("tmp_data:\n")); dump_data(0, tmp_blob.data, tmp_blob.length); DEBUG(0, ("validate_blob:\n")); dump_data(0, validate_blob.data, validate_blob.length); - return False; + torture_fail(tctx, talloc_asprintf(tctx, "(saved test) PAC push failed: length[%u] matches, but data does not", (unsigned)tmp_blob.length)); } - ret = kerberos_create_pac(test, + ret = kerberos_create_pac(mem_ctx, server_info_out, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -527,8 +499,7 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, "(saved test) regnerated PAC create failed"); - return False; + torture_fail(tctx, "(saved test) regnerated PAC create failed"); } dump_data(10,validate_blob.data,validate_blob.length); @@ -538,9 +509,9 @@ static BOOL torture_pac_saved_check(struct torture_context *test, * pointer, padding etc algorithms as win2k3. */ if (tmp_blob.length != validate_blob.length) { - nt_status = ndr_pull_struct_blob(&validate_blob, test, &pac_data2, + nt_status = ndr_pull_struct_blob(&validate_blob, mem_ctx, &pac_data2, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA); - torture_assert_ntstatus_ok(test, nt_status, "can't parse the PAC"); + torture_assert_ntstatus_ok(tctx, nt_status, "can't parse the PAC"); NDR_PRINT_DEBUG(PAC_DATA, pac_data); @@ -552,15 +523,15 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, "(saved test) PAC regenerate failed: original buffer length[%u] != created buffer length[%u]", - (unsigned)tmp_blob.length, (unsigned)validate_blob.length); - return False; + torture_fail(tctx, talloc_asprintf(tctx, + "(saved test) PAC regenerate failed: original buffer length[%u] != created buffer length[%u]", + (unsigned)tmp_blob.length, (unsigned)validate_blob.length)); } if (memcmp(tmp_blob.data, validate_blob.data, tmp_blob.length) != 0) { - nt_status = ndr_pull_struct_blob(&validate_blob, test, &pac_data2, + nt_status = ndr_pull_struct_blob(&validate_blob, mem_ctx, &pac_data2, (ndr_pull_flags_fn_t)ndr_pull_PAC_DATA); - torture_assert_ntstatus_ok(test, nt_status, "can't parse the PAC"); + torture_assert_ntstatus_ok(tctx, nt_status, "can't parse the PAC"); NDR_PRINT_DEBUG(PAC_DATA, pac_data); @@ -572,17 +543,17 @@ static BOOL torture_pac_saved_check(struct torture_context *test, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - torture_fail(test, "(saved test) PAC regenerate failed: length[%u] matches, but data does not", (unsigned)tmp_blob.length); DEBUG(0, ("tmp_data:\n")); dump_data(0, tmp_blob.data, tmp_blob.length); DEBUG(0, ("validate_blob:\n")); dump_data(0, validate_blob.data, validate_blob.length); - return False; + torture_fail(tctx, talloc_asprintf(tctx, + "(saved test) PAC regenerate failed: length[%u] matches, but data does not", (unsigned)tmp_blob.length)); } /* Break the auth time, to ensure we check this vital detail (not setting this caused all the pain in the first place... */ - nt_status = kerberos_decode_pac(test, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -590,14 +561,13 @@ static BOOL torture_pac_saved_check(struct torture_context *test, client_principal, authtime + 1, NULL); if (NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, "(saved test) PAC decoding DID NOT fail on broken auth time (time + 1)"); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); krb5_free_principal(smb_krb5_context->krb5_context, client_principal); - return False; + torture_fail(tctx, "(saved test) PAC decoding DID NOT fail on broken auth time (time + 1)"); } /* Break the client principal */ @@ -606,17 +576,17 @@ static BOOL torture_pac_saved_check(struct torture_context *test, ret = krb5_parse_name(smb_krb5_context->krb5_context, "not the right principal", &client_principal); if (ret) { - torture_fail(test, "(saved test) parsing of bogus client principal failed: %s", - smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, test)); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + torture_fail(tctx, talloc_asprintf(tctx, + "(saved test) parsing of bogus client principal failed: %s", + smb_get_krb5_error_message(smb_krb5_context->krb5_context, ret, mem_ctx))); } - nt_status = kerberos_decode_pac(test, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -624,19 +594,17 @@ static BOOL torture_pac_saved_check(struct torture_context *test, client_principal, authtime, NULL); if (NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, "(saved test) PAC decoding DID NOT fail on modified principal"); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + torture_fail(tctx, "(saved test) PAC decoding DID NOT fail on modified principal"); } /* Finally... Bugger up the signature, and check we fail the checksum */ tmp_blob.data[tmp_blob.length - 2]++; - nt_status = kerberos_decode_pac(test, &pac_data, + nt_status = kerberos_decode_pac(mem_ctx, &pac_data, tmp_blob, smb_krb5_context->krb5_context, &krbtgt_keyblock, @@ -644,32 +612,29 @@ static BOOL torture_pac_saved_check(struct torture_context *test, client_principal, authtime, NULL); if (NT_STATUS_IS_OK(nt_status)) { - torture_fail(test, "(saved test) PAC decoding DID NOT fail on broken checksum"); - krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - return False; + torture_fail(tctx, "(saved test) PAC decoding DID NOT fail on broken checksum"); } krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &krbtgt_keyblock); krb5_free_keyblock_contents(smb_krb5_context->krb5_context, &server_keyblock); - - return True; + return true; } struct torture_suite *torture_pac(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-PAC"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "PAC"); - torture_suite_add_simple_tcase(suite, "self check", - torture_pac_self_check, NULL); + torture_suite_add_simple_test(suite, "self check", + torture_pac_self_check); - torture_suite_add_simple_tcase(suite, "saved check", - torture_pac_saved_check, NULL); + torture_suite_add_simple_test(suite, "saved check", + torture_pac_saved_check); return suite; } diff --git a/source4/torture/basic/aliases.c b/source4/torture/basic/aliases.c index 3643d098ba..01ca33359d 100644 --- a/source4/torture/basic/aliases.c +++ b/source4/torture/basic/aliases.c @@ -34,62 +34,62 @@ struct trans2_blobs { }; /* look for aliases for a query */ -static void gen_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset) +static bool gen_aliases(struct torture_context *tctx, + struct smbcli_state *cli, struct smb_trans2 *t2, + int level_offset) { - TALLOC_CTX *mem_ctx; uint16_t level; struct trans2_blobs *alias_blobs = NULL; struct trans2_blobs *t2b, *t2b2; int count=0, alias_count=0; - mem_ctx = talloc_init("aliases"); - for (level=0;level<2000;level++) { NTSTATUS status; SSVAL(t2->in.params.data, level_offset, level); - status = smb_raw_trans2(cli->tree, mem_ctx, t2); + status = smb_raw_trans2(cli->tree, tctx, t2); if (!NT_STATUS_IS_OK(status)) continue; - t2b = talloc(mem_ctx, struct trans2_blobs); + t2b = talloc(tctx, struct trans2_blobs); t2b->level = level; t2b->params = t2->out.params; t2b->data = t2->out.data; DLIST_ADD(alias_blobs, t2b); - d_printf("\tFound level %4u (0x%03x) of size %3d (0x%02x)\n", + torture_comment(tctx, + "\tFound level %4u (0x%03x) of size %3d (0x%02x)\n", level, level, (int)t2b->data.length, (int)t2b->data.length); count++; } - d_printf("Found %d levels with success status\n", count); + torture_comment(tctx, "Found %d levels with success status\n", count); for (t2b=alias_blobs; t2b; t2b=t2b->next) { for (t2b2=alias_blobs; t2b2; t2b2=t2b2->next) { if (t2b->level >= t2b2->level) continue; if (data_blob_equal(&t2b->params, &t2b2->params) && data_blob_equal(&t2b->data, &t2b2->data)) { - printf("\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n", + torture_comment(tctx, + "\tLevel %u (0x%x) and level %u (0x%x) are possible aliases\n", t2b->level, t2b->level, t2b2->level, t2b2->level); alias_count++; } } } - d_printf("Found %d aliased levels\n", alias_count); - - talloc_free(mem_ctx); + torture_comment(tctx, "Found %d aliased levels\n", alias_count); + + return true; } /* look for qfsinfo aliases */ -static void qfsinfo_aliases(struct smbcli_state *cli) +static bool qfsinfo_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_QFSINFO; - d_printf("\nChecking for QFSINFO aliases\n"); - t2.in.max_param = 0; t2.in.max_data = smb_raw_max_trans_data(cli->tree, 0); t2.in.max_setup = 0; @@ -100,19 +100,18 @@ static void qfsinfo_aliases(struct smbcli_state *cli) t2.in.params = data_blob(NULL, 2); t2.in.data = data_blob(NULL, 0); - gen_aliases(cli, &t2, 0); + return gen_aliases(tctx, cli, &t2, 0); } /* look for qfileinfo aliases */ -static void qfileinfo_aliases(struct smbcli_state *cli) +static bool qfileinfo_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_QFILEINFO; const char *fname = "\\qfileinfo_aliases.txt"; int fnum; - d_printf("\nChecking for QFILEINFO aliases\n"); - t2.in.max_param = 2; t2.in.max_data = smb_raw_max_trans_data(cli->tree, 2); t2.in.max_setup = 0; @@ -125,33 +124,32 @@ static void qfileinfo_aliases(struct smbcli_state *cli) smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, cli, fname); - if (fnum == -1) { - printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", fname, + smbcli_errstr(cli->tree))); smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2)); SSVAL(t2.in.params.data, 0, fnum); - gen_aliases(cli, &t2, 2); + if (!gen_aliases(tctx, cli, &t2, 2)) + return false; smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); + + return true; } /* look for qpathinfo aliases */ -static void qpathinfo_aliases(struct smbcli_state *cli) +static bool qpathinfo_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_QPATHINFO; const char *fname = "\\qpathinfo_aliases.txt"; int fnum; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("qpathinfo"); - - d_printf("\nChecking for QPATHINFO aliases\n"); t2.in.max_param = 2; t2.in.max_data = smb_raw_max_trans_data(cli->tree, 2); @@ -160,42 +158,40 @@ static void qpathinfo_aliases(struct smbcli_state *cli) t2.in.timeout = 0; t2.in.setup_count = 1; t2.in.setup = &setup; - t2.in.params = data_blob_talloc(mem_ctx, NULL, 6); + t2.in.params = data_blob_talloc(tctx, NULL, 6); t2.in.data = data_blob(NULL, 0); smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, cli, fname); - if (fnum == -1) { - printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", fname, + smbcli_errstr(cli->tree))); smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2)); smbcli_close(cli->tree, fnum); SIVAL(t2.in.params.data, 2, 0); - smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params, + smbcli_blob_append_string(cli->session, tctx, &t2.in.params, fname, STR_TERMINATE); - gen_aliases(cli, &t2, 0); + if (!gen_aliases(tctx, cli, &t2, 0)) + return false; smbcli_unlink(cli->tree, fname); - talloc_free(mem_ctx); + + return true; } /* look for trans2 findfirst aliases */ -static void findfirst_aliases(struct smbcli_state *cli) +static bool findfirst_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_FINDFIRST; const char *fname = "\\findfirst_aliases.txt"; int fnum; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("findfirst"); - - d_printf("\nChecking for FINDFIRST aliases\n"); t2.in.max_param = 16; t2.in.max_data = smb_raw_max_trans_data(cli->tree, 16); @@ -204,14 +200,14 @@ static void findfirst_aliases(struct smbcli_state *cli) t2.in.timeout = 0; t2.in.setup_count = 1; t2.in.setup = &setup; - t2.in.params = data_blob_talloc(mem_ctx, NULL, 12); + t2.in.params = data_blob_talloc(tctx, NULL, 12); t2.in.data = data_blob(NULL, 0); smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, cli, fname); - if (fnum == -1) { - printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", fname, + smbcli_errstr(cli->tree))); smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2)); smbcli_close(cli->tree, fnum); @@ -222,28 +218,29 @@ static void findfirst_aliases(struct smbcli_state *cli) SSVAL(t2.in.params.data, 6, 0); SIVAL(t2.in.params.data, 8, 0); - smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params, + smbcli_blob_append_string(cli->session, tctx, &t2.in.params, fname, STR_TERMINATE); - gen_aliases(cli, &t2, 6); + if (!gen_aliases(tctx, cli, &t2, 6)) + return false; smbcli_unlink(cli->tree, fname); - talloc_free(mem_ctx); + + return true; } /* look for aliases for a set function */ -static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int level_offset) +static bool gen_set_aliases(struct torture_context *tctx, + struct smbcli_state *cli, + struct smb_trans2 *t2, int level_offset) { - TALLOC_CTX *mem_ctx; uint16_t level; struct trans2_blobs *alias_blobs = NULL; struct trans2_blobs *t2b; int count=0, dsize; - mem_ctx = talloc_init("aliases"); - for (level=1;level<1100;level++) { NTSTATUS status, status1; SSVAL(t2->in.params.data, level_offset, level); @@ -254,7 +251,7 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int data_blob_free(&t2->in.data); t2->in.data = data_blob(NULL, dsize); data_blob_clear(&t2->in.data); - status = smb_raw_trans2(cli->tree, mem_ctx, t2); + status = smb_raw_trans2(cli->tree, tctx, t2); /* some error codes mean that this whole level doesn't exist */ if (NT_STATUS_EQUAL(NT_STATUS_INVALID_LEVEL, status) || NT_STATUS_EQUAL(NT_STATUS_INVALID_INFO_CLASS, status) || @@ -274,7 +271,7 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int } if (!NT_STATUS_EQUAL(status, status1)) { - printf("level=%d size=%d %s\n", level, dsize, nt_errstr(status)); + torture_comment(tctx, "level=%d size=%d %s\n", level, dsize, nt_errstr(status)); } status1 = status; } @@ -282,33 +279,34 @@ static void gen_set_aliases(struct smbcli_state *cli, struct smb_trans2 *t2, int if (!NT_STATUS_IS_OK(status) && !NT_STATUS_EQUAL(status, NT_STATUS_INVALID_PARAMETER)) continue; - t2b = talloc(mem_ctx, struct trans2_blobs); + t2b = talloc(tctx, struct trans2_blobs); t2b->level = level; t2b->params = t2->out.params; t2b->data = t2->out.data; DLIST_ADD(alias_blobs, t2b); - d_printf("\tFound level %4u (0x%03x) of size %3d (0x%02x)\n", + torture_comment(tctx, + "\tFound level %4u (0x%03x) of size %3d (0x%02x)\n", level, level, (int)t2->in.data.length, (int)t2->in.data.length); count++; } - d_printf("Found %d valid levels\n", count); - talloc_free(mem_ctx); + torture_comment(tctx, "Found %d valid levels\n", count); + + return true; } /* look for setfileinfo aliases */ -static void setfileinfo_aliases(struct smbcli_state *cli) +static bool setfileinfo_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_SETFILEINFO; const char *fname = "\\setfileinfo_aliases.txt"; int fnum; - d_printf("\nChecking for SETFILEINFO aliases\n"); - t2.in.max_param = 2; t2.in.max_data = 0; t2.in.max_setup = 0; @@ -321,33 +319,31 @@ static void setfileinfo_aliases(struct smbcli_state *cli) smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, cli, fname); - if (fnum == -1) { - printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", fname, + smbcli_errstr(cli->tree))); smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2)); SSVAL(t2.in.params.data, 0, fnum); SSVAL(t2.in.params.data, 4, 0); - gen_set_aliases(cli, &t2, 2); + gen_set_aliases(tctx, cli, &t2, 2); smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); + + return true; } /* look for setpathinfo aliases */ -static void setpathinfo_aliases(struct smbcli_state *cli) +static bool setpathinfo_aliases(struct torture_context *tctx, + struct smbcli_state *cli) { struct smb_trans2 t2; uint16_t setup = TRANSACT2_SETPATHINFO; const char *fname = "\\setpathinfo_aliases.txt"; int fnum; - TALLOC_CTX *mem_ctx; - - mem_ctx = talloc_init("findfirst"); - - d_printf("\nChecking for SETPATHINFO aliases\n"); t2.in.max_param = 32; t2.in.max_data = smb_raw_max_trans_data(cli->tree, 32); @@ -356,53 +352,50 @@ static void setpathinfo_aliases(struct smbcli_state *cli) t2.in.timeout = 0; t2.in.setup_count = 1; t2.in.setup = &setup; - t2.in.params = data_blob_talloc(mem_ctx, NULL, 4); + t2.in.params = data_blob_talloc(tctx, NULL, 4); t2.in.data = data_blob(NULL, 0); smbcli_unlink(cli->tree, fname); fnum = create_complex_file(cli, cli, fname); - if (fnum == -1) { - printf("ERROR: open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", fname, + smbcli_errstr(cli->tree))); smbcli_write(cli->tree, fnum, 0, &t2, 0, sizeof(t2)); smbcli_close(cli->tree, fnum); SSVAL(t2.in.params.data, 2, 0); - smbcli_blob_append_string(cli->session, mem_ctx, &t2.in.params, + smbcli_blob_append_string(cli->session, tctx, &t2.in.params, fname, STR_TERMINATE); - gen_set_aliases(cli, &t2, 0); + if (!gen_set_aliases(tctx, cli, &t2, 0)) + return false; - if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { - printf("unlink: %s\n", smbcli_errstr(cli->tree)); - } - talloc_free(mem_ctx); + torture_assert_ntstatus_ok(tctx, smbcli_unlink(cli->tree, fname), + talloc_asprintf(tctx, "unlink: %s", smbcli_errstr(cli->tree))); + + return true; } /* look for aliased info levels in trans2 calls */ -BOOL torture_trans2_aliases(struct torture_context *torture) +struct torture_suite *torture_trans2_aliases(void) { - struct smbcli_state *cli; - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - - qfsinfo_aliases(cli); - qfileinfo_aliases(cli); - qpathinfo_aliases(cli); - findfirst_aliases(cli); - setfileinfo_aliases(cli); - setpathinfo_aliases(cli); - - if (!torture_close_connection(cli)) { - return False; - } - - return True; + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "ALIASES"); + + torture_suite_add_1smb_test(suite, "QFILEINFO aliases", + qfsinfo_aliases); + torture_suite_add_1smb_test(suite, "QFSINFO aliases", qfileinfo_aliases); + torture_suite_add_1smb_test(suite, "QPATHINFO aliases", qpathinfo_aliases); + torture_suite_add_1smb_test(suite, "FINDFIRST aliases", findfirst_aliases); + torture_suite_add_1smb_test(suite, "setfileinfo_aliases", + setfileinfo_aliases); + torture_suite_add_1smb_test(suite, "setpathinfo_aliases", + setpathinfo_aliases); + + return suite; } diff --git a/source4/torture/basic/attr.c b/source4/torture/basic/attr.c index a98f815a92..8e1a53d7c0 100644 --- a/source4/torture/basic/attr.c +++ b/source4/torture/basic/attr.c @@ -87,22 +87,15 @@ static const struct trunc_open_results attr_results[] = { }; -BOOL torture_openattrtest(struct torture_context *torture) +BOOL torture_openattrtest(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = "\\openattr.file"; int fnum1; - BOOL correct = True; uint16_t attr; uint_t i, j, k, l; int failures = 0; - printf("starting open attr test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - for (k = 0, i = 0; i < sizeof(open_attrs_table)/sizeof(uint32_t); i++) { smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); @@ -111,15 +104,13 @@ BOOL torture_openattrtest(struct torture_context *torture) open_attrs_table[i], NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("open %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open %d (1) of %s failed (%s)", i, + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close %d (1) of %s failed (%s)\n", i, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close %d (1) of %s failed (%s)", i, fname, + smbcli_errstr(cli1->tree))); for (j = 0; j < ARRAY_SIZE(open_attrs_table); j++) { fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -132,40 +123,37 @@ BOOL torture_openattrtest(struct torture_context *torture) if (fnum1 == -1) { for (l = 0; l < ARRAY_SIZE(attr_results); l++) { if (attr_results[l].num == k) { - printf("[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(%s)\n", + torture_comment(tctx, "[%d] trunc open 0x%x -> 0x%x of %s failed - should have succeeded !(%s)\n", k, open_attrs_table[i], open_attrs_table[j], fname, smbcli_errstr(cli1->tree)); - correct = False; CHECK_MAX_FAILURES(error_exit); } } - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_ACCESS_DENIED)) { - printf("[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s\n", + torture_assert_ntstatus_equal(tctx, + smbcli_nt_error(cli1->tree), NT_STATUS_ACCESS_DENIED, + talloc_asprintf(tctx, "[%d] trunc open 0x%x -> 0x%x failed with wrong error code %s", k, open_attrs_table[i], open_attrs_table[j], - smbcli_errstr(cli1->tree)); - correct = False; + smbcli_errstr(cli1->tree))); CHECK_MAX_FAILURES(error_exit); - } #if 0 - printf("[%d] trunc open 0x%x -> 0x%x failed\n", k, open_attrs_table[i], open_attrs_table[j]); + torture_comment(tctx, "[%d] trunc open 0x%x -> 0x%x failed\n", k, open_attrs_table[i], open_attrs_table[j]); #endif k++; continue; } - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close %d (2) of %s failed (%s)\n", j, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close %d (2) of %s failed (%s)", j, + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL))) { - printf("getatr(2) failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_getatr(cli1->tree, fname, &attr, NULL, NULL), + talloc_asprintf(tctx, "getatr(2) failed (%s)", smbcli_errstr(cli1->tree))); #if 0 - printf("[%d] getatr check [0x%x] trunc [0x%x] got attr 0x%x\n", + torture_comment(tctx, "[%d] getatr check [0x%x] trunc [0x%x] got attr 0x%x\n", k, open_attrs_table[i], open_attrs_table[j], attr ); #endif @@ -174,12 +162,11 @@ BOOL torture_openattrtest(struct torture_context *torture) if (attr != attr_results[l].result_attr || open_attrs_table[i] != attr_results[l].init_attr || open_attrs_table[j] != attr_results[l].trunc_attr) { - printf("[%d] getatr check failed. [0x%x] trunc [0x%x] got attr 0x%x, should be 0x%x\n", + torture_comment(tctx, "[%d] getatr check failed. [0x%x] trunc [0x%x] got attr 0x%x, should be 0x%x\n", k, open_attrs_table[i], open_attrs_table[j], (uint_t)attr, attr_results[l].result_attr); - correct = False; CHECK_MAX_FAILURES(error_exit); } break; @@ -192,11 +179,6 @@ error_exit: smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); - printf("open attr test %s.\n", correct ? "passed" : "failed"); - - if (!torture_close_connection(cli1)) { - correct = False; - } - return correct; + return true; } diff --git a/source4/torture/basic/base.c b/source4/torture/basic/base.c index 27bafa3a75..1c2b835aa8 100644 --- a/source4/torture/basic/base.c +++ b/source4/torture/basic/base.c @@ -35,11 +35,11 @@ #define CHECK_MAX_FAILURES(label) do { if (++failures >= torture_failures) goto label; } while (0) -static struct smbcli_state *open_nbt_connection(void) +static struct smbcli_state *open_nbt_connection(struct torture_context *tctx) { struct nbt_name called, calling; struct smbcli_state *cli; - const char *host = lp_parm_string(-1, "torture", "host"); + const char *host = torture_setting_string(tctx, "host", NULL); make_nbt_name_client(&calling, lp_netbios_name()); @@ -47,17 +47,17 @@ static struct smbcli_state *open_nbt_connection(void) cli = smbcli_state_init(NULL); if (!cli) { - printf("Failed initialize smbcli_struct to connect with %s\n", host); + torture_comment(tctx, "Failed initialize smbcli_struct to connect with %s\n", host); goto failed; } if (!smbcli_socket_connect(cli, host)) { - printf("Failed to connect with %s\n", host); + torture_comment(tctx, "Failed to connect with %s\n", host); goto failed; } if (!smbcli_transport_establish(cli, &calling, &called)) { - printf("%s rejected the session\n",host); + torture_comment(tctx, "%s rejected the session\n",host); goto failed; } @@ -68,46 +68,42 @@ failed: return NULL; } -static BOOL tcon_devtest(struct smbcli_state *cli, - const char *myshare, const char *devtype, - NTSTATUS expected_error) +static BOOL tcon_devtest(struct torture_context *tctx, + struct smbcli_state *cli, + const char *myshare, const char *devtype, + NTSTATUS expected_error) { BOOL status; - BOOL ret; - const char *password = lp_parm_string(-1, "torture", "password"); + const char *password = torture_setting_string(tctx, "password", NULL); status = NT_STATUS_IS_OK(smbcli_tconX(cli, myshare, devtype, password)); - printf("Trying share %s with devtype %s\n", myshare, devtype); + torture_comment(tctx, "Trying share %s with devtype %s\n", myshare, devtype); if (NT_STATUS_IS_OK(expected_error)) { - if (status) { - ret = True; - } else { - printf("tconX to share %s with type %s " - "should have succeeded but failed\n", - myshare, devtype); - ret = False; + if (!status) { + torture_fail(tctx, talloc_asprintf(tctx, + "tconX to share %s with type %s " + "should have succeeded but failed", + myshare, devtype)); } smbcli_tdis(cli); } else { if (status) { - printf("tconx to share %s with type %s " + torture_fail(tctx, talloc_asprintf(tctx, + "tconx to share %s with type %s " "should have failed but succeeded\n", - myshare, devtype); - ret = False; + myshare, devtype)); } else { if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree), expected_error)) { - ret = True; } else { - printf("Returned unexpected error\n"); - ret = False; + torture_fail(tctx, "Returned unexpected error"); } } } - return ret; + return true; } @@ -116,93 +112,74 @@ static BOOL tcon_devtest(struct smbcli_state *cli, test whether fnums and tids open on one VC are available on another (a major security hole) */ -static BOOL run_fdpasstest(struct torture_context *torture) +static bool run_fdpasstest(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; const char *fname = "\\fdpass.tst"; int fnum1, oldtid; uint8_t buf[1024]; - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting fdpasstest\n"); - smbcli_unlink(cli1->tree, fname); - printf("Opening a file on connection 1\n"); + torture_comment(tctx, "Opening a file on connection 1\n"); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, + "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree))); - printf("writing to file on connection 1\n"); + torture_comment(tctx, "writing to file on connection 1\n"); - if (smbcli_write(cli1->tree, fnum1, 0, "hello world\n", 0, 13) != 13) { - printf("write failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, + smbcli_write(cli1->tree, fnum1, 0, "hello world\n", 0, 13) == 13, + talloc_asprintf(tctx, + "write failed (%s)\n", smbcli_errstr(cli1->tree))); oldtid = cli2->tree->tid; cli2->session->vuid = cli1->session->vuid; cli2->tree->tid = cli1->tree->tid; cli2->session->pid = cli1->session->pid; - printf("reading from file on connection 2\n"); + torture_comment(tctx, "reading from file on connection 2\n"); - if (smbcli_read(cli2->tree, fnum1, buf, 0, 13) == 13) { - printf("read succeeded! nasty security hole [%s]\n", - buf); - return False; - } + torture_assert(tctx, smbcli_read(cli2->tree, fnum1, buf, 0, 13) != 13, + talloc_asprintf(tctx, + "read succeeded! nasty security hole [%s]\n", buf)); smbcli_close(cli1->tree, fnum1); smbcli_unlink(cli1->tree, fname); cli2->tree->tid = oldtid; - torture_close_connection(cli1); - torture_close_connection(cli2); - - printf("finished fdpasstest\n"); - return True; + return true; } /** This checks how the getatr calls works */ -static BOOL run_attrtest(struct torture_context *torture) +static BOOL run_attrtest(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; int fnum; time_t t, t2; const char *fname = "\\attrib123456789.tst"; BOOL correct = True; - printf("starting attrib test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - smbcli_unlink(cli->tree, fname); fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) { - printf("getatr failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } - printf("New file time is %s", ctime(&t)); + torture_comment(tctx, "New file time is %s", ctime(&t)); if (abs(t - time(NULL)) > 60*60*24*10) { - printf("ERROR: SMBgetatr bug. time is %s", + torture_comment(tctx, "ERROR: SMBgetatr bug. time is %s", ctime(&t)); t = time(NULL); correct = False; @@ -210,44 +187,38 @@ static BOOL run_attrtest(struct torture_context *torture) t2 = t-60*60*24; /* 1 day ago */ - printf("Setting file time to %s", ctime(&t2)); + torture_comment(tctx, "Setting file time to %s", ctime(&t2)); if (NT_STATUS_IS_ERR(smbcli_setatr(cli->tree, fname, 0, t2))) { - printf("setatr failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "setatr failed (%s)\n", smbcli_errstr(cli->tree)); correct = True; } if (NT_STATUS_IS_ERR(smbcli_getatr(cli->tree, fname, NULL, NULL, &t))) { - printf("getatr failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "getatr failed (%s)\n", smbcli_errstr(cli->tree)); correct = True; } - printf("Retrieved file time as %s", ctime(&t)); + torture_comment(tctx, "Retrieved file time as %s", ctime(&t)); if (t != t2) { - printf("ERROR: getatr/setatr bug. times are\n%s", + torture_comment(tctx, "ERROR: getatr/setatr bug. times are\n%s", ctime(&t)); - printf("%s", ctime(&t2)); + torture_comment(tctx, "%s", ctime(&t2)); correct = True; } smbcli_unlink(cli->tree, fname); - if (!torture_close_connection(cli)) { - correct = False; - } - - printf("attrib test finished\n"); - return correct; } /** This checks a couple of trans2 calls */ -static BOOL run_trans2test(struct torture_context *torture) +static BOOL run_trans2test(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; int fnum; size_t size; time_t c_time, a_time, m_time, w_time, m_time2; @@ -257,33 +228,27 @@ static BOOL run_trans2test(struct torture_context *torture) const char *pname; BOOL correct = True; - printf("starting trans2 test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - smbcli_unlink(cli->tree, fname); - printf("Testing qfileinfo\n"); + torture_comment(tctx, "Testing qfileinfo\n"); fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (NT_STATUS_IS_ERR(smbcli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time, NULL, NULL))) { - printf("ERROR: qfileinfo failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qfileinfo failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } - printf("Testing NAME_INFO\n"); + torture_comment(tctx, "Testing NAME_INFO\n"); if (NT_STATUS_IS_ERR(smbcli_qfilename(cli->tree, fnum, &pname))) { - printf("ERROR: qfilename failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qfilename failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } if (!pname || strcmp(pname, fname)) { - printf("qfilename gave different name? [%s] [%s]\n", + torture_comment(tctx, "qfilename gave different name? [%s] [%s]\n", fname, pname); correct = False; } @@ -294,30 +259,30 @@ static BOOL run_trans2test(struct torture_context *torture) fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (fnum == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); return False; } smbcli_close(cli->tree, fnum); - printf("Checking for sticky create times\n"); + torture_comment(tctx, "Checking for sticky create times\n"); if (NT_STATUS_IS_ERR(smbcli_qpathinfo(cli->tree, fname, &c_time, &a_time, &m_time, &size, NULL))) { - printf("ERROR: qpathinfo failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qpathinfo failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } else { if (c_time != m_time) { - printf("create time=%s", ctime(&c_time)); - printf("modify time=%s", ctime(&m_time)); - printf("This system appears to have sticky create times\n"); + torture_comment(tctx, "create time=%s", ctime(&c_time)); + torture_comment(tctx, "modify time=%s", ctime(&m_time)); + torture_comment(tctx, "This system appears to have sticky create times\n"); } if (a_time % (60*60) == 0) { - printf("access time=%s", ctime(&a_time)); - printf("This system appears to set a midnight access time\n"); + torture_comment(tctx, "access time=%s", ctime(&a_time)); + torture_comment(tctx, "This system appears to set a midnight access time\n"); correct = False; } if (abs(m_time - time(NULL)) > 60*60*24*7) { - printf("ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time)); + torture_comment(tctx, "ERROR: totally incorrect times - maybe word reversed? mtime=%s", ctime(&m_time)); correct = False; } } @@ -328,12 +293,12 @@ static BOOL run_trans2test(struct torture_context *torture) O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, fname, &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) { - printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } else { if (w_time < 60*60*24*2) { - printf("write time=%s", ctime(&w_time)); - printf("This system appears to set a initial 0 write time\n"); + torture_comment(tctx, "write time=%s", ctime(&w_time)); + torture_comment(tctx, "This system appears to set a initial 0 write time\n"); correct = False; } } @@ -344,12 +309,12 @@ static BOOL run_trans2test(struct torture_context *torture) /* check if the server updates the directory modification time when creating a new file */ if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, dname))) { - printf("ERROR: mkdir failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: mkdir failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } sleep(3); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time, &w_time, &size, NULL, NULL))) { - printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } @@ -358,41 +323,35 @@ static BOOL run_trans2test(struct torture_context *torture) smbcli_write(cli->tree, fnum, 0, &fnum, 0, sizeof(fnum)); smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_qpathinfo2(cli->tree, "\\trans2\\", &c_time, &a_time, &m_time2, &w_time, &size, NULL, NULL))) { - printf("ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "ERROR: qpathinfo2 failed (%s)\n", smbcli_errstr(cli->tree)); correct = False; } else { if (m_time2 == m_time) { - printf("This system does not update directory modification times\n"); + torture_comment(tctx, "This system does not update directory modification times\n"); correct = False; } } smbcli_unlink(cli->tree, fname2); smbcli_rmdir(cli->tree, dname); - if (!torture_close_connection(cli)) { - correct = False; - } - - printf("trans2 test finished\n"); - return correct; } /* send smb negprot commands, not reading the response */ -static BOOL run_negprot_nowait(struct torture_context *torture) +static BOOL run_negprot_nowait(struct torture_context *tctx) { int i; struct smbcli_state *cli, *cli2; BOOL correct = True; - printf("starting negprot nowait test\n"); + torture_comment(tctx, "starting negprot nowait test\n"); - cli = open_nbt_connection(); + cli = open_nbt_connection(tctx); if (!cli) { return False; } - printf("Filling send buffer\n"); + torture_comment(tctx, "Filling send buffer\n"); for (i=0;i<100;i++) { struct smbcli_request *req; @@ -400,30 +359,30 @@ static BOOL run_negprot_nowait(struct torture_context *torture) event_loop_once(cli->transport->socket->event.ctx); if (req->state == SMBCLI_REQUEST_ERROR) { if (i > 0) { - printf("Failed to fill pipe packet[%d] - %s (ignored)\n", i+1, nt_errstr(req->status)); + torture_comment(tctx, "Failed to fill pipe packet[%d] - %s (ignored)\n", i+1, nt_errstr(req->status)); break; } else { - printf("Failed to fill pipe - %s \n", nt_errstr(req->status)); + torture_comment(tctx, "Failed to fill pipe - %s \n", nt_errstr(req->status)); torture_close_connection(cli); return False; } } } - printf("Opening secondary connection\n"); + torture_comment(tctx, "Opening secondary connection\n"); if (!torture_open_connection(&cli2, 1)) { - printf("Failed to open secondary connection\n"); + torture_comment(tctx, "Failed to open secondary connection\n"); correct = False; } if (!torture_close_connection(cli2)) { - printf("Failed to close secondary connection\n"); + torture_comment(tctx, "Failed to close secondary connection\n"); correct = False; } torture_close_connection(cli); - printf("finished negprot nowait test\n"); + torture_comment(tctx, "finished negprot nowait test\n"); return correct; } @@ -432,9 +391,8 @@ static BOOL run_negprot_nowait(struct torture_context *torture) this checks to see if a secondary tconx can use open files from an earlier tconx */ -static BOOL run_tcon_test(struct torture_context *torture) +static BOOL run_tcon_test(struct torture_context *tctx, struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname = "\\tcontest.tmp"; int fnum1; uint16_t cnum1, cnum2, cnum3; @@ -442,23 +400,17 @@ static BOOL run_tcon_test(struct torture_context *torture) uint8_t buf[4]; BOOL ret = True; struct smbcli_tree *tree1; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); - const char *password = lp_parm_string(-1, "torture", "password"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("starting tcontest\n"); + const char *host = torture_setting_string(tctx, "host", NULL); + const char *share = torture_setting_string(tctx, "share", NULL); + const char *password = torture_setting_string(tctx, "password", NULL); if (smbcli_deltree(cli->tree, fname) == -1) { - printf("unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); return False; } @@ -467,13 +419,13 @@ static BOOL run_tcon_test(struct torture_context *torture) memset(&buf, 0, 4); /* init buf so valgrind won't complain */ if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) != 4) { - printf("initial write failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "initial write failed (%s)\n", smbcli_errstr(cli->tree)); return False; } tree1 = cli->tree; /* save old tree connection */ if (NT_STATUS_IS_ERR(smbcli_tconX(cli, share, "?????", password))) { - printf("%s refused 2nd tree connect (%s)\n", host, + torture_comment(tctx, "%s refused 2nd tree connect (%s)\n", host, smbcli_errstr(cli->tree)); talloc_free(cli); return False; @@ -487,10 +439,10 @@ static BOOL run_tcon_test(struct torture_context *torture) cli->tree->tid = cnum2; if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { - printf("* server allows write with wrong TID\n"); + torture_comment(tctx, "* server allows write with wrong TID\n"); ret = False; } else { - printf("server fails write with wrong TID : %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "server fails write with wrong TID : %s\n", smbcli_errstr(cli->tree)); } @@ -498,10 +450,10 @@ static BOOL run_tcon_test(struct torture_context *torture) cli->tree->tid = cnum3; if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { - printf("* server allows write with invalid TID\n"); + torture_comment(tctx, "* server allows write with invalid TID\n"); ret = False; } else { - printf("server fails write with invalid TID : %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "server fails write with invalid TID : %s\n", smbcli_errstr(cli->tree)); } /* try a write with an invalid vuid */ @@ -509,24 +461,24 @@ static BOOL run_tcon_test(struct torture_context *torture) cli->tree->tid = cnum1; if (smbcli_write(cli->tree, fnum1, 0, buf, 130, 4) == 4) { - printf("* server allows write with invalid VUID\n"); + torture_comment(tctx, "* server allows write with invalid VUID\n"); ret = False; } else { - printf("server fails write with invalid VUID : %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "server fails write with invalid VUID : %s\n", smbcli_errstr(cli->tree)); } cli->session->vuid = vuid1; cli->tree->tid = cnum1; if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) { - printf("close failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(cli->tree)); return False; } cli->tree->tid = cnum2; if (NT_STATUS_IS_ERR(smbcli_tdis(cli))) { - printf("secondary tdis failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "secondary tdis failed (%s)\n", smbcli_errstr(cli->tree)); return False; } @@ -535,73 +487,52 @@ static BOOL run_tcon_test(struct torture_context *torture) smbcli_unlink(tree1, fname); - if (!torture_close_connection(cli)) { - return False; - } - return ret; } /** checks for correct tconX support */ -static BOOL run_tcon_devtype_test(struct torture_context *torture) +static BOOL run_tcon_devtype_test(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1 = NULL; - NTSTATUS status; - BOOL ret = True; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); - - status = smbcli_full_connection(NULL, - &cli1, host, - share, NULL, - cmdline_credentials, NULL); + const char *share = torture_setting_string(tctx, "share", NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("could not open connection\n"); - return False; - } + if (!tcon_devtest(tctx, cli1, "IPC$", "A:", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - if (!tcon_devtest(cli1, "IPC$", "A:", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, "IPC$", "?????", NT_STATUS_OK)) + return false; - if (!tcon_devtest(cli1, "IPC$", "?????", NT_STATUS_OK)) - ret = False; - - if (!tcon_devtest(cli1, "IPC$", "LPT:", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, "IPC$", "LPT:", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - if (!tcon_devtest(cli1, "IPC$", "IPC", NT_STATUS_OK)) - ret = False; + if (!tcon_devtest(tctx, cli1, "IPC$", "IPC", NT_STATUS_OK)) + return false; - if (!tcon_devtest(cli1, "IPC$", "FOOBA", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, "IPC$", "FOOBA", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - if (!tcon_devtest(cli1, share, "A:", NT_STATUS_OK)) - ret = False; + if (!tcon_devtest(tctx, cli1, share, "A:", NT_STATUS_OK)) + return false; - if (!tcon_devtest(cli1, share, "?????", NT_STATUS_OK)) - ret = False; + if (!tcon_devtest(tctx, cli1, share, "?????", NT_STATUS_OK)) + return false; - if (!tcon_devtest(cli1, share, "LPT:", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, share, "LPT:", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - if (!tcon_devtest(cli1, share, "IPC", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, share, "IPC", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - if (!tcon_devtest(cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE)) - ret = False; + if (!tcon_devtest(tctx, cli1, share, "FOOBA", NT_STATUS_BAD_DEVICE_TYPE)) + return false; - talloc_free(cli1); - - if (ret) - printf("Passed tcondevtest\n"); - - return ret; + return true; } -static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2) +static BOOL rw_torture2(struct torture_context *tctx, + struct smbcli_state *c1, struct smbcli_state *c2) { const char *lockfname = "\\torture2.lck"; int fnum1; @@ -612,119 +543,86 @@ static BOOL rw_torture2(struct smbcli_state *c1, struct smbcli_state *c2) BOOL correct = True; ssize_t bytes_read, bytes_written; - if (smbcli_deltree(c1->tree, lockfname) == -1) { - printf("unlink failed (%s)\n", smbcli_errstr(c1->tree)); - } + torture_assert(tctx, smbcli_deltree(c1->tree, lockfname) != -1, + talloc_asprintf(tctx, + "unlink failed (%s)", smbcli_errstr(c1->tree))); fnum1 = smbcli_open(c1->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("first open read/write of %s failed (%s)\n", - lockfname, smbcli_errstr(c1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, + "first open read/write of %s failed (%s)", + lockfname, smbcli_errstr(c1->tree))); fnum2 = smbcli_open(c2->tree, lockfname, O_RDONLY, DENY_NONE); - if (fnum2 == -1) { - printf("second open read-only of %s failed (%s)\n", - lockfname, smbcli_errstr(c2->tree)); - smbcli_close(c1->tree, fnum1); - return False; - } + torture_assert(tctx, fnum2 != -1, + talloc_asprintf(tctx, + "second open read-only of %s failed (%s)", + lockfname, smbcli_errstr(c2->tree))); - printf("Checking data integrity over %d ops\n", torture_numops); + torture_comment(tctx, "Checking data integrity over %d ops\n", + torture_numops); for (i=0;itree, fnum1, 0, buf, 0, buf_size)) != buf_size) { - printf("write failed (%s)\n", smbcli_errstr(c1->tree)); - printf("wrote %d, expected %d\n", (int)bytes_written, (int)buf_size); + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c1->tree)); + torture_comment(tctx, "wrote %d, expected %d\n", (int)bytes_written, (int)buf_size); correct = False; break; } if ((bytes_read = smbcli_read(c2->tree, fnum2, buf_rd, 0, buf_size)) != buf_size) { - printf("read failed (%s)\n", smbcli_errstr(c2->tree)); - printf("read %d, expected %d\n", (int)bytes_read, (int)buf_size); + torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c2->tree)); + torture_comment(tctx, "read %d, expected %d\n", (int)bytes_read, (int)buf_size); correct = False; break; } - if (memcmp(buf_rd, buf, buf_size) != 0) - { - printf("read/write compare failed\n"); - correct = False; - break; - } + torture_assert(tctx, memcmp(buf_rd, buf, buf_size) == 0, + "read/write compare failed\n"); } - if (NT_STATUS_IS_ERR(smbcli_close(c2->tree, fnum2))) { - printf("close failed (%s)\n", smbcli_errstr(c2->tree)); - correct = False; - } - if (NT_STATUS_IS_ERR(smbcli_close(c1->tree, fnum1))) { - printf("close failed (%s)\n", smbcli_errstr(c1->tree)); - correct = False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(c2->tree, fnum2), + talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(c2->tree))); + torture_assert_ntstatus_ok(tctx, smbcli_close(c1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(c1->tree))); - if (NT_STATUS_IS_ERR(smbcli_unlink(c1->tree, lockfname))) { - printf("unlink failed (%s)\n", smbcli_errstr(c1->tree)); - correct = False; - } + torture_assert_ntstatus_ok(tctx, smbcli_unlink(c1->tree, lockfname), + talloc_asprintf(tctx, "unlink failed (%s)", smbcli_errstr(c1->tree))); return correct; } -#define BOOLSTR(b) ((b) ? "Yes" : "No") - -static BOOL run_readwritetest(struct torture_context *torture) +static bool run_readwritetest(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; - BOOL test1, test2 = True; - - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting readwritetest\n"); - - test1 = rw_torture2(cli1, cli2); - printf("Passed readwritetest v1: %s\n", BOOLSTR(test1)); + torture_comment(tctx, "Running readwritetest v1\n"); + if (!rw_torture2(tctx, cli1, cli2)) + return false; - if (test1) { - test2 = rw_torture2(cli1, cli1); - printf("Passed readwritetest v2: %s\n", BOOLSTR(test2)); - } - - if (!torture_close_connection(cli1)) { - test1 = False; - } + torture_comment(tctx, "Running readwritetest v2\n"); - if (!torture_close_connection(cli2)) { - test2 = False; - } + if (!rw_torture2(tctx, cli1, cli1)) + return false; - return (test1 && test2); + return true; } - - - - /* test the timing of deferred open requests */ -static BOOL run_deferopen(struct smbcli_state *cli, int dummy) +static BOOL run_deferopen(struct torture_context *tctx, struct smbcli_state *cli, int dummy) { const char *fname = "\\defer_open_test.dat"; int retries=4; @@ -732,11 +630,11 @@ static BOOL run_deferopen(struct smbcli_state *cli, int dummy) BOOL correct = True; if (retries <= 0) { - printf("failed to connect\n"); + torture_comment(tctx, "failed to connect\n"); return False; } - printf("Testing deferred open requests.\n"); + torture_comment(tctx, "Testing deferred open requests.\n"); while (i < 4) { int fnum = -1; @@ -755,23 +653,23 @@ static BOOL run_deferopen(struct smbcli_state *cli, int dummy) if (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) { double e = timeval_elapsed(&tv); if (e < 0.5 || e > 1.5) { - fprintf(stderr,"Timing incorrect %.2f violation\n", + torture_comment(tctx,"Timing incorrect %.2f violation\n", e); } } } while (NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)); if (fnum == -1) { - fprintf(stderr,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx,"Failed to open %s, error=%s\n", fname, smbcli_errstr(cli->tree)); return False; } - printf("pid %u open %d\n", (unsigned)getpid(), i); + torture_comment(tctx, "pid %u open %d\n", (unsigned)getpid(), i); sleep(10); i++; if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { - fprintf(stderr,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx,"Failed to close %s, error=%s\n", fname, smbcli_errstr(cli->tree)); return False; } sleep(2); @@ -780,15 +678,12 @@ static BOOL run_deferopen(struct smbcli_state *cli, int dummy) if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { /* All until the last unlink will fail with sharing violation. */ if (!NT_STATUS_EQUAL(smbcli_nt_error(cli->tree),NT_STATUS_SHARING_VIOLATION)) { - printf("unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "unlink of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); correct = False; } } - printf("deferred test finished\n"); - if (!torture_close_connection(cli)) { - correct = False; - } + torture_comment(tctx, "deferred test finished\n"); return correct; } @@ -796,24 +691,17 @@ static BOOL run_deferopen(struct smbcli_state *cli, int dummy) Try with a wrong vuid and check error message. */ -static BOOL run_vuidtest(struct torture_context *torture) +static BOOL run_vuidtest(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname = "\\vuid.tst"; int fnum; size_t size; time_t c_time, a_time, m_time; - BOOL correct = True; uint16_t orig_vuid; NTSTATUS result; - printf("starting vuid test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - smbcli_unlink(cli->tree, fname); fnum = smbcli_open(cli->tree, fname, @@ -823,50 +711,40 @@ static BOOL run_vuidtest(struct torture_context *torture) cli->session->vuid += 1234; - printf("Testing qfileinfo with wrong vuid\n"); + torture_comment(tctx, "Testing qfileinfo with wrong vuid\n"); if (NT_STATUS_IS_OK(result = smbcli_qfileinfo(cli->tree, fnum, NULL, &size, &c_time, &a_time, &m_time, NULL, NULL))) { - printf("ERROR: qfileinfo passed with wrong vuid\n"); - correct = False; + torture_fail(tctx, "qfileinfo passed with wrong vuid"); } if (!NT_STATUS_EQUAL(cli->transport->error.e.nt_status, NT_STATUS_DOS(ERRSRV, ERRbaduid)) && !NT_STATUS_EQUAL(cli->transport->error.e.nt_status, NT_STATUS_INVALID_HANDLE)) { - printf("ERROR: qfileinfo should have returned DOS error " + torture_fail(tctx, talloc_asprintf(tctx, + "qfileinfo should have returned DOS error " "ERRSRV:ERRbaduid\n but returned %s\n", - smbcli_errstr(cli->tree)); - correct = False; + smbcli_errstr(cli->tree))); } cli->session->vuid -= 1234; - if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum))) { - printf("close failed (%s)\n", smbcli_errstr(cli->tree)); - correct = False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli->tree, fnum), + talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli->tree))); smbcli_unlink(cli->tree, fname); - if (!torture_close_connection(cli)) { - correct = False; - } - - printf("vuid test finished\n"); - - return correct; + return true; } /* Test open mode returns on read-only files. */ - static BOOL run_opentest(struct torture_context *torture) + static BOOL run_opentest(struct torture_context *tctx, struct smbcli_state *cli1, + struct smbcli_state *cli2) { - static struct smbcli_state *cli1; - static struct smbcli_state *cli2; const char *fname = "\\readonly.file"; char *control_char_fname; int fnum1, fnum2; @@ -877,12 +755,6 @@ static BOOL run_vuidtest(struct torture_context *torture) int failures = 0; int i; - printf("starting open test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - asprintf(&control_char_fname, "\\readonly.afile"); for (i = 1; i <= 0x1f; i++) { control_char_fname[10] = i; @@ -891,7 +763,7 @@ static BOOL run_vuidtest(struct torture_context *torture) if (!check_error(__location__, cli1, ERRDOS, ERRinvalidname, NT_STATUS_OBJECT_NAME_INVALID)) { - printf("Error code should be NT_STATUS_OBJECT_NAME_INVALID, was %s for file with %d char\n", + torture_comment(tctx, "Error code should be NT_STATUS_OBJECT_NAME_INVALID, was %s for file with %d char\n", smbcli_errstr(cli1->tree), i); failures++; } @@ -905,31 +777,31 @@ static BOOL run_vuidtest(struct torture_context *torture) free(control_char_fname); if (!failures) - printf("Create file with control char names passed.\n"); + torture_comment(tctx, "Create file with control char names passed.\n"); smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_setatr(cli1->tree, fname, FILE_ATTRIBUTE_READONLY, 0))) { - printf("smbcli_setatr failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "smbcli_setatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test1); return False; } fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE); if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test1); return False; } @@ -939,10 +811,10 @@ static BOOL run_vuidtest(struct torture_context *torture) if (check_error(__location__, cli1, ERRDOS, ERRnoaccess, NT_STATUS_ACCESS_DENIED)) { - printf("correct error code ERRDOS/ERRnoaccess returned\n"); + torture_comment(tctx, "correct error code ERRDOS/ERRnoaccess returned\n"); } - printf("finished open test 1\n"); + torture_comment(tctx, "finished open test 1\n"); error_test1: smbcli_close(cli1->tree, fnum1); @@ -952,7 +824,7 @@ error_test1: fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_WRITE); if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } @@ -961,23 +833,23 @@ error_test1: if (check_error(__location__, cli1, ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION)) { - printf("correct error code ERRDOS/ERRbadshare returned\n"); + torture_comment(tctx, "correct error code ERRDOS/ERRbadshare returned\n"); } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } smbcli_unlink(cli1->tree, fname); - printf("finished open test 2\n"); + torture_comment(tctx, "finished open test 2\n"); /* Test truncate open disposition on file opened for read. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum1 == -1) { - printf("(3) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(3) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } @@ -986,24 +858,24 @@ error_test1: memset(buf, '\0', 20); if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) { - printf("write failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(cli1->tree)); correct = False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(3) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(3) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } /* Ensure size == 20. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { - printf("(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); return False; } if (fsize != 20) { - printf("(3) file size != 20\n"); + torture_comment(tctx, "(3) file size != 20\n"); CHECK_MAX_FAILURES(error_test3); return False; } @@ -1012,64 +884,60 @@ error_test1: fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY|O_TRUNC, DENY_NONE); if (fnum1 == -1) { - printf("(3) open (2) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(3) open (2) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "close2 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } /* Ensure size == 0. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { - printf("(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(3) getatr failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test3); return False; } if (fsize != 0) { - printf("(3) file size != 0\n"); + torture_comment(tctx, "(3) file size != 0\n"); CHECK_MAX_FAILURES(error_test3); return False; } - printf("finished open test 3\n"); + torture_comment(tctx, "finished open test 3\n"); error_test3: smbcli_unlink(cli1->tree, fname); - printf("testing ctemp\n"); + torture_comment(tctx, "testing ctemp\n"); fnum1 = smbcli_ctemp(cli1->tree, "\\", &tmp_path); if (fnum1 == -1) { - printf("ctemp failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "ctemp failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test4); return False; } - printf("ctemp gave path %s\n", tmp_path); + torture_comment(tctx, "ctemp gave path %s\n", tmp_path); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close of temp failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "close of temp failed (%s)\n", smbcli_errstr(cli1->tree)); } if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, tmp_path))) { - printf("unlink of temp failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "unlink of temp failed (%s)\n", smbcli_errstr(cli1->tree)); } error_test4: /* Test the non-io opens... */ - if (!torture_open_connection(&cli2, 1)) { - return False; - } - smbcli_setatr(cli2->tree, fname, 0, 0); smbcli_unlink(cli2->tree, fname); - printf("TEST #1 testing 2 non-io opens (no delete)\n"); + torture_comment(tctx, "TEST #1 testing 2 non-io opens (no delete)\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 1 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 1 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test10); return False; } @@ -1077,31 +945,31 @@ error_test4: fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 == -1) { - printf("test 1 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 1 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test10); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); return False; } - printf("non-io open test #1 passed.\n"); + torture_comment(tctx, "non-io open test #1 passed.\n"); error_test10: smbcli_unlink(cli1->tree, fname); - printf("TEST #2 testing 2 non-io opens (first with delete)\n"); + torture_comment(tctx, "TEST #2 testing 2 non-io opens (first with delete)\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 2 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 2 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test20); return False; } @@ -1110,31 +978,31 @@ error_test10: NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 == -1) { - printf("test 2 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 2 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test20); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 1 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 1 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } - printf("non-io open test #2 passed.\n"); + torture_comment(tctx, "non-io open test #2 passed.\n"); error_test20: smbcli_unlink(cli1->tree, fname); - printf("TEST #3 testing 2 non-io opens (second with delete)\n"); + torture_comment(tctx, "TEST #3 testing 2 non-io opens (second with delete)\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 3 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 3 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test30); return False; } @@ -1143,31 +1011,31 @@ error_test20: NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 == -1) { - printf("test 3 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 3 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test30); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 3 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 3 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("test 3 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 3 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); return False; } - printf("non-io open test #3 passed.\n"); + torture_comment(tctx, "non-io open test #3 passed.\n"); error_test30: smbcli_unlink(cli1->tree, fname); - printf("TEST #4 testing 2 non-io opens (both with delete)\n"); + torture_comment(tctx, "TEST #4 testing 2 non-io opens (both with delete)\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 4 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 4 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test40); return False; } @@ -1176,29 +1044,29 @@ error_test30: NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 != -1) { - printf("test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 4 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test40); return False; } - printf("test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); + torture_comment(tctx, "test 4 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 4 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 4 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } - printf("non-io open test #4 passed.\n"); + torture_comment(tctx, "non-io open test #4 passed.\n"); error_test40: smbcli_unlink(cli1->tree, fname); - printf("TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n"); + torture_comment(tctx, "TEST #5 testing 2 non-io opens (both with delete - both with file share delete)\n"); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, SEC_STD_DELETE|SEC_FILE_READ_ATTRIBUTE, FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 5 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 5 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test50); return False; } @@ -1207,24 +1075,24 @@ error_test40: NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 == -1) { - printf("test 5 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 5 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test50); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 5 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 5 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("test 5 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 5 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); return False; } - printf("non-io open test #5 passed.\n"); + torture_comment(tctx, "non-io open test #5 passed.\n"); error_test50: - printf("TEST #6 testing 1 non-io open, one io open\n"); + torture_comment(tctx, "TEST #6 testing 1 non-io open, one io open\n"); smbcli_unlink(cli1->tree, fname); @@ -1232,7 +1100,7 @@ error_test50: NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 6 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 6 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test60); return False; } @@ -1241,24 +1109,24 @@ error_test50: NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 == -1) { - printf("test 6 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 6 open 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test60); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 6 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 6 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("test 6 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 6 close 2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); return False; } - printf("non-io open test #6 passed.\n"); + torture_comment(tctx, "non-io open test #6 passed.\n"); error_test60: - printf("TEST #7 testing 1 non-io open, one io open with delete\n"); + torture_comment(tctx, "TEST #7 testing 1 non-io open, one io open with delete\n"); smbcli_unlink(cli1->tree, fname); @@ -1266,7 +1134,7 @@ error_test60: NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); if (fnum1 == -1) { - printf("test 7 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 7 open 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test70); return False; } @@ -1275,29 +1143,29 @@ error_test60: NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN_IF, 0, 0); if (fnum2 != -1) { - printf("test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); + torture_comment(tctx, "test 7 open 2 of %s SUCCEEDED - should have failed (%s)\n", fname, smbcli_errstr(cli2->tree)); CHECK_MAX_FAILURES(error_test70); return False; } - printf("test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); + torture_comment(tctx, "test 7 open 2 of %s gave %s (correct error should be %s)\n", fname, smbcli_errstr(cli2->tree), "sharing violation"); if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("test 7 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "test 7 close 1 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } - printf("non-io open test #7 passed.\n"); + torture_comment(tctx, "non-io open test #7 passed.\n"); error_test70: - printf("TEST #8 testing one normal open, followed by lock, followed by open with truncate\n"); + torture_comment(tctx, "TEST #8 testing one normal open, followed by lock, followed by open with truncate\n"); smbcli_unlink(cli1->tree, fname); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - printf("(8) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) open (1) of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } @@ -1306,72 +1174,65 @@ error_test70: memset(buf, '\0', 20); if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, 20) != 20) { - printf("(8) write failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) write failed (%s)\n", smbcli_errstr(cli1->tree)); correct = False; } /* Ensure size == 20. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { - printf("(8) getatr (1) failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) getatr (1) failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); return False; } if (fsize != 20) { - printf("(8) file size != 20\n"); + torture_comment(tctx, "(8) file size != 20\n"); CHECK_MAX_FAILURES(error_test80); return False; } /* Get an exclusive lock on the open file. */ if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) { - printf("(8) lock1 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) lock1 failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); return False; } fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE); if (fnum1 == -1) { - printf("(8) open (2) of %s with truncate failed (%s)\n", fname, smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) open (2) of %s with truncate failed (%s)\n", fname, smbcli_errstr(cli1->tree)); return False; } /* Ensure size == 0. */ if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &fsize, NULL))) { - printf("(8) getatr (2) failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) getatr (2) failed (%s)\n", smbcli_errstr(cli1->tree)); CHECK_MAX_FAILURES(error_test80); return False; } if (fsize != 0) { - printf("(8) file size != 0\n"); + torture_comment(tctx, "(8) file size != 0\n"); CHECK_MAX_FAILURES(error_test80); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "(8) close1 failed (%s)\n", smbcli_errstr(cli1->tree)); return False; } error_test80: - printf("open test #8 passed.\n"); + torture_comment(tctx, "open test #8 passed.\n"); smbcli_unlink(cli1->tree, fname); - if (!torture_close_connection(cli1)) { - correct = False; - } - if (!torture_close_connection(cli2)) { - correct = False; - } - return correct; } @@ -1399,19 +1260,12 @@ error_test80: /** Test ntcreate calls made by xcopy */ -static BOOL run_xcopy(struct torture_context *torture) +static bool run_xcopy(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = "\\test.txt"; - BOOL correct = True; int fnum1, fnum2; - printf("starting xcopy test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, FIRST_DESIRED_ACCESS, FILE_ATTRIBUTE_ARCHIVE, @@ -1419,62 +1273,43 @@ static BOOL run_xcopy(struct torture_context *torture) NTCREATEX_DISP_OVERWRITE_IF, 0x4044, 0); - if (fnum1 == -1) { - printf("First open failed - %s\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, + "First open failed - %s", smbcli_errstr(cli1->tree))); fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, SECOND_DESIRED_ACCESS, 0, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0x200000, 0); - if (fnum2 == -1) { - printf("second open failed - %s\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, + "second open failed - %s", smbcli_errstr(cli1->tree))); - if (!torture_close_connection(cli1)) { - correct = False; - } - - return correct; + return true; } -static BOOL run_iometer(struct torture_context *torture) +static bool run_iometer(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname = "\\iobw.tst"; int fnum; size_t filesize; NTSTATUS status; char buf[2048]; int ops; - BOOL result = False; - - printf("Starting iometer test\n"); memset(buf, 0, sizeof(buf)); - if (!torture_open_connection(&cli, 0)) { - return False; - } - status = smbcli_getatr(cli->tree, fname, NULL, &filesize, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("smbcli_getatr failed: %s\n", nt_errstr(status)); - goto done; - } + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "smbcli_getatr failed: %s", nt_errstr(status))); - printf("size: %d\n", (int)filesize); + torture_comment(tctx, "size: %d\n", (int)filesize); filesize -= (sizeof(buf) - 1); fnum = smbcli_nt_create_full(cli->tree, fname, 0x16, 0x2019f, 0, 0x3, 3, 0x42, 0x3); - if (fnum == -1) { - printf("open failed: %s\n", smbcli_errstr(cli->tree)); - goto done; - } + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, "open failed: %s", + smbcli_errstr(cli->tree))); ops = 0; @@ -1487,61 +1322,40 @@ static BOOL run_iometer(struct torture_context *torture) for (i=0; i torture_numops) { - result = True; - goto done; + return true; } res = smbcli_read(cli->tree, fnum, buf, random() % filesize, sizeof(buf)); - if (res != sizeof(buf)) { - printf("read failed: %s\n", - smbcli_errstr(cli->tree)); - goto done; - } + torture_assert(tctx, res == sizeof(buf), + talloc_asprintf(tctx, "read failed: %s", + smbcli_errstr(cli->tree))); } for (i=0; i torture_numops) { - result = True; - goto done; + return true; } res = smbcli_write(cli->tree, fnum, 0, buf, random() % filesize, sizeof(buf)); - if (res != sizeof(buf)) { - printf("read failed: %s\n", - smbcli_errstr(cli->tree)); - goto done; - } + torture_assert(tctx, res == sizeof(buf), + talloc_asprintf(tctx, "read failed: %s", + smbcli_errstr(cli->tree))); } } - result = True; - done: - - if (!torture_close_connection(cli)) { - printf("close_connection failed: %s\n", - smbcli_errstr(cli->tree)); - return False; - } - - return result; + return true; } /** tries variants of chkpath */ -static BOOL torture_chkpath_test(struct torture_context *torture) +static BOOL torture_chkpath_test(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; int fnum; BOOL ret; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("starting chkpath test\n"); - - printf("Testing valid and invalid paths\n"); + torture_comment(tctx, "Testing valid and invalid paths\n"); /* cleanup from an old run */ smbcli_rmdir(cli->tree, "\\chkpath.dir\\dir2"); @@ -1549,29 +1363,29 @@ static BOOL torture_chkpath_test(struct torture_context *torture) smbcli_rmdir(cli->tree, "\\chkpath.dir"); if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir"))) { - printf("mkdir1 failed : %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "mkdir1 failed : %s\n", smbcli_errstr(cli->tree)); return False; } if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\chkpath.dir\\dir2"))) { - printf("mkdir2 failed : %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "mkdir2 failed : %s\n", smbcli_errstr(cli->tree)); return False; } fnum = smbcli_open(cli->tree, "\\chkpath.dir\\foo.txt", O_RDWR|O_CREAT|O_EXCL, DENY_NONE); if (fnum == -1) { - printf("open1 failed (%s)\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "open1 failed (%s)\n", smbcli_errstr(cli->tree)); return False; } smbcli_close(cli->tree, fnum); if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir"))) { - printf("chkpath1 failed: %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "chkpath1 failed: %s\n", smbcli_errstr(cli->tree)); ret = False; } if (NT_STATUS_IS_ERR(smbcli_chkpath(cli->tree, "\\chkpath.dir\\dir2"))) { - printf("chkpath2 failed: %s\n", smbcli_errstr(cli->tree)); + torture_comment(tctx, "chkpath2 failed: %s\n", smbcli_errstr(cli->tree)); ret = False; } @@ -1579,7 +1393,7 @@ static BOOL torture_chkpath_test(struct torture_context *torture) ret = check_error(__location__, cli, ERRDOS, ERRbadpath, NT_STATUS_NOT_A_DIRECTORY); } else { - printf("* chkpath on a file should fail\n"); + torture_comment(tctx, "* chkpath on a file should fail\n"); ret = False; } @@ -1587,7 +1401,7 @@ static BOOL torture_chkpath_test(struct torture_context *torture) ret = check_error(__location__, cli, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_NAME_NOT_FOUND); } else { - printf("* chkpath on a non existent file should fail\n"); + torture_comment(tctx, "* chkpath on a non existent file should fail\n"); ret = False; } @@ -1595,7 +1409,7 @@ static BOOL torture_chkpath_test(struct torture_context *torture) ret = check_error(__location__, cli, ERRDOS, ERRbadpath, NT_STATUS_OBJECT_PATH_NOT_FOUND); } else { - printf("* chkpath on a non existent component should fail\n"); + torture_comment(tctx, "* chkpath on a non existent component should fail\n"); ret = False; } @@ -1603,10 +1417,6 @@ static BOOL torture_chkpath_test(struct torture_context *torture) smbcli_unlink(cli->tree, "\\chkpath.dir\\*"); smbcli_rmdir(cli->tree, "\\chkpath.dir"); - if (!torture_close_connection(cli)) { - return False; - } - return ret; } @@ -1614,7 +1424,7 @@ static BOOL torture_chkpath_test(struct torture_context *torture) * This is a test to excercise some weird Samba3 error paths. */ -static BOOL torture_samba3_errorpaths(struct torture_context *torture) +static BOOL torture_samba3_errorpaths(struct torture_context *tctx) { BOOL nt_status_support; struct smbcli_state *cli_nt = NULL, *cli_dos = NULL; @@ -1627,14 +1437,14 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) NTSTATUS status; if (mem_ctx == NULL) { - printf("talloc_init failed\n"); + torture_comment(tctx, "talloc_init failed\n"); return False; } nt_status_support = lp_nt_status_support(); if (!lp_set_cmdline("nt status support", "yes")) { - printf("Could not set 'nt status support = yes'\n"); + torture_comment(tctx, "Could not set 'nt status support = yes'\n"); goto fail; } @@ -1643,7 +1453,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) } if (!lp_set_cmdline("nt status support", "no")) { - printf("Could not set 'nt status support = yes'\n"); + torture_comment(tctx, "Could not set 'nt status support = yes'\n"); goto fail; } @@ -1653,7 +1463,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) if (!lp_set_cmdline("nt status support", nt_status_support ? "yes":"no")) { - printf("Could not reset 'nt status support = yes'"); + torture_comment(tctx, "Could not reset 'nt status support = yes'"); goto fail; } @@ -1661,7 +1471,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) smbcli_rmdir(cli_nt->tree, dname); if (!NT_STATUS_IS_OK(smbcli_mkdir(cli_nt->tree, dname))) { - printf("smbcli_mkdir(%s) failed: %s\n", dname, + torture_comment(tctx, "smbcli_mkdir(%s) failed: %s\n", dname, smbcli_errstr(cli_nt->tree)); goto fail; } @@ -1681,14 +1491,14 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) status = smb_raw_open(cli_nt->tree, mem_ctx, &io); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION)); goto fail; } status = smb_raw_open(cli_dos->tree, mem_ctx, &io); if (!NT_STATUS_EQUAL(status, NT_STATUS_DOS(ERRDOS, ERRfilexists))) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_DOS(ERRDOS, ERRfilexists))); goto fail; @@ -1696,14 +1506,14 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) status = smbcli_mkdir(cli_nt->tree, dname); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION)); goto fail; } status = smbcli_mkdir(cli_dos->tree, dname); if (!NT_STATUS_EQUAL(status, NT_STATUS_DOS(ERRDOS, ERRnoaccess))) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_DOS(ERRDOS, ERRnoaccess))); goto fail; @@ -1712,7 +1522,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) io.ntcreatex.in.create_options = NTCREATEX_OPTIONS_DIRECTORY; status = smb_raw_open(cli_nt->tree, mem_ctx, &io); if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_COLLISION)) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_OBJECT_NAME_COLLISION)); goto fail; @@ -1720,7 +1530,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) status = smb_raw_open(cli_dos->tree, mem_ctx, &io); if (!NT_STATUS_EQUAL(status, NT_STATUS_DOS(ERRDOS, ERRfilexists))) { - printf("(%s) incorrect status %s should be %s\n", + torture_comment(tctx, "(%s) incorrect status %s should be %s\n", __location__, nt_errstr(status), nt_errstr(NT_STATUS_DOS(ERRDOS, ERRfilexists))); goto fail; @@ -1732,28 +1542,28 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) fnum = smbcli_open(cli_nt->tree, fname, O_RDWR | O_CREAT, 5); if (fnum != -1) { - printf("Open(%s) with invalid deny mode succeeded -- " + torture_comment(tctx, "Open(%s) with invalid deny mode succeeded -- " "expected failure\n", fname); smbcli_close(cli_nt->tree, fnum); goto fail; } if (!NT_STATUS_EQUAL(smbcli_nt_error(cli_nt->tree), NT_STATUS_DOS(ERRDOS,ERRbadaccess))) { - printf("Expected DOS error ERRDOS/ERRbadaccess, " + torture_comment(tctx, "Expected DOS error ERRDOS/ERRbadaccess, " "got %s\n", smbcli_errstr(cli_nt->tree)); goto fail; } fnum = smbcli_open(cli_dos->tree, fname, O_RDWR | O_CREAT, 5); if (fnum != -1) { - printf("Open(%s) with invalid deny mode succeeded -- " + torture_comment(tctx, "Open(%s) with invalid deny mode succeeded -- " "expected failure\n", fname); smbcli_close(cli_nt->tree, fnum); goto fail; } if (!NT_STATUS_EQUAL(smbcli_nt_error(cli_nt->tree), NT_STATUS_DOS(ERRDOS,ERRbadaccess))) { - printf("Expected DOS error ERRDOS:ERRbadaccess, " + torture_comment(tctx, "Expected DOS error ERRDOS:ERRbadaccess, " "got %s\n", smbcli_errstr(cli_nt->tree)); goto fail; } @@ -1767,7 +1577,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (fnum != -1) { - printf("Open(%s) succeeded -- expected failure\n", + torture_comment(tctx, "Open(%s) succeeded -- expected failure\n", os2_fname); smbcli_close(cli_dos->tree, fnum); goto fail; @@ -1775,7 +1585,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) if (!NT_STATUS_EQUAL(smbcli_nt_error(cli_dos->tree), NT_STATUS_DOS(ERRDOS, ERRcannotopen))) { - printf("Expected DOS error ERRDOS/ERRcannotopen, got %s\n", + torture_comment(tctx, "Expected DOS error ERRDOS/ERRcannotopen, got %s\n", smbcli_errstr(cli_dos->tree)); goto fail; } @@ -1784,7 +1594,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (fnum != -1) { - printf("Open(%s) succeeded -- expected failure\n", + torture_comment(tctx, "Open(%s) succeeded -- expected failure\n", os2_fname); smbcli_close(cli_nt->tree, fnum); goto fail; @@ -1792,7 +1602,7 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) if (!NT_STATUS_EQUAL(smbcli_nt_error(cli_nt->tree), NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("Expected error NT_STATUS_OBJECT_NAME_NOT_FOUND, " + torture_comment(tctx, "Expected error NT_STATUS_OBJECT_NAME_NOT_FOUND, " "got %s\n", smbcli_errstr(cli_nt->tree)); goto fail; } @@ -1814,52 +1624,61 @@ static BOOL torture_samba3_errorpaths(struct torture_context *torture) NTSTATUS torture_base_init(void) { - register_torture_op("BASE-FDPASS", run_fdpasstest); - register_torture_op("BASE-LOCK1", torture_locktest1); - register_torture_op("BASE-LOCK2", torture_locktest2); - register_torture_op("BASE-LOCK3", torture_locktest3); - register_torture_op("BASE-LOCK4", torture_locktest4); - register_torture_op("BASE-LOCK5", torture_locktest5); - register_torture_op("BASE-LOCK6", torture_locktest6); - register_torture_op("BASE-LOCK7", torture_locktest7); - register_torture_op("BASE-UNLINK", torture_unlinktest); - register_torture_op("BASE-ATTR", run_attrtest); - register_torture_op("BASE-TRANS2", run_trans2test); - register_torture_op("BASE-NEGNOWAIT", run_negprot_nowait); - register_torture_op("BASE-DIR1", torture_dirtest1); - register_torture_op("BASE-DIR2", torture_dirtest2); - register_torture_op("BASE-DENY1", torture_denytest1); - register_torture_op("BASE-DENY2", torture_denytest2); - register_torture_op("BASE-DENY3", torture_denytest3); - register_torture_op("BASE-DENYDOS", torture_denydos_sharing); - register_torture_multi_op("BASE-NTDENY1", torture_ntdenytest1); - register_torture_op("BASE-NTDENY2", torture_ntdenytest2); - register_torture_op("BASE-TCON", run_tcon_test); - register_torture_op("BASE-TCONDEV", run_tcon_devtype_test); - register_torture_op("BASE-VUID", run_vuidtest); - register_torture_op("BASE-RW1", run_readwritetest); - register_torture_op("BASE-OPEN", run_opentest); - register_torture_multi_op("BASE-DEFER_OPEN", run_deferopen); - register_torture_op("BASE-XCOPY", run_xcopy); - register_torture_op("BASE-IOMETER", run_iometer); - register_torture_op("BASE-RENAME", torture_test_rename); - register_torture_op("BASE-DELETE", torture_test_delete); - register_torture_op("BASE-PROPERTIES", torture_test_properties); - register_torture_op("BASE-MANGLE", torture_mangle); - register_torture_op("BASE-OPENATTR", torture_openattrtest); - register_torture_op("BASE-CHARSET", torture_charset); - register_torture_op("BASE-CHKPATH", torture_chkpath_test); - register_torture_op("BASE-SECLEAK", torture_sec_leak); - register_torture_op("BASE-DISCONNECT", torture_disconnect); - register_torture_op("BASE-DELAYWRITE", torture_delay_write); - register_torture_op("BASE-SAMBA3ERROR", torture_samba3_errorpaths); - - register_torture_op("SCAN-CASETABLE", torture_casetable); - register_torture_op("SCAN-UTABLE", torture_utable); - register_torture_op("SCAN-SMB", torture_smb_scan); - register_torture_op("SCAN-ALIASES", torture_trans2_aliases); - register_torture_op("SCAN-TRANS2", torture_trans2_scan); - register_torture_op("SCAN-NTTRANS", torture_nttrans_scan); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), "BASE"); + + torture_suite_add_2smb_test(suite, "FDPASS", run_fdpasstest); + torture_suite_add_suite(suite, torture_base_locktest()); + torture_suite_add_1smb_test(suite, "UNLINK", torture_unlinktest); + torture_suite_add_1smb_test(suite, "ATTR", run_attrtest); + torture_suite_add_1smb_test(suite, "TRANS2", run_trans2test); + torture_suite_add_simple_test(suite, "NEGNOWAIT", run_negprot_nowait); + torture_suite_add_1smb_test(suite, "DIR1", torture_dirtest1); + torture_suite_add_1smb_test(suite, "DIR2", torture_dirtest2); + torture_suite_add_1smb_test(suite, "DENY1", torture_denytest1); + torture_suite_add_2smb_test(suite, "DENY2", torture_denytest2); + torture_suite_add_2smb_test(suite, "DENY3", torture_denytest3); + torture_suite_add_1smb_test(suite, "DENYDOS", torture_denydos_sharing); + torture_suite_add_smb_multi_test(suite, "NTDENY1", torture_ntdenytest1); + torture_suite_add_2smb_test(suite, "NTDENY2", torture_ntdenytest2); + torture_suite_add_1smb_test(suite, "TCON", run_tcon_test); + torture_suite_add_1smb_test(suite, "TCONDEV", run_tcon_devtype_test); + torture_suite_add_1smb_test(suite, "VUID", run_vuidtest); + torture_suite_add_2smb_test(suite, "RW1", run_readwritetest); + torture_suite_add_2smb_test(suite, "OPEN", run_opentest); + torture_suite_add_smb_multi_test(suite, "DEFER_OPEN", run_deferopen); + torture_suite_add_1smb_test(suite, "XCOPY", run_xcopy); + torture_suite_add_1smb_test(suite, "IOMETER", run_iometer); + torture_suite_add_1smb_test(suite, "RENAME", torture_test_rename); + torture_suite_add_suite(suite, torture_test_delete()); + torture_suite_add_1smb_test(suite, "PROPERTIES", torture_test_properties); + torture_suite_add_1smb_test(suite, "MANGLE", torture_mangle); + torture_suite_add_1smb_test(suite, "OPENATTR", torture_openattrtest); + torture_suite_add_1smb_test(suite, "CHARSET", torture_charset); + torture_suite_add_1smb_test(suite, "CHKPATH", torture_chkpath_test); + torture_suite_add_1smb_test(suite, "SECLEAK", torture_sec_leak); + torture_suite_add_simple_test(suite, "DISCONNECT", torture_disconnect); + torture_suite_add_suite(suite, torture_delay_write()); + torture_suite_add_simple_test(suite, "SAMBA3ERROR", torture_samba3_errorpaths); + + torture_suite_add_1smb_test(suite, "CASETABLE", torture_casetable); + torture_suite_add_1smb_test(suite, "UTABLE", torture_utable); + torture_suite_add_simple_test(suite, "SMB", torture_smb_scan); + torture_suite_add_suite(suite, torture_trans2_aliases()); + torture_suite_add_1smb_test(suite, "TRANS2", torture_trans2_scan); + torture_suite_add_1smb_test(suite, "NTTRANS", torture_nttrans_scan); + + torture_suite_add_simple_test(suite, "BENCH-HOLDCON", torture_holdcon); + torture_suite_add_simple_test(suite, "BENCH-READWRITE", run_benchrw); + torture_suite_add_smb_multi_test(suite, "BENCH-TORTURE", run_torture); + torture_suite_add_1smb_test(suite, "SCAN-PIPE_NUMBER", run_pipe_number); + torture_suite_add_1smb_test(suite, "SCAN-IOCTL", torture_ioctl_test); + torture_suite_add_smb_multi_test(suite, "SCAN-MAXFID", run_maxfidtest); + + suite->description = talloc_strdup(suite, + "Basic SMB tests (imported from the original smbtorture)"); + + torture_register_suite(suite); return NT_STATUS_OK; } 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; } diff --git a/source4/torture/basic/delaywrite.c b/source4/torture/basic/delaywrite.c index e42ca1239d..4c2a511721 100644 --- a/source4/torture/basic/delaywrite.c +++ b/source4/torture/basic/delaywrite.c @@ -32,7 +32,7 @@ #define BASEDIR "\\delaywrite" -static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static BOOL test_delayed_write_update(struct torture_context *tctx, struct smbcli_state *cli) { union smb_fileinfo finfo1, finfo2; const char *fname = BASEDIR "\\torture_file.txt"; @@ -42,15 +42,13 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ ssize_t written; time_t t; - printf("Testing delayed update of write time\n"); - if (!torture_setup_dir(cli, BASEDIR)) { return False; } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - printf("Failed to open %s\n", fname); + torture_comment(tctx, "Failed to open %s\n", fname); return False; } @@ -58,15 +56,15 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ finfo1.basic_info.in.file.fnum = fnum1; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("Initial write time %s\n", - nt_time_string(mem_ctx, finfo1.basic_info.out.write_time)); + torture_comment(tctx, "Initial write time %s\n", + nt_time_string(tctx, finfo1.basic_info.out.write_time)); /* 3 second delay to ensure we get past any 2 second time granularity (older systems may have that) */ @@ -75,7 +73,7 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1); if (written != 1) { - printf("write failed - wrote %d bytes (%s)\n", + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); return False; } @@ -83,17 +81,17 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ t = time(NULL); while (time(NULL) < t+120) { - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); ret = False; break; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time after %d seconds\n", + torture_comment(tctx, "Server updated write_time after %d seconds\n", (int)(time(NULL) - t)); break; } @@ -102,7 +100,7 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - printf("Server did not update write time?!\n"); + torture_comment(tctx, "Server did not update write time?!\n"); ret = False; } @@ -119,9 +117,9 @@ static BOOL test_delayed_write_update(struct smbcli_state *cli, TALLOC_CTX *mem_ * Do as above, but using 2 connections. */ -static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static BOOL test_delayed_write_update2(struct torture_context *tctx, struct smbcli_state *cli, + struct smbcli_state *cli2) { - struct smbcli_state *cli2=NULL; union smb_fileinfo finfo1, finfo2; const char *fname = BASEDIR "\\torture_file.txt"; NTSTATUS status; @@ -132,19 +130,13 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem time_t t; union smb_flush flsh; - printf("Testing delayed update of write time using 2 connections\n"); - - if (!torture_open_connection(&cli2, 1)) { - return False; - } - if (!torture_setup_dir(cli, BASEDIR)) { return False; } fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT, DENY_NONE); if (fnum1 == -1) { - printf("Failed to open %s\n", fname); + torture_comment(tctx, "Failed to open %s\n", fname); return False; } @@ -152,15 +144,15 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem finfo1.basic_info.in.file.fnum = fnum1; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("Initial write time %s\n", - nt_time_string(mem_ctx, finfo1.basic_info.out.write_time)); + torture_comment(tctx, "Initial write time %s\n", + nt_time_string(tctx, finfo1.basic_info.out.write_time)); /* 3 second delay to ensure we get past any 2 second time granularity (older systems may have that) */ @@ -198,17 +190,17 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem while (time(NULL) < t+120) { finfo2.basic_info.in.file.path = fname; - status = smb_raw_pathinfo(cli2->tree, mem_ctx, &finfo2); + status = smb_raw_pathinfo(cli2->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); ret = False; break; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time after %d seconds\n", + torture_comment(tctx, "Server updated write_time after %d seconds\n", (int)(time(NULL) - t)); break; } @@ -217,7 +209,7 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - printf("Server did not update write time?!\n"); + torture_comment(tctx, "Server did not update write time?!\n"); ret = False; } @@ -227,23 +219,23 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem finfo1.basic_info.in.file.fnum = fnum1; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("Modified write time %s\n", - nt_time_string(mem_ctx, finfo1.basic_info.out.write_time)); + torture_comment(tctx, "Modified write time %s\n", + nt_time_string(tctx, finfo1.basic_info.out.write_time)); - printf("Doing a 10 byte write to extend the file and see if this changes the last write time.\n"); + torture_comment(tctx, "Doing a 10 byte write to extend the file and see if this changes the last write time.\n"); written = smbcli_write(cli->tree, fnum1, 0, "0123456789", 1, 10); if (written != 10) { - printf("write failed - wrote %d bytes (%s)\n", + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); return False; } @@ -251,7 +243,7 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem /* Just to prove to tridge that the an smbflush has no effect on the write time :-). The setfileinfo IS STICKY. JRA. */ - printf("Doing flush after write\n"); + torture_comment(tctx, "Doing flush after write\n"); flsh.flush.level = RAW_FLUSH_FLUSH; flsh.flush.in.file.fnum = fnum1; @@ -267,17 +259,17 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem don't have any effect. But make sure. */ while (time(NULL) < t+15) { - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); ret = False; break; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time after %d seconds\n", + torture_comment(tctx, "Server updated write_time after %d seconds\n", (int)(time(NULL) - t)); break; } @@ -286,47 +278,47 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - printf("Server did not update write time\n"); + torture_comment(tctx, "Server did not update write time\n"); } fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { - printf("Failed to open %s\n", fname); + torture_comment(tctx, "Failed to open %s\n", fname); return False; } - printf("Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n"); + torture_comment(tctx, "Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n"); written = smbcli_write(cli->tree, fnum2, 0, "0123456789", 11, 10); if (written != 10) { - printf("write failed - wrote %d bytes (%s)\n", + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); return False; } - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time\n"); + torture_comment(tctx, "Server updated write_time\n"); } - printf("Closing the first fd to see if write time updated.\n"); + torture_comment(tctx, "Closing the first fd to see if write time updated.\n"); smbcli_close(cli->tree, fnum1); fnum1 = -1; - printf("Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n"); + torture_comment(tctx, "Doing a 10 byte write to extend the file via second fd and see if this changes the last write time.\n"); written = smbcli_write(cli->tree, fnum2, 0, "0123456789", 21, 10); if (written != 10) { - printf("write failed - wrote %d bytes (%s)\n", + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); return False; } @@ -334,16 +326,16 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; finfo1.basic_info.in.file.fnum = fnum2; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time\n"); + torture_comment(tctx, "Server updated write_time\n"); } t = time(NULL); @@ -352,17 +344,17 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem don't have any effect. But make sure. */ while (time(NULL) < t+15) { - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); ret = False; break; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time after %d seconds\n", + torture_comment(tctx, "Server updated write_time after %d seconds\n", (int)(time(NULL) - t)); break; } @@ -371,17 +363,17 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - printf("Server did not update write time\n"); + torture_comment(tctx, "Server did not update write time\n"); } - printf("Closing both fd's to see if write time updated.\n"); + torture_comment(tctx, "Closing both fd's to see if write time updated.\n"); smbcli_close(cli->tree, fnum2); fnum2 = -1; fnum1 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); if (fnum1 == -1) { - printf("Failed to open %s\n", fname); + torture_comment(tctx, "Failed to open %s\n", fname); return False; } @@ -389,23 +381,23 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem finfo1.basic_info.in.file.fnum = fnum1; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("Second open initial write time %s\n", - nt_time_string(mem_ctx, finfo1.basic_info.out.write_time)); + torture_comment(tctx, "Second open initial write time %s\n", + nt_time_string(tctx, finfo1.basic_info.out.write_time)); sleep(10); - printf("Doing a 10 byte write to extend the file to see if this changes the last write time.\n"); + torture_comment(tctx, "Doing a 10 byte write to extend the file to see if this changes the last write time.\n"); written = smbcli_write(cli->tree, fnum1, 0, "0123456789", 31, 10); if (written != 10) { - printf("write failed - wrote %d bytes (%s)\n", + torture_comment(tctx, "write failed - wrote %d bytes (%s)\n", (int)written, __location__); return False; } @@ -413,16 +405,16 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; finfo1.basic_info.in.file.fnum = fnum1; finfo2 = finfo1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); return False; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time\n"); + torture_comment(tctx, "Server updated write_time\n"); } t = time(NULL); @@ -431,17 +423,17 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem don't have any effect. But make sure. */ while (time(NULL) < t+15) { - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); ret = False; break; } - printf("write time %s\n", - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "write time %s\n", + nt_time_string(tctx, finfo2.basic_info.out.write_time)); if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("Server updated write_time after %d seconds\n", + torture_comment(tctx, "Server updated write_time after %d seconds\n", (int)(time(NULL) - t)); break; } @@ -450,7 +442,7 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem } if (finfo1.basic_info.out.write_time == finfo2.basic_info.out.write_time) { - printf("Server did not update write time\n"); + torture_comment(tctx, "Server did not update write time\n"); } @@ -458,9 +450,6 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem second connection to ensure it's the same. This is very easy for a Windows server but a bastard to get right on a POSIX server. JRA. */ - if (cli2 != NULL) { - torture_close_connection(cli2); - } if (fnum1 != -1) smbcli_close(cli->tree, fnum1); smbcli_unlink(cli->tree, fname); @@ -480,7 +469,8 @@ static BOOL test_delayed_write_update2(struct smbcli_state *cli, TALLOC_CTX *mem * nasty.... */ -static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) +static BOOL test_finfo_after_write(struct torture_context *tctx, struct smbcli_state *cli, + struct smbcli_state *cli2) { union smb_fileinfo finfo1, finfo2; const char *fname = BASEDIR "\\torture_file.txt"; @@ -489,9 +479,6 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx int fnum2; BOOL ret = True; ssize_t written; - struct smbcli_state *cli2=NULL; - - printf("Testing finfo update on close\n"); if (!torture_setup_dir(cli, BASEDIR)) { return False; @@ -506,7 +493,7 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx finfo1.basic_info.level = RAW_FILEINFO_BASIC_INFO; finfo1.basic_info.in.file.fnum = fnum1; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo1); + status = smb_raw_fileinfo(cli->tree, tctx, &finfo1); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); @@ -519,19 +506,15 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx written = smbcli_write(cli->tree, fnum1, 0, "x", 0, 1); if (written != 1) { - printf("(%s) written gave %d - should have been 1\n", + torture_comment(tctx, "(%s) written gave %d - should have been 1\n", __location__, (int)written); ret = False; goto done; } - if (!torture_open_connection(&cli2, 1)) { - return False; - } - fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE); if (fnum2 == -1) { - printf("(%s) failed to open 2nd time - %s\n", + torture_comment(tctx, "(%s) failed to open 2nd time - %s\n", __location__, smbcli_errstr(cli2->tree)); ret = False; goto done; @@ -540,7 +523,7 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx written = smbcli_write(cli2->tree, fnum2, 0, "x", 0, 1); if (written != 1) { - printf("(%s) written gave %d - should have been 1\n", + torture_comment(tctx, "(%s) written gave %d - should have been 1\n", __location__, (int)written); ret = False; goto done; @@ -549,7 +532,7 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx finfo2.basic_info.level = RAW_FILEINFO_BASIC_INFO; finfo2.basic_info.in.file.path = fname; - status = smb_raw_pathinfo(cli2->tree, mem_ctx, &finfo2); + status = smb_raw_pathinfo(cli2->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("(%s) fileinfo failed: %s\n", @@ -560,31 +543,31 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx if (finfo1.basic_info.out.create_time != finfo2.basic_info.out.create_time) { - printf("(%s) create_time changed\n", __location__); + torture_comment(tctx, "(%s) create_time changed\n", __location__); ret = False; goto done; } if (finfo1.basic_info.out.access_time != finfo2.basic_info.out.access_time) { - printf("(%s) access_time changed\n", __location__); + torture_comment(tctx, "(%s) access_time changed\n", __location__); ret = False; goto done; } if (finfo1.basic_info.out.write_time != finfo2.basic_info.out.write_time) { - printf("(%s) write_time changed\n", __location__); - printf("write time conn 1 = %s, conn 2 = %s\n", - nt_time_string(mem_ctx, finfo1.basic_info.out.write_time), - nt_time_string(mem_ctx, finfo2.basic_info.out.write_time)); + torture_comment(tctx, "(%s) write_time changed\n", __location__); + torture_comment(tctx, "write time conn 1 = %s, conn 2 = %s\n", + nt_time_string(tctx, finfo1.basic_info.out.write_time), + nt_time_string(tctx, finfo2.basic_info.out.write_time)); ret = False; goto done; } if (finfo1.basic_info.out.change_time != finfo2.basic_info.out.change_time) { - printf("(%s) change_time changed\n", __location__); + torture_comment(tctx, "(%s) change_time changed\n", __location__); ret = False; goto done; } @@ -595,14 +578,13 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx * *not* have updated the stat on disk */ smbcli_close(cli2->tree, fnum2); - torture_close_connection(cli2); cli2 = NULL; /* This call is only for the people looking at ethereal :-) */ finfo2.basic_info.level = RAW_FILEINFO_BASIC_INFO; finfo2.basic_info.in.file.path = fname; - status = smb_raw_pathinfo(cli->tree, mem_ctx, &finfo2); + status = smb_raw_pathinfo(cli->tree, tctx, &finfo2); if (!NT_STATUS_IS_OK(status)) { DEBUG(0, ("fileinfo failed: %s\n", nt_errstr(status))); @@ -615,9 +597,6 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx smbcli_close(cli->tree, fnum1); smbcli_unlink(cli->tree, fname); smbcli_deltree(cli->tree, BASEDIR); - if (cli2 != NULL) { - torture_close_connection(cli2); - } return ret; } @@ -626,23 +605,13 @@ static BOOL test_finfo_after_write(struct smbcli_state *cli, TALLOC_CTX *mem_ctx /* testing of delayed update of write_time */ -BOOL torture_delay_write(struct torture_context *torture) +struct torture_suite *torture_delay_write(void) { - struct smbcli_state *cli; - BOOL ret = True; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "DELAYWRITE"); - mem_ctx = talloc_init("torture_delay_write"); + torture_suite_add_2smb_test(suite, "finfo update on close", test_finfo_after_write); + torture_suite_add_1smb_test(suite, "delayed update of write time", test_delayed_write_update); + torture_suite_add_2smb_test(suite, "delayed update of write time using 2 connections", test_delayed_write_update2); - ret &= test_finfo_after_write(cli, mem_ctx); - ret &= test_delayed_write_update(cli, mem_ctx); - ret &= test_delayed_write_update2(cli, mem_ctx); - - torture_close_connection(cli); - talloc_free(mem_ctx); - return ret; + return suite; } diff --git a/source4/torture/basic/delete.c b/source4/torture/basic/delete.c index 445333ca6f..4f787ebb65 100644 --- a/source4/torture/basic/delete.c +++ b/source4/torture/basic/delete.c @@ -29,11 +29,11 @@ #include "torture/raw/proto.h" -static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, - const char *fname, BOOL expect_it, - const char *where) +static bool check_delete_on_close(struct torture_context *tctx, + struct smbcli_state *cli, int fnum, + const char *fname, bool expect_it, + const char *where) { - TALLOC_CTX *mem_ctx = talloc_init("single_search"); union smb_search_data data; NTSTATUS status; @@ -41,20 +41,14 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, size_t size; uint16_t mode; - BOOL res = True; - - status = torture_single_search(cli, mem_ctx, + status = torture_single_search(cli, tctx, fname, RAW_SEARCH_TRANS2, RAW_SEARCH_DATA_FULL_DIRECTORY_INFO, FILE_ATTRIBUTE_DIRECTORY, &data); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) single_search failed (%s)\n", - where, nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "single_search failed (%s)", where)); if (fnum != -1) { union smb_fileinfo io; @@ -63,53 +57,33 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, io.all_info.level = RAW_FILEINFO_ALL_INFO; io.all_info.in.file.fnum = fnum; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qfileinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } + status = smb_raw_fileinfo(cli->tree, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, + "qfileinfo failed (%s)", where)); - if (expect_it != io.all_info.out.delete_pending) { - printf("%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d\n", - where, expect_it, io.all_info.out.delete_pending); - res = False; - goto done; - } + torture_assert(tctx, expect_it == io.all_info.out.delete_pending, + talloc_asprintf(tctx, + "%s - Expected del_on_close flag %d, qfileinfo/all_info gave %d", + where, expect_it, io.all_info.out.delete_pending)); - if (nlink != io.all_info.out.nlink) { - printf("%s - Expected nlink %d, qfileinfo/all_info gave %d\n", - where, nlink, io.all_info.out.nlink); - res = False; - goto done; - } + torture_assert(tctx, nlink == io.all_info.out.nlink, + talloc_asprintf(tctx, + "%s - Expected nlink %d, qfileinfo/all_info gave %d", + where, nlink, io.all_info.out.nlink)); io.standard_info.level = RAW_FILEINFO_STANDARD_INFO; io.standard_info.in.file.fnum = fnum; - status = smb_raw_fileinfo(cli->tree, mem_ctx, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } - - if (expect_it != io.standard_info.out.delete_pending) { - printf("%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n", - where, expect_it, io.standard_info.out.delete_pending); - res = False; - goto done; - } + status = smb_raw_fileinfo(cli->tree, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "qpathinfo failed (%s)", where)); - if (nlink != io.standard_info.out.nlink) { - printf("%s - Expected nlink %d, qfileinfo/standard_info gave %d\n", - where, nlink, io.all_info.out.nlink); - res = False; - goto done; - } + torture_assert(tctx, expect_it == io.standard_info.out.delete_pending, + talloc_asprintf(tctx, "%s - Expected del_on_close flag %d, qfileinfo/standard_info gave %d\n", + where, expect_it, io.standard_info.out.delete_pending)); + torture_assert(tctx, nlink == io.standard_info.out.nlink, + talloc_asprintf(tctx, "%s - Expected nlink %d, qfileinfo/standard_info gave %d", + where, nlink, io.all_info.out.nlink)); } status = smbcli_qpathinfo(cli->tree, fname, @@ -117,35 +91,19 @@ static BOOL check_delete_on_close(struct smbcli_state *cli, int fnum, &size, &mode); if (expect_it) { - if (!NT_STATUS_EQUAL(status, NT_STATUS_DELETE_PENDING)) { - printf("(%s) qpathinfo did not give correct error " - "code (%s) -- NT_STATUS_DELETE_PENDING " - "expected\n", where, - nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DELETE_PENDING, + "qpathinfo did not give correct error code"); } else { - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) qpathinfo failed (%s)\n", where, - nt_errstr(status)); - res = False; - goto done; - } + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "qpathinfo failed (%s)", where)); } - done: - talloc_free(mem_ctx); - return res; + return true; } -#define CHECK_STATUS(_cli, _expected) do { \ - if (!NT_STATUS_EQUAL(_cli->tree->session->transport->error.e.nt_status, _expected)) { \ - printf("(%d) Incorrect status %s - should be %s\n", \ - __LINE__, nt_errstr(_cli->tree->session->transport->error.e.nt_status), nt_errstr(_expected)); \ - correct = False; \ - goto fail; \ - }} while (0) +#define CHECK_STATUS(_cli, _expected) \ + torture_assert_ntstatus_equal(tctx, _cli->tree->session->transport->error.e.nt_status, _expected, \ + "Incorrect status") static const char *fname = "\\delete.file"; static const char *fname_new = "\\delete.new"; @@ -153,19 +111,19 @@ static const char *dname = "\\delete.dir"; static void del_clean_area(struct smbcli_state *cli1, struct smbcli_state *cli2) { + smb_raw_exit(cli1->session); + smb_raw_exit(cli2->session); + smbcli_deltree(cli1->tree, dname); smbcli_setatr(cli1->tree, fname, 0, 0); smbcli_unlink(cli1->tree, fname); smbcli_setatr(cli1->tree, fname_new, 0, 0); smbcli_unlink(cli1->tree, fname_new); - - smb_raw_exit(cli1->session); - smb_raw_exit(cli2->session); } /* Test 1 - this should delete the file on close. */ -static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest1(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -177,31 +135,21 @@ static BOOL deltest1(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", smbcli_errstr(cli1->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + fname)); - printf("first delete on close test succeeded.\n"); return True; } /* Test 2 - this should delete the file on close. */ -static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest2(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -212,23 +160,17 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); if (fnum1 != -1) { @@ -240,14 +182,12 @@ static BOOL deltest2(struct smbcli_state *cli1, struct smbcli_state *cli2) return False; } smbcli_unlink(cli1->tree, fname); - } else { - printf("second delete on close test succeeded.\n"); } - return True; + return true; } /* Test 3 - ... */ -static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest3(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; @@ -260,11 +200,8 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should fail with a sharing violation - open for delete is only compatible with SHARE_DELETE. */ @@ -275,11 +212,9 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 != -1) { - printf("(%s) open - 2 of %s succeeded - should have failed.\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum2 == -1, + talloc_asprintf(tctx, "open - 2 of %s succeeded - should have failed.", + fname)); /* This should succeed. */ @@ -289,29 +224,21 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("(%s) close 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum2), + talloc_asprintf(tctx, "close 2 failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail - file should no longer be there. */ @@ -325,18 +252,16 @@ static BOOL deltest3(struct smbcli_state *cli1, struct smbcli_state *cli2) } smbcli_unlink(cli1->tree, fname); return False; - } else { - printf("third delete on close test succeeded.\n"); } return True; } /* Test 4 ... */ -static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest4(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -348,11 +273,8 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should succeed. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -362,23 +284,18 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE | NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 2 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum2), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail - no more opens once delete on close set. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -386,60 +303,43 @@ static BOOL deltest4(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 != -1) { - printf("(%s) open - 3 of %s succeeded ! Should have failed.\n", - __location__, fname ); - return False; - } + torture_assert(tctx, fnum2 == -1, + talloc_asprintf(tctx, "open - 3 of %s succeeded ! Should have failed.", + fname )); + CHECK_STATUS(cli1, NT_STATUS_DELETE_PENDING); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); - printf("fourth delete on close test succeeded.\n"); - - fail: - return correct; } /* Test 5 ... */ -static BOOL deltest5(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest5(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; del_clean_area(cli1, cli2); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } - + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); + /* This should fail - only allowed on NT opens with DELETE access. */ - if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on OpenX file succeeded - should fail !\n", - __location__); - return False; - } + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + "setting delete_on_close on OpenX file succeeded - should fail !"); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); - printf("fifth delete on close test succeeded.\n"); return True; } /* Test 6 ... */ -static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest6(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -453,35 +353,28 @@ static BOOL deltest6(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should fail - only allowed on NT opens with DELETE access. */ - if (NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file with no delete access succeeded - should fail !\n", - __location__); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_nt_delete_on_close(cli1->tree, fnum1, True)), + "setting delete_on_close on file with no delete access succeeded - should fail !"); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); - printf("sixth delete on close test succeeded.\n"); return True; } /* Test 7 ... */ -static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest7(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -492,68 +385,42 @@ static BOOL deltest7(struct smbcli_state *cli1, struct smbcli_state *cli2) FILE_ATTRIBUTE_NORMAL, 0, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, False))) { - printf("(%s) unsetting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, False), + "unsetting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); /* This next open should succeed - we reset the flag. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - printf("seventh delete on close test succeeded.\n"); - - fail: + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli1->tree))); return correct; } /* Test 8 ... */ -static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest8(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -565,12 +432,9 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_DATA| @@ -580,57 +444,36 @@ static BOOL deltest8(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE|NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, -1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), + talloc_asprintf(tctx, "close - 2 failed (%s)", smbcli_errstr(cli2->tree))); /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have been deleted on close !\n", - __location__, fname); - correct = False; - } else { - printf("eighth delete on close test succeeded.\n"); - } - - fail: + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !\n", fname)); return correct; } /* Test 9 ... */ -static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest9(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; @@ -644,21 +487,17 @@ static BOOL deltest9(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have failed!\n", - __location__, fname); - return False; - } + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have failed!", + fname)); - printf("ninth delete on close test succeeded.\n"); return True; } /* Test 10 ... */ -static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest10(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; - BOOL correct = True; del_clean_area(cli1, cli2); @@ -670,39 +509,25 @@ static BOOL deltest10(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* This should delete the file. */ - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); /* This should fail.. */ fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded should have been deleted on close !\n", - __location__, fname); - correct = False; - goto fail; - } else { - printf("tenth delete on close test succeeded.\n"); - } - - fail: - - return correct; + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded should have been deleted on close !", + fname)); + return true; } /* Test 11 ... */ -static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest11(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; NTSTATUS status; @@ -717,32 +542,23 @@ static BOOL deltest11(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); status = smbcli_nt_delete_on_close(cli1->tree, fnum1, True); - if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { - printf("(%s) setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, + talloc_asprintf(tctx, "setting delete_on_close should fail with NT_STATUS_CANNOT_DELETE. Got %s instead)", smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close failed (%s)", + smbcli_errstr(cli1->tree))); - printf("eleventh delete on close test succeeded.\n"); return True; } /* Test 12 ... */ -static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest12(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; NTSTATUS status; @@ -759,32 +575,26 @@ static BOOL deltest12(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded. Should fail with " - "NT_STATUS_CANNOT_DELETE.\n", __location__, fname); - smbcli_close(cli1->tree, fnum1); - return False; - } else { - status = smbcli_nt_error(cli1->tree); - if (!NT_STATUS_EQUAL(status, NT_STATUS_CANNOT_DELETE)) { - printf("(%s) setting delete_on_close on open should " + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded. Should fail with " + "NT_STATUS_CANNOT_DELETE.\n", fname)); + + status = smbcli_nt_error(cli1->tree); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_CANNOT_DELETE, + talloc_asprintf(tctx, "setting delete_on_close on open should " "fail with NT_STATUS_CANNOT_DELETE. Got %s " - "instead)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } - } + "instead)", + smbcli_errstr(cli1->tree))); - printf("twelvth delete on close test succeeded.\n"); - return True; + return true; } /* Test 13 ... */ -static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest13(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -802,12 +612,9 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_FILE_READ_DATA| @@ -819,70 +626,48 @@ static BOOL deltest13(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (fnum2 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, + "open of %s failed (%s)", + fname, smbcli_errstr(cli2->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, - True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, + True), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli2->tree, fnum2, - False))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli2->tree, fnum2, + False), + "setting delete_on_close on file failed !"); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli2->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), + talloc_asprintf(tctx, "close - 2 failed (%s)", + smbcli_errstr(cli2->tree))); fnum1 = smbcli_open(cli1->tree, fname, O_RDONLY, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed!\n", - __location__, fname); - correct = False; - goto fail; - } - - printf("thirteenth delete on close test succeeded.\n"); + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed!", + fname)); - fail: + smbcli_close(cli1->tree, fnum1); return correct; } /* Test 14 ... */ -static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest14(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int dnum1 = -1; - BOOL correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -897,21 +682,13 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE| NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, 0, 0); - if (dnum1 == -1) { - printf("(%s) open of %s failed: %s!\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, dnum1, True))) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } - correct &= check_delete_on_close(cli1, dnum1, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); + torture_assert_ntstatus_ok(tctx, smbcli_nt_delete_on_close(cli1->tree, dnum1, True), + "setting delete_on_close on file failed !"); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, True, __location__); smbcli_close(cli1->tree, dnum1); /* Now it should be gone... */ @@ -925,26 +702,17 @@ static BOOL deltest14(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_WRITE| NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, 0, 0); - if (dnum1 != -1) { - printf("(%s) setting delete_on_close on file succeeded !\n", - __location__); - correct = False; - goto fail; - } - - printf("fourteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, dnum1 == -1, "setting delete_on_close on file succeeded !"); return correct; } /* Test 15 ... */ -static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest15(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; + bool correct = true; int fnum2 = -1; - BOOL correct = True; NTSTATUS status; del_clean_area(cli1, cli2); @@ -964,21 +732,12 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); status = smbcli_rename(cli2->tree, fname, fname_new); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) renaming failed: %s !\n", - __location__, nt_errstr(status)); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, "renaming failed!"); fnum2 = smbcli_nt_create_full(cli2->tree, fname_new, 0, SEC_GENERIC_ALL, @@ -989,28 +748,21 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname_new, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname_new, smbcli_errstr(cli1->tree))); status = smbcli_nt_delete_on_close(cli2->tree, fnum2, True); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, + "setting delete_on_close on file failed !"); smbcli_close(cli2->tree, fnum2); /* The file should be around under the new name, there's a second * handle open */ - correct &= check_delete_on_close(cli1, fnum1, fname_new, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname_new, True, __location__); fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, SEC_GENERIC_ALL, @@ -1021,14 +773,10 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); smbcli_close(cli2->tree, fnum2); smbcli_close(cli1->tree, fnum1); @@ -1042,12 +790,8 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); @@ -1060,27 +804,19 @@ static BOOL deltest15(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - if (fnum1 != -1) { - printf("(%s) smbcli_open succeeded, should have " - "failed\n", __location__); - smbcli_close(cli1->tree, fnum1); - correct = False; - goto fail; - } - - printf("fifteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, + "smbcli_open succeeded, should have " + "failed"); return correct; } /* Test 16 ... */ -static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest16(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = true; del_clean_area(cli1, cli2); @@ -1102,19 +838,14 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert (tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli2->tree, fname, 0, @@ -1126,49 +857,36 @@ static BOOL deltest16(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, 0, 0); - /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli1, -1, fname, False, __location__); - correct &= check_delete_on_close(cli2, fnum2, fname, False, __location__); - correct &= check_delete_on_close(cli2, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, -1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli2, fnum2, fname, True, __location__); - correct &= check_delete_on_close(cli2, -1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, fnum2, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli2, -1, fname, True, __location__); smbcli_close(cli2->tree, fnum2); /* And the file should be deleted ! */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, fname); - correct = False; - goto fail; - } - - printf("sixteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + fname)); return correct; } /* Test 17 ... */ -static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest17(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1189,12 +907,8 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, 0, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* And close - just to create the file. */ smbcli_close(cli1->tree, fnum1); @@ -1209,15 +923,11 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -1231,45 +941,33 @@ static BOOL deltest17(struct smbcli_state *cli1, struct smbcli_state *cli2) 0, 0); /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); /* still not reported as being set on either */ - correct &= check_delete_on_close(cli1, fnum1, fname, False, __location__); - correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, fname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, fname, False, __location__); smbcli_close(cli1->tree, fnum2); /* See if the file is deleted - shouldn't be.... */ fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) open of %s failed (should succeed) - %s\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - - printf("seventeenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (should succeed) - %s", + fname, smbcli_errstr(cli1->tree))); return correct; } /* Test 18 ... */ -static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest18(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1293,15 +991,11 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1315,19 +1009,15 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); - correct &= check_delete_on_close(cli1, fnum2, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, False, __location__); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); @@ -1340,26 +1030,18 @@ static BOOL deltest18(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, dname); - correct = False; - goto fail; - } - - printf("eighteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, talloc_asprintf(tctx, "open of %s succeeded (should fail)", + dname)); return correct; } /* Test 19 ... */ -static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest19(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int fnum2 = -1; - BOOL correct = True; + bool correct = True; del_clean_area(cli1, cli2); @@ -1379,12 +1061,8 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); /* And close - just to create the directory. */ smbcli_close(cli1->tree, fnum1); @@ -1401,15 +1079,11 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_DISP_OPEN, NTCREATEX_OPTIONS_DIRECTORY|NTCREATEX_OPTIONS_DELETE_ON_CLOSE, 0); - if (fnum1 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open - 1 of %s failed (%s)", fname, smbcli_errstr(cli1->tree))); /* The delete on close bit is *not* reported as being set. */ - correct &= check_delete_on_close(cli1, fnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, dname, False, __location__); /* Now try opening again for read-only. */ fnum2 = smbcli_nt_create_full(cli1->tree, dname, 0, @@ -1422,16 +1096,12 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_OPTIONS_DIRECTORY, 0); /* Should work. */ - if (fnum2 == -1) { - printf("(%s) open - 1 of %s failed (%s)\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, "open - 1 of %s failed (%s)", + dname, smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); - correct &= check_delete_on_close(cli1, fnum2, dname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum2, dname, True, __location__); smbcli_close(cli1->tree, fnum2); @@ -1447,26 +1117,18 @@ static BOOL deltest19(struct smbcli_state *cli1, struct smbcli_state *cli2) CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND); - if (fnum1 != -1) { - printf("(%s) open of %s succeeded (should fail)\n", - __location__, dname); - correct = False; - goto fail; - } - - printf("nineteenth delete on close test succeeded.\n"); - - fail: + torture_assert(tctx, fnum1 == -1, + talloc_asprintf(tctx, "open of %s succeeded (should fail)", dname)); return correct; } /* Test 20 ... */ -static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) +static bool deltest20(struct torture_context *tctx, struct smbcli_state *cli1, struct smbcli_state *cli2) { int fnum1 = -1; int dnum1 = -1; - BOOL correct = True; + bool correct = True; NTSTATUS status; del_clean_area(cli1, cli2); @@ -1485,14 +1147,10 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) NTCREATEX_SHARE_ACCESS_DELETE, NTCREATEX_DISP_CREATE, NTCREATEX_OPTIONS_DIRECTORY, 0); - if (dnum1 == -1) { - printf("(%s) open of %s failed: %s!\n", - __location__, dname, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, dnum1 != -1, talloc_asprintf(tctx, "open of %s failed: %s!", + dname, smbcli_errstr(cli1->tree))); - correct &= check_delete_on_close(cli1, dnum1, dname, False, __location__); + correct &= check_delete_on_close(tctx, cli1, dnum1, dname, False, __location__); status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); { @@ -1500,72 +1158,54 @@ static BOOL deltest20(struct smbcli_state *cli1, struct smbcli_state *cli2) asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); - if (fnum1 != -1) { - printf("(%s) smbcli_open succeeded, should have " - "failed with NT_STATUS_DELETE_PENDING\n", - __location__); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 == -1, + "smbcli_open succeeded, should have " + "failed with NT_STATUS_DELETE_PENDING" + ); - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), - NT_STATUS_DELETE_PENDING)) { - printf("(%s) smbcli_open returned %s, expected " - "NT_STATUS_DELETE_PENDING\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert_ntstatus_equal(tctx, + smbcli_nt_error(cli1->tree), + NT_STATUS_DELETE_PENDING, + "smbcli_open failed"); } status = smbcli_nt_delete_on_close(cli1->tree, dnum1, False); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) setting delete_on_close on file failed !\n", - __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, status, + "setting delete_on_close on file failed !"); { char *fullname; asprintf(&fullname, "\\%s%s", dname, fname); fnum1 = smbcli_open(cli1->tree, fullname, O_CREAT|O_RDWR, DENY_NONE); - if (fnum1 == -1) { - printf("(%s) smbcli_open failed: %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "smbcli_open failed: %s\n", + smbcli_errstr(cli1->tree))); smbcli_close(cli1->tree, fnum1); } status = smbcli_nt_delete_on_close(cli1->tree, dnum1, True); - if (!NT_STATUS_EQUAL(status, NT_STATUS_DIRECTORY_NOT_EMPTY)) { - printf("(%s) setting delete_on_close returned %s, expected " - "NT_STATUS_DIRECTORY_NOT_EMPTY\n", __location__, - smbcli_errstr(cli1->tree)); - correct = False; - goto fail; - } - + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_DIRECTORY_NOT_EMPTY, + "setting delete_on_close failed"); smbcli_close(cli1->tree, dnum1); - printf("twentieth delete on close test succeeded.\n"); - - fail: - return correct; } /* Test 21 ... */ -static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2) +static bool deltest21(struct torture_context *tctx) { int fnum1 = -1; - struct smbcli_state *cli1 = *ppcli1; - struct smbcli_state *cli2 = *ppcli2; - BOOL correct = True; + struct smbcli_state *cli1; + struct smbcli_state *cli2; + bool correct = True; + + if (!torture_open_connection(&cli1, 0)) + return False; + + if (!torture_open_connection(&cli2, 1)) + return False; del_clean_area(cli1, cli2); @@ -1576,32 +1216,26 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 FILE_ATTRIBUTE_NORMAL, NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) open of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "open of %s failed (%s)", + fname, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_nt_delete_on_close(cli1->tree, fnum1, True))) { - printf("(%s) setting delete_on_close failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_nt_delete_on_close(cli1->tree, fnum1, True), + talloc_asprintf(tctx, "setting delete_on_close failed (%s)", + smbcli_errstr(cli1->tree))); /* Ensure delete on close is set. */ - correct &= check_delete_on_close(cli1, fnum1, fname, True, __location__); + correct &= check_delete_on_close(tctx, cli1, fnum1, fname, True, __location__); /* Now yank the rug from under cli1. */ smbcli_transport_dead(cli1->transport, NT_STATUS_LOCAL_DISCONNECT); fnum1 = -1; - if (!torture_open_connection(ppcli1, 0)) { + if (!torture_open_connection(&cli1, 0)) { return False; } - cli1 = *ppcli1; - /* On slow build farm machines it might happen that they are not fast * enogh to delete the file for this test */ msleep(200); @@ -1618,73 +1252,41 @@ static BOOL deltest21(struct smbcli_state **ppcli1, struct smbcli_state **ppcli2 CHECK_STATUS(cli1, NT_STATUS_OBJECT_NAME_NOT_FOUND); - printf("twenty-first delete on close test succeeded.\n"); - - fail: - return correct; } /* Test delete on close semantics. */ -BOOL torture_test_delete(struct torture_context *torture) +struct torture_suite *torture_test_delete(void) { - struct smbcli_state *cli1 = NULL; - struct smbcli_state *cli2 = NULL; - BOOL correct = True; - - printf("starting delete test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - if (!torture_open_connection(&cli2, 1)) { - printf("(%s) failed to open second connection.\n", - __location__); - correct = False; - goto fail; - } - - correct &= deltest1(cli1, cli2); - correct &= deltest2(cli1, cli2); - correct &= deltest3(cli1, cli2); - correct &= deltest4(cli1, cli2); - correct &= deltest5(cli1, cli2); - correct &= deltest6(cli1, cli2); - correct &= deltest7(cli1, cli2); - correct &= deltest8(cli1, cli2); - correct &= deltest9(cli1, cli2); - correct &= deltest10(cli1, cli2); - correct &= deltest11(cli1, cli2); - correct &= deltest12(cli1, cli2); - correct &= deltest13(cli1, cli2); - correct &= deltest14(cli1, cli2); - correct &= deltest15(cli1, cli2); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "DELETE"); + + torture_suite_add_2smb_test(suite, "deltest1", deltest1); + torture_suite_add_2smb_test(suite, "deltest2", deltest2); + torture_suite_add_2smb_test(suite, "deltest3", deltest3); + torture_suite_add_2smb_test(suite, "deltest4", deltest4); + torture_suite_add_2smb_test(suite, "deltest5", deltest5); + torture_suite_add_2smb_test(suite, "deltest6", deltest6); + torture_suite_add_2smb_test(suite, "deltest7", deltest7); + torture_suite_add_2smb_test(suite, "deltest8", deltest8); + torture_suite_add_2smb_test(suite, "deltest9", deltest9); + torture_suite_add_2smb_test(suite, "deltest10", deltest10); + torture_suite_add_2smb_test(suite, "deltest11", deltest11); + torture_suite_add_2smb_test(suite, "deltest12", deltest12); + torture_suite_add_2smb_test(suite, "deltest13", deltest13); + torture_suite_add_2smb_test(suite, "deltest14", deltest14); + torture_suite_add_2smb_test(suite, "deltest15", deltest15); if (!lp_parm_bool(-1, "target", "samba3", False)) { - correct &= deltest16(cli1, cli2); - correct &= deltest17(cli1, cli2); - correct &= deltest18(cli1, cli2); - correct &= deltest19(cli1, cli2); - correct &= deltest20(cli1, cli2); + torture_suite_add_2smb_test(suite, "deltest16", deltest16); + torture_suite_add_2smb_test(suite, "deltest17", deltest17); + torture_suite_add_2smb_test(suite, "deltest18", deltest18); + torture_suite_add_2smb_test(suite, "deltest19", deltest19); + torture_suite_add_2smb_test(suite, "deltest20", deltest20); } - correct &= deltest21(&cli1, &cli2); + torture_suite_add_simple_test(suite, "deltest21", deltest21); - if (!correct) { - printf("Failed delete test\n"); - } else { - printf("delete test ok !\n"); - } - - fail: - del_clean_area(cli1, cli2); - - if (!torture_close_connection(cli1)) { - correct = False; - } - if (!torture_close_connection(cli2)) { - correct = False; - } - return correct; + return suite; } diff --git a/source4/torture/basic/denytest.c b/source4/torture/basic/denytest.c index 86186c5667..cd724b1d4e 100644 --- a/source4/torture/basic/denytest.c +++ b/source4/torture/basic/denytest.c @@ -25,7 +25,6 @@ #include "libcli/libcli.h" #include "torture/util.h" -extern BOOL torture_showall; extern int torture_failures; #define CHECK_MAX_FAILURES(label) do { if (++failures >= torture_failures) goto label; } while (0) @@ -1401,18 +1400,18 @@ static const struct { }; -static void progress_bar(uint_t i, uint_t total) +static void progress_bar(struct torture_context *tctx, uint_t i, uint_t total) { - printf("%5d/%5d\r", i, total); + torture_comment(tctx, "%5d/%5d\r", i, total); fflush(stdout); } /* this produces a matrix of deny mode behaviour for 1 connection */ -BOOL torture_denytest1(struct torture_context *torture) +BOOL torture_denytest1(struct torture_context *tctx, + struct smbcli_state *cli1) { - static struct smbcli_state *cli1; int fnum1, fnum2; int i; BOOL correct = True; @@ -1420,13 +1419,7 @@ BOOL torture_denytest1(struct torture_context *torture) const char *fnames[2] = {"\\denytest1.dat", "\\denytest1.exe"}; int failures=0; - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - printf("starting denytest1\n"); - - printf("Testing deny modes with 1 connection\n"); + torture_comment(tctx, "Testing deny modes with 1 connection\n"); for (i=0;i<2;i++) { smbcli_unlink(cli1->tree, fnames[i]); @@ -1435,7 +1428,7 @@ BOOL torture_denytest1(struct torture_context *torture) smbcli_close(cli1->tree, fnum1); } - printf("testing %d entries\n", (int)ARRAY_SIZE(denytable1)); + torture_comment(tctx, "testing %d entries\n", (int)ARRAY_SIZE(denytable1)); GetTimeOfDay(&tv_start); @@ -1443,7 +1436,7 @@ BOOL torture_denytest1(struct torture_context *torture) enum deny_result res; const char *fname = fnames[denytable1[i].isexe]; - progress_bar(i, ARRAY_SIZE(denytable1)); + progress_bar(tctx, i, ARRAY_SIZE(denytable1)); fnum1 = smbcli_open(cli1->tree, fname, denytable1[i].mode1, @@ -1467,12 +1460,13 @@ BOOL torture_denytest1(struct torture_context *torture) } } - if (torture_showall || res != denytable1[i].result) { + if (lp_parm_bool(-1, "torture", "showall", False) || + res != denytable1[i].result) { int64_t tdif; GetTimeOfDay(&tv); tdif = usec_time_diff(&tv, &tv_start); tdif /= 1000; - printf("%lld: %s %8s %10s %8s %10s %s (correct=%s)\n", + torture_comment(tctx, "%lld: %s %8s %10s %8s %10s %s (correct=%s)\n", (long long)tdif, fname, denystr(denytable1[i].deny1), @@ -1497,11 +1491,7 @@ failed: smbcli_unlink(cli1->tree, fnames[i]); } - if (!torture_close_connection(cli1)) { - correct = False; - } - - printf("finshed denytest1 (%d failures)\n", failures); + torture_comment(tctx, "finshed denytest1 (%d failures)\n", failures); return correct; } @@ -1509,9 +1499,10 @@ failed: /* this produces a matrix of deny mode behaviour with 2 connections */ -BOOL torture_denytest2(struct torture_context *torture) +BOOL torture_denytest2(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - static struct smbcli_state *cli1, *cli2; int fnum1, fnum2; int i; BOOL correct = True; @@ -1519,15 +1510,6 @@ BOOL torture_denytest2(struct torture_context *torture) struct timeval tv, tv_start; int failures=0; - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting denytest2\n"); - - printf("Testing deny modes with 2 connections\n"); - for (i=0;i<2;i++) { smbcli_unlink(cli1->tree, fnames[i]); fnum1 = smbcli_open(cli1->tree, fnames[i], O_RDWR|O_CREAT, DENY_NONE); @@ -1541,7 +1523,7 @@ BOOL torture_denytest2(struct torture_context *torture) enum deny_result res; const char *fname = fnames[denytable2[i].isexe]; - progress_bar(i, ARRAY_SIZE(denytable1)); + progress_bar(tctx, i, ARRAY_SIZE(denytable1)); fnum1 = smbcli_open(cli1->tree, fname, denytable2[i].mode1, @@ -1565,12 +1547,13 @@ BOOL torture_denytest2(struct torture_context *torture) } } - if (torture_showall || res != denytable2[i].result) { + if (lp_parm_bool(-1, "torture", "showall", False) || + res != denytable2[i].result) { int64_t tdif; GetTimeOfDay(&tv); tdif = usec_time_diff(&tv, &tv_start); tdif /= 1000; - printf("%lld: %s %8s %10s %8s %10s %s (correct=%s)\n", + torture_comment(tctx, "%lld: %s %8s %10s %8s %10s %s (correct=%s)\n", (long long)tdif, fname, denystr(denytable2[i].deny1), @@ -1595,14 +1578,7 @@ failed: smbcli_unlink(cli1->tree, fnames[i]); } - if (!torture_close_connection(cli1)) { - correct = False; - } - if (!torture_close_connection(cli2)) { - correct = False; - } - - printf("finshed denytest2 (%d failures)\n", failures); + torture_comment(tctx, "finshed denytest2 (%d failures)\n", failures); return correct; } @@ -1611,23 +1587,13 @@ failed: /* simple test harness for playing with deny modes */ -BOOL torture_denytest3(struct torture_context *torture) +BOOL torture_denytest3(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; int fnum1, fnum2; const char *fname; - printf("starting deny3 test\n"); - - printf("Testing simple deny modes\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - if (!torture_open_connection(&cli2, 1)) { - return False; - } - fname = "\\deny_dos1.dat"; smbcli_unlink(cli1->tree, fname); @@ -1636,7 +1602,7 @@ BOOL torture_denytest3(struct torture_context *torture) if (fnum1 != -1) smbcli_close(cli1->tree, fnum1); if (fnum2 != -1) smbcli_close(cli1->tree, fnum2); smbcli_unlink(cli1->tree, fname); - printf("fnum1=%d fnum2=%d\n", fnum1, fnum2); + torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2); fname = "\\deny_dos2.dat"; @@ -1647,11 +1613,7 @@ BOOL torture_denytest3(struct torture_context *torture) if (fnum1 != -1) smbcli_close(cli1->tree, fnum1); if (fnum2 != -1) smbcli_close(cli2->tree, fnum2); smbcli_unlink(cli1->tree, fname); - printf("fnum1=%d fnum2=%d\n", fnum1, fnum2); - - - torture_close_connection(cli1); - torture_close_connection(cli2); + torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2); return True; } @@ -1758,7 +1720,8 @@ static NTSTATUS predict_share_conflict(uint32_t sa1, uint32_t am1, uint32_t sa2, /* a denytest for ntcreatex */ -static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *cli2, int client) +static BOOL torture_ntdenytest(struct torture_context *tctx, + struct smbcli_state *cli1, struct smbcli_state *cli2, int client) { const struct bit_value share_access_bits[] = { { NTCREATEX_SHARE_ACCESS_READ, "S_R" }, @@ -1787,7 +1750,7 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c int failures = 0; uint8_t buf[1]; - printf("format: server correct\n"); + torture_comment(tctx, "format: server correct\n"); ZERO_STRUCT(buf); @@ -1812,7 +1775,7 @@ static BOOL torture_ntdenytest(struct smbcli_state *cli1, struct smbcli_state *c io1.ntcreatex.in.fname = fname; io2 = io1; - printf("testing %d entries on %s\n", torture_numops, fname); + torture_comment(tctx, "testing %d entries on %s\n", torture_numops, fname); for (i=0;itree, fname); - printf("finshed ntdenytest (%d failures)\n", failures); + torture_comment(tctx, "finshed ntdenytest (%d failures)\n", failures); return correct; } @@ -1925,47 +1888,31 @@ failed: /* a denytest for ntcreatex */ -BOOL torture_ntdenytest1(struct smbcli_state *cli, int client) +BOOL torture_ntdenytest1(struct torture_context *tctx, struct smbcli_state *cli, int client) { extern int torture_seed; srandom(torture_seed + client); - printf("starting ntdenytest1 client %d\n", client); + torture_comment(tctx, "starting ntdenytest1 client %d\n", client); - return torture_ntdenytest(cli, cli, client); + return torture_ntdenytest(tctx, cli, cli, client); } /* a denytest for ntcreatex */ -BOOL torture_ntdenytest2(struct torture_context *torture) +BOOL torture_ntdenytest2(struct torture_context *torture, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; - BOOL ret; - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - if (!torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting ntdenytest2\n"); - - ret = torture_ntdenytest(cli1, cli2, 0); - - torture_close_connection(cli1); - torture_close_connection(cli2); - - return ret; + return torture_ntdenytest(torture, cli1, cli2, 0); } #define CHECK_STATUS(status, correct) do { \ if (!NT_STATUS_EQUAL(status, correct)) { \ - printf("(%s) Incorrect status %s - should be %s\n", \ + torture_comment(tctx, "(%s) Incorrect status %s - should be %s\n", \ __location__, nt_errstr(status), nt_errstr(correct)); \ ret = False; \ goto done; \ @@ -1973,7 +1920,7 @@ BOOL torture_ntdenytest2(struct torture_context *torture) #define CHECK_VAL(v, correct) do { \ if ((v) != (correct)) { \ - printf("(%s) wrong value for %s 0x%x - should be 0x%x\n", \ + torture_comment(tctx, "(%s) wrong value for %s 0x%x - should be 0x%x\n", \ __location__, #v, (int)(v), (int)correct); \ ret = False; \ }} while (0) @@ -1981,9 +1928,9 @@ BOOL torture_ntdenytest2(struct torture_context *torture) /* test sharing of handles with DENY_DOS on a single connection */ -BOOL torture_denydos_sharing(struct torture_context *torture) +BOOL torture_denydos_sharing(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; union smb_open io; union smb_fileinfo finfo; const char *fname = "\\torture_denydos.txt"; @@ -1993,13 +1940,9 @@ BOOL torture_denydos_sharing(struct torture_context *torture) union smb_setfileinfo sfinfo; TALLOC_CTX *mem_ctx; - if (!torture_open_connection(&cli, 0)) { - return False; - } - mem_ctx = talloc_new(cli); - printf("Checking DENY_DOS shared handle semantics\n"); + torture_comment(tctx, "Checking DENY_DOS shared handle semantics\n"); smbcli_unlink(cli->tree, fname); io.openx.level = RAW_OPEN_OPENX; @@ -2013,7 +1956,7 @@ BOOL torture_denydos_sharing(struct torture_context *torture) io.openx.in.size = 0; io.openx.in.timeout = 0; - printf("openx twice with RDWR/DENY_DOS\n"); + torture_comment(tctx, "openx twice with RDWR/DENY_DOS\n"); status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); fnum1 = io.openx.out.file.fnum; @@ -2022,7 +1965,7 @@ BOOL torture_denydos_sharing(struct torture_context *torture) CHECK_STATUS(status, NT_STATUS_OK); fnum2 = io.openx.out.file.fnum; - printf("fnum1=%d fnum2=%d\n", fnum1, fnum2); + torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2); sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION; sfinfo.position_information.in.file.fnum = fnum1; @@ -2030,7 +1973,7 @@ BOOL torture_denydos_sharing(struct torture_context *torture) status = smb_raw_setfileinfo(cli->tree, &sfinfo); CHECK_STATUS(status, NT_STATUS_OK); - printf("two handles should be same file handle\n"); + torture_comment(tctx, "two handles should be same file handle\n"); finfo.position_information.level = RAW_FILEINFO_POSITION_INFORMATION; finfo.position_information.in.file.fnum = fnum1; status = smb_raw_fileinfo(cli->tree, mem_ctx, &finfo); @@ -2046,7 +1989,7 @@ BOOL torture_denydos_sharing(struct torture_context *torture) smbcli_close(cli->tree, fnum1); smbcli_close(cli->tree, fnum2); - printf("openx twice with RDWR/DENY_NONE\n"); + torture_comment(tctx, "openx twice with RDWR/DENY_NONE\n"); io.openx.in.open_mode = OPENX_MODE_ACCESS_RDWR | OPENX_MODE_DENY_NONE; status = smb_raw_open(cli->tree, mem_ctx, &io); CHECK_STATUS(status, NT_STATUS_OK); @@ -2057,9 +2000,9 @@ BOOL torture_denydos_sharing(struct torture_context *torture) CHECK_STATUS(status, NT_STATUS_OK); fnum2 = io.openx.out.file.fnum; - printf("fnum1=%d fnum2=%d\n", fnum1, fnum2); + torture_comment(tctx, "fnum1=%d fnum2=%d\n", fnum1, fnum2); - printf("two handles should be separate\n"); + torture_comment(tctx, "two handles should be separate\n"); sfinfo.generic.level = RAW_SFILEINFO_POSITION_INFORMATION; sfinfo.position_information.in.file.fnum = fnum1; sfinfo.position_information.in.position = 1000; diff --git a/source4/torture/basic/dir.c b/source4/torture/basic/dir.c index 01d25e5d4a..c86f134c32 100644 --- a/source4/torture/basic/dir.c +++ b/source4/torture/basic/dir.c @@ -34,22 +34,16 @@ static void list_fn(struct clilist_file_info *finfo, const char *name, void *sta /* test directory listing speed */ -BOOL torture_dirtest1(struct torture_context *torture) +BOOL torture_dirtest1(struct torture_context *tctx, + struct smbcli_state *cli) { int i; - struct smbcli_state *cli; int fnum; BOOL correct = True; extern int torture_numops; struct timeval tv; - printf("starting dirtest1\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("Creating %d random filenames\n", torture_numops); + torture_comment(tctx, "Creating %d random filenames\n", torture_numops); srandom(0); tv = timeval_current(); @@ -66,11 +60,11 @@ BOOL torture_dirtest1(struct torture_context *torture) free(fname); } - printf("Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL)); - printf("Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL)); - printf("Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL)); - printf("dirtest core %g seconds\n", timeval_elapsed(&tv)); + torture_comment(tctx, "dirtest core %g seconds\n", timeval_elapsed(&tv)); srandom(0); for (i=0;itree, "\\LISTDIR\\*", FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL); - printf("num_seen = %d\n", num_seen ); + torture_comment(tctx, "num_seen = %d\n", num_seen ); /* We should see (torture_entries) each of files & directories + . and .. */ if (num_seen != (2*torture_entries)+2) { correct = False; @@ -152,7 +134,7 @@ BOOL torture_dirtest2(struct torture_context *torture) * relevant entries. */ num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_DIRECTORY<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL); - printf("num_seen = %d\n", num_seen ); + torture_comment(tctx, "num_seen = %d\n", num_seen ); if (num_seen != torture_entries+2) { correct = False; fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n", @@ -160,7 +142,7 @@ BOOL torture_dirtest2(struct torture_context *torture) } num_seen = smbcli_list_old(cli->tree, "\\LISTDIR\\*", (FILE_ATTRIBUTE_ARCHIVE<<8)|FILE_ATTRIBUTE_DIRECTORY, list_fn, NULL); - printf("num_seen = %d\n", num_seen ); + torture_comment(tctx, "num_seen = %d\n", num_seen ); if (num_seen != torture_entries) { correct = False; fprintf(stderr,"(%s) entry count mismatch, should be %d, was %d\n", @@ -175,16 +157,10 @@ BOOL torture_dirtest2(struct torture_context *torture) } #if 0 - printf("Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL)); - printf("Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL)); - printf("Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "a*.*", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "b*.*", 0, list_fn, NULL)); + torture_comment(tctx, "Matched %d\n", smbcli_list(cli->tree, "xyzabc", 0, list_fn, NULL)); #endif - if (!torture_close_connection(cli)) { - correct = False; - } - - printf("finished dirtest1\n"); - return correct; } diff --git a/source4/torture/basic/disconnect.c b/source4/torture/basic/disconnect.c index 92cb828606..348f59d057 100644 --- a/source4/torture/basic/disconnect.c +++ b/source4/torture/basic/disconnect.c @@ -129,11 +129,11 @@ static BOOL test_disconnect_lock(struct smbcli_state *cli, TALLOC_CTX *mem_ctx) */ BOOL torture_disconnect(struct torture_context *torture) { - struct smbcli_state *cli; BOOL ret = True; TALLOC_CTX *mem_ctx; int i; extern int torture_numops; + struct smbcli_state *cli; mem_ctx = talloc_init("torture_raw_mux"); @@ -169,7 +169,6 @@ BOOL torture_disconnect(struct torture_context *torture) smb_raw_exit(cli->session); smbcli_deltree(cli->tree, BASEDIR); - torture_close_connection(cli); talloc_free(mem_ctx); return ret; } diff --git a/source4/torture/basic/locking.c b/source4/torture/basic/locking.c index c4aae64ca8..c966c667e6 100644 --- a/source4/torture/basic/locking.c +++ b/source4/torture/basic/locking.c @@ -24,6 +24,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" #include "libcli/libcli.h" +#include "torture/ui.h" #include "torture/util.h" #include "torture/torture.h" #include "system/time.h" @@ -38,150 +39,113 @@ must not use posix semantics) 2) support for lock timeouts */ -BOOL torture_locktest1(struct torture_context *torture) +bool torture_locktest1(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; const char *fname = BASEDIR "\\lockt1.lck"; int fnum1, fnum2, fnum3; time_t t1, t2; uint_t lock_timeout; - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting locktest1\n"); - if (!torture_setup_dir(cli1, BASEDIR)) { return False; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, + "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); - if (fnum2 == -1) { - printf("(%s) open2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, talloc_asprintf(tctx, + "open2 of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree))); fnum3 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE); - if (fnum3 == -1) { - printf("open3 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; - } + torture_assert(tctx, fnum3 != -1, talloc_asprintf(tctx, + "open3 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree))); - if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK))) { - printf("lock1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK), + talloc_asprintf(tctx, "lock1 failed (%s)", smbcli_errstr(cli1->tree))); + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock2 succeeded! This is a locking bug\n"); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock2 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; - } + if (!check_error(__location__, cli2, ERRDOS, ERRlock, + NT_STATUS_LOCK_NOT_GRANTED)) return False; - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock2 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock2 succeeded! This is a locking bug\n"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT)) return False; - } - if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 5, 9, 0, WRITE_LOCK))) { - printf("lock1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli1->tree, fnum1, 5, 9, 0, WRITE_LOCK), + talloc_asprintf(tctx, + "lock1 failed (%s)", smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 5, 9, 0, WRITE_LOCK))) { - printf("lock2 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 5, 9, 0, WRITE_LOCK)), + "lock2 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; - } - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock2 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock2 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; - } - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock2 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock2 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, + NT_STATUS_FILE_LOCK_CONFLICT)) return False; lock_timeout = (6 + (random() % 20)); - printf("Testing lock timeout with timeout=%u\n", lock_timeout); + torture_comment(tctx, "Testing lock timeout with timeout=%u\n", + lock_timeout); t1 = time(NULL); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK))) { - printf("lock3 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, lock_timeout * 1000, WRITE_LOCK)), + "lock3 succeeded! This is a locking bug\n"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, NT_STATUS_FILE_LOCK_CONFLICT)) return False; - } t2 = time(NULL); if (t2 - t1 < 5) { - printf("error: This server appears not to support timed lock requests\n"); + torture_fail(tctx, + "error: This server appears not to support timed lock requests"); } - printf("server slept for %u seconds for a %u second timeout\n", + torture_comment(tctx, "server slept for %u seconds for a %u second timeout\n", (uint_t)(t2-t1), lock_timeout); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum2))) { - printf("close1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum2), + talloc_asprintf(tctx, "close1 failed (%s)", smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock4 succeeded! This is a locking bug\n"); - return False; - } else { - if (!check_error(__location__, cli2, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum3))) { - printf("close3 failed (%s)\n", smbcli_errstr(cli2->tree)); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock4 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli2, ERRDOS, ERRlock, + NT_STATUS_FILE_LOCK_CONFLICT)) return False; - if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, fname))) { - printf("unlink failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli1->tree))); + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum3), + talloc_asprintf(tctx, "close3 failed (%s)", smbcli_errstr(cli2->tree))); - if (!torture_close_connection(cli1)) { - return False; - } - - if (!torture_close_connection(cli2)) { - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_unlink(cli1->tree, fname), + talloc_asprintf(tctx, "unlink failed (%s)", smbcli_errstr(cli1->tree))); - printf("Passed locktest1\n"); - return True; + return true; } @@ -196,139 +160,110 @@ BOOL torture_locktest1(struct torture_context *torture) 3) the server denies unlock requests by an incorrect client PID */ -BOOL torture_locktest2(struct torture_context *torture) +bool torture_locktest2(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname = BASEDIR "\\lockt2.lck"; int fnum1, fnum2, fnum3; - BOOL correct = True; - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("starting locktest2\n"); if (!torture_setup_dir(cli, BASEDIR)) { return False; } - printf("Testing pid context\n"); + torture_comment(tctx, "Testing pid context\n"); cli->session->pid = 1; fnum1 = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, + "open of %s failed (%s)", fname, smbcli_errstr(cli->tree))); fnum2 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); - if (fnum2 == -1) { - printf("(%s) open2 of %s failed (%s)\n", - __location__, fname, smbcli_errstr(cli->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, + talloc_asprintf(tctx, "open2 of %s failed (%s)", + fname, smbcli_errstr(cli->tree))); cli->session->pid = 2; fnum3 = smbcli_open(cli->tree, fname, O_RDWR, DENY_NONE); - if (fnum3 == -1) { - printf("open3 of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; - } + torture_assert(tctx, fnum3 != -1, + talloc_asprintf(tctx, + "open3 of %s failed (%s)\n", fname, smbcli_errstr(cli->tree))); cli->session->pid = 1; - if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) { - printf("lock1 failed (%s)\n", smbcli_errstr(cli->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK), + talloc_asprintf(tctx, + "lock1 failed (%s)", smbcli_errstr(cli->tree))); - if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK))) { - printf("WRITE lock1 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum1, 0, 4, 0, WRITE_LOCK)), + "WRITE lock1 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli, ERRDOS, ERRlock, + NT_STATUS_LOCK_NOT_GRANTED)) return False; - if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK))) { - printf("WRITE lock2 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_LOCK_NOT_GRANTED)) return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, WRITE_LOCK)), + "WRITE lock2 succeeded! This is a locking bug"); - if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK))) { - printf("READ lock2 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, ERRDOS, ERRlock, - NT_STATUS_FILE_LOCK_CONFLICT)) return False; - } + if (!check_error(__location__, cli, ERRDOS, ERRlock, + NT_STATUS_LOCK_NOT_GRANTED)) return False; - if (NT_STATUS_IS_ERR(smbcli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK))) { - printf("lock at 100 failed (%s)\n", smbcli_errstr(cli->tree)); - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum2, 0, 4, 0, READ_LOCK)), + "READ lock2 succeeded! This is a locking bug"); + + if (!check_error(__location__, cli, ERRDOS, ERRlock, + NT_STATUS_FILE_LOCK_CONFLICT)) return False; + + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli->tree, fnum1, 100, 4, 0, WRITE_LOCK), + talloc_asprintf(tctx, + "lock at 100 failed (%s)", smbcli_errstr(cli->tree))); cli->session->pid = 2; - if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 100, 4))) { - printf("unlock at 100 succeeded! This is a locking bug\n"); - correct = False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 100, 4)), + "unlock at 100 succeeded! This is a locking bug"); - if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 4))) { - printf("unlock1 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, - ERRDOS, ERRnotlocked, - NT_STATUS_RANGE_NOT_LOCKED)) return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 4)), + "unlock1 succeeded! This is a locking bug"); - if (NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 8))) { - printf("unlock2 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, + if (!check_error(__location__, cli, ERRDOS, ERRnotlocked, NT_STATUS_RANGE_NOT_LOCKED)) return False; - } - if (NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK))) { - printf("lock3 succeeded! This is a locking bug\n"); - correct = False; - } else { - if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_unlock(cli->tree, fnum1, 0, 8)), + "unlock2 succeeded! This is a locking bug"); - cli->session->pid = 1; + if (!check_error(__location__, cli, + ERRDOS, ERRnotlocked, + NT_STATUS_RANGE_NOT_LOCKED)) return False; - if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum1))) { - printf("close1 failed (%s)\n", smbcli_errstr(cli->tree)); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli->tree, fnum3, 0, 4, 0, WRITE_LOCK)), + "lock3 succeeded! This is a locking bug"); - if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum2))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli->tree)); - return False; - } + if (!check_error(__location__, cli, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; - if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnum3))) { - printf("close3 failed (%s)\n", smbcli_errstr(cli->tree)); - return False; - } + cli->session->pid = 1; - if (!torture_close_connection(cli)) { - correct = False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli->tree, fnum1), + talloc_asprintf(tctx, "close1 failed (%s)", smbcli_errstr(cli->tree))); - printf("locktest2 finished\n"); + torture_assert_ntstatus_ok(tctx, smbcli_close(cli->tree, fnum2), + talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli->tree))); - return correct; + torture_assert_ntstatus_ok(tctx, smbcli_close(cli->tree, fnum3), + talloc_asprintf(tctx, "close3 failed (%s)", smbcli_errstr(cli->tree))); + + return true; } @@ -337,157 +272,113 @@ BOOL torture_locktest2(struct torture_context *torture) 1) the server supports the full offset range in lock requests */ -BOOL torture_locktest3(struct torture_context *torture) +bool torture_locktest3(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; const char *fname = BASEDIR "\\lockt3.lck"; int fnum1, fnum2, i; uint32_t offset; - BOOL correct = True; extern int torture_numops; #define NEXT_OFFSET offset += (~(uint32_t)0) / torture_numops - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting locktest3\n"); - - printf("Testing 32 bit offset ranges\n"); + torture_comment(tctx, "Testing 32 bit offset ranges"); if (!torture_setup_dir(cli1, BASEDIR)) { return False; } fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum1 == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, + talloc_asprintf(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli1->tree))); fnum2 = smbcli_open(cli2->tree, fname, O_RDWR, DENY_NONE); - if (fnum2 == -1) { - printf("open2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree)); - return False; - } + torture_assert(tctx, fnum2 != -1, + talloc_asprintf(tctx, "open2 of %s failed (%s)\n", fname, smbcli_errstr(cli2->tree))); - printf("Establishing %d locks\n", torture_numops); + torture_comment(tctx, "Establishing %d locks\n", torture_numops); for (offset=i=0;itree, fnum1, offset-1, 1, 0, WRITE_LOCK))) { - printf("lock1 %d failed (%s)\n", - i, - smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK), + talloc_asprintf(tctx, "lock1 %d failed (%s)", i, smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) { - printf("lock2 %d failed (%s)\n", - i, - smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, + smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK), + talloc_asprintf(tctx, "lock2 %d failed (%s)", + i, smbcli_errstr(cli1->tree))); } - printf("Testing %d locks\n", torture_numops); + torture_comment(tctx, "Testing %d locks\n", torture_numops); for (offset=i=0;itree, fnum1, offset-2, 1, 0, WRITE_LOCK))) { - printf("error: lock1 %d succeeded!\n", i); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, offset-2, 1, 0, WRITE_LOCK)), + talloc_asprintf(tctx, "error: lock1 %d succeeded!", i)); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-1, 1, 0, WRITE_LOCK))) { - printf("error: lock2 %d succeeded!\n", i); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-1, 1, 0, WRITE_LOCK)), + talloc_asprintf(tctx, "error: lock2 %d succeeded!", i)); - if (NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK))) { - printf("error: lock3 %d succeeded!\n", i); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, offset-1, 1, 0, WRITE_LOCK)), + talloc_asprintf(tctx, "error: lock3 %d succeeded!", i)); - if (NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK))) { - printf("error: lock4 %d succeeded!\n", i); - return False; - } + torture_assert(tctx, + !NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, offset-2, 1, 0, WRITE_LOCK)), + talloc_asprintf(tctx, "error: lock4 %d succeeded!", i)); } - printf("Removing %d locks\n", torture_numops); + torture_comment(tctx, "Removing %d locks\n", torture_numops); for (offset=i=0;itree, fnum1, offset-1, 1))) { - printf("unlock1 %d failed (%s)\n", + torture_assert_ntstatus_ok(tctx, + smbcli_unlock(cli1->tree, fnum1, offset-1, 1), + talloc_asprintf(tctx, "unlock1 %d failed (%s)", i, - smbcli_errstr(cli1->tree)); - return False; - } + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_unlock(cli2->tree, fnum2, offset-2, 1))) { - printf("unlock2 %d failed (%s)\n", + torture_assert_ntstatus_ok(tctx, + smbcli_unlock(cli2->tree, fnum2, offset-2, 1), + talloc_asprintf(tctx, "unlock2 %d failed (%s)", i, - smbcli_errstr(cli1->tree)); - return False; - } - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("close1 failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli2->tree, fnum2))) { - printf("close2 failed (%s)\n", smbcli_errstr(cli2->tree)); - return False; + smbcli_errstr(cli1->tree))); } - if (NT_STATUS_IS_ERR(smbcli_unlink(cli1->tree, fname))) { - printf("unlink failed (%s)\n", smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close1 failed (%s)", smbcli_errstr(cli1->tree))); - if (!torture_close_connection(cli1)) { - correct = False; - } - - if (!torture_close_connection(cli2)) { - correct = False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli2->tree, fnum2), + talloc_asprintf(tctx, "close2 failed (%s)", smbcli_errstr(cli2->tree))); - printf("finished locktest3\n"); + torture_assert_ntstatus_ok(tctx, smbcli_unlink(cli1->tree, fname), + talloc_asprintf(tctx, "unlink failed (%s)", smbcli_errstr(cli1->tree))); - return correct; + return true; } #define EXPECTED(ret, v) if ((ret) != (v)) { \ - printf("** "); correct = False; \ + torture_comment(tctx, "** "); correct = False; \ } /* looks at overlapping locks */ -BOOL torture_locktest4(struct torture_context *torture) +BOOL torture_locktest4(struct torture_context *tctx, + struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; const char *fname = BASEDIR "\\lockt4.lck"; int fnum1, fnum2, f; BOOL ret; uint8_t buf[1000]; BOOL correct = True; - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting locktest4\n"); - if (!torture_setup_dir(cli1, BASEDIR)) { return False; } @@ -498,7 +389,7 @@ BOOL torture_locktest4(struct torture_context *torture) memset(buf, 0, sizeof(buf)); if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file\n"); + torture_comment(tctx, "Failed to create file\n"); correct = False; goto fail; } @@ -506,74 +397,74 @@ BOOL torture_locktest4(struct torture_context *torture) ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 2, 4, 0, WRITE_LOCK)); EXPECTED(ret, False); - printf("the same process %s set overlapping write locks\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 10, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 12, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the same process %s set overlapping read locks\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 20, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 22, 4, 0, WRITE_LOCK)); EXPECTED(ret, False); - printf("a different connection %s set overlapping write locks\n", ret?"can":"cannot"); + torture_comment(tctx, "a different connection %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 30, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 32, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("a different connection %s set overlapping read locks\n", ret?"can":"cannot"); + torture_comment(tctx, "a different connection %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 40, 4, 0, WRITE_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 42, 4, 0, WRITE_LOCK))); EXPECTED(ret, False); - printf("a different pid %s set overlapping write locks\n", ret?"can":"cannot"); + torture_comment(tctx, "a different pid %s set overlapping write locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 50, 4, 0, READ_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 52, 4, 0, READ_LOCK))); EXPECTED(ret, True); - printf("a different pid %s set overlapping read locks\n", ret?"can":"cannot"); + torture_comment(tctx, "a different pid %s set overlapping read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 60, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the same process %s set the same read lock twice\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s set the same read lock twice\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 70, 4, 0, WRITE_LOCK)); EXPECTED(ret, False); - printf("the same process %s set the same write lock twice\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s set the same write lock twice\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 80, 4, 0, WRITE_LOCK)); EXPECTED(ret, False); - printf("the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s overlay a read lock with a write lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 90, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s overlay a write lock with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK((cli1->session->pid = 1, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, WRITE_LOCK))) && NT_STATUS_IS_OK((cli1->session->pid = 2, smbcli_lock(cli1->tree, fnum1, 100, 4, 0, READ_LOCK))); EXPECTED(ret, False); - printf("a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot"); + torture_comment(tctx, "a different pid %s overlay a write lock with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 110, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 112, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 110, 6)); EXPECTED(ret, False); - printf("the same process %s coalesce read locks\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s coalesce read locks\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 120, 4, 0, WRITE_LOCK)) && (smbcli_read(cli2->tree, fnum2, buf, 120, 4) == 4); EXPECTED(ret, False); - printf("this server %s strict write locking\n", ret?"doesn't do":"does"); + torture_comment(tctx, "this server %s strict write locking\n", ret?"doesn't do":"does"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 130, 4) == 4); EXPECTED(ret, False); - printf("this server %s strict read locking\n", ret?"doesn't do":"does"); + torture_comment(tctx, "this server %s strict read locking\n", ret?"doesn't do":"does"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 140, 4, 0, READ_LOCK)) && @@ -581,7 +472,7 @@ BOOL torture_locktest4(struct torture_context *torture) NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 140, 4)); EXPECTED(ret, True); - printf("this server %s do recursive read locking\n", ret?"does":"doesn't"); + torture_comment(tctx, "this server %s do recursive read locking\n", ret?"does":"doesn't"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 150, 4, 0, WRITE_LOCK)) && @@ -591,21 +482,21 @@ BOOL torture_locktest4(struct torture_context *torture) !(smbcli_write(cli2->tree, fnum2, 0, buf, 150, 4) == 4) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 150, 4)); EXPECTED(ret, True); - printf("this server %s do recursive lock overlays\n", ret?"does":"doesn't"); + torture_comment(tctx, "this server %s do recursive lock overlays\n", ret?"does":"doesn't"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 160, 4, 0, READ_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 160, 4)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 160, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 160, 4) == 4); EXPECTED(ret, True); - printf("the same process %s remove a read lock using write locking\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s remove a read lock using write locking\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 170, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 170, 4)) && (smbcli_write(cli2->tree, fnum2, 0, buf, 170, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 170, 4) == 4); EXPECTED(ret, True); - printf("the same process %s remove a write lock using read locking\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s remove a write lock using read locking\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 190, 4, 0, READ_LOCK)) && @@ -613,7 +504,7 @@ BOOL torture_locktest4(struct torture_context *torture) !(smbcli_write(cli2->tree, fnum2, 0, buf, 190, 4) == 4) && (smbcli_read(cli2->tree, fnum2, buf, 190, 4) == 4); EXPECTED(ret, True); - printf("the same process %s remove the first lock first\n", ret?"does":"doesn't"); + torture_comment(tctx, "the same process %s remove the first lock first\n", ret?"does":"doesn't"); smbcli_close(cli1->tree, fnum1); smbcli_close(cli2->tree, fnum2); @@ -627,38 +518,28 @@ BOOL torture_locktest4(struct torture_context *torture) smbcli_close(cli1->tree, f); smbcli_close(cli1->tree, fnum1); EXPECTED(ret, True); - printf("the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't"); + torture_comment(tctx, "the server %s have the NT byte range lock bug\n", !ret?"does":"doesn't"); fail: smbcli_close(cli1->tree, fnum1); smbcli_close(cli2->tree, fnum2); smbcli_unlink(cli1->tree, fname); - torture_close_connection(cli1); - torture_close_connection(cli2); - printf("finished locktest4\n"); return correct; } /* looks at lock upgrade/downgrade. */ -BOOL torture_locktest5(struct torture_context *torture) +BOOL torture_locktest5(struct torture_context *tctx, struct smbcli_state *cli1, + struct smbcli_state *cli2) { - struct smbcli_state *cli1, *cli2; const char *fname = BASEDIR "\\lockt5.lck"; int fnum1, fnum2, fnum3; BOOL ret; uint8_t buf[1000]; BOOL correct = True; - if (!torture_open_connection(&cli1, 0) || - !torture_open_connection(&cli2, 1)) { - return False; - } - - printf("starting locktest5\n"); - if (!torture_setup_dir(cli1, BASEDIR)) { return False; } @@ -669,11 +550,8 @@ BOOL torture_locktest5(struct torture_context *torture) memset(buf, 0, sizeof(buf)); - if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file\n"); - correct = False; - goto fail; - } + torture_assert(tctx, smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) == sizeof(buf), + "Failed to create file"); /* Check for NT bug... */ ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 8, 0, READ_LOCK)) && @@ -682,7 +560,7 @@ BOOL torture_locktest5(struct torture_context *torture) fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 7, 1, 0, WRITE_LOCK)); EXPECTED(ret, True); - printf("this server %s the NT locking bug\n", ret ? "doesn't have" : "has"); + torture_comment(tctx, "this server %s the NT locking bug\n", ret ? "doesn't have" : "has"); smbcli_close(cli1->tree, fnum1); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR, DENY_NONE); smbcli_unlock(cli1->tree, fnum3, 0, 1); @@ -690,12 +568,12 @@ BOOL torture_locktest5(struct torture_context *torture) ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, WRITE_LOCK)) && NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 1, 1, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the same process %s overlay a write with a read lock\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s overlay a write with a read lock\n", ret?"can":"cannot"); ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK)); EXPECTED(ret, False); - printf("a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot"); + torture_comment(tctx, "a different processs %s get a read lock on the first process lock stack\n", ret?"can":"cannot"); /* Unlock the process 2 lock. */ smbcli_unlock(cli2->tree, fnum2, 0, 4); @@ -703,7 +581,7 @@ BOOL torture_locktest5(struct torture_context *torture) ret = NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum3, 0, 4, 0, READ_LOCK)); EXPECTED(ret, False); - printf("the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot"); + torture_comment(tctx, "the same processs on a different fnum %s get a read lock\n", ret?"can":"cannot"); /* Unlock the process 1 fnum3 lock. */ smbcli_unlock(cli1->tree, fnum3, 0, 4); @@ -713,7 +591,7 @@ BOOL torture_locktest5(struct torture_context *torture) NT_STATUS_IS_OK(smbcli_lock(cli1->tree, fnum1, 0, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the same process %s stack read locks\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s stack read locks\n", ret?"can":"cannot"); /* Unlock the first process lock, then check this was the WRITE lock that was removed. */ @@ -722,7 +600,7 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, READ_LOCK)); EXPECTED(ret, True); - printf("the first unlock removes the %s lock\n", ret?"WRITE":"READ"); + torture_comment(tctx, "the first unlock removes the %s lock\n", ret?"WRITE":"READ"); /* Unlock the process 2 lock. */ smbcli_unlock(cli2->tree, fnum2, 0, 4); @@ -734,32 +612,23 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)); EXPECTED(ret, True); - printf("the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot"); + torture_comment(tctx, "the same process %s unlock the stack of 4 locks\n", ret?"can":"cannot"); /* Ensure the next unlock fails. */ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)); EXPECTED(ret, False); - printf("the same process %s count the lock stack\n", !ret?"can":"cannot"); + torture_comment(tctx, "the same process %s count the lock stack\n", !ret?"can":"cannot"); /* Ensure connection 2 can get a write lock. */ ret = NT_STATUS_IS_OK(smbcli_lock(cli2->tree, fnum2, 0, 4, 0, WRITE_LOCK)); EXPECTED(ret, True); - printf("a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot"); + torture_comment(tctx, "a different processs %s get a write lock on the unlocked stack\n", ret?"can":"cannot"); - fail: smbcli_close(cli1->tree, fnum1); smbcli_close(cli2->tree, fnum2); smbcli_unlink(cli1->tree, fname); - if (!torture_close_connection(cli1)) { - correct = False; - } - if (!torture_close_connection(cli2)) { - correct = False; - } - - printf("finished locktest5\n"); return correct; } @@ -767,51 +636,42 @@ ret = NT_STATUS_IS_OK(smbcli_unlock(cli1->tree, fnum1, 0, 4)) && /* tries the unusual lockingX locktype bits */ -BOOL torture_locktest6(struct torture_context *torture) +BOOL torture_locktest6(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname[1] = { "\\lock6.txt" }; int i; int fnum; NTSTATUS status; - if (!torture_open_connection(&cli, 0)) { - return False; - } - if (!torture_setup_dir(cli, BASEDIR)) { return False; } - printf("starting locktest6\n"); - for (i=0;i<1;i++) { - printf("Testing %s\n", fname[i]); + torture_comment(tctx, "Testing %s\n", fname[i]); smbcli_unlink(cli->tree, fname[i]); fnum = smbcli_open(cli->tree, fname[i], O_RDWR|O_CREAT|O_EXCL, DENY_NONE); status = smbcli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CHANGE_LOCKTYPE); smbcli_close(cli->tree, fnum); - printf("CHANGE_LOCKTYPE gave %s\n", nt_errstr(status)); + torture_comment(tctx, "CHANGE_LOCKTYPE gave %s\n", nt_errstr(status)); fnum = smbcli_open(cli->tree, fname[i], O_RDWR, DENY_NONE); status = smbcli_locktype(cli->tree, fnum, 0, 8, 0, LOCKING_ANDX_CANCEL_LOCK); smbcli_close(cli->tree, fnum); - printf("CANCEL_LOCK gave %s\n", nt_errstr(status)); + torture_comment(tctx, "CANCEL_LOCK gave %s\n", nt_errstr(status)); smbcli_unlink(cli->tree, fname[i]); } - torture_close_connection(cli); - - printf("finished locktest6\n"); return True; } -BOOL torture_locktest7(struct torture_context *torture) +BOOL torture_locktest7(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = BASEDIR "\\lockt7.lck"; int fnum1; int fnum2 = -1; @@ -819,158 +679,109 @@ BOOL torture_locktest7(struct torture_context *torture) uint8_t buf[200]; BOOL correct = False; - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - printf("starting locktest7\n"); - - if (!torture_setup_dir(cli1, BASEDIR)) { - return False; - } + torture_assert(tctx, torture_setup_dir(cli1, BASEDIR), + talloc_asprintf(tctx, "Unable to set up %s", BASEDIR)); fnum1 = smbcli_open(cli1->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); memset(buf, 0, sizeof(buf)); - if (smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) != sizeof(buf)) { - printf("Failed to create file (%s)\n", __location__); - goto fail; - } + torture_assert(tctx, smbcli_write(cli1->tree, fnum1, 0, buf, 0, sizeof(buf)) == sizeof(buf), + "Failed to create file"); cli1->session->pid = 1; - if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK))) { - printf("Unable to apply read lock on range 130:4, error was %s (%s)\n", - smbcli_errstr(cli1->tree), __location__); - goto fail; - } else { - printf("pid1 successfully locked range 130:4 for READ\n"); - } + torture_assert_ntstatus_ok(tctx, smbcli_lock(cli1->tree, fnum1, 130, 4, 0, READ_LOCK), + talloc_asprintf(tctx, "Unable to apply read lock on range 130:4, error was %s", + smbcli_errstr(cli1->tree))); - if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) { - printf("pid1 unable to read the range 130:4, error was %s (%s)\n", - smbcli_errstr(cli1->tree), __location__); - goto fail; - } else { - printf("pid1 successfully read the range 130:4\n"); - } + torture_comment(tctx, "pid1 successfully locked range 130:4 for READ\n"); + + torture_assert(tctx, smbcli_read(cli1->tree, fnum1, buf, 130, 4) == 4, + talloc_asprintf(tctx, "pid1 unable to read the range 130:4, error was %s)", + smbcli_errstr(cli1->tree))); + + torture_comment(tctx, "pid1 successfully read the range 130:4\n"); if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) { - printf("pid1 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) { - printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", - __location__); - goto fail; - } + torture_comment(tctx, "pid1 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); + torture_assert_ntstatus_equal(tctx, smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT, + "Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)"); } else { - printf("pid1 successfully wrote to the range 130:4 (should be denied) (%s)\n", - __location__); - goto fail; + torture_fail(tctx, "pid1 successfully wrote to the range 130:4 (should be denied)"); } cli1->session->pid = 2; if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) { - printf("pid2 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); + torture_comment(tctx, "pid2 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); } else { - printf("pid2 successfully read the range 130:4\n"); + torture_comment(tctx, "pid2 successfully read the range 130:4\n"); } if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) { - printf("pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) { - printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", - __location__); - goto fail; - } + torture_comment(tctx, "pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); + torture_assert_ntstatus_equal(tctx, smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT, + "Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)"); } else { - printf("pid2 successfully wrote to the range 130:4 (should be denied) (%s)\n", - __location__); - goto fail; + torture_fail(tctx, "pid2 successfully wrote to the range 130:4 (should be denied)"); } cli1->session->pid = 1; smbcli_unlock(cli1->tree, fnum1, 130, 4); - if (NT_STATUS_IS_ERR(smbcli_lock(cli1->tree, fnum1, 130, 4, 0, WRITE_LOCK))) { - printf("Unable to apply write lock on range 130:4, error was %s (%s)\n", - smbcli_errstr(cli1->tree), __location__); - goto fail; - } else { - printf("pid1 successfully locked range 130:4 for WRITE\n"); - } + torture_assert_ntstatus_ok(tctx, smbcli_lock(cli1->tree, fnum1, 130, 4, 0, WRITE_LOCK), + talloc_asprintf(tctx, "Unable to apply write lock on range 130:4, error was %s", + smbcli_errstr(cli1->tree))); + torture_comment(tctx, "pid1 successfully locked range 130:4 for WRITE\n"); - if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) { - printf("pid1 unable to read the range 130:4, error was %s (%s)\n", - smbcli_errstr(cli1->tree), __location__); - goto fail; - } else { - printf("pid1 successfully read the range 130:4\n"); - } + torture_assert(tctx, smbcli_read(cli1->tree, fnum1, buf, 130, 4) == 4, + talloc_asprintf(tctx, "pid1 unable to read the range 130:4, error was %s", + smbcli_errstr(cli1->tree))); + torture_comment(tctx, "pid1 successfully read the range 130:4\n"); - if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) { - printf("pid1 unable to write to the range 130:4, error was %s (%s)\n", - smbcli_errstr(cli1->tree), __location__); - goto fail; - } else { - printf("pid1 successfully wrote to the range 130:4\n"); - } + torture_assert(tctx, smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) == 4, + talloc_asprintf(tctx, "pid1 unable to write to the range 130:4, error was %s", + smbcli_errstr(cli1->tree))); + torture_comment(tctx, "pid1 successfully wrote to the range 130:4\n"); cli1->session->pid = 2; if (smbcli_read(cli1->tree, fnum1, buf, 130, 4) != 4) { - printf("pid2 unable to read the range 130:4, error was %s\n", + torture_comment(tctx, "pid2 unable to read the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); - if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) { - printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", - __location__); - goto fail; - } + torture_assert_ntstatus_equal(tctx, smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT, + "Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT)"); } else { - printf("pid2 successfully read the range 130:4 (should be denied) (%s)\n", - __location__); - goto fail; + torture_fail(tctx, "pid2 successfully read the range 130:4 (should be denied)"); } if (smbcli_write(cli1->tree, fnum1, 0, buf, 130, 4) != 4) { - printf("pid2 unable to write to the range 130:4, error was %s\n", + torture_comment(tctx, "pid2 unable to write to the range 130:4, error was %s\n", smbcli_errstr(cli1->tree)); if (!NT_STATUS_EQUAL(smbcli_nt_error(cli1->tree), NT_STATUS_FILE_LOCK_CONFLICT)) { - printf("Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", + torture_comment(tctx, "Incorrect error (should be NT_STATUS_FILE_LOCK_CONFLICT) (%s)\n", __location__); goto fail; } } else { - printf("pid2 successfully wrote to the range 130:4 (should be denied) (%s)\n", + torture_comment(tctx, "pid2 successfully wrote to the range 130:4 (should be denied) (%s)\n", __location__); goto fail; } - printf("Testing truncate of locked file.\n"); + torture_comment(tctx, "Testing truncate of locked file.\n"); fnum2 = smbcli_open(cli1->tree, fname, O_RDWR|O_TRUNC, DENY_NONE); - if (fnum2 == -1) { - printf("Unable to truncate locked file (%s)\n", __location__); - correct = False; - goto fail; - } else { - printf("Truncated locked file.\n"); - } + torture_assert(tctx, fnum2 != -1, "Unable to truncate locked file"); - if (NT_STATUS_IS_ERR(smbcli_getatr(cli1->tree, fname, NULL, &size, NULL))) { - printf("getatr failed (%s) (%s)\n", smbcli_errstr(cli1->tree), __location__); - correct = False; - goto fail; - } + torture_comment(tctx, "Truncated locked file.\n"); - if (size != 0) { - printf("Unable to truncate locked file. Size was %u (%s)\n", - (unsigned)size, __location__); - correct = False; - goto fail; - } + torture_assert_ntstatus_ok(tctx, smbcli_getatr(cli1->tree, fname, NULL, &size, NULL), + talloc_asprintf(tctx, "getatr failed (%s)", smbcli_errstr(cli1->tree))); + + torture_assert(tctx, size == 0, talloc_asprintf(tctx, "Unable to truncate locked file. Size was %u", (unsigned)size)); cli1->session->pid = 1; @@ -981,9 +792,21 @@ fail: smbcli_close(cli1->tree, fnum1); smbcli_close(cli1->tree, fnum2); smbcli_unlink(cli1->tree, fname); - torture_close_connection(cli1); - printf("finished locktest7\n"); return correct; } +struct torture_suite *torture_base_locktest(void) +{ + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), + "LOCK"); + torture_suite_add_2smb_test(suite, "LOCK1", torture_locktest1); + torture_suite_add_1smb_test(suite, "LOCK2", torture_locktest2); + torture_suite_add_2smb_test(suite, "LOCK3", torture_locktest3); + torture_suite_add_2smb_test(suite, "LOCK4", torture_locktest4); + torture_suite_add_2smb_test(suite, "LOCK5", torture_locktest5); + torture_suite_add_1smb_test(suite, "LOCK6", torture_locktest6); + torture_suite_add_1smb_test(suite, "LOCK7", torture_locktest7); + + return suite; +} diff --git a/source4/torture/basic/mangle_test.c b/source4/torture/basic/mangle_test.c index 7e17adece7..091e471e8a 100644 --- a/source4/torture/basic/mangle_test.c +++ b/source4/torture/basic/mangle_test.c @@ -155,18 +155,12 @@ static void gen_name(char *name) } -BOOL torture_mangle(struct torture_context *torture) +BOOL torture_mangle(struct torture_context *torture, + struct smbcli_state *cli) { extern int torture_numops; - static struct smbcli_state *cli; int i; - printf("starting mangle test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - /* we will use an internal tdb to store the names we have used */ tdb = tdb_open(NULL, 100000, TDB_INTERNAL, 0, 0); if (!tdb) { @@ -203,8 +197,5 @@ BOOL torture_mangle(struct torture_context *torture) printf("\nTotal collisions %u/%u - %.2f%% (%u failures)\n", collisions, total, (100.0*collisions) / total, failures); - torture_close_connection(cli); - - printf("mangle test finished\n"); return (failures == 0); } diff --git a/source4/torture/basic/misc.c b/source4/torture/basic/misc.c new file mode 100644 index 0000000000..c00372b805 --- /dev/null +++ b/source4/torture/basic/misc.c @@ -0,0 +1,855 @@ +/* + Unix SMB/CIFS implementation. + SMB torture tester + Copyright (C) Andrew Tridgell 1997-2003 + Copyright (C) Jelmer Vernooij 2006 + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#include "includes.h" +#include "libcli/raw/libcliraw.h" +#include "system/time.h" +#include "system/wait.h" +#include "system/filesys.h" +#include "libcli/raw/ioctl.h" +#include "libcli/libcli.h" +#include "lib/events/events.h" +#include "libcli/resolve/resolve.h" +#include "auth/credentials/credentials.h" +#include "librpc/gen_ndr/ndr_nbt.h" +#include "torture/torture.h" +#include "torture/util.h" +#include "libcli/smb_composite/smb_composite.h" +#include "libcli/composite/composite.h" + +extern struct cli_credentials *cmdline_credentials; +static void benchrw_callback(struct smbcli_request *req); +enum benchrw_stage { + START, + OPEN_CONNECTION, + CLEANUP_TESTDIR, + MK_TESTDIR, + OPEN_FILE, + INITIAL_WRITE, + READ_WRITE_DATA, + MAX_OPS_REACHED, + ERROR, + CLOSE_FILE, + CLEANUP, + FINISHED +}; + +struct benchrw_state{ + struct torture_context *tctx; + char *dname; + char *fname; + uint16_t fnum; + int nr; + struct smbcli_tree *cli; + uint8_t *buffer; + int writecnt; + int readcnt; + int completed; + TALLOC_CTX *mem_ctx; + void *req_params; + enum benchrw_stage mode; + struct params{ + struct unclist{ + const char *host; + const char *share; + } **unc; + const char *workgroup; + int retry; + unsigned int writeblocks; + unsigned int blocksize; + unsigned int writeratio; + } *lp_params; + }; + +static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) +{ + while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) { + if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; + } + return True; +} + + +static BOOL rw_torture(struct torture_context *tctx, struct smbcli_state *c) +{ + const char *lockfname = "\\torture.lck"; + char *fname; + int fnum; + int fnum2; + pid_t pid2, pid = getpid(); + int i, j; + uint8_t buf[1024]; + BOOL correct = True; + + fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, + DENY_NONE); + if (fnum2 == -1) + fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE); + if (fnum2 == -1) { + torture_comment(tctx, "open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree)); + return False; + } + + + for (i=0;itree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); + if (fnum == -1) { + torture_comment(tctx, "open failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + break; + } + + if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) { + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + for (j=0;j<50;j++) { + if (smbcli_write(c->tree, fnum, 0, buf, + sizeof(pid)+(j*sizeof(buf)), + sizeof(buf)) != sizeof(buf)) { + torture_comment(tctx, "write failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + } + + pid2 = 0; + + if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) { + torture_comment(tctx, "read failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (pid2 != pid) { + torture_comment(tctx, "data corruption!\n"); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) { + torture_comment(tctx, "close failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) { + torture_comment(tctx, "unlink failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + + if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) { + torture_comment(tctx, "unlock failed (%s)\n", smbcli_errstr(c->tree)); + correct = False; + } + free(fname); + } + + smbcli_close(c->tree, fnum2); + smbcli_unlink(c->tree, lockfname); + + torture_comment(tctx, "%d\n", i); + + return correct; +} + +BOOL run_torture(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +{ + return rw_torture(tctx, cli); +} + + +/* + see how many RPC pipes we can open at once +*/ +BOOL run_pipe_number(struct torture_context *tctx, + struct smbcli_state *cli1) +{ + const char *pipe_name = "\\WKSSVC"; + int fnum; + int num_pipes = 0; + + while(1) { + fnum = smbcli_nt_create_full(cli1->tree, pipe_name, 0, SEC_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, + NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN_IF, 0, 0); + + if (fnum == -1) { + torture_comment(tctx, "Open of pipe %s failed with error (%s)\n", pipe_name, smbcli_errstr(cli1->tree)); + break; + } + num_pipes++; + torture_comment(tctx, "%d\r", num_pipes); + fflush(stdout); + } + + torture_comment(tctx, "pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name ); + return True; +} + + + + +/* + open N connections to the server and just hold them open + used for testing performance when there are N idle users + already connected + */ +BOOL torture_holdcon(struct torture_context *tctx) +{ + int i; + struct smbcli_state **cli; + int num_dead = 0; + + torture_comment(tctx, "Opening %d connections\n", torture_numops); + + cli = malloc_array_p(struct smbcli_state *, torture_numops); + + for (i=0;itree, "\\"); + if (!NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "Connection %d is dead\n", i); + cli[i] = NULL; + num_dead++; + } + usleep(100); + } + } + + if (num_dead == torture_numops) { + torture_comment(tctx, "All connections dead - finishing\n"); + break; + } + + torture_comment(tctx, "."); + fflush(stdout); + } + + return True; +} + +/* +test how many open files this server supports on the one socket +*/ +BOOL run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy) +{ +#define MAXFID_TEMPLATE "\\maxfid\\fid%d\\maxfid.%d.%d" + char *fname; + int fnums[0x11000], i; + int retries=4, maxfid; + BOOL correct = True; + + if (retries <= 0) { + torture_comment(tctx, "failed to connect\n"); + return False; + } + + if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { + torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", + smbcli_errstr(cli->tree)); + return False; + } + if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) { + torture_comment(tctx, "Failed to mkdir \\maxfid, error=%s\n", + smbcli_errstr(cli->tree)); + return False; + } + + torture_comment(tctx, "Testing maximum number of open files\n"); + + for (i=0; i<0x11000; i++) { + if (i % 1000 == 0) { + asprintf(&fname, "\\maxfid\\fid%d", i/1000); + if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { + torture_comment(tctx, "Failed to mkdir %s, error=%s\n", + fname, smbcli_errstr(cli->tree)); + return False; + } + free(fname); + } + asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid()); + if ((fnums[i] = smbcli_open(cli->tree, fname, + O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == + -1) { + torture_comment(tctx, "open of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + torture_comment(tctx, "maximum fnum is %d\n", i); + break; + } + free(fname); + torture_comment(tctx, "%6d\r", i); + } + torture_comment(tctx, "%6d\n", i); + i--; + + maxfid = i; + + torture_comment(tctx, "cleaning up\n"); + for (i=0;itree, fnums[i]))) { + torture_comment(tctx, "Close of fnum %d failed - %s\n", fnums[i], smbcli_errstr(cli->tree)); + } + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { + torture_comment(tctx, "unlink of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + correct = False; + } + free(fname); + + asprintf(&fname, MAXFID_TEMPLATE, (maxfid-i)/1000, maxfid-i,(int)getpid()); + if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnums[maxfid-i]))) { + torture_comment(tctx, "Close of fnum %d failed - %s\n", fnums[maxfid-i], smbcli_errstr(cli->tree)); + } + if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { + torture_comment(tctx, "unlink of %s failed (%s)\n", + fname, smbcli_errstr(cli->tree)); + correct = False; + } + free(fname); + + torture_comment(tctx, "%6d %6d\r", i, maxfid-i); + } + torture_comment(tctx, "%6d\n", 0); + + if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { + torture_comment(tctx, "Failed to deltree \\maxfid - %s\n", + smbcli_errstr(cli->tree)); + return False; + } + + torture_comment(tctx, "maxfid test finished\n"); + if (!torture_close_connection(cli)) { + correct = False; + } + return correct; +#undef MAXFID_TEMPLATE +} + + + +/* + sees what IOCTLs are supported + */ +BOOL torture_ioctl_test(struct torture_context *tctx, + struct smbcli_state *cli) +{ + uint16_t device, function; + int fnum; + const char *fname = "\\ioctl.dat"; + NTSTATUS status; + union smb_ioctl parms; + TALLOC_CTX *mem_ctx; + + mem_ctx = talloc_named_const(tctx, 0, "ioctl_test"); + + smbcli_unlink(cli->tree, fname); + + fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); + if (fnum == -1) { + torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); + return False; + } + + parms.ioctl.level = RAW_IOCTL_IOCTL; + parms.ioctl.in.file.fnum = fnum; + parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO; + status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); + torture_comment(tctx, "ioctl job info: %s\n", smbcli_errstr(cli->tree)); + + for (device=0;device<0x100;device++) { + torture_comment(tctx, "testing device=0x%x\n", device); + for (function=0;function<0x100;function++) { + parms.ioctl.in.request = (device << 16) | function; + status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); + + if (NT_STATUS_IS_OK(status)) { + torture_comment(tctx, "ioctl device=0x%x function=0x%x OK : %d bytes\n", + device, function, (int)parms.ioctl.out.blob.length); + } + } + } + + return True; +} + +/* + init params using lp_parm_xxx + return number of unclist entries +*/ +static int init_benchrw_params(struct torture_context *tctx, struct params *lpar) +{ + char **unc_list = NULL; + int num_unc_names = 0, conn_index=0, empty_lines=0; + const char *p; + lpar->retry = lp_parm_int(-1, "torture", "retry",3); + lpar->blocksize = lp_parm_int(-1, "torture", "blocksize",65535); + lpar->writeblocks = lp_parm_int(-1, "torture", "writeblocks",15); + lpar->writeratio = lp_parm_int(-1, "torture", "writeratio",5); + lpar->workgroup = lp_workgroup(); + + p = lp_parm_string(-1, "torture", "unclist"); + if (p) { + char *h, *s; + unc_list = file_lines_load(p, &num_unc_names, NULL); + if (!unc_list || num_unc_names <= 0) { + torture_comment(tctx, "Failed to load unc names list from '%s'\n", p); + exit(1); + } + + lpar->unc = talloc_array(tctx, struct unclist *, (num_unc_names-empty_lines)); + for(conn_index = 0; conn_index < num_unc_names; conn_index++) { + /* ignore empty lines */ + if(strlen(unc_list[conn_index % num_unc_names])==0){ + empty_lines++; + continue; + } + if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names], + NULL, &h, &s)) { + torture_comment(tctx, "Failed to parse UNC name %s\n", + unc_list[conn_index % num_unc_names]); + exit(1); + } + lpar->unc[conn_index-empty_lines] = talloc(tctx,struct unclist); + lpar->unc[conn_index-empty_lines]->host = h; + lpar->unc[conn_index-empty_lines]->share = s; + } + return num_unc_names-empty_lines; + }else{ + lpar->unc = talloc_array(tctx, struct unclist *, 1); + lpar->unc[0] = talloc(tctx,struct unclist); + lpar->unc[0]->host = lp_parm_string(-1, "torture", "host"); + lpar->unc[0]->share = lp_parm_string(-1, "torture", "share"); + return 1; + } +} + +/* + Called when the reads & writes are finished. closes the file. +*/ +static NTSTATUS benchrw_close(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_close close_parms; + + NT_STATUS_NOT_OK_RETURN(req->status); + + torture_comment(tctx, "Close file %d (%d)\n",state->nr,state->fnum); + close_parms.close.level = RAW_CLOSE_CLOSE; + close_parms.close.in.file.fnum = state->fnum ; + close_parms.close.in.write_time = 0; + state->mode=CLOSE_FILE; + + req = smb_raw_close_send(state->cli, &close_parms); + NT_STATUS_HAVE_NO_MEMORY(req); + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + Called when the initial write is completed is done. write or read a file. +*/ +static NTSTATUS benchrw_readwrite(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_read rd; + union smb_write wr; + + NT_STATUS_NOT_OK_RETURN(req->status); + + state->completed++; + /*rotate between writes and reads*/ + if( state->completed % state->lp_params->writeratio == 0){ + torture_comment(tctx, "Callback WRITE file:%d (%d/%d)\n", + state->nr,state->completed,torture_numops); + wr.generic.level = RAW_WRITE_WRITEX ; + wr.writex.in.file.fnum = state->fnum ; + wr.writex.in.offset = 0; + wr.writex.in.wmode = 0 ; + wr.writex.in.remaining = 0; + wr.writex.in.count = state->lp_params->blocksize; + wr.writex.in.data = state->buffer; + state->readcnt=0; + req = smb_raw_write_send(state->cli,&wr); + }else{ + torture_comment(tctx, "Callback READ file:%d (%d/%d) Offset:%d\n", + state->nr,state->completed,torture_numops, + (state->readcnt*state->lp_params->blocksize)); + rd.generic.level = RAW_READ_READ ; + rd.read.in.file.fnum = state->fnum ; + rd.read.in.offset = state->readcnt * + state->lp_params->blocksize; + rd.read.in.count = state->lp_params->blocksize; + rd.read.in.remaining = 0 ; + rd.read.out.data = state->buffer; + if(state->readcnt < state->lp_params->writeblocks){ + state->readcnt++; + }else{ + /*start reading from beginn of file*/ + state->readcnt=0; + } + req = smb_raw_read_send(state->cli,&rd); + } + NT_STATUS_HAVE_NO_MEMORY(req); + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + Called when the open is done. writes to the file. +*/ +static NTSTATUS benchrw_open(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_write wr; + if(state->mode == OPEN_FILE){ + NTSTATUS status; + status = smb_raw_open_recv(req,state->mem_ctx,( + union smb_open*)state->req_params); + NT_STATUS_NOT_OK_RETURN(status); + + state->fnum = ((union smb_open*)state->req_params) + ->openx.out.file.fnum; + torture_comment(tctx, "File opened (%d)\n",state->fnum); + state->mode=INITIAL_WRITE; + } + + torture_comment(tctx, "Write initial test file:%d (%d/%d)\n",state->nr, + (state->writecnt+1)*state->lp_params->blocksize, + (state->lp_params->writeblocks*state->lp_params->blocksize)); + wr.generic.level = RAW_WRITE_WRITEX ; + wr.writex.in.file.fnum = state->fnum ; + wr.writex.in.offset = state->writecnt * + state->lp_params->blocksize; + wr.writex.in.wmode = 0 ; + wr.writex.in.remaining = (state->lp_params->writeblocks * + state->lp_params->blocksize)- + ((state->writecnt+1)*state-> + lp_params->blocksize); + wr.writex.in.count = state->lp_params->blocksize; + wr.writex.in.data = state->buffer; + state->writecnt++; + if(state->writecnt == state->lp_params->writeblocks){ + state->mode=READ_WRITE_DATA; + } + req = smb_raw_write_send(state->cli,&wr); + NT_STATUS_HAVE_NO_MEMORY(req); + + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + return NT_STATUS_OK; +} + +/* + Called when the mkdir is done. Opens a file. +*/ +static NTSTATUS benchrw_mkdir(struct torture_context *tctx,struct smbcli_request *req, + struct benchrw_state *state) +{ + union smb_open *open_parms; + uint8_t *writedata; + + NT_STATUS_NOT_OK_RETURN(req->status); + + /* open/create the files */ + torture_comment(tctx, "Open File %d/%d\n",state->nr+1,torture_nprocs); + open_parms=talloc_zero(state->mem_ctx, union smb_open); + NT_STATUS_HAVE_NO_MEMORY(open_parms); + open_parms->openx.level = RAW_OPEN_OPENX; + open_parms->openx.in.flags = 0; + open_parms->openx.in.open_mode = OPENX_MODE_ACCESS_RDWR; + open_parms->openx.in.search_attrs = + FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; + open_parms->openx.in.file_attrs = 0; + open_parms->openx.in.write_time = 0; + open_parms->openx.in.open_func = OPENX_OPEN_FUNC_CREATE; + open_parms->openx.in.size = 0; + open_parms->openx.in.timeout = 0; + open_parms->openx.in.fname = state->fname; + + writedata = talloc_size(state->mem_ctx,state->lp_params->blocksize); + NT_STATUS_HAVE_NO_MEMORY(writedata); + generate_random_buffer(writedata,state->lp_params->blocksize); + state->buffer=writedata; + state->writecnt=1; + state->readcnt=0; + state->req_params=open_parms; + state->mode=OPEN_FILE; + + req = smb_raw_open_send(state->cli,open_parms); + NT_STATUS_HAVE_NO_MEMORY(req); + + /*register the callback function!*/ + req->async.fn = benchrw_callback; + req->async.private = state; + + return NT_STATUS_OK; +} + +/* + handler for completion of a sub-request of the bench-rw test +*/ +static void benchrw_callback(struct smbcli_request *req) +{ + struct benchrw_state *state = req->async.private; + struct torture_context *tctx = state->tctx; + + /*dont send new requests when torture_numops is reached*/ + if(state->completed >= torture_numops){ + state->completed=0; + state->mode=MAX_OPS_REACHED; + } + + switch (state->mode) { + + case MK_TESTDIR: + if (!NT_STATUS_IS_OK(benchrw_mkdir(tctx, req,state))) { + torture_comment(tctx, "Failed to create the test directory - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case OPEN_FILE: + case INITIAL_WRITE: + if (!NT_STATUS_IS_OK(benchrw_open(tctx, req,state))){ + torture_comment(tctx, "Failed to open/write the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case READ_WRITE_DATA: + if (!NT_STATUS_IS_OK(benchrw_readwrite(tctx,req,state))){ + torture_comment(tctx, "Failed to read/write the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case MAX_OPS_REACHED: + if (!NT_STATUS_IS_OK(benchrw_close(tctx,req,state))){ + torture_comment(tctx, "Failed to read/write/close the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + break; + case CLOSE_FILE: + torture_comment(tctx, "File %d closed\n",state->nr); + if (!NT_STATUS_IS_OK(req->status)) { + torture_comment(tctx, "Failed to close the file - %s\n", + nt_errstr(req->status)); + state->mode=ERROR; + return; + } + state->mode=CLEANUP; + return; + default: + break; + } + +} + +/* open connection async callback function*/ +static void async_open_callback(struct composite_context *con) +{ + struct benchrw_state *state = con->async.private_data; + struct torture_context *tctx = state->tctx; + int retry = state->lp_params->retry; + + if (NT_STATUS_IS_OK(con->status)) { + state->cli=((struct smb_composite_connect*) + state->req_params)->out.tree; + state->mode=CLEANUP_TESTDIR; + }else{ + if(state->writecnt < retry){ + torture_comment(tctx, "Failed to open connection:%d, Retry (%d/%d)\n", + state->nr,state->writecnt,retry); + state->writecnt++; + state->mode=START; + usleep(1000); + }else{ + torture_comment(tctx, "Failed to open connection (%d) - %s\n", + state->nr, nt_errstr(con->status)); + state->mode=ERROR; + } + return; + } +} + +/* + establishs a smbcli_tree from scratch (async) +*/ +static struct composite_context *torture_connect_async( + struct torture_context *tctx, + struct smb_composite_connect *smb, + TALLOC_CTX *mem_ctx, + struct event_context *ev, + const char *host, + const char *share, + const char *workgroup) +{ + torture_comment(tctx, "Open Connection to %s/%s\n",host,share); + smb->in.dest_host=talloc_strdup(mem_ctx,host); + smb->in.service=talloc_strdup(mem_ctx,share); + smb->in.port=0; + smb->in.called_name = strupper_talloc(mem_ctx, host); + smb->in.service_type=NULL; + smb->in.credentials=cmdline_credentials; + smb->in.fallback_to_anonymous=False; + smb->in.workgroup=workgroup; + + return smb_composite_connect_send(smb,mem_ctx,ev); +} + +BOOL run_benchrw(struct torture_context *tctx) +{ + struct smb_composite_connect *smb_con; + const char *fname = "\\rwtest.dat"; + struct smbcli_request *req; + struct benchrw_state **state; + int i , num_unc_names; + struct event_context *ev ; + struct composite_context *req1; + struct params lpparams; + union smb_mkdir parms; + int finished = 0; + BOOL success=True; + + torture_comment(tctx, "Start BENCH-READWRITE num_ops=%d num_nprocs=%d\n", + torture_numops,torture_nprocs); + + /*init talloc context*/ + ev = event_context_init(tctx); + state = talloc_array(tctx, struct benchrw_state *, torture_nprocs); + + /* init params using lp_parm_xxx */ + num_unc_names = init_benchrw_params(tctx,&lpparams); + + /* init private data structs*/ + for(i = 0; itctx = tctx; + state[i]->completed=0; + state[i]->lp_params=&lpparams; + state[i]->nr=i; + state[i]->dname=talloc_asprintf(tctx,"benchrw%d",i); + state[i]->fname=talloc_asprintf(tctx,"%s%s", + state[i]->dname,fname); + state[i]->mode=START; + state[i]->writecnt=0; + } + + torture_comment(tctx, "Starting async requests\n"); + while(finished != torture_nprocs){ + finished=0; + for(i = 0; imode){ + /*open multiple connections with the same userid */ + case START: + smb_con = talloc(tctx,struct smb_composite_connect) ; + state[i]->req_params=smb_con; + state[i]->mode=OPEN_CONNECTION; + req1 = torture_connect_async(tctx, smb_con, + tctx,ev, + lpparams.unc[i % num_unc_names]->host, + lpparams.unc[i % num_unc_names]->share, + lpparams.workgroup); + /* register callback fn + private data */ + req1->async.fn = async_open_callback; + req1->async.private_data=state[i]; + break; + /*setup test dirs (sync)*/ + case CLEANUP_TESTDIR: + torture_comment(tctx, "Setup test dir %d\n",i); + smb_raw_exit(state[i]->cli->session); + if (smbcli_deltree(state[i]->cli, + state[i]->dname) == -1) { + torture_comment(tctx, "Unable to delete %s - %s\n", + state[i]->dname, + smbcli_errstr(state[i]->cli)); + state[i]->mode=ERROR; + break; + } + state[i]->mode=MK_TESTDIR; + parms.mkdir.level = RAW_MKDIR_MKDIR; + parms.mkdir.in.path = state[i]->dname; + req = smb_raw_mkdir_send(state[i]->cli,&parms); + /* register callback fn + private data */ + req->async.fn = benchrw_callback; + req->async.private=state[i]; + break; + /* error occured , finish */ + case ERROR: + finished++; + success=False; + break; + /* cleanup , close connection */ + case CLEANUP: + torture_comment(tctx, "Deleting test dir %s %d/%d\n",state[i]->dname, + i+1,torture_nprocs); + smbcli_deltree(state[i]->cli,state[i]->dname); + if (NT_STATUS_IS_ERR(smb_tree_disconnect( + state[i]->cli))) { + torture_comment(tctx, "ERROR: Tree disconnect failed"); + state[i]->mode=ERROR; + break; + } + state[i]->mode=FINISHED; + case FINISHED: + finished++; + break; + default: + event_loop_once(ev); + } + } + } + + return success; +} + diff --git a/source4/torture/basic/properties.c b/source4/torture/basic/properties.c index 63941263ae..6b0b61419b 100644 --- a/source4/torture/basic/properties.c +++ b/source4/torture/basic/properties.c @@ -89,21 +89,13 @@ static void show_bits(const struct bitmapping *bm, uint32_t value) /* print out server properties */ -BOOL torture_test_properties(struct torture_context *torture) +BOOL torture_test_properties(struct torture_context *torture, + struct smbcli_state *cli) { - struct smbcli_state *cli; BOOL correct = True; union smb_fsinfo fs; NTSTATUS status; - printf("starting properties test\n"); - - ZERO_STRUCT(cli); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - d_printf("Capabilities: 0x%08x\n", cli->transport->negotiate.capabilities); show_bits(capability_bits, cli->transport->negotiate.capabilities); d_printf("\n"); @@ -122,10 +114,6 @@ BOOL torture_test_properties(struct torture_context *torture) d_printf("fstype: %s\n", fs.attribute_info.out.fs_type.s); } - if (!torture_close_connection(cli)) { - correct = False; - } - return correct; } diff --git a/source4/torture/basic/rename.c b/source4/torture/basic/rename.c index b80c909470..2d4fb38e9f 100644 --- a/source4/torture/basic/rename.c +++ b/source4/torture/basic/rename.c @@ -28,20 +28,13 @@ /* Test rename on files open with share delete and no share delete. */ -BOOL torture_test_rename(struct torture_context *torture) +BOOL torture_test_rename(struct torture_context *tctx, + struct smbcli_state *cli1) { - struct smbcli_state *cli1; const char *fname = "\\test.txt"; const char *fname1 = "\\test1.txt"; - BOOL correct = True; int fnum1; - printf("starting rename test\n"); - - if (!torture_open_connection(&cli1, 0)) { - return False; - } - smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); fnum1 = smbcli_nt_create_full(cli1->tree, fname, 0, @@ -50,24 +43,14 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) First open failed - %s\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("First rename failed (this is correct) - %s\n", smbcli_errstr(cli1->tree)); - } else { - printf("(%s) First rename succeeded - this should have failed !\n", - __location__); - correct = False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 1 failed (%s)\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "First open failed - %s", + smbcli_errstr(cli1->tree))); + + torture_assert(tctx, NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1)), + "First rename succeeded - this should have failed !"); + + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 1 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); @@ -77,24 +60,17 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_DELETE|NTCREATEX_SHARE_ACCESS_READ, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) Second open failed - %s\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } - - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("(%s) Second rename failed - this should have succeeded - %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } else { - printf("Second rename succeeded\n"); - } - - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 2 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, + "Second open failed - %s", smbcli_errstr(cli1->tree))); + + torture_assert_ntstatus_ok(tctx, smbcli_rename(cli1->tree, fname, fname1), + talloc_asprintf(tctx, + "Second rename failed - this should have succeeded - %s", + smbcli_errstr(cli1->tree))); + + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, + "close - 2 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); @@ -105,33 +81,19 @@ BOOL torture_test_rename(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OVERWRITE_IF, 0, 0); - if (fnum1 == -1) { - printf("(%s) Third open failed - %s\n", __location__, smbcli_errstr(cli1->tree)); - return False; - } - + torture_assert(tctx, fnum1 != -1, talloc_asprintf(tctx, "Third open failed - %s", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_rename(cli1->tree, fname, fname1))) { - printf("(%s) Third rename failed - this should have succeeded - %s\n", - __location__, smbcli_errstr(cli1->tree)); - correct = False; - } else { - printf("Third rename succeeded\n"); - } + torture_assert_ntstatus_ok(tctx, smbcli_rename(cli1->tree, fname, fname1), + talloc_asprintf(tctx, "Third rename failed - this should have succeeded - %s", + smbcli_errstr(cli1->tree))); - if (NT_STATUS_IS_ERR(smbcli_close(cli1->tree, fnum1))) { - printf("(%s) close - 3 failed (%s)\n", - __location__, smbcli_errstr(cli1->tree)); - return False; - } + torture_assert_ntstatus_ok(tctx, smbcli_close(cli1->tree, fnum1), + talloc_asprintf(tctx, "close - 3 failed (%s)", smbcli_errstr(cli1->tree))); smbcli_unlink(cli1->tree, fname); smbcli_unlink(cli1->tree, fname1); - if (!torture_close_connection(cli1)) { - correct = False; - } - - return correct; + return true; } diff --git a/source4/torture/basic/scanner.c b/source4/torture/basic/scanner.c index 47da8f7efe..60cfacd840 100644 --- a/source4/torture/basic/scanner.c +++ b/source4/torture/basic/scanner.c @@ -242,19 +242,13 @@ static BOOL scan_trans2(struct smbcli_state *cli, int op, int level, } -BOOL torture_trans2_scan(struct torture_context *torture) +BOOL torture_trans2_scan(struct torture_context *torture, + struct smbcli_state *cli) { - static struct smbcli_state *cli; int op, level; const char *fname = "\\scanner.dat"; int fnum, dnum, qfnum; - printf("starting trans2 scan test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); if (fnum == -1) { printf("file open failed - %s\n", smbcli_errstr(cli->tree)); @@ -299,9 +293,6 @@ BOOL torture_trans2_scan(struct torture_context *torture) } } - torture_close_connection(cli); - - printf("trans2 scan finished\n"); return True; } @@ -483,19 +474,13 @@ static BOOL scan_nttrans(struct smbcli_state *cli, int op, int level, } -BOOL torture_nttrans_scan(struct torture_context *torture) +BOOL torture_nttrans_scan(struct torture_context *torture, + struct smbcli_state *cli) { - static struct smbcli_state *cli; int op, level; const char *fname = "\\scanner.dat"; int fnum, dnum; - printf("starting nttrans scan test\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } - fnum = smbcli_open(cli->tree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_NONE); dnum = smbcli_open(cli->tree, "\\", O_RDONLY, DENY_NONE); diff --git a/source4/torture/basic/secleak.c b/source4/torture/basic/secleak.c index 78267b0295..b39c46b853 100644 --- a/source4/torture/basic/secleak.c +++ b/source4/torture/basic/secleak.c @@ -56,15 +56,10 @@ static BOOL try_failed_login(struct smbcli_state *cli) return True; } -BOOL torture_sec_leak(struct torture_context *torture) +BOOL torture_sec_leak(struct torture_context *tctx, struct smbcli_state *cli) { - struct smbcli_state *cli; time_t t1 = time(NULL); - int timelimit = lp_parm_int(-1, "torture", "timelimit", 20); - - if (!torture_open_connection(&cli, 0)) { - return False; - } + int timelimit = torture_setting_int(tctx, "timelimit", 20); while (time(NULL) < t1+timelimit) { if (!try_failed_login(cli)) { diff --git a/source4/torture/basic/unlink.c b/source4/torture/basic/unlink.c index b64c52e110..a8469e4bf6 100644 --- a/source4/torture/basic/unlink.c +++ b/source4/torture/basic/unlink.c @@ -34,49 +34,36 @@ 1) the server does not allow an unlink on a file that is open */ -BOOL torture_unlinktest(struct torture_context *torture) +BOOL torture_unlinktest(struct torture_context *tctx, struct smbcli_state *cli) { - struct smbcli_state *cli; const char *fname = BASEDIR "\\unlink.tst"; int fnum; BOOL correct = True; union smb_open io; NTSTATUS status; - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("starting unlink test\n"); - - if (!torture_setup_dir(cli, BASEDIR)) { - return False; - } + torture_assert(tctx, torture_setup_dir(cli, BASEDIR), + talloc_asprintf(tctx, "Failed setting up %s", BASEDIR)); cli->session->pid = 1; - printf("Opening a file\n"); + torture_comment(tctx, "Opening a file\n"); fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; - } - - printf("Unlinking a open file\n"); - - if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) { - printf("(%s) error: server allowed unlink on an open file\n", __location__); - correct = False; - } else { - correct = check_error(__location__, cli, ERRDOS, ERRbadshare, + torture_assert(tctx, fnum != -1, talloc_asprintf(tctx, "open of %s failed (%s)", fname, smbcli_errstr(cli->tree))); + + torture_comment(tctx, "Unlinking a open file\n"); + + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)), + "server allowed unlink on an open file"); + + correct = check_error(__location__, cli, ERRDOS, ERRbadshare, NT_STATUS_SHARING_VIOLATION); - } smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); - printf("testing unlink after ntcreatex with DELETE access\n"); + torture_comment(tctx, "testing unlink after ntcreatex with DELETE access\n"); io.ntcreatex.level = RAW_OPEN_NTCREATEX; io.ntcreatex.in.root_fid = 0; @@ -92,23 +79,14 @@ BOOL torture_unlinktest(struct torture_context *torture) io.ntcreatex.in.access_mask = SEC_RIGHTS_FILE_ALL; status = smb_raw_open(cli->tree, cli, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("(%s) failed to open %s\n", __location__, fname); - } - if (NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname))) { - printf("(%s) error: server allowed unlink on an open file\n", __location__); - correct = False; - } else { - correct = check_error(__location__, cli, ERRDOS, ERRbadshare, - NT_STATUS_SHARING_VIOLATION); - } + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "failed to open %s", fname)); - if (!torture_close_connection(cli)) { - correct = False; - } + torture_assert(tctx, !NT_STATUS_IS_OK(smbcli_unlink(cli->tree, fname)), + "server allowed unlink on an open file"); + + correct = check_error(__location__, cli, ERRDOS, ERRbadshare, + NT_STATUS_SHARING_VIOLATION); - printf("unlink test finished\n"); - return correct; } diff --git a/source4/torture/basic/utable.c b/source4/torture/basic/utable.c index 8e13babd0a..28122da214 100644 --- a/source4/torture/basic/utable.c +++ b/source4/torture/basic/utable.c @@ -26,9 +26,9 @@ #include "torture/util.h" #include "pstring.h" -BOOL torture_utable(struct torture_context *torture) +bool torture_utable(struct torture_context *tctx, + struct smbcli_state *cli) { - struct smbcli_state *cli; fstring fname; const char *alt_name; int fnum; @@ -37,19 +37,12 @@ BOOL torture_utable(struct torture_context *torture) int chars_allowed=0, alt_allowed=0; uint8_t valid[0x10000]; - printf("starting utable\n"); - - printf("Generating valid character table\n"); - - if (!torture_open_connection(&cli, 0)) { - return False; - } + torture_comment(tctx, "Generating valid character table\n"); memset(valid, 0, sizeof(valid)); - if (!torture_setup_dir(cli, "\\utable")) { - return False; - } + torture_assert(tctx, torture_setup_dir(cli, "\\utable"), + "Setting up dir \\utable failed"); for (c=1; c < 0x10000; c++) { char *p; @@ -74,32 +67,31 @@ BOOL torture_utable(struct torture_context *torture) if (strncmp(alt_name, "X_A_L", 5) != 0) { alt_allowed++; valid[c] = 1; - d_printf("fname=[%s] alt_name=[%s]\n", fname, alt_name); + torture_comment(tctx, "fname=[%s] alt_name=[%s]\n", fname, alt_name); } smbcli_close(cli->tree, fnum); smbcli_unlink(cli->tree, fname); if (c % 100 == 0) { - printf("%d (%d/%d)\r", c, chars_allowed, alt_allowed); + torture_comment(tctx, "%d (%d/%d)\r", c, chars_allowed, alt_allowed); } } - printf("%d (%d/%d)\n", c, chars_allowed, alt_allowed); + torture_comment(tctx, "%d (%d/%d)\n", c, chars_allowed, alt_allowed); smbcli_rmdir(cli->tree, "\\utable"); - d_printf("%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed); + torture_comment(tctx, "%d chars allowed %d alt chars allowed\n", chars_allowed, alt_allowed); fd = open("valid.dat", O_WRONLY|O_CREAT|O_TRUNC, 0644); - if (fd == -1) { - d_printf("Failed to create valid.dat - %s", strerror(errno)); - return False; - } + torture_assert(tctx, fd != -1, + talloc_asprintf(tctx, + "Failed to create valid.dat - %s", strerror(errno))); write(fd, valid, 0x10000); close(fd); - d_printf("wrote valid.dat\n"); + torture_comment(tctx, "wrote valid.dat\n"); - return True; + return true; } @@ -121,34 +113,28 @@ static char *form_name(int c) return fname; } -BOOL torture_casetable(struct torture_context *torture) +bool torture_casetable(struct torture_context *tctx, + struct smbcli_state *cli) { - static struct smbcli_state *cli; char *fname; int fnum; int c, i; #define MAX_EQUIVALENCE 8 codepoint_t equiv[0x10000][MAX_EQUIVALENCE]; - printf("starting casetable\n"); - if (!torture_open_connection(&cli, 0)) { - return False; - } - - printf("Determining upper/lower case table\n"); + torture_comment(tctx, "Determining upper/lower case table\n"); memset(equiv, 0, sizeof(equiv)); - if (!torture_setup_dir(cli, "\\utable")) { - return False; - } + torture_assert(tctx, torture_setup_dir(cli, "\\utable"), + "Error setting up dir \\utable"); for (c=1; c < 0x10000; c++) { size_t size; if (c == '.' || c == '\\') continue; - d_printf("%04x (%c)\n", c, isprint(c)?c:'.'); + torture_comment(tctx, "%04x (%c)\n", c, isprint(c)?c:'.'); fname = form_name(c); fnum = smbcli_nt_create_full(cli->tree, fname, 0, @@ -161,10 +147,9 @@ BOOL torture_casetable(struct torture_context *torture) NTCREATEX_SHARE_ACCESS_NONE, NTCREATEX_DISP_OPEN_IF, 0, 0); - if (fnum == -1) { - printf("Failed to create file with char %04x\n", c); - continue; - } + torture_assert(tctx, fnum != -1, + talloc_asprintf(tctx, + "Failed to create file with char %04x\n", c)); size = 0; @@ -176,21 +161,20 @@ BOOL torture_casetable(struct torture_context *torture) int c2[MAX_EQUIVALENCE]; if (size/sizeof(int) >= MAX_EQUIVALENCE) { - printf("too many chars match?? size=%d c=0x%04x\n", + torture_comment(tctx, "too many chars match?? size=%d c=0x%04x\n", (int)size, c); smbcli_close(cli->tree, fnum); return False; } smbcli_read(cli->tree, fnum, c2, 0, size); - printf("%04x: ", c); + torture_comment(tctx, "%04x: ", c); equiv[c][0] = c; for (i=0; itree, fnum, 0, &c, size, sizeof(c)); @@ -200,5 +184,5 @@ BOOL torture_casetable(struct torture_context *torture) smbcli_unlink(cli->tree, "\\utable\\*"); smbcli_rmdir(cli->tree, "\\utable"); - return True; + return true; } diff --git a/source4/torture/config.mk b/source4/torture/config.mk index be2d6a1bde..32205c5566 100644 --- a/source4/torture/config.mk +++ b/source4/torture/config.mk @@ -30,6 +30,7 @@ PRIVATE_PROTO_HEADER = \ basic/proto.h OBJ_FILES = \ basic/base.o \ + basic/misc.o \ basic/scanner.o \ basic/utable.o \ basic/charset.o \ @@ -94,11 +95,6 @@ PUBLIC_DEPENDENCIES = \ include smb2/config.mk -[MODULE::torture_misc] -SUBSYSTEM = torture -INIT_FUNCTION = torture_misc_init -OBJ_FILES = misc.o - [MODULE::torture_rpc] # TORTURE_NET and TORTURE_NBT use functions from torture_rpc... #OUTPUT_TYPE = INTEGRATED @@ -232,7 +228,6 @@ OBJ_FILES = \ nbt/winsbench.o \ nbt/winsreplication.o \ nbt/dgram.o \ - nbt/browse.o \ nbt/nbt.o PUBLIC_DEPENDENCIES = \ LIBCLI_SMB LIBCLI_NBT LIBCLI_DGRAM LIBCLI_WREPL diff --git a/source4/torture/ldap/common.c b/source4/torture/ldap/common.c index 5dc482776a..5b28e825f2 100644 --- a/source4/torture/ldap/common.c +++ b/source4/torture/ldap/common.c @@ -101,10 +101,19 @@ NTSTATUS torture_ldap_close(struct ldap_connection *conn) NTSTATUS torture_ldap_init(void) { - register_torture_op("BENCH-CLDAP", torture_bench_cldap); - register_torture_op("LDAP-BASIC", torture_ldap_basic); - register_torture_op("LDAP-SCHEMA", torture_ldap_schema); - register_torture_op("LDAP-CLDAP", torture_cldap); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "LDAP"); + torture_suite_add_simple_test(suite, "BENCH-CLDAP", + torture_bench_cldap); + torture_suite_add_simple_test(suite, "BASIC", torture_ldap_basic); + torture_suite_add_simple_test(suite, "CLDAP", torture_cldap); + torture_suite_add_simple_test(suite, "SCHEMA", torture_ldap_schema); + + suite->description = talloc_strdup( + suite, "LDAP and CLDAP tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/libnet/libnet.c b/source4/torture/libnet/libnet.c index a4654a7cfb..f45365dfc0 100644 --- a/source4/torture/libnet/libnet.c +++ b/source4/torture/libnet/libnet.c @@ -24,30 +24,39 @@ NTSTATUS torture_net_init(void) { - register_torture_op("NET-USERINFO", torture_userinfo); - register_torture_op("NET-USERADD", torture_useradd); - register_torture_op("NET-USERDEL", torture_userdel); - register_torture_op("NET-USERMOD", torture_usermod); - register_torture_op("NET-DOMOPEN", torture_domainopen); - register_torture_op("NET-API-LOOKUP", torture_lookup); - register_torture_op("NET-API-LOOKUPHOST", torture_lookup_host); - register_torture_op("NET-API-LOOKUPPDC", torture_lookup_pdc); - register_torture_op("NET-API-LOOKUPNAME", torture_lookup_sam_name); - register_torture_op("NET-API-CREATEUSER", torture_createuser); - register_torture_op("NET-API-DELETEUSER", torture_deleteuser); - register_torture_op("NET-API-MODIFYUSER", torture_modifyuser); - register_torture_op("NET-API-USERINFO", torture_userinfo_api); - register_torture_op("NET-API-RPCCONN-BIND", torture_rpc_connect_binding); - register_torture_op("NET-API-RPCCONN-SRV", torture_rpc_connect_srv); - register_torture_op("NET-API-RPCCONN-PDC", torture_rpc_connect_pdc); - register_torture_op("NET-API-RPCCONN-DC", torture_rpc_connect_dc); - register_torture_op("NET-API-RPCCONN-DCINFO", torture_rpc_connect_dc_info); - register_torture_op("NET-API-LISTSHARES", torture_listshares); - register_torture_op("NET-API-DELSHARE", torture_delshare); - register_torture_op("NET-API-DOMOPENLSA", torture_domain_open_lsa); - register_torture_op("NET-API-DOMCLOSELSA", torture_domain_close_lsa); - register_torture_op("NET-API-DOMOPENSAMR", torture_domain_open_samr); - register_torture_op("NET-API-DOMCLOSESAMR", torture_domain_close_samr); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "NET"); + + torture_suite_add_simple_test(suite, "USERINFO", torture_userinfo); + torture_suite_add_simple_test(suite, "USERADD", torture_useradd); + torture_suite_add_simple_test(suite, "USERDEL", torture_userdel); + torture_suite_add_simple_test(suite, "USERMOD", torture_usermod); + torture_suite_add_simple_test(suite, "DOMOPEN", torture_domainopen); + torture_suite_add_simple_test(suite, "API-LOOKUP", torture_lookup); + torture_suite_add_simple_test(suite, "API-LOOKUPHOST", torture_lookup_host); + torture_suite_add_simple_test(suite, "API-LOOKUPPDC", torture_lookup_pdc); + torture_suite_add_simple_test(suite, "API-LOOKUPNAME", torture_lookup_sam_name); + torture_suite_add_simple_test(suite, "API-CREATEUSER", torture_createuser); + torture_suite_add_simple_test(suite, "API-DELETEUSER", torture_deleteuser); + torture_suite_add_simple_test(suite, "API-MODIFYUSER", torture_modifyuser); + torture_suite_add_simple_test(suite, "API-USERINFO", torture_userinfo_api); + torture_suite_add_simple_test(suite, "API-RPCCONN-BIND", torture_rpc_connect_binding); + torture_suite_add_simple_test(suite, "API-RPCCONN-SRV", torture_rpc_connect_srv); + torture_suite_add_simple_test(suite, "API-RPCCONN-PDC", torture_rpc_connect_pdc); + torture_suite_add_simple_test(suite, "API-RPCCONN-DC", torture_rpc_connect_dc); + torture_suite_add_simple_test(suite, "API-RPCCONN-DCINFO", torture_rpc_connect_dc_info); + torture_suite_add_simple_test(suite, "API-LISTSHARES", torture_listshares); + torture_suite_add_simple_test(suite, "API-DELSHARE", torture_delshare); + torture_suite_add_simple_test(suite, "API-DOMOPENLSA", torture_domain_open_lsa); + torture_suite_add_simple_test(suite, "API-DOMCLOSELSA", torture_domain_close_lsa); + torture_suite_add_simple_test(suite, "API-DOMOPENSAMR", torture_domain_open_samr); + torture_suite_add_simple_test(suite, "API-DOMCLOSESAMR", torture_domain_close_samr); + + suite->description = talloc_strdup(suite, + "libnet convenience interface tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/local/binding_string.c b/source4/torture/local/binding_string.c index 3c38183ec9..f6bf35671e 100644 --- a/source4/torture/local/binding_string.c +++ b/source4/torture/local/binding_string.c @@ -25,37 +25,32 @@ #include "librpc/rpc/dcerpc.h" #include "torture/torture.h" -static BOOL test_BindingString(struct torture_context *torture, - const void *_binding) +static bool test_BindingString(struct torture_context *tctx, + const void *test_data) { - const char *binding = _binding; + const char *binding = test_data; struct dcerpc_binding *b, *b2; const char *s, *s2; struct epm_tower tower; + TALLOC_CTX *mem_ctx = tctx; /* Parse */ - torture_assert_ntstatus_ok(torture, - dcerpc_parse_binding(torture, binding, &b), + torture_assert_ntstatus_ok(tctx, dcerpc_parse_binding(mem_ctx, binding, &b), "Error parsing binding string"); - s = dcerpc_binding_string(torture, b); - if (!s) { - torture_fail(torture, "Error converting binding back to string"); - return False; - } + s = dcerpc_binding_string(mem_ctx, b); + torture_assert(tctx, s != NULL, "Error converting binding back to string"); - torture_assert_casestr_equal(torture, binding, s, + torture_assert_casestr_equal(tctx, binding, s, "Mismatch while comparing original and regenerated binding strings"); /* Generate protocol towers */ - torture_assert_ntstatus_ok(torture, - dcerpc_binding_build_tower(torture, b, &tower), + torture_assert_ntstatus_ok(tctx, dcerpc_binding_build_tower(mem_ctx, b, &tower), "Error generating protocol tower"); /* Convert back to binding and then back to string and compare */ - torture_assert_ntstatus_ok(torture, - dcerpc_binding_from_tower(torture, &tower, &b2), + torture_assert_ntstatus_ok(tctx, dcerpc_binding_from_tower(mem_ctx, &tower, &b2), "Error generating binding from tower for original binding"); /* Compare to a stripped down version of the binding string because @@ -64,25 +59,16 @@ static BOOL test_BindingString(struct torture_context *torture, b->flags = 0; - s = dcerpc_binding_string(torture, b); - if (!s) { - torture_fail(torture, "Error converting binding back to string for (stripped down)"); - return False; - } + s = dcerpc_binding_string(mem_ctx, b); + torture_assert(tctx, s != NULL, "Error converting binding back to string for (stripped down)"); + s2 = dcerpc_binding_string(mem_ctx, b2); + torture_assert(tctx, s != NULL, "Error converting binding back to string"); - s2 = dcerpc_binding_string(torture, b2); - if (!s) { - torture_fail(torture, "Error converting binding back to string"); - return False; - } - - if (is_ipaddress(b->host) && strcasecmp(s, s2) != 0) { - torture_fail(torture, "Mismatch while comparing original and from protocol tower generated binding strings: '%s' <> '%s'\n", s, s2); - return False; - } + if (is_ipaddress(b->host)) + torture_assert_casestr_equal(tctx, s, s2, "Mismatch while comparing original and from protocol tower generated binding strings"); - return True; + return true; } static const char *test_strings[] = { @@ -114,7 +100,7 @@ struct torture_suite *torture_local_binding_string(TALLOC_CTX *mem_ctx) { int i; struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-BINDING"); + "BINDING"); for (i = 0; i < ARRAY_SIZE(test_strings); i++) { torture_suite_add_simple_tcase(suite, test_strings[i], diff --git a/source4/torture/local/config.mk b/source4/torture/local/config.mk index c9494039e0..682fb55416 100644 --- a/source4/torture/local/config.mk +++ b/source4/torture/local/config.mk @@ -7,9 +7,9 @@ PRIVATE_PROTO_HEADER = \ proto.h OBJ_FILES = \ iconv.o \ + ../../lib/talloc/testsuite.o \ ../../lib/replace/test/testsuite.o \ ../../lib/replace/test/os2_delete.o \ - ../../lib/talloc/testsuite.o \ ../../lib/crypto/md4test.o \ ../../lib/crypto/md5test.o \ ../../lib/crypto/hmacmd5test.o \ diff --git a/source4/torture/local/dbspeed.c b/source4/torture/local/dbspeed.c index 10620440ce..757c13cf6e 100644 --- a/source4/torture/local/dbspeed.c +++ b/source4/torture/local/dbspeed.c @@ -73,13 +73,13 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data) if (!tdb_add_record(tdbw, "S-1-5-21-53173311-3623041448-2049097239-%u", "UID %u", i)) { - torture_fail(torture, "Failed to add SID %d", i); + _torture_fail_ext(torture, "Failed to add SID %d", i); goto failed; } if (!tdb_add_record(tdbw, "UID %u", "S-1-5-21-53173311-3623041448-2049097239-%u", i)) { - torture_fail(torture, "Failed to add UID %d", i); + _torture_fail_ext(torture, "Failed to add UID %d", i); goto failed; } } @@ -95,7 +95,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data) key.dsize = strlen((char *)key.dptr)+1; data = tdb_fetch(tdbw->tdb, key); if (data.dptr == NULL) { - torture_fail(torture, "Failed to fetch SID %d", i); + _torture_fail_ext(torture, "Failed to fetch SID %d", i); goto failed; } free(data.dptr); @@ -103,7 +103,7 @@ static BOOL test_tdb_speed(struct torture_context *torture, const void *_data) key.dsize = strlen((char *)key.dptr)+1; data = tdb_fetch(tdbw->tdb, key); if (data.dptr == NULL) { - torture_fail(torture, "Failed to fetch UID %d", i); + _torture_fail_ext(torture, "Failed to fetch UID %d", i); goto failed; } free(data.dptr); @@ -186,13 +186,13 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data) for (i=0;i 100) { - torture_fail(torture, "memory leak in ldb add"); + _torture_fail_ext(torture, "memory leak in ldb add"); goto failed; } @@ -210,14 +210,16 @@ static BOOL test_ldb_speed(struct torture_context *torture, const void *_data) i); if (ldb_search(ldb, dn, LDB_SCOPE_BASE, NULL, NULL, &res) != LDB_SUCCESS || res->count != 1) { - torture_fail(torture, "Failed to find SID %d", i); + torture_fail(torture, talloc_asprintf(torture, + "Failed to find SID %d", i)); } talloc_free(res); talloc_free(dn); expr = talloc_asprintf(tmp_ctx, "(UID=%u)", i); if (ldb_search(ldb, NULL, LDB_SCOPE_SUBTREE, expr, NULL, &res) != LDB_SUCCESS || res->count != 1) { - torture_fail(torture, "Failed to find UID %d", i); + torture_fail(torture, talloc_asprintf(torture, + "Failed to find UID %d", i)); } talloc_free(res); talloc_free(expr); diff --git a/source4/torture/local/event.c b/source4/torture/local/event.c index f55cd8d466..6579b1b277 100644 --- a/source4/torture/local/event.c +++ b/source4/torture/local/event.c @@ -40,13 +40,13 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f, { int *fd = private; - torture_comment(test, "event[%d] fd[%d] events[0x%08X]%s%s", fde_count, - *fd, flags, + torture_comment(test, "event[%d] fd[%d] events[0x%08X]%s%s\n", + fde_count, *fd, flags, (flags & EVENT_FD_READ)?" EVENT_FD_READ":"", (flags & EVENT_FD_WRITE)?" EVENT_FD_WRITE":""); if (fde_count > 5) { - torture_fail(test, "got more than fde 5 events - bug!"); + _torture_fail_ext(test, "got more than fde 5 events - bug!"); talloc_free(fde); fde = NULL; return; @@ -59,13 +59,13 @@ static void fde_handler(struct event_context *ev_ctx, struct fd_event *f, static void timed_handler(struct event_context *ev_ctx, struct timed_event *te, struct timeval tval, void *private) { - torture_comment(test, "timed_handler called[%d]", te_count); + torture_comment(test, "timed_handler called[%d]\n", te_count); if (te_count > 2) { close(write_fd); write_fd = -1; } if (te_count > 5) { - torture_comment(test, "remove fd event!"); + torture_comment(test, "remove fd event!\n"); talloc_free(fde); fde = NULL; return; @@ -74,17 +74,19 @@ static void timed_handler(struct event_context *ev_ctx, struct timed_event *te, event_add_timed(ev_ctx, ev_ctx, timeval_current_ofs(0,500), timed_handler, private); } -static BOOL test_event_context(struct torture_context *torture, const void *_data) +static bool test_event_context(struct torture_context *torture_ctx, + const void *test_data) { struct event_context *ev_ctx; int fd[2] = { -1, -1 }; - BOOL try_epoll = (BOOL)_data; + BOOL try_epoll = (BOOL)test_data; + TALLOC_CTX *mem_ctx = torture_ctx; - ev_ctx = event_context_init_ops(torture, + ev_ctx = event_context_init_ops(mem_ctx, event_standard_get_ops(), &try_epoll); - test = torture; + test = torture_ctx; /* reset globals */ write_fd = -1; @@ -108,13 +110,12 @@ static BOOL test_event_context(struct torture_context *torture, const void *_dat close(write_fd); talloc_free(ev_ctx); - - return True; + return true; } struct torture_suite *torture_local_event(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-EVENT"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "EVENT"); torture_suite_add_simple_tcase(suite, "standard with select", test_event_context, diff --git a/source4/torture/local/iconv.c b/source4/torture/local/iconv.c index de48d52657..28834a6680 100644 --- a/source4/torture/local/iconv.c +++ b/source4/torture/local/iconv.c @@ -107,7 +107,7 @@ static void show_buf(const char *name, uint8_t *buf, size_t size) "charset", then convert it back again and ensure we get the same buffer back */ -static int test_buffer(struct torture_context *test, +static bool test_buffer(struct torture_context *test, uint8_t *inbuf, size_t size, const char *charset) { uint8_t buf1[1000], buf2[1000], buf3[1000]; @@ -116,7 +116,6 @@ static int test_buffer(struct torture_context *test, char *ptr_out; size_t size_in1, size_in2, size_in3; size_t ret1, ret2, ret3, len1, len2; - int ok = 1; int errno1, errno2; static iconv_t cd; static smb_iconv_t cd2, cd3; @@ -133,7 +132,7 @@ static int test_buffer(struct torture_context *test, cd = iconv_open(charset, "UTF-16LE"); if (cd == (iconv_t)-1) { cd = NULL; - return False; + return false; } cd2 = smb_iconv_open(charset, "UTF-16LE"); cd3 = smb_iconv_open("UTF-16LE", charset); @@ -169,42 +168,30 @@ static int test_buffer(struct torture_context *test, if (len2 > len1 && memcmp(buf1, buf2, len1) == 0 && get_codepoint((char *)(buf2+len1), len2-len1, charset) >= (1<<20)) { - return ok; + return true; } if (len1 > len2 && memcmp(buf1, buf2, len2) == 0 && get_codepoint((char *)(buf1+len2), len1-len2, charset) >= (1<<20)) { - return ok; + return true; } - if (ret1 != ret2) { - torture_fail(test, "ret1=%d ret2=%d", (int)ret1, (int)ret2); - ok = 0; - } + torture_assert_int_equal(test, ret1, ret2, "ret mismatch"); if (errno1 != errno2) { - torture_fail(test, "e1=%s e2=%s", strerror(errno1), strerror(errno2)); show_buf(" rem1:", inbuf+(size-size_in1), size_in1); show_buf(" rem2:", inbuf+(size-size_in2), size_in2); - ok = 0; + torture_fail(test, talloc_asprintf(test, + "e1=%s e2=%s", strerror(errno1), strerror(errno2))); } - if (outsize1 != outsize2) { - torture_fail(test, "outsize mismatch outsize1=%d outsize2=%d", - (int)outsize1, (int)outsize2); - ok = 0; - } + torture_assert_int_equal(test, outsize1, outsize2, "outsize mismatch"); - if (size_in1 != size_in2) { - torture_fail(test, "size_in mismatch size_in1=%d size_in2=%d", - (int)size_in1, (int)size_in2); - ok = 0; - } + torture_assert_int_equal(test, size_in1, size_in2, "size_in mismatch"); - if (!ok || - len1 != len2 || + if (len1 != len2 || memcmp(buf1, buf2, len1) != 0) { - torture_fail(test, "size=%d ret1=%d ret2=%d", (int)size, (int)ret1, (int)ret2); + torture_comment(test, "size=%d ret1=%d ret2=%d", (int)size, (int)ret1, (int)ret2); show_buf(" IN1:", inbuf, size-size_in1); show_buf(" IN2:", inbuf, size-size_in2); show_buf("OUT1:", buf1, len1); @@ -218,7 +205,7 @@ static int test_buffer(struct torture_context *test, get_codepoint((char *)(buf1+len2),len1-len2, charset)); } - ok = 0; + torture_fail(test, "failed"); } /* convert back to UTF-16, putting result in buf3 */ @@ -236,42 +223,33 @@ static int test_buffer(struct torture_context *test, get_codepoint((char *)(inbuf+sizeof(buf3) - outsize3), size - (sizeof(buf3) - outsize3), "UTF-16LE") >= (1<<20)) { - return ok; + return true; } - if (ret3 != 0) { - torture_fail(test, "pull failed - %s", strerror(errno)); - ok = 0; - } + torture_assert_int_equal(test, ret3, 0, talloc_asprintf(test, + "pull failed - %s", strerror(errno))); if (strncmp(charset, "UTF", 3) != 0) { /* don't expect perfect mappings for non UTF charsets */ - return ok; + return true; } - if (outsize3 != sizeof(buf3) - size) { - torture_fail(test, "wrong outsize3 - %d should be %d", - (int)outsize3, (int)(sizeof(buf3) - size)); - ok = 0; - } + torture_assert_int_equal(test, outsize3, sizeof(buf3) - size, + "wrong outsize3"); if (memcmp(buf3, inbuf, size) != 0) { - torture_fail(test, "pull bytes mismatch:"); + torture_comment(test, "pull bytes mismatch:"); show_buf("inbuf", inbuf, size); show_buf(" buf3", buf3, sizeof(buf3) - outsize3); - ok = 0; + torture_fail(test, ""); torture_comment(test, "next codepoint is %u\n", get_codepoint((char *)(inbuf+sizeof(buf3) - outsize3), size - (sizeof(buf3) - outsize3), "UTF-16LE")); } - if (!ok) { - torture_fail(test, "test_buffer failed for charset %s", charset); - } - - return ok; + return true; } @@ -279,18 +257,14 @@ static int test_buffer(struct torture_context *test, test the push_codepoint() and next_codepoint() functions for a given codepoint */ -static int test_codepoint(struct torture_context *test, const void *data) +static bool test_codepoint(struct torture_context *tctx, unsigned int codepoint) { uint8_t buf[10]; size_t size, size2; - unsigned int codepoint = *((const unsigned int *)data); codepoint_t c; size = push_codepoint((char *)buf, codepoint); - if (size == -1) { - torture_assert(test, codepoint >= 0xd800 && codepoint <= 0x10000, "Invalid Codepoint range"); - return True; - } + torture_assert(tctx, size != -1 || (codepoint >= 0xd800 && codepoint <= 0x10000), "Invalid Codepoint range"); buf[size] = random(); buf[size+1] = random(); buf[size+2] = random(); @@ -298,31 +272,27 @@ static int test_codepoint(struct torture_context *test, const void *data) c = next_codepoint((char *)buf, &size2); - if (c != codepoint) { - torture_fail(test, "next_codepoint(%u) failed - gave %u", codepoint, c); - return False; - } + torture_assert(tctx, c == codepoint, talloc_asprintf(tctx, + "next_codepoint(%u) failed - gave %u", codepoint, c)); - if (size2 != size) { - torture_fail(test, "next_codepoint(%u) gave wrong size %d (should be %d)\n", - codepoint, (int)size2, (int)size); - return False; - } + torture_assert(tctx, size2 == size, + talloc_asprintf(tctx, "next_codepoint(%u) gave wrong size %d (should be %d)\n", + codepoint, (int)size2, (int)size)); - return True; + return true; } -static BOOL test_next_codepoint(struct torture_context *test, const void *data) +static bool test_next_codepoint(struct torture_context *tctx) { unsigned int codepoint; for (codepoint=0;codepoint<(1<<20);codepoint++) { - if (!test_codepoint(test, &codepoint)) - return False; + if (!test_codepoint(tctx, codepoint)) + return false; } - return True; + return true; } -static BOOL test_first_1m(struct torture_context *test, const void *data) +static bool test_first_1m(struct torture_context *tctx) { unsigned int codepoint; size_t size; @@ -339,14 +309,13 @@ static BOOL test_first_1m(struct torture_context *test, const void *data) } } - if (!test_buffer(test, inbuf, size, "UTF-8")) - return False; + if (!test_buffer(tctx, inbuf, size, "UTF-8")) + return false; } - - return True; + return true; } -static BOOL test_random_5m(struct torture_context *test, const void *data) +static bool test_random_5m(struct torture_context *tctx) { unsigned char inbuf[1000]; unsigned int i; @@ -356,7 +325,7 @@ static BOOL test_random_5m(struct torture_context *test, const void *data) if (i % 1000 == 0) { if (!lp_parm_bool(-1, "torture", "progress", True)) { - torture_comment(test, "i=%u \r", i); + torture_comment(tctx, "i=%u \r", i); } } @@ -374,20 +343,19 @@ static BOOL test_random_5m(struct torture_context *test, const void *data) inbuf[c] |= 0xdc; } } - if (!test_buffer(test, inbuf, size, "UTF-8")) - return False; + if (!test_buffer(tctx, inbuf, size, "UTF-8")) + return false; - if (!test_buffer(test, inbuf, size, "CP850")) - return False; + if (!test_buffer(tctx, inbuf, size, "CP850")) + return false; } - - return True; + return true; } struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx) { static iconv_t cd; - struct torture_suite *suite; + struct torture_suite *suite = torture_suite_create(mem_ctx, "ICONV"); if (!lp_parm_bool(-1, "iconv", "native", True)) { printf("system iconv disabled - skipping test\n"); @@ -401,18 +369,15 @@ struct torture_suite *torture_local_iconv(TALLOC_CTX *mem_ctx) } iconv_close(cd); - suite = torture_suite_create(mem_ctx, "LOCAL-ICONV"); srandom(time(NULL)); + torture_suite_add_simple_test(suite, "next_codepoint()", + test_next_codepoint); - torture_suite_add_simple_tcase(suite, "next_codepoint()", - test_next_codepoint, NULL); - - torture_suite_add_simple_tcase(suite, "first 1M codepoints", - test_first_1m, NULL); - - torture_suite_add_simple_tcase(suite, "5M random UTF-16LE sequences", - test_random_5m, NULL); + torture_suite_add_simple_test(suite, "first 1M codepoints", + test_first_1m); + torture_suite_add_simple_test(suite, "5M random UTF-16LE sequences", + test_random_5m); return suite; } diff --git a/source4/torture/local/idtree.c b/source4/torture/local/idtree.c index 1d317dbce3..dd8618d0db 100644 --- a/source4/torture/local/idtree.c +++ b/source4/torture/local/idtree.c @@ -23,8 +23,7 @@ #include "includes.h" #include "torture/torture.h" -static BOOL torture_local_idtree_simple(struct torture_context *test, - const void *_data) +static bool torture_local_idtree_simple(struct torture_context *tctx) { struct idr_context *idr; int i; @@ -32,11 +31,12 @@ static BOOL torture_local_idtree_simple(struct torture_context *test, int *present; extern int torture_numops; int n = torture_numops; + TALLOC_CTX *mem_ctx = tctx; - idr = idr_init(test); + idr = idr_init(mem_ctx); - ids = talloc_zero_array(test, int, n); - present = talloc_zero_array(test, int, n); + ids = talloc_zero_array(mem_ctx, int, n); + present = talloc_zero_array(mem_ctx, int, n); for (i=0;imsg_ctx1, MSG_ID2, rpcecho, ECHO_ECHODATA, &r, - test); - torture_assert_ntstatus_ok(test, status, "EchoData failed"); + mem_ctx); + torture_assert_ntstatus_ok(tctx, status, "EchoData failed"); /* check the answer */ if (memcmp(r.out.out_data, r.in.in_data, r.in.len) != 0) { - torture_fail(test, "EchoData wrong answer"); NDR_PRINT_OUT_DEBUG(echo_EchoData, &r); - return False; + torture_fail(tctx, "EchoData wrong answer"); } - torture_comment(test, "Echo '%*.*s' -> '%*.*s'", + torture_comment(tctx, "Echo '%*.*s' -> '%*.*s'\n", r.in.len, r.in.len, r.in.in_data, r.in.len, r.in.len, r.out.out_data); - - return True; + return true; } @@ -159,28 +157,29 @@ static void irpc_callback(struct irpc_request *irpc) /* test echo speed */ -static BOOL test_speed(struct torture_context *test, - const void *_data, - const void *_data2) +static bool test_speed(struct torture_context *tctx, + const void *tcase_data, + const void *test_data) { int ping_count = 0; int pong_count = 0; - const struct irpc_test_data *data = _data; + const struct irpc_test_data *data = tcase_data; struct timeval tv; struct echo_AddOne r; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + TALLOC_CTX *mem_ctx = tctx; + int timelimit = torture_setting_int(tctx, "timelimit", 10); tv = timeval_current(); r.in.in_data = 0; - torture_comment(test, "Sending echo for %d seconds", timelimit); + torture_comment(tctx, "Sending echo for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { struct irpc_request *irpc; irpc = IRPC_CALL_SEND(data->msg_ctx1, MSG_ID2, rpcecho, ECHO_ADDONE, - &r, test); - torture_assert(test, irpc != NULL, "AddOne send failed"); + &r, mem_ctx); + torture_assert(tctx, irpc != NULL, "AddOne send failed"); irpc->async.fn = irpc_callback; irpc->async.private = &pong_count; @@ -192,39 +191,33 @@ static BOOL test_speed(struct torture_context *test, } } - torture_comment(test, "waiting for %d remaining replies (done %d)", + torture_comment(tctx, "waiting for %d remaining replies (done %d)\n", ping_count - pong_count, pong_count); while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) { event_loop_once(data->ev); } - if (ping_count != pong_count) { - torture_fail(test, "ping test failed! received %d, sent %d", - pong_count, ping_count); - } + torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed"); - torture_comment(test, "echo rate of %.0f messages/sec", + torture_comment(tctx, "echo rate of %.0f messages/sec\n", (ping_count+pong_count)/timeval_elapsed(&tv)); - - return True; + return true; } -static BOOL irpc_setup(struct torture_context *test, void **_data) +static BOOL irpc_setup(struct torture_context *tctx, void **_data) { struct irpc_test_data *data; - *_data = data = talloc(test, struct irpc_test_data); + *_data = data = talloc(tctx, struct irpc_test_data); lp_set_cmdline("lock dir", "lockdir.tmp"); - data->ev = event_context_init(test); - torture_assert(test, - data->msg_ctx1 = messaging_init(test, MSG_ID1, data->ev), + data->ev = event_context_init(tctx); + torture_assert(tctx, data->msg_ctx1 = messaging_init(tctx, MSG_ID1, data->ev), "Failed to init first messaging context"); - torture_assert(test, - data->msg_ctx2 = messaging_init(test, MSG_ID2, data->ev), + torture_assert(tctx, data->msg_ctx2 = messaging_init(tctx, MSG_ID2, data->ev), "Failed to init second messaging context"); /* register the server side function */ @@ -239,7 +232,7 @@ static BOOL irpc_setup(struct torture_context *test, void **_data) struct torture_suite *torture_local_irpc(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-IRPC"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "IRPC"); struct torture_tcase *tcase = torture_suite_add_tcase(suite, "irpc"); int i; uint32_t *values = talloc_array(tcase, uint32_t, 5); diff --git a/source4/torture/local/local.c b/source4/torture/local/local.c index 4a6c43761a..42fe94bc92 100644 --- a/source4/torture/local/local.c +++ b/source4/torture/local/local.c @@ -49,17 +49,34 @@ NTSTATUS torture_local_init(void) { int i; - TALLOC_CTX *mem_ctx = talloc_autofree_context(); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "LOCAL"); + struct torture_suite *talloc_suite = torture_suite_create( + talloc_autofree_context(), + "TALLOC"); - register_torture_op("LOCAL-REPLACE", torture_local_replace); - register_torture_op("LOCAL-TALLOC", torture_local_talloc); - register_torture_op("LOCAL-CRYPTO-MD4", torture_local_crypto_md4); - register_torture_op("LOCAL-CRYPTO-MD5", torture_local_crypto_md5); - register_torture_op("LOCAL-CRYPTO-HMACMD5", torture_local_crypto_hmacmd5); - register_torture_op("LOCAL-CRYPTO-SHA1", torture_local_crypto_sha1); - register_torture_op("LOCAL-CRYPTO-HMACSHA1", torture_local_crypto_hmacsha1); + torture_local_talloc(talloc_suite); + torture_suite_add_suite(suite, talloc_suite); + torture_suite_add_simple_test(suite, "REPLACE", torture_local_replace); + torture_suite_add_simple_test(suite, "CRYPTO-SHA1", + torture_local_crypto_sha1); + torture_suite_add_simple_test(suite, + "CRYPTO-MD4", torture_local_crypto_md4); + torture_suite_add_simple_test(suite, "CRYPTO-MD5", + torture_local_crypto_md5); + torture_suite_add_simple_test(suite, "CRYPTO-HMACMD5", + torture_local_crypto_hmacmd5); + torture_suite_add_simple_test(suite, "CRYPTO-HMACSHA1", + torture_local_crypto_hmacsha1); for (i = 0; suite_generators[i]; i++) - torture_register_suite(suite_generators[i](mem_ctx)); + torture_suite_add_suite(suite, + suite_generators[i](talloc_autofree_context())); + + suite->description = talloc_strdup(suite, + "Local, Samba-specific tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/local/messaging.c b/source4/torture/local/messaging.c index 8161c3ea4f..27c343948b 100644 --- a/source4/torture/local/messaging.c +++ b/source4/torture/local/messaging.c @@ -55,7 +55,7 @@ static void exit_message(struct messaging_context *msg, void *private, /* test ping speed */ -static BOOL test_ping_speed(struct torture_context *torture, const void *_data) +static bool test_ping_speed(struct torture_context *tctx) { struct event_context *ev; struct messaging_context *msg_client_ctx; @@ -63,35 +63,30 @@ static BOOL test_ping_speed(struct torture_context *torture, const void *_data) int ping_count = 0; int pong_count = 0; struct timeval tv; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + int timelimit = torture_setting_int(tctx, "timelimit", 10); uint32_t msg_ping, msg_exit; + TALLOC_CTX *mem_ctx = tctx; lp_set_cmdline("lock dir", "lockdir.tmp"); - ev = event_context_init(torture); + ev = event_context_init(mem_ctx); - msg_server_ctx = messaging_init(torture, 1, ev); + msg_server_ctx = messaging_init(mem_ctx, 1, ev); - if (!msg_server_ctx) { - torture_fail(torture, "Failed to init ping messaging context"); - return False; - } + torture_assert(tctx, msg_server_ctx != NULL, "Failed to init ping messaging context"); messaging_register_tmp(msg_server_ctx, NULL, ping_message, &msg_ping); - messaging_register_tmp(msg_server_ctx, torture, exit_message, &msg_exit); + messaging_register_tmp(msg_server_ctx, mem_ctx, exit_message, &msg_exit); - msg_client_ctx = messaging_init(torture, 2, ev); + msg_client_ctx = messaging_init(mem_ctx, 2, ev); - if (!msg_client_ctx) { - torture_fail(torture, "msg_client_ctx messaging_init() failed"); - return False; - } + torture_assert(tctx, msg_client_ctx != NULL, "msg_client_ctx messaging_init() failed"); messaging_register_tmp(msg_client_ctx, &pong_count, pong_message, &msg_pong); tv = timeval_current(); - torture_comment(torture, "Sending pings for %d seconds", timelimit); + torture_comment(tctx, "Sending pings for %d seconds", timelimit); while (timeval_elapsed(&tv) < timelimit) { DATA_BLOB data; NTSTATUS status1, status2; @@ -102,51 +97,41 @@ static BOOL test_ping_speed(struct torture_context *torture, const void *_data) status1 = messaging_send(msg_client_ctx, 1, msg_ping, &data); status2 = messaging_send(msg_client_ctx, 1, msg_ping, NULL); - if (!NT_STATUS_IS_OK(status1)) { - torture_fail(torture, "msg1 failed - %s", nt_errstr(status1)); - } else { - ping_count++; - } + torture_assert_ntstatus_ok(tctx, status1, "msg1 failed"); + ping_count++; - if (!NT_STATUS_IS_OK(status2)) { - torture_fail(torture, "msg2 failed - %s", nt_errstr(status2)); - } else { - ping_count++; - } + torture_assert_ntstatus_ok(tctx, status2, "msg2 failed"); + ping_count++; while (ping_count > pong_count + 20) { event_loop_once(ev); } } - torture_comment(torture, "waiting for %d remaining replies (done %d)", + torture_comment(tctx, "waiting for %d remaining replies (done %d)", ping_count - pong_count, pong_count); while (timeval_elapsed(&tv) < 30 && pong_count < ping_count) { event_loop_once(ev); } - torture_comment(torture, "sending exit"); + torture_comment(tctx, "sending exit"); messaging_send(msg_client_ctx, 1, msg_exit, NULL); - if (ping_count != pong_count) { - torture_fail(torture, "ping test failed! received %d, sent %d", - pong_count, ping_count); - } + torture_assert_int_equal(tctx, ping_count, pong_count, "ping test failed"); - torture_comment(torture, "ping rate of %.0f messages/sec", + torture_comment(tctx, "ping rate of %.0f messages/sec", (ping_count+pong_count)/timeval_elapsed(&tv)); talloc_free(msg_client_ctx); talloc_free(msg_server_ctx); talloc_free(ev); - - return True; + return true; } struct torture_suite *torture_local_messaging(TALLOC_CTX *mem_ctx) { - struct torture_suite *s = torture_suite_create(mem_ctx, "LOCAL-MESSAGING"); - torture_suite_add_simple_tcase(s, "ping_speed", test_ping_speed, NULL); + struct torture_suite *s = torture_suite_create(mem_ctx, "MESSAGING"); + torture_suite_add_simple_test(s, "ping_speed", test_ping_speed); return s; } diff --git a/source4/torture/local/ndr.c b/source4/torture/local/ndr.c index a24c64746a..b14b066455 100644 --- a/source4/torture/local/ndr.c +++ b/source4/torture/local/ndr.c @@ -23,64 +23,59 @@ #include "torture/torture.h" #include "librpc/ndr/libndr.h" -static BOOL test_check_string_terminator(struct torture_context *test, - const void *_data) +static bool test_check_string_terminator(struct torture_context *tctx) { struct ndr_pull *ndr; DATA_BLOB blob; + TALLOC_CTX *mem_ctx = tctx; /* Simple test */ blob = strhex_to_data_blob("0000"); - ndr = ndr_pull_init_blob(&blob, test); + ndr = ndr_pull_init_blob(&blob, mem_ctx); - torture_assert_ntstatus_ok(test, - ndr_check_string_terminator(ndr, 1, 2), + torture_assert_ntstatus_ok(tctx, ndr_check_string_terminator(ndr, 1, 2), "simple check_string_terminator test failed"); - torture_assert(test, ndr->offset == 0, + torture_assert(tctx, ndr->offset == 0, "check_string_terminator did not reset offset"); if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 1, 3))) { - torture_fail(test, "check_string_terminator checked beyond string boundaries"); - return False; + torture_fail(tctx, "check_string_terminator checked beyond string boundaries"); } - torture_assert(test, ndr->offset == 0, + torture_assert(tctx, ndr->offset == 0, "check_string_terminator did not reset offset"); talloc_free(ndr); blob = strhex_to_data_blob("11220000"); - ndr = ndr_pull_init_blob(&blob, test); + ndr = ndr_pull_init_blob(&blob, mem_ctx); - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, ndr_check_string_terminator(ndr, 4, 1), "check_string_terminator failed to recognize terminator"); - torture_assert_ntstatus_ok(test, + torture_assert_ntstatus_ok(tctx, ndr_check_string_terminator(ndr, 3, 1), "check_string_terminator failed to recognize terminator"); if (NT_STATUS_IS_OK(ndr_check_string_terminator(ndr, 2, 1))) { - torture_fail(test, + torture_fail(tctx, "check_string_terminator erroneously reported terminator"); - return False; } - torture_assert (test, ndr->offset == 0, + torture_assert(tctx, ndr->offset == 0, "check_string_terminator did not reset offset"); - - return True; + return true; } struct torture_suite *torture_local_ndr(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-NDR"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "NDR"); - torture_suite_add_simple_tcase(suite, "string terminator", - test_check_string_terminator, - NULL); + torture_suite_add_simple_test(suite, "string terminator", + test_check_string_terminator); return suite; } diff --git a/source4/torture/local/registry.c b/source4/torture/local/registry.c index 0e72c11aeb..d200ba6e1b 100644 --- a/source4/torture/local/registry.c +++ b/source4/torture/local/registry.c @@ -36,50 +36,51 @@ const static struct test_backend_settings { { NULL, NULL } }; -static BOOL test_hive(struct torture_context *ctx, const void *_backend) +static bool test_hive(struct torture_context *tctx, + const void *test_data) { WERROR error; struct registry_key *root, *subkey; uint32_t count; - const struct test_backend_settings *backend = _backend; + const struct test_backend_settings *backend = test_data; + TALLOC_CTX *mem_ctx = tctx; if (!reg_has_backend(backend->name)) { - torture_skip(ctx, "Backend '%s' support not compiled in", - backend->name); - return True; + torture_skip(tctx, talloc_asprintf(tctx, + "Backend '%s' support not compiled in", backend->name)); } - error = reg_open_hive(ctx, backend->name, + error = reg_open_hive(mem_ctx, backend->name, backend->location, NULL, cmdline_credentials, &root); - torture_assert_werr_ok(ctx, error, "reg_open_hive()"); + torture_assert_werr_ok(tctx, error, "reg_open_hive()"); /* This is a new backend. There should be no subkeys and no * values */ error = reg_key_num_subkeys(root, &count); - torture_assert_werr_ok(ctx, error, "reg_key_num_subkeys()"); + torture_assert_werr_ok(tctx, error, "reg_key_num_subkeys()"); - torture_assert(ctx, count != 0, "New key has non-zero subkey count"); + torture_assert(tctx, count != 0, "New key has non-zero subkey count"); error = reg_key_num_values(root, &count); - torture_assert_werr_ok(ctx, error, "reg_key_num_values"); + torture_assert_werr_ok(tctx, error, "reg_key_num_values"); - torture_assert(ctx, count != 0, "New key has non-zero value count"); + torture_assert(tctx, count != 0, "New key has non-zero value count"); - error = reg_key_add_name(ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey); - torture_assert_werr_ok(ctx, error, "reg_key_add_name"); + error = reg_key_add_name(mem_ctx, root, "Nested\\Key", SEC_MASK_GENERIC, NULL, &subkey); + torture_assert_werr_ok(tctx, error, "reg_key_add_name"); error = reg_key_del(root, "Nested\\Key"); - torture_assert_werr_ok(ctx, error, "reg_key_del"); + torture_assert_werr_ok(tctx, error, "reg_key_del"); talloc_free(root); - - return True; + return true; } + struct torture_suite *torture_registry(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-REGISTRY"); + "REGISTRY"); int i; registry_init(); diff --git a/source4/torture/local/resolve.c b/source4/torture/local/resolve.c index a9878e88ee..62aa600a3c 100644 --- a/source4/torture/local/resolve.c +++ b/source4/torture/local/resolve.c @@ -25,68 +25,67 @@ #include "libcli/resolve/resolve.h" #include "torture/torture.h" -static BOOL test_async_resolve(struct torture_context *test, const void *_data) +static bool test_async_resolve(struct torture_context *tctx) { struct nbt_name n; struct event_context *ev; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); - const char *host = lp_parm_string(-1, "torture", "host"); + int timelimit = torture_setting_int(tctx, "timelimit", 10); + const char *host = torture_setting_string(tctx, "host", NULL); int count = 0; struct timeval tv = timeval_current(); + TALLOC_CTX *mem_ctx = tctx; - ev = event_context_init(test); + ev = event_context_init(mem_ctx); ZERO_STRUCT(n); n.name = host; - torture_comment(test, "Testing async resolve of localhost for %d seconds", + torture_comment(tctx, "Testing async resolve of localhost for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { const char *s; struct composite_context *c = resolve_name_host_send(&n, ev); - torture_assert(test, c, "resolve_name_host_send"); - torture_assert_ntstatus_ok(test, resolve_name_host_recv(c, test, &s), + torture_assert(tctx, c != NULL, "resolve_name_host_send"); + torture_assert_ntstatus_ok(tctx, resolve_name_host_recv(c, mem_ctx, &s), "async resolve failed"); count++; } - torture_comment(test, "async rate of %.1f resolves/sec", + torture_comment(tctx, "async rate of %.1f resolves/sec\n", count/timeval_elapsed(&tv)); - - return True; + return true; } /* test resolution using sync method */ -static BOOL test_sync_resolve(struct torture_context *test, const void *_data) +static bool test_sync_resolve(struct torture_context *tctx) { - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + int timelimit = torture_setting_int(tctx, "timelimit", 10); struct timeval tv = timeval_current(); int count = 0; - const char *host = lp_parm_string(-1, "torture", "host"); + const char *host = torture_setting_string(tctx, "host", NULL); - torture_comment(test, "Testing sync resolve of localhost for %d seconds", + torture_comment(tctx, "Testing sync resolve of localhost for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { sys_inet_ntoa(interpret_addr2(host)); count++; } - torture_comment(test, "sync rate of %.1f resolves/sec", + torture_comment(tctx, "sync rate of %.1f resolves/sec\n", count/timeval_elapsed(&tv)); - - return True; + return true; } struct torture_suite *torture_local_resolve(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-RESOLVE"); + "RESOLVE"); - torture_suite_add_simple_tcase(suite, "async", test_async_resolve, NULL); - torture_suite_add_simple_tcase(suite, "sync", test_sync_resolve, NULL); + torture_suite_add_simple_test(suite, "async", test_async_resolve); + torture_suite_add_simple_test(suite, "sync", test_sync_resolve); return suite; } diff --git a/source4/torture/local/sddl.c b/source4/torture/local/sddl.c index 2db1006380..1bc6457a67 100644 --- a/source4/torture/local/sddl.c +++ b/source4/torture/local/sddl.c @@ -29,37 +29,31 @@ /* test one SDDL example */ -static BOOL test_sddl(struct torture_context *mem_ctx, const void *_sddl) +static bool test_sddl(struct torture_context *tctx, + const void *test_data) { struct security_descriptor *sd, *sd2; struct dom_sid *domain; - const char *sddl = _sddl; + const char *sddl = test_data; const char *sddl2; + TALLOC_CTX *mem_ctx = tctx; domain = dom_sid_parse_talloc(mem_ctx, "S-1-2-3-4"); sd = sddl_decode(mem_ctx, sddl, domain); - if (sd == NULL) { - printf("Failed to decode '%s'\n", sddl); - return False; - } + torture_assert(tctx, sd != NULL, talloc_asprintf(tctx, + "Failed to decode '%s'\n", sddl)); sddl2 = sddl_encode(mem_ctx, sd, domain); - if (sddl2 == NULL) { - printf("Failed to re-encode '%s'\n", sddl); - return False; - } + torture_assert(tctx, sddl2 != NULL, talloc_asprintf(tctx, + "Failed to re-encode '%s'\n", sddl)); sd2 = sddl_decode(mem_ctx, sddl2, domain); - if (sd2 == NULL) { - printf("Failed to decode2 '%s'\n", sddl2); - return False; - } + torture_assert(tctx, sd2 != NULL, talloc_asprintf(tctx, + "Failed to decode2 '%s'\n", sddl2)); - if (!security_descriptor_equal(sd, sd2)) { - printf("Failed equality test for '%s'\n", sddl); - return False; - } + torture_assert(tctx, security_descriptor_equal(sd, sd2), + talloc_asprintf(tctx, "Failed equality test for '%s'\n", sddl)); #if 0 /* flags don't have a canonical order ... */ @@ -73,7 +67,7 @@ static BOOL test_sddl(struct torture_context *mem_ctx, const void *_sddl) } talloc_free(sd); talloc_free(domain); - return True; + return true; } static const char *examples[] = { @@ -99,7 +93,7 @@ static const char *examples[] = { /* test a set of example SDDL strings */ struct torture_suite *torture_local_sddl(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-SDDL"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "SDDL"); int i; for (i = 0; i < ARRAY_SIZE(examples); i++) { diff --git a/source4/torture/local/socket.c b/source4/torture/local/socket.c index a49e0dd93e..e2f9896b33 100644 --- a/source4/torture/local/socket.c +++ b/source4/torture/local/socket.c @@ -30,7 +30,7 @@ /* basic testing of udp routines */ -static BOOL test_udp(struct torture_context *test, const void *data) +static bool test_udp(struct torture_context *tctx) { struct socket_context *sock1, *sock2; NTSTATUS status; @@ -38,95 +38,79 @@ static BOOL test_udp(struct torture_context *test, const void *data) size_t size = 100 + (random() % 100); DATA_BLOB blob, blob2; size_t sent, nread; - BOOL ret = True; + TALLOC_CTX *mem_ctx = tctx; status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock1, 0); - torture_assert_ntstatus_ok(test, status, "creating DGRAM IP socket 1"); - talloc_steal(test, sock1); + torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1"); + talloc_steal(mem_ctx, sock1); status = socket_create("ip", SOCKET_TYPE_DGRAM, &sock2, 0); - torture_assert_ntstatus_ok(test, status, "creating DGRAM IP socket 1"); - talloc_steal(test, sock2); + torture_assert_ntstatus_ok(tctx, status, "creating DGRAM IP socket 1"); + talloc_steal(mem_ctx, sock2); localhost = socket_address_from_strings(sock1, sock1->backend_name, iface_best_ip("127.0.0.1"), 0); - torture_assert(test, localhost, "Localhost not found"); + torture_assert(tctx, localhost, "Localhost not found"); status = socket_listen(sock1, localhost, 0, 0); - torture_assert_ntstatus_ok(test, status, "listen on socket 1"); + torture_assert_ntstatus_ok(tctx, status, "listen on socket 1"); - srv_addr = socket_get_my_addr(sock1, test); - if (srv_addr == NULL || strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) != 0) { - torture_fail(test, "Expected server address of %s but got %s", - iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL); - return False; - } + srv_addr = socket_get_my_addr(sock1, mem_ctx); + torture_assert(tctx, srv_addr != NULL && strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) == 0, + talloc_asprintf(tctx, + "Expected server address of %s but got %s", + iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL)); - torture_comment(test, "server port is %d", srv_addr->port); + torture_comment(tctx, "server port is %d\n", srv_addr->port); - blob = data_blob_talloc(test, NULL, size); - blob2 = data_blob_talloc(test, NULL, size); + blob = data_blob_talloc(mem_ctx, NULL, size); + blob2 = data_blob_talloc(mem_ctx, NULL, size); generate_random_buffer(blob.data, blob.length); sent = size; status = socket_sendto(sock2, &blob, &sent, srv_addr); - torture_assert_ntstatus_ok(test, status, "sendto() on socket 2"); + torture_assert_ntstatus_ok(tctx, status, "sendto() on socket 2"); status = socket_recvfrom(sock1, blob2.data, size, &nread, sock1, &from_addr); - torture_assert_ntstatus_ok(test, status, "recvfrom() on socket 1"); - - if (strcmp(from_addr->addr, srv_addr->addr) != 0) { - torture_fail(test, "Unexpected recvfrom addr %s", from_addr->addr); - return False; - } - if (nread != size) { - torture_fail(test, "Unexpected recvfrom size %d should be %d\n", - (int)nread, (int)size); - return False; - } - - torture_assert(test, memcmp(blob2.data, blob.data, size) == 0, + torture_assert_ntstatus_ok(tctx, status, "recvfrom() on socket 1"); + + torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr, + "different address"); + + torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size"); + + torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0, "Bad data in recvfrom"); generate_random_buffer(blob.data, blob.length); status = socket_sendto(sock1, &blob, &sent, from_addr); - torture_assert_ntstatus_ok(test, status, "sendto() on socket 1"); + torture_assert_ntstatus_ok(tctx, status, "sendto() on socket 1"); status = socket_recvfrom(sock2, blob2.data, size, &nread, sock2, &from_addr); - torture_assert_ntstatus_ok(test, status, "recvfrom() on socket 2"); - if (strcmp(from_addr->addr, srv_addr->addr) != 0) { - torture_fail(test, "Unexpected recvfrom addr %s\n", from_addr->addr); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "recvfrom() on socket 2"); + torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr, + "Unexpected recvfrom addr"); - if (nread != size) { - torture_fail(test, "Unexpected recvfrom size %d should be %d\n", - (int)nread, (int)size); - return False; - } - - if (from_addr->port != srv_addr->port) { - torture_fail(test, "Unexpected recvfrom port %d should be %d\n", - from_addr->port, srv_addr->port); - return False; - } - - torture_assert(test, memcmp(blob2.data, blob.data, size) == 0, + torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size"); + + torture_assert_int_equal(tctx, from_addr->port, srv_addr->port, + "Unexpected recvfrom port"); + + torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0, "Bad data in recvfrom"); talloc_free(sock1); talloc_free(sock2); - - return ret; + return true; } /* basic testing of tcp routines */ -static BOOL test_tcp(struct torture_context *test, const void *data) +static bool test_tcp(struct torture_context *tctx) { struct socket_context *sock1, *sock2, *sock3; NTSTATUS status; @@ -134,84 +118,74 @@ static BOOL test_tcp(struct torture_context *test, const void *data) size_t size = 100 + (random() % 100); DATA_BLOB blob, blob2; size_t sent, nread; - struct event_context *ev = event_context_init(test); + TALLOC_CTX *mem_ctx = tctx; + struct event_context *ev = event_context_init(mem_ctx); status = socket_create("ip", SOCKET_TYPE_STREAM, &sock1, 0); - torture_assert_ntstatus_ok(test, status, "creating IP stream socket 1"); - talloc_steal(test, sock1); + torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1"); + talloc_steal(mem_ctx, sock1); status = socket_create("ip", SOCKET_TYPE_STREAM, &sock2, 0); - torture_assert_ntstatus_ok(test, status, "creating IP stream socket 1"); - talloc_steal(test, sock2); + torture_assert_ntstatus_ok(tctx, status, "creating IP stream socket 1"); + talloc_steal(mem_ctx, sock2); localhost = socket_address_from_strings(sock1, sock1->backend_name, iface_best_ip("127.0.0.1"), 0); - torture_assert(test, localhost, "Localhost not found"); + torture_assert(tctx, localhost, "Localhost not found"); status = socket_listen(sock1, localhost, 0, 0); - torture_assert_ntstatus_ok(test, status, "listen on socket 1"); + torture_assert_ntstatus_ok(tctx, status, "listen on socket 1"); - srv_addr = socket_get_my_addr(sock1, test); - torture_assert(test, srv_addr && srv_addr->addr, + srv_addr = socket_get_my_addr(sock1, mem_ctx); + torture_assert(tctx, srv_addr && srv_addr->addr, "Unexpected socket_get_my_addr NULL\n"); - if (strcmp(srv_addr->addr, iface_best_ip("127.0.0.1")) != 0) { - torture_fail(test, "Expected server address of %s but got %s\n", - iface_best_ip("127.0.0.1"), srv_addr ? srv_addr->addr : NULL); - return False; - } + torture_assert_str_equal(tctx, srv_addr->addr, iface_best_ip("127.0.0.1"), + "Unexpected server address"); - torture_comment(test, "server port is %d", srv_addr->port); + torture_comment(tctx, "server port is %d\n", srv_addr->port); status = socket_connect_ev(sock2, NULL, srv_addr, 0, ev); - torture_assert_ntstatus_ok(test, status, "connect() on socket 2"); + torture_assert_ntstatus_ok(tctx, status, "connect() on socket 2"); status = socket_accept(sock1, &sock3); - torture_assert_ntstatus_ok(test, status, "accept() on socket 1"); - talloc_steal(test, sock3); + torture_assert_ntstatus_ok(tctx, status, "accept() on socket 1"); + talloc_steal(mem_ctx, sock3); talloc_free(sock1); - blob = data_blob_talloc(test, NULL, size); - blob2 = data_blob_talloc(test, NULL, size); + blob = data_blob_talloc(mem_ctx, NULL, size); + blob2 = data_blob_talloc(mem_ctx, NULL, size); generate_random_buffer(blob.data, blob.length); sent = size; status = socket_send(sock2, &blob, &sent); - torture_assert_ntstatus_ok(test, status, "send() on socket 2"); + torture_assert_ntstatus_ok(tctx, status, "send() on socket 2"); status = socket_recv(sock3, blob2.data, size, &nread); - torture_assert_ntstatus_ok(test, status, "recv() on socket 3"); + torture_assert_ntstatus_ok(tctx, status, "recv() on socket 3"); - from_addr = socket_get_peer_addr(sock3, test); + from_addr = socket_get_peer_addr(sock3, mem_ctx); - torture_assert(test, from_addr && from_addr->addr, + torture_assert(tctx, from_addr && from_addr->addr, "Unexpected recvfrom addr NULL"); - if (strcmp(from_addr->addr, srv_addr->addr) != 0) { - torture_fail(test, "Unexpected recvfrom addr %s\n", - from_addr ? from_addr->addr : NULL); - return False; - } - if (nread != size) { - torture_fail(test, "Unexpected recvfrom size %d should be %d\n", - (int)nread, (int)size); - return False; - } - - torture_assert(test, - memcmp(blob2.data, blob.data, size) == 0, - "Bad data in recv"); + torture_assert_str_equal(tctx, from_addr->addr, srv_addr->addr, + "Unexpected recvfrom addr"); - return True; + torture_assert_int_equal(tctx, nread, size, "Unexpected recvfrom size"); + + torture_assert(tctx, memcmp(blob2.data, blob.data, size) == 0, + "Bad data in recv"); + return true; } struct torture_suite *torture_local_socket(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-SOCKET"); + "SOCKET"); - torture_suite_add_simple_tcase(suite, "udp", test_udp, NULL); - torture_suite_add_simple_tcase(suite, "tcp", test_tcp, NULL); + torture_suite_add_simple_test(suite, "udp", test_udp); + torture_suite_add_simple_test(suite, "tcp", test_tcp); return suite; } diff --git a/source4/torture/local/torture.c b/source4/torture/local/torture.c index 67712e3ee7..4a5bc99d35 100644 --- a/source4/torture/local/torture.c +++ b/source4/torture/local/torture.c @@ -27,58 +27,57 @@ #include "libcli/raw/libcliraw.h" #include "torture/util.h" -static BOOL test_tempdir(struct torture_context *torture, - const void *_data) +static bool test_tempdir(struct torture_context *tctx) { char *location = NULL; + TALLOC_CTX *mem_ctx = tctx; - torture_assert_ntstatus_ok(torture, torture_temp_dir(torture, "tempdir", &location), + torture_assert_ntstatus_ok(tctx, torture_temp_dir(mem_ctx, "tempdir", &location), "torture_temp_dir should return NT_STATUS_OK" ); - torture_assert(torture, directory_exist(location), + torture_assert(tctx, directory_exist(location), "created dir doesn't exist"); - - return True; + return true; } -static BOOL test_setup_server(struct torture_context *torture, - const void *_data) +static bool test_setup_server(struct torture_context *tctx) { pid_t pid; + TALLOC_CTX *mem_ctx = tctx; - torture_assert_ntstatus_ok(torture, torture_setup_server(torture, + torture_assert_ntstatus_ok(tctx, torture_setup_server(mem_ctx, "setupserver-success", "./script/tests/mktestsetup.sh", "./bin/smbd", &pid), "starting smbd failed"); - torture_assert(torture, pid > 0, "Pid invalid"); + torture_assert(tctx, pid > 0, "Pid invalid"); - torture_comment(torture, "Created smbd with pid %d", pid); + torture_comment(tctx, "Created smbd with pid %d\n", pid); kill(pid, SIGINT); waitpid(pid, NULL, 0); - torture_assert_ntstatus_equal(torture, torture_setup_server(torture, + torture_assert_ntstatus_equal(tctx, torture_setup_server(mem_ctx, "setupserver-fail", "./invalid-script", "./bin/smbd", &pid), NT_STATUS_UNSUCCESSFUL, "invalid script specified"); - torture_assert(torture, pid == -1, "Pid not -1 after failure"); - - return True; + torture_assert(tctx, pid == -1, "Pid not -1 after failure"); + return true; } + struct torture_suite *torture_local_torture(TALLOC_CTX *mem_ctx) { struct torture_suite *suite = torture_suite_create(mem_ctx, - "LOCAL-TORTURE"); + "TORTURE"); - torture_suite_add_simple_tcase(suite, "tempdir", test_tempdir, NULL); - torture_suite_add_simple_tcase(suite, "setup server", test_setup_server, NULL); + torture_suite_add_simple_test(suite, "tempdir", test_tempdir); + torture_suite_add_simple_test(suite, "setup server", test_setup_server); return suite; } diff --git a/source4/torture/local/util_file.c b/source4/torture/local/util_file.c index 3c11d3d94e..87d25b222e 100644 --- a/source4/torture/local/util_file.c +++ b/source4/torture/local/util_file.c @@ -31,66 +31,65 @@ #define TEST_DATA TEST_LINE1 "\n" TEST_LINE2 "\n" TEST_LINE3 -static BOOL test_file_load_save(struct torture_context *test, const void *_data) +static bool test_file_load_save(struct torture_context *tctx) { size_t len; char *data; + TALLOC_CTX *mem_ctx = tctx; - torture_assert(test, - file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)), + torture_assert(tctx, file_save(TEST_FILENAME, TEST_DATA, strlen(TEST_DATA)), "saving file"); - data = file_load(TEST_FILENAME, &len, test); - torture_assert(test, data, "loading file"); + data = file_load(TEST_FILENAME, &len, mem_ctx); + torture_assert(tctx, data, "loading file"); - torture_assert(test, len == strlen(TEST_DATA), "Length"); + torture_assert(tctx, len == strlen(TEST_DATA), "Length"); - torture_assert(test, memcmp(data, TEST_DATA, len) == 0, "Contents"); + torture_assert(tctx, memcmp(data, TEST_DATA, len) == 0, "Contents"); unlink(TEST_FILENAME); - - return True; + return true; } -static BOOL test_afdgets(struct torture_context *test, const void *data) + +static bool test_afdgets(struct torture_context *tctx) { int fd; char *line; + TALLOC_CTX *mem_ctx = tctx; - torture_assert(test, - file_save(TEST_FILENAME, (const void *)TEST_DATA, + torture_assert(tctx, file_save(TEST_FILENAME, (const void *)TEST_DATA, strlen(TEST_DATA)), "saving file"); fd = open(TEST_FILENAME, O_RDONLY); - torture_assert(test, fd != -1, "opening file"); + torture_assert(tctx, fd != -1, "opening file"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE1) == 0, "line 1 mismatch"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE2) == 0, "line 2 mismatch"); - line = afdgets(fd, test, 8); - torture_assert(test, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch"); + line = afdgets(fd, mem_ctx, 8); + torture_assert(tctx, strcmp(line, TEST_LINE3) == 0, "line 3 mismatch"); close(fd); unlink(TEST_FILENAME); - - return True; + return true; } struct torture_suite *torture_local_util_file(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-FILE"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "FILE"); - torture_suite_add_simple_tcase(suite, "file_load_save", - test_file_load_save, NULL); + torture_suite_add_simple_test(suite, "file_load_save", + test_file_load_save); - torture_suite_add_simple_tcase(suite, "afdgets", - test_afdgets, NULL); + torture_suite_add_simple_test(suite, "afdgets", + test_afdgets); return suite; } diff --git a/source4/torture/local/util_strlist.c b/source4/torture/local/util_strlist.c index 65f8bc914a..7dbb5f8ce6 100644 --- a/source4/torture/local/util_strlist.c +++ b/source4/torture/local/util_strlist.c @@ -33,15 +33,17 @@ static const char *test_lists_shell_strings[] = { NULL }; -static BOOL test_lists_shell(struct torture_context *test, const void *_data) +static bool test_lists_shell(struct torture_context *tctx, + const void *test_data) { - const char *data = _data; + const char *data = test_data; const char **ret1, **ret2, *tmp; BOOL match = True; + TALLOC_CTX *mem_ctx = tctx; - ret1 = str_list_make_shell(test, data, " "); - tmp = str_list_join_shell(test, ret1, ' '); - ret2 = str_list_make_shell(test, tmp, " "); + ret1 = str_list_make_shell(mem_ctx, data, " "); + tmp = str_list_join_shell(mem_ctx, ret1, ' '); + ret2 = str_list_make_shell(mem_ctx, tmp, " "); if ((ret1 == NULL || ret2 == NULL) && ret2 != ret1) { match = False; @@ -58,17 +60,14 @@ static BOOL test_lists_shell(struct torture_context *test, const void *_data) match = False; } - if (!match) { - torture_fail(test, "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp); - return False; - } - - return True; + torture_assert(tctx, match, talloc_asprintf(tctx, + "str_list_{make,join}_shell: Error double parsing, first run:\n%s\nSecond run: \n%s", data, tmp)); + return true; } struct torture_suite *torture_local_util_strlist(TALLOC_CTX *mem_ctx) { - struct torture_suite *suite = torture_suite_create(mem_ctx, "LOCAL-STRLIST"); + struct torture_suite *suite = torture_suite_create(mem_ctx, "STRLIST"); int i; for (i = 0; test_lists_shell_strings[i]; i++) { diff --git a/source4/torture/misc.c b/source4/torture/misc.c deleted file mode 100644 index 62b956337c..0000000000 --- a/source4/torture/misc.c +++ /dev/null @@ -1,893 +0,0 @@ -/* - Unix SMB/CIFS implementation. - SMB torture tester - Copyright (C) Andrew Tridgell 1997-2003 - Copyright (C) Jelmer Vernooij 2006 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. -*/ - -#include "includes.h" -#include "libcli/raw/libcliraw.h" -#include "system/time.h" -#include "system/wait.h" -#include "system/filesys.h" -#include "libcli/raw/ioctl.h" -#include "libcli/libcli.h" -#include "lib/events/events.h" -#include "libcli/resolve/resolve.h" -#include "auth/credentials/credentials.h" -#include "librpc/gen_ndr/ndr_nbt.h" -#include "torture/torture.h" -#include "torture/util.h" -#include "libcli/smb_composite/smb_composite.h" -#include "libcli/composite/composite.h" - -extern struct cli_credentials *cmdline_credentials; -void benchrw_callback(struct smbcli_request *req); -enum benchrw_stage { - START, - OPEN_CONNECTION, - CLEANUP_TESTDIR, - MK_TESTDIR, - OPEN_FILE, - INITIAL_WRITE, - READ_WRITE_DATA, - MAX_OPS_REACHED, - ERROR, - CLOSE_FILE, - CLEANUP, - FINISHED -}; - -struct benchrw_state{ - char *dname; - char *fname; - uint16_t fnum; - int nr; - struct smbcli_tree *cli; - uint8_t *buffer; - int writecnt; - int readcnt; - int completed; - TALLOC_CTX *mem_ctx; - void *req_params; - enum benchrw_stage mode; - struct params{ - struct unclist{ - const char *host; - const char *share; - } **unc; - const char *workgroup; - int retry; - unsigned int writeblocks; - unsigned int blocksize; - unsigned int writeratio; - } *lp_params; - }; - -static BOOL wait_lock(struct smbcli_state *c, int fnum, uint32_t offset, uint32_t len) -{ - while (NT_STATUS_IS_ERR(smbcli_lock(c->tree, fnum, offset, len, -1, WRITE_LOCK))) { - if (!check_error(__location__, c, ERRDOS, ERRlock, NT_STATUS_LOCK_NOT_GRANTED)) return False; - } - return True; -} - - -static BOOL rw_torture(struct smbcli_state *c) -{ - const char *lockfname = "\\torture.lck"; - char *fname; - int fnum; - int fnum2; - pid_t pid2, pid = getpid(); - int i, j; - uint8_t buf[1024]; - BOOL correct = True; - - fnum2 = smbcli_open(c->tree, lockfname, O_RDWR | O_CREAT | O_EXCL, - DENY_NONE); - if (fnum2 == -1) - fnum2 = smbcli_open(c->tree, lockfname, O_RDWR, DENY_NONE); - if (fnum2 == -1) { - printf("open of %s failed (%s)\n", lockfname, smbcli_errstr(c->tree)); - return False; - } - - - for (i=0;itree, fname, O_RDWR | O_CREAT | O_TRUNC, DENY_ALL); - if (fnum == -1) { - printf("open failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - break; - } - - if (smbcli_write(c->tree, fnum, 0, &pid, 0, sizeof(pid)) != sizeof(pid)) { - printf("write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - - for (j=0;j<50;j++) { - if (smbcli_write(c->tree, fnum, 0, buf, - sizeof(pid)+(j*sizeof(buf)), - sizeof(buf)) != sizeof(buf)) { - printf("write failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - } - - pid2 = 0; - - if (smbcli_read(c->tree, fnum, &pid2, 0, sizeof(pid)) != sizeof(pid)) { - printf("read failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - - if (pid2 != pid) { - printf("data corruption!\n"); - correct = False; - } - - if (NT_STATUS_IS_ERR(smbcli_close(c->tree, fnum))) { - printf("close failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - - if (NT_STATUS_IS_ERR(smbcli_unlink(c->tree, fname))) { - printf("unlink failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - - if (NT_STATUS_IS_ERR(smbcli_unlock(c->tree, fnum2, n*sizeof(int), sizeof(int)))) { - printf("unlock failed (%s)\n", smbcli_errstr(c->tree)); - correct = False; - } - free(fname); - } - - smbcli_close(c->tree, fnum2); - smbcli_unlink(c->tree, lockfname); - - printf("%d\n", i); - - return correct; -} - -static BOOL run_torture(struct smbcli_state *cli, int dummy) -{ - BOOL ret; - - ret = rw_torture(cli); - - if (!torture_close_connection(cli)) { - ret = False; - } - - return ret; -} - - -/* - see how many RPC pipes we can open at once -*/ -static BOOL run_pipe_number(struct torture_context *torture) -{ - struct smbcli_state *cli1; - const char *pipe_name = "\\WKSSVC"; - int fnum; - int num_pipes = 0; - - printf("starting pipenumber test\n"); - if (!torture_open_connection(&cli1, 0)) { - return False; - } - - while(1) { - fnum = smbcli_nt_create_full(cli1->tree, pipe_name, 0, SEC_FILE_READ_DATA, FILE_ATTRIBUTE_NORMAL, - NTCREATEX_SHARE_ACCESS_READ|NTCREATEX_SHARE_ACCESS_WRITE, NTCREATEX_DISP_OPEN_IF, 0, 0); - - if (fnum == -1) { - printf("Open of pipe %s failed with error (%s)\n", pipe_name, smbcli_errstr(cli1->tree)); - break; - } - num_pipes++; - printf("%d\r", num_pipes); - fflush(stdout); - } - - printf("pipe_number test - we can open %d %s pipes.\n", num_pipes, pipe_name ); - torture_close_connection(cli1); - return True; -} - - - - -/* - open N connections to the server and just hold them open - used for testing performance when there are N idle users - already connected - */ - static BOOL torture_holdcon(struct torture_context *torture) -{ - int i; - struct smbcli_state **cli; - int num_dead = 0; - - printf("Opening %d connections\n", torture_numops); - - cli = malloc_array_p(struct smbcli_state *, torture_numops); - - for (i=0;itree, "\\"); - if (!NT_STATUS_IS_OK(status)) { - printf("Connection %d is dead\n", i); - cli[i] = NULL; - num_dead++; - } - usleep(100); - } - } - - if (num_dead == torture_numops) { - printf("All connections dead - finishing\n"); - break; - } - - printf("."); - fflush(stdout); - } - - return True; -} - -/* -test how many open files this server supports on the one socket -*/ -static BOOL run_maxfidtest(struct smbcli_state *cli, int dummy) -{ -#define MAXFID_TEMPLATE "\\maxfid\\fid%d\\maxfid.%d.%d" - char *fname; - int fnums[0x11000], i; - int retries=4, maxfid; - BOOL correct = True; - - if (retries <= 0) { - printf("failed to connect\n"); - return False; - } - - if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { - printf("Failed to deltree \\maxfid - %s\n", - smbcli_errstr(cli->tree)); - return False; - } - if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, "\\maxfid"))) { - printf("Failed to mkdir \\maxfid, error=%s\n", - smbcli_errstr(cli->tree)); - return False; - } - - printf("Testing maximum number of open files\n"); - - for (i=0; i<0x11000; i++) { - if (i % 1000 == 0) { - asprintf(&fname, "\\maxfid\\fid%d", i/1000); - if (NT_STATUS_IS_ERR(smbcli_mkdir(cli->tree, fname))) { - printf("Failed to mkdir %s, error=%s\n", - fname, smbcli_errstr(cli->tree)); - return False; - } - free(fname); - } - asprintf(&fname, MAXFID_TEMPLATE, i/1000, i,(int)getpid()); - if ((fnums[i] = smbcli_open(cli->tree, fname, - O_RDWR|O_CREAT|O_TRUNC, DENY_NONE)) == - -1) { - printf("open of %s failed (%s)\n", - fname, smbcli_errstr(cli->tree)); - printf("maximum fnum is %d\n", i); - break; - } - free(fname); - printf("%6d\r", i); - } - printf("%6d\n", i); - i--; - - maxfid = i; - - printf("cleaning up\n"); - for (i=0;itree, fnums[i]))) { - printf("Close of fnum %d failed - %s\n", fnums[i], smbcli_errstr(cli->tree)); - } - if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { - printf("unlink of %s failed (%s)\n", - fname, smbcli_errstr(cli->tree)); - correct = False; - } - free(fname); - - asprintf(&fname, MAXFID_TEMPLATE, (maxfid-i)/1000, maxfid-i,(int)getpid()); - if (NT_STATUS_IS_ERR(smbcli_close(cli->tree, fnums[maxfid-i]))) { - printf("Close of fnum %d failed - %s\n", fnums[maxfid-i], smbcli_errstr(cli->tree)); - } - if (NT_STATUS_IS_ERR(smbcli_unlink(cli->tree, fname))) { - printf("unlink of %s failed (%s)\n", - fname, smbcli_errstr(cli->tree)); - correct = False; - } - free(fname); - - printf("%6d %6d\r", i, maxfid-i); - } - printf("%6d\n", 0); - - if (smbcli_deltree(cli->tree, "\\maxfid") == -1) { - printf("Failed to deltree \\maxfid - %s\n", - smbcli_errstr(cli->tree)); - return False; - } - - printf("maxfid test finished\n"); - if (!torture_close_connection(cli)) { - correct = False; - } - return correct; -#undef MAXFID_TEMPLATE -} - - - -/* - sees what IOCTLs are supported - */ -static BOOL torture_ioctl_test(struct torture_context *torture) -{ - struct smbcli_state *cli; - uint16_t device, function; - int fnum; - const char *fname = "\\ioctl.dat"; - NTSTATUS status; - union smb_ioctl parms; - TALLOC_CTX *mem_ctx; - - if (!torture_open_connection(&cli, 0)) { - return False; - } - - mem_ctx = talloc_named_const(torture, 0, "ioctl_test"); - - printf("starting ioctl test\n"); - - smbcli_unlink(cli->tree, fname); - - fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE); - if (fnum == -1) { - printf("open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree)); - return False; - } - - parms.ioctl.level = RAW_IOCTL_IOCTL; - parms.ioctl.in.file.fnum = fnum; - parms.ioctl.in.request = IOCTL_QUERY_JOB_INFO; - status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); - printf("ioctl job info: %s\n", smbcli_errstr(cli->tree)); - - for (device=0;device<0x100;device++) { - printf("testing device=0x%x\n", device); - for (function=0;function<0x100;function++) { - parms.ioctl.in.request = (device << 16) | function; - status = smb_raw_ioctl(cli->tree, mem_ctx, &parms); - - if (NT_STATUS_IS_OK(status)) { - printf("ioctl device=0x%x function=0x%x OK : %d bytes\n", - device, function, (int)parms.ioctl.out.blob.length); - } - } - } - - if (!torture_close_connection(cli)) { - return False; - } - - return True; -} - -/* - init params using lp_parm_xxx - return number of unclist entries -*/ -int init_benchrw_params(TALLOC_CTX *mem_ctx,struct params *lpar) -{ - char **unc_list = NULL; - int num_unc_names = 0, conn_index=0, empty_lines=0; - const char *p; - lpar->retry = lp_parm_int(-1, "torture", "retry",3); - lpar->blocksize = lp_parm_int(-1, "torture", "blocksize",65535); - lpar->writeblocks = lp_parm_int(-1, "torture", "writeblocks",15); - lpar->writeratio = lp_parm_int(-1, "torture", "writeratio",5); - lpar->workgroup = lp_workgroup(); - - p = lp_parm_string(-1, "torture", "unclist"); - if (p) { - char *h, *s; - unc_list = file_lines_load(p, &num_unc_names, NULL); - if (!unc_list || num_unc_names <= 0) { - printf("Failed to load unc names list from '%s'\n", p); - exit(1); - } - - lpar->unc = talloc_array(mem_ctx, struct unclist *, (num_unc_names-empty_lines)); - for(conn_index = 0; conn_index < num_unc_names; conn_index++) { - /* ignore empty lines */ - if(strlen(unc_list[conn_index % num_unc_names])==0){ - empty_lines++; - continue; - } - if (!smbcli_parse_unc(unc_list[conn_index % num_unc_names], - NULL, &h, &s)) { - printf("Failed to parse UNC name %s\n", - unc_list[conn_index % num_unc_names]); - exit(1); - } - lpar->unc[conn_index-empty_lines] = talloc(mem_ctx,struct unclist); - lpar->unc[conn_index-empty_lines]->host = h; - lpar->unc[conn_index-empty_lines]->share = s; - } - return num_unc_names-empty_lines; - }else{ - lpar->unc = talloc_array(mem_ctx, struct unclist *, 1); - lpar->unc[0] = talloc(mem_ctx,struct unclist); - lpar->unc[0]->host = lp_parm_string(-1, "torture", "host"); - lpar->unc[0]->share = lp_parm_string(-1, "torture", "share"); - return 1; - } -} - -/* - Called when the reads & writes are finished. closes the file. -*/ -NTSTATUS benchrw_close(struct smbcli_request *req, - struct benchrw_state *state) -{ - union smb_close close_parms; - - NT_STATUS_NOT_OK_RETURN(req->status); - - printf("Close file %d (%d)\n",state->nr,state->fnum); - close_parms.close.level = RAW_CLOSE_CLOSE; - close_parms.close.in.file.fnum = state->fnum ; - close_parms.close.in.write_time = 0; - state->mode=CLOSE_FILE; - - req = smb_raw_close_send(state->cli, &close_parms); - NT_STATUS_HAVE_NO_MEMORY(req); - /*register the callback function!*/ - req->async.fn = benchrw_callback; - req->async.private = state; - - return NT_STATUS_OK; -} - -/* - Called when the initial write is completed is done. write or read a file. -*/ -NTSTATUS benchrw_readwrite(struct smbcli_request *req, - struct benchrw_state *state) -{ - union smb_read rd; - union smb_write wr; - - NT_STATUS_NOT_OK_RETURN(req->status); - - state->completed++; - /*rotate between writes and reads*/ - if( state->completed % state->lp_params->writeratio == 0){ - printf("Callback WRITE file:%d (%d/%d)\n", - state->nr,state->completed,torture_numops); - wr.generic.level = RAW_WRITE_WRITEX ; - wr.writex.in.file.fnum = state->fnum ; - wr.writex.in.offset = 0; - wr.writex.in.wmode = 0 ; - wr.writex.in.remaining = 0; - wr.writex.in.count = state->lp_params->blocksize; - wr.writex.in.data = state->buffer; - state->readcnt=0; - req = smb_raw_write_send(state->cli,&wr); - }else{ - printf("Callback READ file:%d (%d/%d) Offset:%d\n", - state->nr,state->completed,torture_numops, - (state->readcnt*state->lp_params->blocksize)); - rd.generic.level = RAW_READ_READ ; - rd.read.in.file.fnum = state->fnum ; - rd.read.in.offset = state->readcnt * - state->lp_params->blocksize; - rd.read.in.count = state->lp_params->blocksize; - rd.read.in.remaining = 0 ; - rd.read.out.data = state->buffer; - if(state->readcnt < state->lp_params->writeblocks){ - state->readcnt++; - }else{ - /*start reading from beginn of file*/ - state->readcnt=0; - } - req = smb_raw_read_send(state->cli,&rd); - } - NT_STATUS_HAVE_NO_MEMORY(req); - /*register the callback function!*/ - req->async.fn = benchrw_callback; - req->async.private = state; - - return NT_STATUS_OK; -} - -/* - Called when the open is done. writes to the file. -*/ -NTSTATUS benchrw_open(struct smbcli_request *req, - struct benchrw_state *state) -{ - union smb_write wr; - if(state->mode == OPEN_FILE){ - NTSTATUS status; - status = smb_raw_open_recv(req,state->mem_ctx,( - union smb_open*)state->req_params); - NT_STATUS_NOT_OK_RETURN(status); - - state->fnum = ((union smb_open*)state->req_params) - ->openx.out.file.fnum; - printf("File opened (%d)\n",state->fnum); - state->mode=INITIAL_WRITE; - } - - printf("Write initial test file:%d (%d/%d)\n",state->nr, - (state->writecnt+1)*state->lp_params->blocksize, - (state->lp_params->writeblocks*state->lp_params->blocksize)); - wr.generic.level = RAW_WRITE_WRITEX ; - wr.writex.in.file.fnum = state->fnum ; - wr.writex.in.offset = state->writecnt * - state->lp_params->blocksize; - wr.writex.in.wmode = 0 ; - wr.writex.in.remaining = (state->lp_params->writeblocks * - state->lp_params->blocksize)- - ((state->writecnt+1)*state-> - lp_params->blocksize); - wr.writex.in.count = state->lp_params->blocksize; - wr.writex.in.data = state->buffer; - state->writecnt++; - if(state->writecnt == state->lp_params->writeblocks){ - state->mode=READ_WRITE_DATA; - } - req = smb_raw_write_send(state->cli,&wr); - NT_STATUS_HAVE_NO_MEMORY(req); - - /*register the callback function!*/ - req->async.fn = benchrw_callback; - req->async.private = state; - return NT_STATUS_OK; -} - -/* - Called when the mkdir is done. Opens a file. -*/ -NTSTATUS benchrw_mkdir(struct smbcli_request *req, - struct benchrw_state *state) -{ - union smb_open *open_parms; - uint8_t *writedata; - - NT_STATUS_NOT_OK_RETURN(req->status); - - /* open/create the files */ - printf("Open File %d/%d\n",state->nr+1,torture_nprocs); - open_parms=talloc_zero(state->mem_ctx, union smb_open); - NT_STATUS_HAVE_NO_MEMORY(open_parms); - open_parms->openx.level = RAW_OPEN_OPENX; - open_parms->openx.in.flags = 0; - open_parms->openx.in.open_mode = OPENX_MODE_ACCESS_RDWR; - open_parms->openx.in.search_attrs = - FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; - open_parms->openx.in.file_attrs = 0; - open_parms->openx.in.write_time = 0; - open_parms->openx.in.open_func = OPENX_OPEN_FUNC_CREATE; - open_parms->openx.in.size = 0; - open_parms->openx.in.timeout = 0; - open_parms->openx.in.fname = state->fname; - - writedata = talloc_size(state->mem_ctx,state->lp_params->blocksize); - NT_STATUS_HAVE_NO_MEMORY(writedata); - generate_random_buffer(writedata,state->lp_params->blocksize); - state->buffer=writedata; - state->writecnt=1; - state->readcnt=0; - state->req_params=open_parms; - state->mode=OPEN_FILE; - - req = smb_raw_open_send(state->cli,open_parms); - NT_STATUS_HAVE_NO_MEMORY(req); - - /*register the callback function!*/ - req->async.fn = benchrw_callback; - req->async.private = state; - - return NT_STATUS_OK; -} - -/* - handler for completion of a sub-request of the bench-rw test -*/ -void benchrw_callback(struct smbcli_request *req) -{ - struct benchrw_state *state = req->async.private; - - /*dont send new requests when torture_numops is reached*/ - if(state->completed >= torture_numops){ - state->completed=0; - state->mode=MAX_OPS_REACHED; - } - - switch (state->mode) { - - case MK_TESTDIR: - if (!NT_STATUS_IS_OK(benchrw_mkdir(req,state))) { - printf("Failed to create the test directory - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; - } - break; - case OPEN_FILE: - case INITIAL_WRITE: - if (!NT_STATUS_IS_OK(benchrw_open(req,state))){ - printf("Failed to open/write the file - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; - } - break; - case READ_WRITE_DATA: - if (!NT_STATUS_IS_OK(benchrw_readwrite(req,state))){ - printf("Failed to read/write the file - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; - } - break; - case MAX_OPS_REACHED: - if (!NT_STATUS_IS_OK(benchrw_close(req,state))){ - printf("Failed to read/write/close the file - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; - } - break; - case CLOSE_FILE: - printf("File %d closed\n",state->nr); - if (!NT_STATUS_IS_OK(req->status)) { - printf("Failed to close the file - %s\n", - nt_errstr(req->status)); - state->mode=ERROR; - return; - } - state->mode=CLEANUP; - return; - default: - break; - } - -} - -/* open connection async callback function*/ -void async_open_callback(struct composite_context *con) -{ - struct benchrw_state *state = con->async.private_data; - int retry = state->lp_params->retry; - - if (NT_STATUS_IS_OK(con->status)) { - state->cli=((struct smb_composite_connect*) - state->req_params)->out.tree; - state->mode=CLEANUP_TESTDIR; - }else{ - if(state->writecnt < retry){ - printf("Failed to open connection:%d, Retry (%d/%d)\n", - state->nr,state->writecnt,retry); - state->writecnt++; - state->mode=START; - usleep(1000); - }else{ - printf("Failed to open connection (%d) - %s\n", - state->nr, nt_errstr(con->status)); - state->mode=ERROR; - } - return; - } -} - -/* - establishs a smbcli_tree from scratch (async) -*/ -struct composite_context *torture_connect_async( - struct smb_composite_connect *smb, - TALLOC_CTX *mem_ctx, - struct event_context *ev, - const char *host, - const char *share, - const char *workgroup) -{ - printf("Open Connection to %s/%s\n",host,share); - smb->in.dest_host=talloc_strdup(mem_ctx,host); - smb->in.service=talloc_strdup(mem_ctx,share); - smb->in.port=0; - smb->in.called_name = strupper_talloc(mem_ctx, host); - smb->in.service_type=NULL; - smb->in.credentials=cmdline_credentials; - smb->in.fallback_to_anonymous=False; - smb->in.workgroup=workgroup; - - return smb_composite_connect_send(smb,mem_ctx,ev); -} - -static BOOL run_benchrw(struct torture_context *torture) -{ - struct smb_composite_connect *smb_con; - const char *fname = "\\rwtest.dat"; - struct smbcli_request *req; - struct benchrw_state **state; - int i , num_unc_names; - TALLOC_CTX *mem_ctx; - struct event_context *ev ; - struct composite_context *req1; - struct params lpparams; - union smb_mkdir parms; - int finished = 0; - BOOL success=True; - - printf("Start BENCH-READWRITE num_ops=%d num_nprocs=%d\n", - torture_numops,torture_nprocs); - - /*init talloc context*/ - mem_ctx = talloc_named_const(torture, 0, "bench-readwrite"); - ev = event_context_init(mem_ctx); - state = talloc_array(mem_ctx, struct benchrw_state *, torture_nprocs); - - /* init params using lp_parm_xxx */ - num_unc_names = init_benchrw_params(mem_ctx,&lpparams); - - /* init private data structs*/ - for(i = 0; icompleted=0; - state[i]->lp_params=&lpparams; - state[i]->nr=i; - state[i]->dname=talloc_asprintf(mem_ctx,"benchrw%d",i); - state[i]->fname=talloc_asprintf(mem_ctx,"%s%s", - state[i]->dname,fname); - state[i]->mode=START; - state[i]->writecnt=0; - } - - printf("Starting async requests\n"); - while(finished != torture_nprocs){ - finished=0; - for(i = 0; imode){ - /*open multiple connections with the same userid */ - case START: - smb_con = talloc(mem_ctx,struct smb_composite_connect) ; - state[i]->req_params=smb_con; - state[i]->mode=OPEN_CONNECTION; - req1 = torture_connect_async(smb_con, - mem_ctx,ev, - lpparams.unc[i % num_unc_names]->host, - lpparams.unc[i % num_unc_names]->share, - lpparams.workgroup); - /* register callback fn + private data */ - req1->async.fn = async_open_callback; - req1->async.private_data=state[i]; - break; - /*setup test dirs (sync)*/ - case CLEANUP_TESTDIR: - printf("Setup test dir %d\n",i); - smb_raw_exit(state[i]->cli->session); - if (smbcli_deltree(state[i]->cli, - state[i]->dname) == -1) { - printf("Unable to delete %s - %s\n", - state[i]->dname, - smbcli_errstr(state[i]->cli)); - state[i]->mode=ERROR; - break; - } - state[i]->mode=MK_TESTDIR; - parms.mkdir.level = RAW_MKDIR_MKDIR; - parms.mkdir.in.path = state[i]->dname; - req = smb_raw_mkdir_send(state[i]->cli,&parms); - /* register callback fn + private data */ - req->async.fn = benchrw_callback; - req->async.private=state[i]; - break; - /* error occured , finish */ - case ERROR: - finished++; - success=False; - break; - /* cleanup , close connection */ - case CLEANUP: - printf("Deleting test dir %s %d/%d\n",state[i]->dname, - i+1,torture_nprocs); - smbcli_deltree(state[i]->cli,state[i]->dname); - if (NT_STATUS_IS_ERR(smb_tree_disconnect( - state[i]->cli))) { - printf("ERROR: Tree disconnect failed"); - state[i]->mode=ERROR; - break; - } - state[i]->mode=FINISHED; - case FINISHED: - finished++; - break; - default: - event_loop_once(ev); - } - } - } - - printf("BENCH-READWRITE done. Closing connections.\n"); - - /*free all allocated memory*/ - talloc_free(mem_ctx); - - return success; -} - - -NTSTATUS torture_misc_init(void) -{ - register_torture_op("BENCH-HOLDCON", torture_holdcon); - register_torture_op("SCAN-PIPE_NUMBER", run_pipe_number); - register_torture_op("SCAN-IOCTL", torture_ioctl_test); - register_torture_op("BENCH-READWRITE", run_benchrw); - register_torture_multi_op("BENCH-TORTURE", run_torture); - register_torture_multi_op("SCAN-MAXFID", run_maxfidtest); - - return NT_STATUS_OK; -} diff --git a/source4/torture/nbench/nbench.c b/source4/torture/nbench/nbench.c index 47621d46a0..fe3c905b46 100644 --- a/source4/torture/nbench/nbench.c +++ b/source4/torture/nbench/nbench.c @@ -20,6 +20,7 @@ #include "includes.h" #include "libcli/libcli.h" +#include "torture/ui.h" #include "torture/util.h" #include "torture/torture.h" #include "system/filesys.h" @@ -35,7 +36,7 @@ static const char *loadfile; #define ival(s) strtol(s, NULL, 0) /* run a test that simulates an approximate netbench client load */ -static BOOL run_netbench(struct smbcli_state *cli, int client) +static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli, int client) { extern int torture_nprocs; int i; @@ -211,7 +212,7 @@ BOOL torture_nbench(struct torture_context *torture) signal(SIGALRM, nb_alarm); alarm(1); - torture_create_procs(run_netbench, &correct); + torture_create_procs(torture, run_netbench, &correct); alarm(0); if (torture_nprocs > 1) { @@ -224,6 +225,15 @@ BOOL torture_nbench(struct torture_context *torture) NTSTATUS torture_nbench_init(void) { - register_torture_op("BENCH-NBENCH", torture_nbench); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "BENCH"); + + torture_suite_add_simple_test(suite, "NBENCH", torture_nbench); + + suite->description = talloc_strdup(suite, + "Benchmarks"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/nbt/dgram.c b/source4/torture/nbt/dgram.c index def8adaa48..9183019ad4 100644 --- a/source4/torture/nbt/dgram.c +++ b/source4/torture/nbt/dgram.c @@ -61,13 +61,12 @@ static void netlogon_handler(struct dgram_mailslot_handler *dgmslot, /* test UDP/138 netlogon requests */ -static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx, - struct nbt_name name, const char *address) +static bool nbt_test_netlogon(struct torture_context *tctx) { struct dgram_mailslot_handler *dgmslot; - struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(mem_ctx, NULL); + struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL); struct socket_address *dest; - const char *myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + const char *myaddress; struct nbt_netlogon_packet logon; struct nbt_name myname; NTSTATUS status; @@ -76,11 +75,25 @@ static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx, struct socket_address *socket_address; + const char *address; + struct nbt_name name; + + name.name = lp_workgroup(); + name.type = NBT_NAME_LOGON; + name.scope = NULL; + + /* do an initial name resolution to find its IP */ + torture_assert_ntstatus_ok(tctx, + resolve_name(&name, tctx, &address, event_context_find(tctx)), + talloc_asprintf(tctx, "Failed to resolve %s", name.name)); + + myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + + socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, lp_dgram_port()); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, + "Error getting address"); /* try receiving replies on port 138 first, which will only work if we are root and smbd/nmbd are not running - fall @@ -91,9 +104,7 @@ static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx, talloc_free(socket_address); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, "Error getting address"); socket_listen(dgmsock->sock, socket_address, 0, 0); } @@ -115,38 +126,27 @@ static BOOL nbt_test_netlogon(TALLOC_CTX *mem_ctx, dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, address, 0); - if (!dest) { - return False; - } + torture_assert(tctx, dest != NULL, "Error getting address"); status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, &myname, &logon); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to send netlogon request - %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); while (timeval_elapsed(&tv) < 5 && replies == 0) { event_loop_once(dgmsock->event_ctx); } - talloc_free(dgmsock); - return True; - -failed: - talloc_free(dgmsock); - return False; + return true; } /* test UDP/138 netlogon requests */ -static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx, - struct nbt_name name, const char *address) +static bool nbt_test_netlogon2(struct torture_context *tctx) { struct dgram_mailslot_handler *dgmslot; - struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(mem_ctx, NULL); + struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL); struct socket_address *dest; - const char *myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + const char *myaddress; struct nbt_netlogon_packet logon; struct nbt_name myname; NTSTATUS status; @@ -155,11 +155,23 @@ static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx, struct socket_address *socket_address; + const char *address; + struct nbt_name name; + + name.name = lp_workgroup(); + name.type = NBT_NAME_LOGON; + name.scope = NULL; + + /* do an initial name resolution to find its IP */ + torture_assert_ntstatus_ok(tctx, + resolve_name(&name, tctx, &address, event_context_find(tctx)), + talloc_asprintf(tctx, "Failed to resolve %s", name.name)); + + myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, lp_dgram_port()); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, "Error getting address"); /* try receiving replies on port 138 first, which will only work if we are root and smbd/nmbd are not running - fall @@ -170,9 +182,8 @@ static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx, talloc_free(socket_address); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + + torture_assert(tctx, socket_address != NULL, "Error getting address"); socket_listen(dgmsock->sock, socket_address, 0, 0); } @@ -196,27 +207,17 @@ static BOOL nbt_test_netlogon2(TALLOC_CTX *mem_ctx, dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, address, 0); - if (!dest) { - goto failed; - } + + torture_assert(tctx, dest != NULL, "Error getting address"); status = dgram_mailslot_netlogon_send(dgmsock, &name, dest, &myname, &logon); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to send netlogon request - %s\n", nt_errstr(status)); - goto failed; - } - + torture_assert_ntstatus_ok(tctx, status, "Failed to send netlogon request"); while (timeval_elapsed(&tv) < 5 && replies == 0) { event_loop_once(dgmsock->event_ctx); } - talloc_free(dgmsock); - return True; - -failed: - talloc_free(dgmsock); - return False; + return true; } @@ -247,17 +248,16 @@ static void ntlogon_handler(struct dgram_mailslot_handler *dgmslot, /* test UDP/138 ntlogon requests */ -static BOOL nbt_test_ntlogon(TALLOC_CTX *mem_ctx, - struct nbt_name name, const char *address) +static bool nbt_test_ntlogon(struct torture_context *tctx) { struct dgram_mailslot_handler *dgmslot; - struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(mem_ctx, NULL); + struct nbt_dgram_socket *dgmsock = nbt_dgram_socket_init(tctx, NULL); struct socket_address *dest; struct test_join *join_ctx; struct cli_credentials *machine_credentials; const struct dom_sid *dom_sid; - const char *myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); + const char *myaddress; struct nbt_ntlogon_packet logon; struct nbt_name myname; NTSTATUS status; @@ -265,12 +265,23 @@ static BOOL nbt_test_ntlogon(TALLOC_CTX *mem_ctx, int replies = 0; struct socket_address *socket_address; + const char *address; + struct nbt_name name; + + name.name = lp_workgroup(); + name.type = NBT_NAME_LOGON; + name.scope = NULL; + + /* do an initial name resolution to find its IP */ + torture_assert_ntstatus_ok(tctx, + resolve_name(&name, tctx, &address, event_context_find(tctx)), + talloc_asprintf(tctx, "Failed to resolve %s", name.name)); + + myaddress = talloc_strdup(dgmsock, iface_best_ip(address)); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, lp_dgram_port()); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, "Error getting address"); /* try receiving replies on port 138 first, which will only work if we are root and smbd/nmbd are not running - fall @@ -281,20 +292,15 @@ static BOOL nbt_test_ntlogon(TALLOC_CTX *mem_ctx, talloc_free(socket_address); socket_address = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, "Error getting address"); socket_listen(dgmsock->sock, socket_address, 0, 0); } join_ctx = torture_join_domain(TEST_NAME, ACB_WSTRUST, &machine_credentials); - if (join_ctx == NULL) { - printf("Failed to join domain %s as %s\n", lp_workgroup(), TEST_NAME); - talloc_free(dgmsock); - return False; - } + torture_assert(tctx, join_ctx != NULL, + talloc_asprintf(tctx, "Failed to join domain %s as %s\n", lp_workgroup(), TEST_NAME)); dom_sid = torture_join_sid(join_ctx); @@ -319,61 +325,31 @@ static BOOL nbt_test_ntlogon(TALLOC_CTX *mem_ctx, dest = socket_address_from_strings(dgmsock, dgmsock->sock->backend_name, address, 0); - if (!dest) { - goto failed; - } + torture_assert(tctx, dest != NULL, "Error getting address"); status = dgram_mailslot_ntlogon_send(dgmsock, DGRAM_DIRECT_UNIQUE, &name, dest, &myname, &logon); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to send ntlogon request - %s\n", nt_errstr(status)); - goto failed; - } - + torture_assert_ntstatus_ok(tctx, status, "Failed to send ntlogon request"); while (timeval_elapsed(&tv) < 5 && replies == 0) { event_loop_once(dgmsock->event_ctx); } torture_leave_domain(join_ctx); - talloc_free(dgmsock); - return True; - -failed: - torture_leave_domain(join_ctx); - talloc_free(dgmsock); - return False; + return true; } /* test nbt dgram operations */ -BOOL torture_nbt_dgram(struct torture_context *torture) +struct torture_suite *torture_nbt_dgram(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - - name.name = lp_workgroup(); - name.type = NBT_NAME_LOGON; - name.scope = NULL; - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, event_context_find(mem_ctx)); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ret &= nbt_test_netlogon(mem_ctx, name, address); - ret &= nbt_test_netlogon2(mem_ctx, name, address); - ret &= nbt_test_ntlogon(mem_ctx, name, address); + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), + "DGRAM"); - talloc_free(mem_ctx); + torture_suite_add_simple_test(suite, "netlogon", nbt_test_netlogon); + torture_suite_add_simple_test(suite, "netlogon2", nbt_test_netlogon2); + torture_suite_add_simple_test(suite, "ntlogon", nbt_test_ntlogon); - return ret; + return suite; } diff --git a/source4/torture/nbt/nbt.c b/source4/torture/nbt/nbt.c index 6cf663f350..b4212337ce 100644 --- a/source4/torture/nbt/nbt.c +++ b/source4/torture/nbt/nbt.c @@ -21,19 +21,42 @@ #include "includes.h" #include "torture/torture.h" #include "torture/nbt/proto.h" +#include "torture/ui.h" +#include "libcli/resolve/resolve.h" + +bool torture_nbt_get_name(struct torture_context *tctx, + struct nbt_name *name, + const char **address) +{ + make_nbt_name_server(name, strupper_talloc(tctx, + torture_setting_string(tctx, "host", NULL))); + + /* do an initial name resolution to find its IP */ + torture_assert_ntstatus_ok(tctx, + resolve_name(name, tctx, address, NULL), + talloc_asprintf(tctx, + "Failed to resolve %s", name->name)); + + return true; +} NTSTATUS torture_nbt_init(void) { + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "NBT"); /* nbt tests */ - register_torture_op("NBT-REGISTER", torture_nbt_register); - register_torture_op("NBT-WINS", torture_nbt_wins); - register_torture_op("NBT-DGRAM", torture_nbt_dgram); - register_torture_op("NBT-BROWSE", torture_nbt_browse); - register_torture_op("NBT-WINSREPLICATION-SIMPLE", torture_nbt_winsreplication_simple); - register_torture_op("NBT-WINSREPLICATION-REPLICA", torture_nbt_winsreplication_replica); - register_torture_op("NBT-WINSREPLICATION-OWNED", torture_nbt_winsreplication_owned); - register_torture_op("BENCH-WINS", torture_bench_wins); - register_torture_op("BENCH-NBT", torture_bench_nbt); - + torture_suite_add_suite(suite, torture_nbt_register()); + torture_suite_add_suite(suite, torture_nbt_wins()); + torture_suite_add_suite(suite, torture_nbt_dgram()); + torture_suite_add_suite(suite, torture_nbt_winsreplication()); + torture_suite_add_suite(suite, torture_bench_nbt()); + torture_suite_add_suite(suite, torture_bench_wins()); + + suite->description = talloc_strdup(suite, + "NetBIOS over TCP/IP and WINS tests"); + + torture_register_suite(suite); + return NT_STATUS_OK; } diff --git a/source4/torture/nbt/query.c b/source4/torture/nbt/query.c index 10e8848b46..33cf2d4335 100644 --- a/source4/torture/nbt/query.c +++ b/source4/torture/nbt/query.c @@ -24,6 +24,7 @@ #include "lib/events/events.h" #include "libcli/resolve/resolve.h" #include "torture/torture.h" +#include "torture/nbt/proto.h" struct result_struct { int num_pass; @@ -44,39 +45,40 @@ static void increment_handler(struct nbt_name_request *req) /* benchmark simple name queries */ -static BOOL bench_namequery(TALLOC_CTX *mem_ctx, struct nbt_name *name, const char *address) +static bool bench_namequery(struct torture_context *tctx) { - struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); + struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL); int num_sent=0; struct result_struct *result; struct nbt_name_query io; struct timeval tv = timeval_current(); - BOOL ret = True; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + int timelimit = torture_setting_int(tctx, "timelimit", 10); - io.in.name = *name; + const char *address; + struct nbt_name name; + + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; + + io.in.name = name; io.in.dest_addr = address; io.in.broadcast = False; io.in.wins_lookup = False; io.in.timeout = 1; - result = talloc_zero(mem_ctx, struct result_struct); + result = talloc_zero(tctx, struct result_struct); - printf("Running for %d seconds\n", timelimit); + torture_comment(tctx, "Running for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { while (num_sent - (result->num_pass+result->num_fail) < 10) { struct nbt_name_request *req; req = nbt_name_query_send(nbtsock, &io); - if (req == NULL) { - printf("Failed to setup request!\n"); - ret = False; - goto failed; - } + torture_assert(tctx, req != NULL, "Failed to setup request!"); req->async.fn = increment_handler; req->async.private = result; num_sent++; if (num_sent % 1000 == 0) { - printf("%.1f queries per second (%d failures) \r", + torture_comment(tctx, "%.1f queries per second (%d failures) \r", result->num_pass / timeval_elapsed(&tv), result->num_fail); } @@ -89,41 +91,22 @@ static BOOL bench_namequery(TALLOC_CTX *mem_ctx, struct nbt_name *name, const ch event_loop_once(nbtsock->event_ctx); } - printf("%.1f queries per second (%d failures) \n", + torture_comment(tctx, "%.1f queries per second (%d failures) \n", result->num_pass / timeval_elapsed(&tv), result->num_fail); -failed: - talloc_free(nbtsock); - return ret; + return true; } /* benchmark how fast a server can respond to name queries */ -BOOL torture_bench_nbt(struct torture_context *torture) +struct torture_suite *torture_bench_nbt(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, event_context_find(mem_ctx)); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ret &= bench_namequery(mem_ctx, &name, address); - - talloc_free(mem_ctx); + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), + "BENCH"); + torture_suite_add_simple_test(suite, "namequery", bench_namequery); - return ret; + return suite; } diff --git a/source4/torture/nbt/register.c b/source4/torture/nbt/register.c index b72b80ab26..f8ae0b2619 100644 --- a/source4/torture/nbt/register.c +++ b/source4/torture/nbt/register.c @@ -26,49 +26,46 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "torture/torture.h" +#include "torture/nbt/proto.h" + +#define CHECK_VALUE(tctx, v, correct) \ + torture_assert_int_equal(tctx, v, correct, "Incorrect value") + +#define CHECK_STRING(tctx, v, correct) \ + torture_assert_casestr_equal(tctx, v, correct, "Incorrect value") + -#define CHECK_VALUE(v, correct) do { \ - if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%d - should be %d\n", \ - __location__, #v, (int)v, (int)correct); \ - ret = False; \ - }} while (0) -#define CHECK_STRING(v, correct) do { \ - if (strcasecmp_m(v, correct) != 0) { \ - printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \ - __location__, #v, v, correct); \ - ret = False; \ - }} while (0) /* test that a server responds correctly to attempted registrations of its name */ -static BOOL nbt_register_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, - const char *address) +static bool nbt_register_own(struct torture_context *tctx) { struct nbt_name_register io; NTSTATUS status; - struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); - BOOL ret = True; - const char *myaddress = iface_best_ip(address); + struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL); struct socket_address *socket_address; + struct nbt_name name; + const char *address; + const char *myaddress; - socket_address = socket_address_from_strings(mem_ctx, nbtsock->sock->backend_name, + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; + + myaddress = iface_best_ip(address); + + socket_address = socket_address_from_strings(tctx, nbtsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, "Unable to get address"); status = socket_listen(nbtsock->sock, socket_address, 0, 0); - if (!NT_STATUS_IS_OK(status)) { - printf("socket_listen for nbt_register_own failed: %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "socket_listen for nbt_register_own failed"); - printf("Testing name defense to name registration\n"); + torture_comment(tctx, "Testing name defense to name registration\n"); - io.in.name = *name; + io.in.name = name; io.in.dest_addr = address; io.in.address = myaddress; io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE; @@ -79,72 +76,62 @@ static BOOL nbt_register_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, io.in.timeout = 3; io.in.retries = 0; - status = nbt_name_register(nbtsock, mem_ctx, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name register\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_register(nbtsock, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "Bad response from %s for name register", + address)); - CHECK_STRING(io.out.name.name, name->name); - CHECK_VALUE(io.out.name.type, name->type); - CHECK_VALUE(io.out.rcode, NBT_RCODE_ACT); + CHECK_STRING(tctx, io.out.name.name, name.name); + CHECK_VALUE(tctx, io.out.name.type, name.type); + CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT); /* check a register demand */ io.in.address = myaddress; io.in.register_demand = True; - status = nbt_name_register(nbtsock, mem_ctx, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name register demand\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register demand - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_register(nbtsock, tctx, &io); + + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "Bad response from %s for name register demand", address)); - CHECK_STRING(io.out.name.name, name->name); - CHECK_VALUE(io.out.name.type, name->type); - CHECK_VALUE(io.out.rcode, NBT_RCODE_ACT); + CHECK_STRING(tctx, io.out.name.name, name.name); + CHECK_VALUE(tctx, io.out.name.type, name.type); + CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT); - return ret; + return true; } /* test that a server responds correctly to attempted name refresh requests */ -static BOOL nbt_refresh_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, - const char *address) +static bool nbt_refresh_own(struct torture_context *tctx) { struct nbt_name_refresh io; NTSTATUS status; - struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); - BOOL ret = True; - const char *myaddress = iface_best_ip(address); + struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL); + const char *myaddress; struct socket_address *socket_address; + struct nbt_name name; + const char *address; - socket_address = socket_address_from_strings(mem_ctx, nbtsock->sock->backend_name, + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; + + myaddress = iface_best_ip(address); + + socket_address = socket_address_from_strings(tctx, nbtsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, + "Can't parse socket address"); status = socket_listen(nbtsock->sock, socket_address, 0, 0); - if (!NT_STATUS_IS_OK(status)) { - printf("socket_listen for nbt_referesh_own failed: %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "socket_listen for nbt_referesh_own failed"); - printf("Testing name defense to name refresh\n"); + torture_comment(tctx, "Testing name defense to name refresh\n"); - io.in.name = *name; + io.in.name = name; io.in.dest_addr = address; io.in.address = myaddress; io.in.nb_flags = NBT_NODE_B | NBT_NM_ACTIVE; @@ -153,52 +140,29 @@ static BOOL nbt_refresh_own(TALLOC_CTX *mem_ctx, struct nbt_name *name, io.in.timeout = 3; io.in.retries = 0; - status = nbt_name_refresh(nbtsock, mem_ctx, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name refresh\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name refresh - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_refresh(nbtsock, tctx, &io); + + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "Bad response from %s for name refresh", address)); - CHECK_STRING(io.out.name.name, name->name); - CHECK_VALUE(io.out.name.type, name->type); - CHECK_VALUE(io.out.rcode, NBT_RCODE_ACT); + CHECK_STRING(tctx, io.out.name.name, name.name); + CHECK_VALUE(tctx, io.out.name.type, name.type); + CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT); - return ret; + return true; } - /* test name registration to a server */ -BOOL torture_nbt_register(struct torture_context *torture) +struct torture_suite *torture_nbt_register(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - - make_nbt_name_server(&name, strupper_talloc(mem_ctx, lp_parm_string(-1, "torture", "host"))); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ret &= nbt_register_own(mem_ctx, &name, address); - ret &= nbt_refresh_own(mem_ctx, &name, address); + struct torture_suite *suite; - talloc_free(mem_ctx); + suite = torture_suite_create(talloc_autofree_context(), "REGISTER"); + torture_suite_add_simple_test(suite, "register_own", nbt_register_own); + torture_suite_add_simple_test(suite, "refresh_own", nbt_refresh_own); - return ret; + return suite; } diff --git a/source4/torture/nbt/wins.c b/source4/torture/nbt/wins.c index 44ac61fe46..53bf5f89c0 100644 --- a/source4/torture/nbt/wins.c +++ b/source4/torture/nbt/wins.c @@ -27,33 +27,25 @@ #include "lib/socket/netif.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "torture/torture.h" +#include "torture/nbt/proto.h" -#define CHECK_VALUE(v, correct) do { \ - if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%d (0x%X) - should be %d (0x%X)\n", \ - __location__, #v, v, v, correct, correct); \ - ret = False; \ - }} while (0) - -#define CHECK_STRING(v, correct) do { \ - if ((v) != (correct) && \ - ((v)==NULL || (correct)==NULL || strcasecmp_m(v, correct) != 0)) { \ - printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \ - __location__, #v, v, correct); \ - ret = False; \ - }} while (0) - -#define CHECK_NAME(_name, correct) do { \ - CHECK_STRING((_name).name, (correct).name); \ - CHECK_VALUE((uint8_t)(_name).type, (uint8_t)(correct).type); \ - CHECK_STRING((_name).scope, (correct).scope); \ +#define CHECK_VALUE(tctx, v, correct) \ + torture_assert_int_equal(tctx, v, correct, "Incorrect value") + +#define CHECK_STRING(tctx, v, correct) \ + torture_assert_casestr_equal(tctx, v, correct, "Incorrect value") + +#define CHECK_NAME(tctx, _name, correct) do { \ + CHECK_STRING(tctx, (_name).name, (correct).name); \ + CHECK_VALUE(tctx, (uint8_t)(_name).type, (uint8_t)(correct).type); \ + CHECK_STRING(tctx, (_name).scope, (correct).scope); \ } while (0) /* test operations against a WINS server */ -static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, +static bool nbt_test_wins_name(struct torture_context *tctx, const char *address, struct nbt_name *name, uint16_t nb_flags) { struct nbt_name_register_wins io; @@ -61,31 +53,27 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, struct nbt_name_refresh_wins refresh; struct nbt_name_release release; NTSTATUS status; - struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); - BOOL ret = True; - const char *myaddress = talloc_strdup(mem_ctx, iface_best_ip(address)); + struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL); + const char *myaddress = talloc_strdup(tctx, iface_best_ip(address)); struct socket_address *socket_address; - socket_address = socket_address_from_strings(mem_ctx, + socket_address = socket_address_from_strings(tctx, nbtsock->sock->backend_name, myaddress, 0); - if (!socket_address) { - return False; - } + torture_assert(tctx, socket_address != NULL, + "Error getting address"); /* we do the listen here to ensure the WINS server receives the packets from the right IP */ status = socket_listen(nbtsock->sock, socket_address, 0, 0); - if (!NT_STATUS_IS_OK(status)) { - printf("socket_listen for WINS failed: %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "socket_listen for WINS failed"); talloc_free(socket_address); - printf("Testing name registration to WINS with name %s at %s nb_flags=0x%x\n", - nbt_name_string(mem_ctx, name), myaddress, nb_flags); + torture_comment(tctx, "Testing name registration to WINS with name %s at %s nb_flags=0x%x\n", + nbt_name_string(tctx, name), myaddress, nb_flags); - printf("release the name\n"); + torture_comment(tctx, "release the name\n"); release.in.name = *name; release.in.dest_addr = address; release.in.address = myaddress; @@ -94,55 +82,36 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, release.in.timeout = 3; release.in.retries = 0; - status = nbt_name_release(nbtsock, mem_ctx, &release); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } - CHECK_VALUE(release.out.rcode, 0); + status = nbt_name_release(nbtsock, tctx, &release); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address)); + CHECK_VALUE(tctx, release.out.rcode, 0); - printf("register the name\n"); + torture_comment(tctx, "register the name\n"); io.in.name = *name; - io.in.wins_servers = str_list_make(mem_ctx, address, NULL); - io.in.addresses = str_list_make(mem_ctx, myaddress, NULL); + io.in.wins_servers = str_list_make(tctx, address, NULL); + io.in.addresses = str_list_make(tctx, myaddress, NULL); io.in.nb_flags = nb_flags; io.in.ttl = 300000; - status = nbt_name_register_wins(nbtsock, mem_ctx, &io); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name register\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_register_wins(nbtsock, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name register", address)); - CHECK_STRING(io.out.wins_server, address); - CHECK_VALUE(io.out.rcode, 0); + CHECK_STRING(tctx, io.out.wins_server, address); + CHECK_VALUE(tctx, io.out.rcode, 0); if (name->type != NBT_NAME_MASTER && name->type != NBT_NAME_LOGON && name->type != NBT_NAME_BROWSER && (nb_flags & NBT_NM_GROUP)) { - printf("Try to register as non-group\n"); + torture_comment(tctx, "Try to register as non-group\n"); io.in.nb_flags &= ~NBT_NM_GROUP; - status = nbt_name_register_wins(nbtsock, mem_ctx, &io); - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register - %s\n", - address, nt_errstr(status)); - return False; - } - CHECK_VALUE(io.out.rcode, NBT_RCODE_ACT); + status = nbt_name_register_wins(nbtsock, tctx, &io); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name register\n", + address)); + CHECK_VALUE(tctx, io.out.rcode, NBT_RCODE_ACT); } - printf("query the name to make sure its there\n"); + torture_comment(tctx, "query the name to make sure its there\n"); query.in.name = *name; query.in.dest_addr = address; query.in.broadcast = False; @@ -150,92 +119,58 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, query.in.timeout = 3; query.in.retries = 0; - status = nbt_name_query(nbtsock, mem_ctx, &query); + status = nbt_name_query(nbtsock, tctx, &query); if (name->type == NBT_NAME_MASTER) { - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } - return ret; - } - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name query\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; + torture_assert_ntstatus_equal( + tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, + talloc_asprintf(tctx, "Bad response from %s for name query", address)); + return true; } + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address)); - CHECK_NAME(query.out.name, *name); - CHECK_VALUE(query.out.num_addrs, 1); + CHECK_NAME(tctx, query.out.name, *name); + CHECK_VALUE(tctx, query.out.num_addrs, 1); if (name->type != NBT_NAME_LOGON && (nb_flags & NBT_NM_GROUP)) { - CHECK_STRING(query.out.reply_addrs[0], "255.255.255.255"); + CHECK_STRING(tctx, query.out.reply_addrs[0], "255.255.255.255"); } else { - CHECK_STRING(query.out.reply_addrs[0], myaddress); + CHECK_STRING(tctx, query.out.reply_addrs[0], myaddress); } - query.in.name.name = strupper_talloc(mem_ctx, name->name); + query.in.name.name = strupper_talloc(tctx, name->name); if (query.in.name.name && strcmp(query.in.name.name, name->name) != 0) { - printf("check case sensitivity\n"); - status = nbt_name_query(nbtsock, mem_ctx, &query); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name query\n", address); - return False; - } - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } + torture_comment(tctx, "check case sensitivity\n"); + status = nbt_name_query(nbtsock, tctx, &query); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, talloc_asprintf(tctx, "Bad response from %s for name query", address)); } query.in.name = *name; if (name->scope) { - query.in.name.scope = strupper_talloc(mem_ctx, name->scope); + query.in.name.scope = strupper_talloc(tctx, name->scope); } if (query.in.name.scope && strcmp(query.in.name.scope, name->scope) != 0) { - printf("check case sensitivity on scope\n"); - status = nbt_name_query(nbtsock, mem_ctx, &query); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name query\n", address); - return False; - } - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } + torture_comment(tctx, "check case sensitivity on scope\n"); + status = nbt_name_query(nbtsock, tctx, &query); + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_OBJECT_NAME_NOT_FOUND, talloc_asprintf(tctx, "Bad response from %s for name query", address)); } - printf("refresh the name\n"); + torture_comment(tctx, "refresh the name\n"); refresh.in.name = *name; - refresh.in.wins_servers = str_list_make(mem_ctx, address, NULL); - refresh.in.addresses = str_list_make(mem_ctx, myaddress, NULL); + refresh.in.wins_servers = str_list_make(tctx, address, NULL); + refresh.in.addresses = str_list_make(tctx, myaddress, NULL); refresh.in.nb_flags = nb_flags; refresh.in.ttl = 12345; - status = nbt_name_refresh_wins(nbtsock, mem_ctx, &refresh); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name refresh\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name refresh - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_refresh_wins(nbtsock, tctx, &refresh); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name refresh", address)); - CHECK_STRING(refresh.out.wins_server, address); - CHECK_VALUE(refresh.out.rcode, 0); + CHECK_STRING(tctx, refresh.out.wins_server, address); + CHECK_VALUE(tctx, refresh.out.rcode, 0); - printf("release the name\n"); + torture_comment(tctx, "release the name\n"); release.in.name = *name; release.in.dest_addr = address; release.in.address = myaddress; @@ -244,59 +179,36 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, release.in.timeout = 3; release.in.retries = 0; - status = nbt_name_release(nbtsock, mem_ctx, &release); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } + status = nbt_name_release(nbtsock, tctx, &release); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, "Bad response from %s for name query", address)); - CHECK_NAME(release.out.name, *name); - CHECK_VALUE(release.out.rcode, 0); - - - printf("release again\n"); - status = nbt_name_release(nbtsock, mem_ctx, &release); - if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", address); - return False; - } - if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", - address, nt_errstr(status)); - return False; - } + CHECK_NAME(tctx, release.out.name, *name); + CHECK_VALUE(tctx, release.out.rcode, 0); + + torture_comment(tctx, "release again\n"); + status = nbt_name_release(nbtsock, tctx, &release); + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "Bad response from %s for name query", + address)); - CHECK_NAME(release.out.name, *name); - CHECK_VALUE(release.out.rcode, 0); + CHECK_NAME(tctx, release.out.name, *name); + CHECK_VALUE(tctx, release.out.rcode, 0); - printf("query the name to make sure its gone\n"); + torture_comment(tctx, "query the name to make sure its gone\n"); query.in.name = *name; - status = nbt_name_query(nbtsock, mem_ctx, &query); + status = nbt_name_query(nbtsock, tctx, &query); if (name->type != NBT_NAME_LOGON && (nb_flags & NBT_NM_GROUP)) { - if (!NT_STATUS_IS_OK(status)) { - printf("ERROR: Name query failed after group release - %s\n", - nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "ERROR: Name query failed after group release"); } else { - if (NT_STATUS_IS_OK(status)) { - printf("ERROR: Name query success after release\n"); - return False; - } - if (!NT_STATUS_EQUAL(status, NT_STATUS_OBJECT_NAME_NOT_FOUND)) { - printf("Incorrect response to name query - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_equal(tctx, status, + NT_STATUS_OBJECT_NAME_NOT_FOUND, + "Incorrect response to name query"); } - return ret; + return true; } @@ -304,64 +216,68 @@ static BOOL nbt_test_wins_name(TALLOC_CTX *mem_ctx, const char *address, /* test operations against a WINS server */ -static BOOL nbt_test_wins(TALLOC_CTX *mem_ctx, const char *address) +static bool nbt_test_wins(struct torture_context *tctx) { struct nbt_name name; - BOOL ret = True; uint32_t r = (uint32_t)(random() % (100000)); + const char *address; + bool ret = true; + + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; - name.name = talloc_asprintf(mem_ctx, "_TORTURE-%5u", r); + name.name = talloc_asprintf(tctx, "_TORTURE-%5u", r); name.type = NBT_NAME_CLIENT; name.scope = NULL; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.type = NBT_NAME_MASTER; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); name.type = NBT_NAME_SERVER; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.type = NBT_NAME_LOGON; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); name.type = NBT_NAME_BROWSER; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); name.type = NBT_NAME_PDC; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.type = 0xBF; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.type = 0xBE; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.scope = "example"; name.type = 0x72; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.scope = "example"; name.type = 0x71; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H | NBT_NM_GROUP); name.scope = "foo.example.com"; name.type = 0x72; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); - name.name = talloc_asprintf(mem_ctx, "_T\01-%5u.foo", r); - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + name.name = talloc_asprintf(tctx, "_T\01-%5u.foo", r); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); name.name = ""; - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); - name.name = talloc_asprintf(mem_ctx, "."); - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + name.name = talloc_asprintf(tctx, "."); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); - name.name = talloc_asprintf(mem_ctx, "%5u-\377\200\300FOO", r); - ret &= nbt_test_wins_name(mem_ctx, address, &name, NBT_NODE_H); + name.name = talloc_asprintf(tctx, "%5u-\377\200\300FOO", r); + ret &= nbt_test_wins_name(tctx, address, &name, NBT_NODE_H); return ret; } @@ -369,28 +285,12 @@ static BOOL nbt_test_wins(TALLOC_CTX *mem_ctx, const char *address) /* test WINS operations */ -BOOL torture_nbt_wins(struct torture_context *torture) +struct torture_suite *torture_nbt_wins(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ret &= nbt_test_wins(mem_ctx, address); + struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), + "WINS"); - talloc_free(mem_ctx); + torture_suite_add_simple_test(suite, "wins", nbt_test_wins); - return ret; + return suite; } diff --git a/source4/torture/nbt/winsbench.c b/source4/torture/nbt/winsbench.c index 6541de8e16..f7c76905ab 100644 --- a/source4/torture/nbt/winsbench.c +++ b/source4/torture/nbt/winsbench.c @@ -27,10 +27,11 @@ #include "system/network.h" #include "lib/socket/netif.h" #include "torture/torture.h" +#include "torture/nbt/proto.h" struct wins_state { int num_names; - BOOL *registered; + bool *registered; int pass_count; int fail_count; const char *wins_server; @@ -43,10 +44,10 @@ struct idx_state { struct wins_state *state; }; -struct nbt_name generate_name(TALLOC_CTX *mem_ctx, int idx) +struct nbt_name generate_name(TALLOC_CTX *tctx, int idx) { struct nbt_name name; - name.name = talloc_asprintf(mem_ctx, "WINSBench%6u", idx); + name.name = talloc_asprintf(tctx, "WINSBench%6u", idx); name.type = 0x4; name.scope = NULL; return name; @@ -64,7 +65,7 @@ static void register_handler(struct nbt_name_request *req) state->fail_count++; } else { state->pass_count++; - state->registered[istate->idx] = True; + state->registered[istate->idx] = true; } talloc_free(istate); } @@ -87,9 +88,9 @@ static void generate_register(struct nbt_name_socket *nbtsock, struct wins_state io.in.dest_addr = state->wins_server; io.in.address = state->my_ip; io.in.nb_flags = NBT_NODE_H; - io.in.register_demand = False; - io.in.broadcast = False; - io.in.multi_homed = False; + io.in.register_demand = false; + io.in.broadcast = false; + io.in.multi_homed = false; io.in.ttl = state->ttl; io.in.timeout = 2; io.in.retries = 1; @@ -116,7 +117,7 @@ static void release_handler(struct nbt_name_request *req) state->fail_count++; } else { state->pass_count++; - state->registered[istate->idx] = False; + state->registered[istate->idx] = false; } talloc_free(istate); } @@ -139,7 +140,7 @@ static void generate_release(struct nbt_name_socket *nbtsock, struct wins_state io.in.dest_addr = state->wins_server; io.in.address = state->my_ip; io.in.nb_flags = NBT_NODE_H; - io.in.broadcast = False; + io.in.broadcast = false; io.in.timeout = 2; io.in.retries = 1; @@ -184,8 +185,8 @@ static void generate_query(struct nbt_name_socket *nbtsock, struct wins_state *s io.in.name = generate_name(tmp_ctx, idx); io.in.dest_addr = state->wins_server; - io.in.broadcast = False; - io.in.wins_lookup = True; + io.in.broadcast = false; + io.in.wins_lookup = true; io.in.timeout = 2; io.in.retries = 1; @@ -218,23 +219,28 @@ static void generate_request(struct nbt_name_socket *nbtsock, struct wins_state /* benchmark simple name queries */ -static BOOL bench_wins(TALLOC_CTX *mem_ctx, struct nbt_name *name, const char *address) +static bool bench_wins(struct torture_context *tctx) { - struct nbt_name_socket *nbtsock = nbt_name_socket_init(mem_ctx, NULL); + struct nbt_name_socket *nbtsock = nbt_name_socket_init(tctx, NULL); int num_sent=0; struct timeval tv = timeval_current(); - BOOL ret = True; - int timelimit = lp_parm_int(-1, "torture", "timelimit", 10); + bool ret = true; + int timelimit = torture_setting_int(tctx, "timelimit", 10); struct wins_state *state; extern int torture_entries; struct socket_address *my_ip; + struct nbt_name name; + const char *address; + + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; state = talloc_zero(nbtsock, struct wins_state); state->num_names = torture_entries; - state->registered = talloc_zero_array(state, BOOL, state->num_names); + state->registered = talloc_zero_array(state, bool, state->num_names); state->wins_server = address; - state->my_ip = talloc_strdup(mem_ctx, iface_best_ip(address)); + state->my_ip = talloc_strdup(tctx, iface_best_ip(address)); state->ttl = timelimit; my_ip = socket_address_from_strings(nbtsock, nbtsock->sock->backend_name, @@ -242,13 +248,13 @@ static BOOL bench_wins(TALLOC_CTX *mem_ctx, struct nbt_name *name, const char *a socket_listen(nbtsock->sock, my_ip, 0, 0); - printf("Running for %d seconds\n", timelimit); + torture_comment(tctx, "Running for %d seconds\n", timelimit); while (timeval_elapsed(&tv) < timelimit) { while (num_sent - (state->pass_count+state->fail_count) < 10) { generate_request(nbtsock, state, num_sent % state->num_names); num_sent++; if (num_sent % 50 == 0) { - printf("%.1f queries per second (%d failures) \r", + torture_comment(tctx, "%.1f queries per second (%d failures) \r", state->pass_count / timeval_elapsed(&tv), state->fail_count); } @@ -261,7 +267,7 @@ static BOOL bench_wins(TALLOC_CTX *mem_ctx, struct nbt_name *name, const char *a event_loop_once(nbtsock->event_ctx); } - printf("%.1f queries per second (%d failures) \n", + torture_comment(tctx, "%.1f queries per second (%d failures) \n", state->pass_count / timeval_elapsed(&tv), state->fail_count); @@ -274,28 +280,13 @@ static BOOL bench_wins(TALLOC_CTX *mem_ctx, struct nbt_name *name, const char *a benchmark how fast a WINS server can respond to a mixture of registration/refresh/release and name query requests */ -BOOL torture_bench_wins(struct torture_context *torture) +struct torture_suite *torture_bench_wins(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, event_context_find(mem_ctx)); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "BENCH-WINS"); - ret &= bench_wins(mem_ctx, &name, address); + torture_suite_add_simple_test(suite, "wins", bench_wins); - talloc_free(mem_ctx); - - return ret; + return suite; } diff --git a/source4/torture/nbt/winsreplication.c b/source4/torture/nbt/winsreplication.c index fe0d0784e1..0639155f00 100644 --- a/source4/torture/nbt/winsreplication.c +++ b/source4/torture/nbt/winsreplication.c @@ -30,40 +30,24 @@ #include "lib/socket/netif.h" #include "librpc/gen_ndr/ndr_nbt.h" #include "torture/torture.h" +#include "torture/nbt/proto.h" -#define CHECK_STATUS(status, correct) do { \ - if (!NT_STATUS_EQUAL(status, correct)) { \ - printf("(%s) Incorrect status %s - should be %s\n", \ - __location__, nt_errstr(status), nt_errstr(correct)); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_STATUS(tctx, status, correct) \ + torture_assert_ntstatus_equal(tctx, status, correct, \ + "Incorrect status") -#define CHECK_VALUE(v, correct) do { \ - if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%d - should be %d\n", \ - __location__, #v, v, correct); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_VALUE(tctx, v, correct) \ + torture_assert(tctx, (v) == (correct), \ + talloc_asprintf(tctx, "Incorrect value %s=%d - should be %d", \ + #v, v, correct)) -#define CHECK_VALUE_UINT64(v, correct) do { \ - if ((v) != (correct)) { \ - printf("(%s) Incorrect value %s=%llu - should be %llu\n", \ - __location__, #v, (long long)v, (long long)correct); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_VALUE_UINT64(tctx, v, correct) \ + torture_assert(tctx, (v) == (correct), \ + talloc_asprintf(tctx, "Incorrect value %s=%llu - should be %llu", \ + #v, (long long)v, (long long)correct)) -#define CHECK_VALUE_STRING(v, correct) do { \ - if ( ((!v) && (correct)) || \ - ((v) && (!correct)) || \ - ((v) && (correct) && strcmp(v,correct) != 0)) { \ - printf("(%s) Incorrect value %s='%s' - should be '%s'\n", \ - __location__, #v, v, correct); \ - ret = False; \ - goto done; \ - }} while (0) +#define CHECK_VALUE_STRING(tctx, v, correct) \ + torture_assert_str_equal(tctx, v, correct, "Invalid value") #define _NBT_NAME(n,t,s) {\ .name = n,\ @@ -97,9 +81,9 @@ static const char *wrepl_name_state_string(enum wrepl_name_state state) test how assoc_ctx's are only usable on the connection they are created on. */ -static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address) +static bool test_assoc_ctx1(struct torture_context *tctx) { - BOOL ret = True; + bool ret = true; struct wrepl_request *req; struct wrepl_socket *wrepl_socket1; struct wrepl_associate associate1; @@ -111,76 +95,79 @@ static BOOL test_assoc_ctx1(TALLOC_CTX *mem_ctx, const char *address) struct wrepl_packet *rep_packet; struct wrepl_associate_stop assoc_stop; NTSTATUS status; + struct nbt_name name; + const char *address; - if (!lp_parm_bool(-1, "torture", "dangerous", False)) { - printf("winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use\n"); - return True; + if (!torture_setting_bool(tctx, "dangerous", false)) { + torture_skip(tctx, "winsrepl: cross connection assoc_ctx usage disabled - enable dangerous tests to use"); } - printf("Test if assoc_ctx is only valid on the conection it was created on\n"); + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; + + torture_comment(tctx, "Test if assoc_ctx is only valid on the conection it was created on\n"); - wrepl_socket1 = wrepl_socket_init(mem_ctx, NULL); - wrepl_socket2 = wrepl_socket_init(mem_ctx, NULL); + wrepl_socket1 = wrepl_socket_init(tctx, NULL); + wrepl_socket2 = wrepl_socket_init(tctx, NULL); - printf("Setup 2 wrepl connections\n"); + torture_comment(tctx, "Setup 2 wrepl connections\n"); status = wrepl_connect(wrepl_socket1, NULL, address); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); status = wrepl_connect(wrepl_socket2, NULL, address); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Send a start association request (conn1)\n"); + torture_comment(tctx, "Send a start association request (conn1)\n"); status = wrepl_associate(wrepl_socket1, &associate1); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("association context (conn1): 0x%x\n", associate1.out.assoc_ctx); + torture_comment(tctx, "association context (conn1): 0x%x\n", associate1.out.assoc_ctx); - printf("Send a start association request (conn2)\n"); + torture_comment(tctx, "Send a start association request (conn2)\n"); status = wrepl_associate(wrepl_socket2, &associate2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("association context (conn2): 0x%x\n", associate2.out.assoc_ctx); + torture_comment(tctx, "association context (conn2): 0x%x\n", associate2.out.assoc_ctx); - printf("Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n"); + torture_comment(tctx, "Send a replication table query, with assoc 1 (conn2), the anwser should be on conn1\n"); ZERO_STRUCT(packet); packet.opcode = WREPL_OPCODE_BITS; packet.assoc_ctx = associate1.out.assoc_ctx; packet.mess_type = WREPL_REPLICATION; packet.message.replication.command = WREPL_REPL_TABLE_QUERY; ZERO_STRUCT(ctrl); - ctrl.send_only = True; + ctrl.send_only = true; req = wrepl_request_send(wrepl_socket2, &packet, &ctrl); - status = wrepl_request_recv(req, mem_ctx, &rep_packet); - CHECK_STATUS(status, NT_STATUS_OK); + status = wrepl_request_recv(req, tctx, &rep_packet); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Send a association request (conn2), to make sure the last request was ignored\n"); + torture_comment(tctx, "Send a association request (conn2), to make sure the last request was ignored\n"); status = wrepl_associate(wrepl_socket2, &associate2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n"); + torture_comment(tctx, "Send a replication table query, with invalid assoc (conn1), receive answer from conn2\n"); pull_table.in.assoc_ctx = 0; req = wrepl_pull_table_send(wrepl_socket1, &pull_table); - status = wrepl_request_recv(req, mem_ctx, &rep_packet); - CHECK_STATUS(status, NT_STATUS_OK); + status = wrepl_request_recv(req, tctx, &rep_packet); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Send a association request (conn1), to make sure the last request was handled correct\n"); + torture_comment(tctx, "Send a association request (conn1), to make sure the last request was handled correct\n"); status = wrepl_associate(wrepl_socket1, &associate2); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); assoc_stop.in.assoc_ctx = associate1.out.assoc_ctx; assoc_stop.in.reason = 4; - printf("Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason); + torture_comment(tctx, "Send a association stop request (conn1), reson: %u\n", assoc_stop.in.reason); status = wrepl_associate_stop(wrepl_socket1, &assoc_stop); - CHECK_STATUS(status, NT_STATUS_END_OF_FILE); + CHECK_STATUS(tctx, status, NT_STATUS_END_OF_FILE); assoc_stop.in.assoc_ctx = associate2.out.assoc_ctx; assoc_stop.in.reason = 0; - printf("Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason); + torture_comment(tctx, "Send a association stop request (conn2), reson: %u\n", assoc_stop.in.reason); status = wrepl_associate_stop(wrepl_socket2, &assoc_stop); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); -done: - printf("Close 2 wrepl connections\n"); + torture_comment(tctx, "Close 2 wrepl connections\n"); talloc_free(wrepl_socket1); talloc_free(wrepl_socket2); return ret; @@ -189,62 +176,66 @@ done: /* test if we always get back the same assoc_ctx */ -static BOOL test_assoc_ctx2(TALLOC_CTX *mem_ctx, const char *address) +static bool test_assoc_ctx2(struct torture_context *tctx) { - BOOL ret = True; struct wrepl_socket *wrepl_socket; struct wrepl_associate associate; uint32_t assoc_ctx1; + struct nbt_name name; NTSTATUS status; + const char *address; + + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; - printf("Test if we always get back the same assoc_ctx\n"); + torture_comment(tctx, "Test if we always get back the same assoc_ctx\n"); - wrepl_socket = wrepl_socket_init(mem_ctx, NULL); + wrepl_socket = wrepl_socket_init(tctx, NULL); - printf("Setup wrepl connections\n"); + torture_comment(tctx, "Setup wrepl connections\n"); status = wrepl_connect(wrepl_socket, NULL, address); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - - printf("Send 1st start association request\n"); + torture_comment(tctx, "Send 1st start association request\n"); status = wrepl_associate(wrepl_socket, &associate); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); assoc_ctx1 = associate.out.assoc_ctx; - printf("1st association context: 0x%x\n", associate.out.assoc_ctx); + torture_comment(tctx, "1st association context: 0x%x\n", associate.out.assoc_ctx); - printf("Send 2nd start association request\n"); + torture_comment(tctx, "Send 2nd start association request\n"); status = wrepl_associate(wrepl_socket, &associate); - CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1); - CHECK_STATUS(status, NT_STATUS_OK); - printf("2nd association context: 0x%x\n", associate.out.assoc_ctx); + torture_assert_ntstatus_ok(tctx, status, "2nd start association failed"); + torture_assert(tctx, associate.out.assoc_ctx == assoc_ctx1, + "Different context returned"); + torture_comment(tctx, "2nd association context: 0x%x\n", associate.out.assoc_ctx); - printf("Send 3rd start association request\n"); + torture_comment(tctx, "Send 3rd start association request\n"); status = wrepl_associate(wrepl_socket, &associate); - CHECK_VALUE(associate.out.assoc_ctx, assoc_ctx1); - CHECK_STATUS(status, NT_STATUS_OK); - printf("3rd association context: 0x%x\n", associate.out.assoc_ctx); + torture_assert(tctx, associate.out.assoc_ctx == assoc_ctx1, + "Different context returned"); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + torture_comment(tctx, "3rd association context: 0x%x\n", associate.out.assoc_ctx); -done: - printf("Close wrepl connections\n"); + torture_comment(tctx, "Close wrepl connections\n"); talloc_free(wrepl_socket); - return ret; + return true; } /* display a replication entry */ -static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name) +static void display_entry(TALLOC_CTX *tctx, struct wrepl_name *name) { int i; - printf("%s\n", nbt_name_string(mem_ctx, &name->name)); - printf("\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n", + torture_comment(tctx, "%s\n", nbt_name_string(tctx, &name->name)); + torture_comment(tctx, "\tTYPE:%u STATE:%u NODE:%u STATIC:%u VERSION_ID: %llu\n", name->type, name->state, name->node, name->is_static, (long long)name->version_id); - printf("\tRAW_FLAGS: 0x%08X OWNER: %-15s\n", + torture_comment(tctx, "\tRAW_FLAGS: 0x%08X OWNER: %-15s\n", name->raw_flags, name->owner); for (i=0;inum_addresses;i++) { - printf("\tADDR: %-15s OWNER: %-15s\n", + torture_comment(tctx, "\tADDR: %-15s OWNER: %-15s\n", name->addresses[i].address, name->addresses[i].owner); } } @@ -252,35 +243,39 @@ static void display_entry(TALLOC_CTX *mem_ctx, struct wrepl_name *name) /* test a full replication dump from a WINS server */ -static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) +static bool test_wins_replication(struct torture_context *tctx) { - BOOL ret = True; struct wrepl_socket *wrepl_socket; NTSTATUS status; int i, j; struct wrepl_associate associate; struct wrepl_pull_table pull_table; struct wrepl_pull_names pull_names; + struct nbt_name name; + const char *address; - printf("Test one pull replication cycle\n"); + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; - wrepl_socket = wrepl_socket_init(mem_ctx, NULL); + torture_comment(tctx, "Test one pull replication cycle\n"); + + wrepl_socket = wrepl_socket_init(tctx, NULL); - printf("Setup wrepl connections\n"); + torture_comment(tctx, "Setup wrepl connections\n"); status = wrepl_connect(wrepl_socket, NULL, address); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Send a start association request\n"); + torture_comment(tctx, "Send a start association request\n"); status = wrepl_associate(wrepl_socket, &associate); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("association context: 0x%x\n", associate.out.assoc_ctx); + torture_comment(tctx, "association context: 0x%x\n", associate.out.assoc_ctx); - printf("Send a replication table query\n"); + torture_comment(tctx, "Send a replication table query\n"); pull_table.in.assoc_ctx = associate.out.assoc_ctx; - status = wrepl_pull_table(wrepl_socket, mem_ctx, &pull_table); + status = wrepl_pull_table(wrepl_socket, tctx, &pull_table); if (NT_STATUS_EQUAL(NT_STATUS_NETWORK_ACCESS_DENIED,status)) { struct wrepl_packet packet; struct wrepl_request *req; @@ -294,17 +289,15 @@ static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) req = wrepl_request_send(wrepl_socket, &packet, NULL); talloc_free(req); - printf("failed - We are not a valid pull partner for the server\n"); - ret = False; - goto done; + torture_fail(tctx, "We are not a valid pull partner for the server"); } - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Found %d replication partners\n", pull_table.out.num_partners); + torture_comment(tctx, "Found %d replication partners\n", pull_table.out.num_partners); for (i=0;iaddress, (long long)partner->max_version, (long long)partner->min_version, @@ -313,20 +306,19 @@ static BOOL test_wins_replication(TALLOC_CTX *mem_ctx, const char *address) pull_names.in.assoc_ctx = associate.out.assoc_ctx; pull_names.in.partner = *partner; - status = wrepl_pull_names(wrepl_socket, mem_ctx, &pull_names); - CHECK_STATUS(status, NT_STATUS_OK); + status = wrepl_pull_names(wrepl_socket, tctx, &pull_names); + CHECK_STATUS(tctx, status, NT_STATUS_OK); - printf("Received %d names\n", pull_names.out.num_names); + torture_comment(tctx, "Received %d names\n", pull_names.out.num_names); for (j=0;jaddress = address; ctx->pull = wrepl_socket_init(ctx, NULL); if (!ctx->pull) return NULL; - printf("Setup wrepl conflict pull connection\n"); + torture_comment(tctx, "Setup wrepl conflict pull connection\n"); status = wrepl_connect(ctx->pull, NULL, ctx->address); if (!NT_STATUS_IS_OK(status)) return NULL; @@ -624,12 +616,12 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem ctx->nbtsock = nbt_name_socket_init(ctx, NULL); if (!ctx->nbtsock) return NULL; - ctx->myaddr = socket_address_from_strings(mem_ctx, ctx->nbtsock->sock->backend_name, iface_best_ip(address), 0); + ctx->myaddr = socket_address_from_strings(tctx, ctx->nbtsock->sock->backend_name, iface_best_ip(address), 0); if (!ctx->myaddr) return NULL; for (i = 0; i < iface_count(); i++) { if (strcmp(ctx->myaddr->addr, iface_n_ip(i)) == 0) continue; - ctx->myaddr2 = socket_address_from_strings(mem_ctx, ctx->nbtsock->sock->backend_name, iface_n_ip(i), 0); + ctx->myaddr2 = socket_address_from_strings(tctx, ctx->nbtsock->sock->backend_name, iface_n_ip(i), 0); if (!ctx->myaddr2) return NULL; break; } @@ -641,7 +633,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem if (!ctx->nbtsock_srv) return NULL; /* Make a port 137 version of ctx->myaddr */ - nbt_srv_addr = socket_address_from_strings(mem_ctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port()); + nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr->addr, lp_nbt_port()); if (!nbt_srv_addr) return NULL; /* And if possible, bind to it. This won't work unless we are root or in sockewrapper */ @@ -664,7 +656,7 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem if (!ctx->nbtsock_srv2) return NULL; /* Make a port 137 version of ctx->myaddr2 */ - nbt_srv_addr = socket_address_from_strings(mem_ctx, + nbt_srv_addr = socket_address_from_strings(tctx, ctx->nbtsock_srv->sock->backend_name, ctx->myaddr2->addr, lp_nbt_port()); if (!nbt_srv_addr) return NULL; @@ -713,11 +705,11 @@ static struct test_wrepl_conflict_conn *test_create_conflict_ctx(TALLOC_CTX *mem return ctx; } -static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx, +static bool test_wrepl_update_one(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx, const struct wrepl_wins_owner *owner, const struct wrepl_wins_name *name) { - BOOL ret = True; struct wrepl_socket *wrepl_socket; struct wrepl_associate associate; struct wrepl_packet update_packet, repl_send; @@ -733,10 +725,10 @@ static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx, wrepl_socket = wrepl_socket_init(ctx, NULL); status = wrepl_connect(wrepl_socket, NULL, ctx->address); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); status = wrepl_associate(wrepl_socket, &associate); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); assoc_ctx = associate.out.assoc_ctx; /* now send a WREPL_REPL_UPDATE message */ @@ -755,9 +747,9 @@ static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx, status = wrepl_request(wrepl_socket, wrepl_socket, &update_packet, &repl_recv); - CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VALUE(repl_recv->mess_type, WREPL_REPLICATION); - CHECK_VALUE(repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VALUE(tctx, repl_recv->mess_type, WREPL_REPLICATION); + CHECK_VALUE(tctx, repl_recv->message.replication.command, WREPL_REPL_SEND_REQUEST); send_request = &repl_recv->message.replication.info.owner; ZERO_STRUCT(repl_send); @@ -774,21 +766,20 @@ static BOOL test_wrepl_update_one(struct test_wrepl_conflict_conn *ctx, status = wrepl_request(wrepl_socket, wrepl_socket, &repl_send, &repl_recv); - CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VALUE(repl_recv->mess_type, WREPL_STOP_ASSOCIATION); - CHECK_VALUE(repl_recv->message.stop.reason, 0); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VALUE(tctx, repl_recv->mess_type, WREPL_STOP_ASSOCIATION); + CHECK_VALUE(tctx, repl_recv->message.stop.reason, 0); -done: talloc_free(wrepl_socket); - return ret; + return true; } -static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx, +static bool test_wrepl_is_applied(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx, const struct wrepl_wins_owner *owner, const struct wrepl_wins_name *name, - BOOL expected) + bool expected) { - BOOL ret = True; NTSTATUS status; struct wrepl_pull_names pull_names; struct wrepl_name *names; @@ -798,8 +789,9 @@ static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx, pull_names.in.partner.min_version = pull_names.in.partner.max_version; status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names); - CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VALUE(pull_names.out.num_names, (expected?1:0)); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + torture_assert(tctx, pull_names.out.num_names == (expected?1:0), + "Invalid number of records returned"); names = pull_names.out.names; @@ -808,34 +800,33 @@ static BOOL test_wrepl_is_applied(struct test_wrepl_conflict_conn *ctx, names[0].state, names[0].node, names[0].is_static); - CHECK_VALUE(names[0].name.type, name->name->type); - CHECK_VALUE_STRING(names[0].name.name, name->name->name); - CHECK_VALUE_STRING(names[0].name.scope, name->name->scope); - CHECK_VALUE(flags, name->flags); - CHECK_VALUE_UINT64(names[0].version_id, name->id); + CHECK_VALUE(tctx, names[0].name.type, name->name->type); + CHECK_VALUE_STRING(tctx, names[0].name.name, name->name->name); + CHECK_VALUE_STRING(tctx, names[0].name.scope, name->name->scope); + CHECK_VALUE(tctx, flags, name->flags); + CHECK_VALUE_UINT64(tctx, names[0].version_id, name->id); if (flags & 2) { - CHECK_VALUE(names[0].num_addresses, + CHECK_VALUE(tctx, names[0].num_addresses, name->addresses.addresses.num_ips); } else { - CHECK_VALUE(names[0].num_addresses, 1); - CHECK_VALUE_STRING(names[0].addresses[0].address, + CHECK_VALUE(tctx, names[0].num_addresses, 1); + CHECK_VALUE_STRING(tctx, names[0].addresses[0].address, name->addresses.ip); } } -done: talloc_free(pull_names.out.names); - return ret; + return true; } -static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx, +static bool test_wrepl_mhomed_merged(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx, const struct wrepl_wins_owner *owner1, uint32_t num_ips1, const struct wrepl_ip *ips1, const struct wrepl_wins_owner *owner2, uint32_t num_ips2, const struct wrepl_ip *ips2, const struct wrepl_wins_name *name2) { - BOOL ret = True; NTSTATUS status; struct wrepl_pull_names pull_names; struct wrepl_name *names; @@ -857,8 +848,8 @@ static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx, pull_names.in.partner.min_version = pull_names.in.partner.max_version; status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names); - CHECK_STATUS(status, NT_STATUS_OK); - CHECK_VALUE(pull_names.out.num_names, 1); + CHECK_STATUS(tctx, status, NT_STATUS_OK); + CHECK_VALUE(tctx, pull_names.out.num_names, 1); names = pull_names.out.names; @@ -866,23 +857,23 @@ static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx, names[0].state, names[0].node, names[0].is_static); - CHECK_VALUE(names[0].name.type, name2->name->type); - CHECK_VALUE_STRING(names[0].name.name, name2->name->name); - CHECK_VALUE_STRING(names[0].name.scope, name2->name->scope); - CHECK_VALUE(flags, name2->flags | WREPL_TYPE_MHOMED); - CHECK_VALUE_UINT64(names[0].version_id, name2->id); + CHECK_VALUE(tctx, names[0].name.type, name2->name->type); + CHECK_VALUE_STRING(tctx, names[0].name.name, name2->name->name); + CHECK_VALUE_STRING(tctx, names[0].name.scope, name2->name->scope); + CHECK_VALUE(tctx, flags, name2->flags | WREPL_TYPE_MHOMED); + CHECK_VALUE_UINT64(tctx, names[0].version_id, name2->id); - CHECK_VALUE(names[0].num_addresses, num_ips); + CHECK_VALUE(tctx, names[0].num_addresses, num_ips); for (i = 0; i < names[0].num_addresses; i++) { const char *addr = names[0].addresses[i].address; const char *owner = names[0].addresses[i].owner; - BOOL found = False; + bool found = false; for (j = 0; j < num_ips2; j++) { if (strcmp(addr, ips2[j].ip) == 0) { - found = True; - CHECK_VALUE_STRING(owner, owner2->address); + found = true; + CHECK_VALUE_STRING(tctx, owner, owner2->address); break; } } @@ -891,22 +882,22 @@ static BOOL test_wrepl_mhomed_merged(struct test_wrepl_conflict_conn *ctx, for (j = 0; j < num_ips1; j++) { if (strcmp(addr, ips1[j].ip) == 0) { - found = True; - CHECK_VALUE_STRING(owner, owner1->address); + found = true; + CHECK_VALUE_STRING(tctx, owner, owner1->address); break; } } if (found) continue; - CHECK_VALUE_STRING(addr, "not found in address list"); + CHECK_VALUE_STRING(tctx, addr, "not found in address list"); } -done: talloc_free(pull_names.out.names); - return ret; + return true; } -static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, +static bool test_wrepl_sgroup_merged(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx, struct wrepl_wins_owner *merge_owner, struct wrepl_wins_owner *owner1, uint32_t num_ips1, const struct wrepl_ip *ips1, @@ -914,7 +905,6 @@ static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, uint32_t num_ips2, const struct wrepl_ip *ips2, const struct wrepl_wins_name *name2) { - BOOL ret = True; NTSTATUS status; struct wrepl_pull_names pull_names; struct wrepl_name *names; @@ -947,7 +937,7 @@ static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, pull_names.in.partner.max_version = 0; status = wrepl_pull_names(ctx->pull, ctx->pull, &pull_names); - CHECK_STATUS(status, NT_STATUS_OK); + CHECK_STATUS(tctx, status, NT_STATUS_OK); names = pull_names.out.names; @@ -965,30 +955,30 @@ static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, } if (!name) { - printf("%s: Name '%s' not found\n", __location__, nbt_name_string(ctx, name2->name)); - return False; + torture_comment(tctx, "%s: Name '%s' not found\n", __location__, nbt_name_string(ctx, name2->name)); + return false; } flags = WREPL_NAME_FLAGS(name->type, name->state, name->node, name->is_static); - CHECK_VALUE(name->name.type, name2->name->type); - CHECK_VALUE_STRING(name->name.name, name2->name->name); - CHECK_VALUE_STRING(name->name.scope, name2->name->scope); - CHECK_VALUE(flags, name2->flags); + CHECK_VALUE(tctx, name->name.type, name2->name->type); + CHECK_VALUE_STRING(tctx, name->name.name, name2->name->name); + CHECK_VALUE_STRING(tctx, name->name.scope, name2->name->scope); + CHECK_VALUE(tctx, flags, name2->flags); - CHECK_VALUE(name->num_addresses, num_ips); + CHECK_VALUE(tctx, name->num_addresses, num_ips); for (i = 0; i < name->num_addresses; i++) { const char *addr = name->addresses[i].address; const char *owner = name->addresses[i].owner; - BOOL found = False; + bool found = false; for (j = 0; j < num_ips2; j++) { if (strcmp(addr, ips2[j].ip) == 0) { - found = True; - CHECK_VALUE_STRING(owner, ips2[j].owner); + found = true; + CHECK_VALUE_STRING(tctx, owner, ips2[j].owner); break; } } @@ -997,11 +987,11 @@ static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, for (j = 0; j < num_ips1; j++) { if (strcmp(addr, ips1[j].ip) == 0) { - found = True; + found = true; if (owner1 == &ctx->c) { - CHECK_VALUE_STRING(owner, owner1->address); + CHECK_VALUE_STRING(tctx, owner, owner1->address); } else { - CHECK_VALUE_STRING(owner, ips1[j].owner); + CHECK_VALUE_STRING(tctx, owner, ips1[j].owner); } break; } @@ -1009,16 +999,16 @@ static BOOL test_wrepl_sgroup_merged(struct test_wrepl_conflict_conn *ctx, if (found) continue; - CHECK_VALUE_STRING(addr, "not found in address list"); + CHECK_VALUE_STRING(tctx, addr, "not found in address list"); } -done: talloc_free(pull_names.out.names); - return ret; + return true; } -static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) +static bool test_conflict_same_owner(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx) { - BOOL ret = True; + static bool ret = true; struct nbt_name name; struct wrepl_wins_name wins_name1; struct wrepl_wins_name wins_name2; @@ -1031,7 +1021,7 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) enum wrepl_name_type type; enum wrepl_name_state state; enum wrepl_name_node node; - BOOL is_static; + bool is_static; uint32_t num_ips; const struct wrepl_ip *ips; } records[] = { @@ -1039,77 +1029,77 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, },{ .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, },{ .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_2), .ips = addresses_A_2, },{ .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = True, + .is_static = true, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, },{ .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_2), .ips = addresses_A_2, },{ .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_2), .ips = addresses_A_2, },{ .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, },{ .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_2), .ips = addresses_A_2, },{ .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, },{ .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, },{ .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, },{ @@ -1117,7 +1107,7 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, } @@ -1133,7 +1123,7 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) for (j=0; ret && j < ARRAY_SIZE(types); j++) { name.type = types[j]; - printf("Test Replica Conflicts with same owner[%s] for %s\n", + torture_comment(tctx, "Test Replica Conflicts with same owner[%s] for %s\n", nbt_name_string(ctx, &name), ctx->a.address); for(i=0; ret && i < ARRAY_SIZE(records); i++) { @@ -1142,7 +1132,7 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) wins_name_cur = wins_name_tmp; if (i > 0) { - printf("%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n", + torture_comment(tctx, "%s,%s%s vs. %s,%s%s with %s ip(s) => %s\n", wrepl_name_type_string(records[i-1].type), wrepl_name_state_string(records[i-1].state), (records[i-1].is_static?",static":""), @@ -1167,19 +1157,19 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) } wins_name_cur->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->a,wins_name_cur); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->a,wins_name_cur); if (records[i].state == WREPL_STATE_RELEASED) { - ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_last, False); - ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, False); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_last, false); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_cur, false); } else { - ret &= test_wrepl_is_applied(ctx, &ctx->a, wins_name_cur, True); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->a, wins_name_cur, true); } /* the first one is a cleanup run */ - if (!ret && i == 0) ret = True; + if (!ret && i == 0) ret = true; if (!ret) { - printf("conflict handled wrong or record[%u]: %s\n", i, __location__); + torture_comment(tctx, "conflict handled wrong or record[%u]: %s\n", i, __location__); return ret; } } @@ -1187,9 +1177,10 @@ static BOOL test_conflict_same_owner(struct test_wrepl_conflict_conn *ctx) return ret; } -static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) +static bool test_conflict_different_owner(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx) { - BOOL ret = True; + bool ret = true; struct wrepl_wins_name wins_name1; struct wrepl_wins_name wins_name2; struct wrepl_wins_name *wins_name_r1; @@ -1199,20 +1190,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) const char *line; /* just better debugging */ struct nbt_name name; const char *comment; - BOOL extra; /* not the worst case, this is an extra test */ - BOOL cleanup; + bool extra; /* not the worst case, this is an extra test */ + bool cleanup; struct { struct wrepl_wins_owner *owner; enum wrepl_name_type type; enum wrepl_name_state state; enum wrepl_name_node node; - BOOL is_static; + bool is_static; uint32_t num_ips; const struct wrepl_ip *ips; - BOOL apply_expected; - BOOL sgroup_merge; + bool apply_expected; + bool sgroup_merge; struct wrepl_wins_owner *merge_owner; - BOOL sgroup_cleanup; + bool sgroup_cleanup; } r1, r2; } records[] = { /* @@ -1223,26 +1214,26 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True /* ignored */ + .apply_expected = true /* ignored */ }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True /* ignored */ + .apply_expected = true /* ignored */ } }, @@ -1261,20 +1252,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -1290,20 +1281,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -1319,20 +1310,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -1348,20 +1339,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -1377,20 +1368,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -1406,20 +1397,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -1439,20 +1430,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -1468,20 +1459,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -1497,20 +1488,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -1526,20 +1517,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -1555,20 +1546,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -1584,20 +1575,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -1616,20 +1607,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -1645,20 +1636,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -1674,20 +1665,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1703,20 +1694,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1732,20 +1723,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1761,20 +1752,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1793,20 +1784,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1822,20 +1813,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false } }, @@ -1851,20 +1842,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1880,20 +1871,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1909,20 +1900,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1938,20 +1929,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -1970,20 +1961,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -1999,20 +1990,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2028,20 +2019,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2057,20 +2048,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2086,20 +2077,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2115,20 +2106,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2147,20 +2138,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2176,20 +2167,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2205,20 +2196,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2234,20 +2225,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2263,20 +2254,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2292,20 +2283,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2324,20 +2315,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2353,20 +2344,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2382,20 +2373,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2411,20 +2402,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2440,20 +2431,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2469,20 +2460,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2501,20 +2492,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2530,20 +2521,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2559,20 +2550,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2588,20 +2579,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2617,20 +2608,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2646,20 +2637,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2678,20 +2669,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2707,20 +2698,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -2736,20 +2727,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2765,20 +2756,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2794,20 +2785,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2823,20 +2814,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2855,20 +2846,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2884,20 +2875,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -2913,20 +2904,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -2942,20 +2933,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -2971,20 +2962,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3000,20 +2991,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3032,20 +3023,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3061,20 +3052,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3090,20 +3081,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3119,20 +3110,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3151,20 +3142,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -3180,20 +3171,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -3209,20 +3200,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3238,20 +3229,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3267,20 +3258,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3296,20 +3287,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3328,20 +3319,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3357,20 +3348,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -3386,20 +3377,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3415,20 +3406,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3444,20 +3435,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3473,20 +3464,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3505,20 +3496,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3534,20 +3525,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false } }, @@ -3563,20 +3554,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3592,20 +3583,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3621,20 +3612,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3650,20 +3641,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3682,20 +3673,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -3711,20 +3702,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false } }, @@ -3740,20 +3731,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3769,20 +3760,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3798,20 +3789,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true } }, @@ -3827,20 +3818,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }, @@ -3859,20 +3850,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -3888,20 +3879,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false } }, @@ -3917,20 +3908,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -3946,20 +3937,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_RELEASED, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = False + .apply_expected = false }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -3975,20 +3966,20 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true } }, @@ -4004,45 +3995,45 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->b, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True, + .apply_expected = true, } }, /* @@ -4056,27 +4047,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4 vs. B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = False, - .sgroup_cleanup = True + .apply_expected = false, + .sgroup_cleanup = true } }, /* @@ -4087,27 +4078,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4 vs. B:NULL", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, - .sgroup_cleanup = True + .apply_expected = false, + .sgroup_cleanup = true } }, /* @@ -4118,51 +4109,51 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4_X_3_4 vs. B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_X_3_4), .ips = addresses_A_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = False, + .apply_expected = false, } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->x, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, } }, /* @@ -4173,27 +4164,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4 vs. B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True, - .sgroup_cleanup = True + .apply_expected = true, + .sgroup_cleanup = true } }, /* @@ -4204,27 +4195,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4 vs. B:A_3_4_OWNER_B", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_OWNER_B), .ips = addresses_A_3_4_OWNER_B, - .apply_expected = True, - .sgroup_cleanup = True + .apply_expected = true, + .sgroup_cleanup = true } }, /* @@ -4235,27 +4226,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4_OWNER_B vs. B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_OWNER_B), .ips = addresses_A_3_4_OWNER_B, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True, - .sgroup_cleanup = True + .apply_expected = true, + .sgroup_cleanup = true } }, /* @@ -4266,27 +4257,27 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4 vs. B:B_3_4 => C:A_3_4_B_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .sgroup_merge = True, - .sgroup_cleanup = True, + .sgroup_merge = true, + .sgroup_cleanup = true, } }, /* @@ -4297,53 +4288,53 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:A_3_4 => B:A_3_4_X_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .sgroup_merge = True, + .sgroup_merge = true, .merge_owner = &ctx->b, - .sgroup_cleanup = False + .sgroup_cleanup = false } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_X_3_4_OWNER_B), .ips = addresses_A_3_4_X_3_4_OWNER_B, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, } }, /* @@ -4354,52 +4345,52 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:X_3_4 vs. B:A_3_4 => C:A_3_4_X_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_X_3_4), .ips = addresses_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .sgroup_merge = True, - .sgroup_cleanup = False + .sgroup_merge = true, + .sgroup_cleanup = false } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->x, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, } }, /* @@ -4410,52 +4401,52 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4_X_3_4 vs. B:A_3_4_OWNER_B => B:A_3_4_OWNER_B_X_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_X_3_4), .ips = addresses_A_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_OWNER_B), .ips = addresses_A_3_4_OWNER_B, - .sgroup_merge = True, + .sgroup_merge = true, .merge_owner = &ctx->b, } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->x, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, } }, /* @@ -4466,52 +4457,52 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:B_3_4_X_1_2 => C:B_3_4_X_1_2_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_1_2), .ips = addresses_B_3_4_X_1_2, - .sgroup_merge = True, - .sgroup_cleanup = False + .sgroup_merge = true, + .sgroup_cleanup = false } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->x, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, } }, /* @@ -4522,53 +4513,53 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:A_3_4_B_3_4 vs. B:NULL => B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4_B_3_4), .ips = addresses_A_3_4_B_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .sgroup_merge = True, + .sgroup_merge = true, .merge_owner = &ctx->b, - .sgroup_cleanup = True + .sgroup_cleanup = true } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True, + .apply_expected = true, } }, /* @@ -4579,53 +4570,53 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:NULL => B:X_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .sgroup_merge = True, + .sgroup_merge = true, .merge_owner = &ctx->b, - .sgroup_cleanup = True + .sgroup_cleanup = true } }, { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->x, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = False, + .apply_expected = false, }, .r2 = { .owner = &ctx->x, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True, + .apply_expected = true, } }, @@ -4637,26 +4628,26 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:NULL => B:NULL", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = 0, .ips = NULL, - .apply_expected = True, + .apply_expected = true, } }, /* @@ -4667,26 +4658,26 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:A_3_4 => B:A_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, - .apply_expected = True, + .apply_expected = true, } }, /* @@ -4697,26 +4688,26 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:B_3_4 => B:B_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True, + .apply_expected = true, } }, /* @@ -4727,26 +4718,26 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), .comment= "A:B_3_4_X_3_4 vs. B:B_3_4_X_3_4 => B:B_3_4_X_3_4", - .extra = True, + .extra = true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, }, .r2 = { .owner = &ctx->b, .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4_X_3_4), .ips = addresses_B_3_4_X_3_4, - .apply_expected = True, + .apply_expected = true, } }, @@ -4758,46 +4749,46 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) { .line = __location__, .name = _NBT_NAME("_DIFF_OWNER", 0x00, NULL), - .cleanup= True, + .cleanup= true, .r1 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true }, .r2 = { .owner = &ctx->a, .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_A_1), .ips = addresses_A_1, - .apply_expected = True + .apply_expected = true } }}; /* do not add entries here, this should be the last record! */ wins_name_r1 = &wins_name1; wins_name_r2 = &wins_name2; - printf("Test Replica Conflicts with different owners\n"); + torture_comment(tctx, "Test Replica Conflicts with different owners\n"); for(i=0; ret && i < ARRAY_SIZE(records); i++) { if (!records[i].extra && !records[i].cleanup) { /* we should test the worst cases */ if (records[i].r2.apply_expected && records[i].r1.ips==records[i].r2.ips) { - printf("(%s) Programmer error, invalid record[%u]: %s\n", + torture_comment(tctx, "(%s) Programmer error, invalid record[%u]: %s\n", __location__, i, records[i].line); - return False; + return false; } else if (!records[i].r2.apply_expected && records[i].r1.ips!=records[i].r2.ips) { - printf("(%s) Programmer error, invalid record[%u]: %s\n", + torture_comment(tctx, "(%s) Programmer error, invalid record[%u]: %s\n", __location__, i, records[i].line); - return False; + return false; } } @@ -4821,7 +4812,7 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) ips = "with different ip(s)"; } - printf("%s,%s%s vs. %s,%s%s %s => %s\n", + torture_comment(tctx, "%s,%s%s vs. %s,%s%s %s => %s\n", wrepl_name_type_string(records[i].r1.type), wrepl_name_state_string(records[i].r1.state), (records[i].r1.is_static?",static":""), @@ -4850,8 +4841,8 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) wins_name_r1->unknown = "255.255.255.255"; /* now apply R1 */ - ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1); - ret &= test_wrepl_is_applied(ctx, records[i].r1.owner, + ret &= test_wrepl_update_one(tctx, ctx, records[i].r1.owner, wins_name_r1); + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r1.owner, wins_name_r1, records[i].r1.apply_expected); /* @@ -4872,34 +4863,34 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) wins_name_r2->unknown = "255.255.255.255"; /* now apply R2 */ - ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2); + ret &= test_wrepl_update_one(tctx, ctx, records[i].r2.owner, wins_name_r2); if (records[i].r1.state == WREPL_STATE_RELEASED) { - ret &= test_wrepl_is_applied(ctx, records[i].r1.owner, - wins_name_r1, False); + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r1.owner, + wins_name_r1, false); } else if (records[i].r2.sgroup_merge) { - ret &= test_wrepl_sgroup_merged(ctx, records[i].r2.merge_owner, + ret &= test_wrepl_sgroup_merged(tctx, ctx, records[i].r2.merge_owner, records[i].r1.owner, records[i].r1.num_ips, records[i].r1.ips, records[i].r2.owner, records[i].r2.num_ips, records[i].r2.ips, wins_name_r2); } else if (records[i].r1.owner != records[i].r2.owner) { - BOOL _expected; + bool _expected; _expected = (records[i].r1.apply_expected && !records[i].r2.apply_expected); - ret &= test_wrepl_is_applied(ctx, records[i].r1.owner, + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r1.owner, wins_name_r1, _expected); } if (records[i].r2.state == WREPL_STATE_RELEASED) { - ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, - wins_name_r2, False); + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r2.owner, + wins_name_r2, false); } else if (!records[i].r2.sgroup_merge) { - ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r2.owner, wins_name_r2, records[i].r2.apply_expected); } if (records[i].r2.sgroup_cleanup) { if (!ret) { - printf("failed before sgroup_cleanup record[%u]: %s\n", i, records[i].line); + torture_comment(tctx, "failed before sgroup_cleanup record[%u]: %s\n", i, records[i].line); return ret; } @@ -4907,16 +4898,16 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) wins_name_r1->name = &records[i].name; wins_name_r1->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_ACTIVE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name_r1->id = ++records[i].r1.owner->max_version; wins_name_r1->addresses.addresses.num_ips = 0; wins_name_r1->addresses.addresses.ips = NULL; wins_name_r1->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, records[i].r1.owner, wins_name_r1); + ret &= test_wrepl_update_one(tctx, ctx, records[i].r1.owner, wins_name_r1); /* here we test how names from an owner are deleted */ if (records[i].r2.sgroup_merge && records[i].r2.num_ips) { - ret &= test_wrepl_sgroup_merged(ctx, NULL, + ret &= test_wrepl_sgroup_merged(tctx, ctx, NULL, records[i].r2.owner, records[i].r2.num_ips, records[i].r2.ips, records[i].r1.owner, @@ -4928,48 +4919,48 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) wins_name_r2->name = &records[i].name; wins_name_r2->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_ACTIVE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name_r2->id = ++records[i].r2.owner->max_version; wins_name_r2->addresses.addresses.num_ips = 0; wins_name_r2->addresses.addresses.ips = NULL; wins_name_r2->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2); + ret &= test_wrepl_update_one(tctx, ctx, records[i].r2.owner, wins_name_r2); /* take ownership of the SGROUP record */ wins_name_r2->name = &records[i].name; wins_name_r2->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_ACTIVE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name_r2->id = ++records[i].r2.owner->max_version; wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1); wins_name_r2->addresses.addresses.ips = discard_const(addresses_B_1); wins_name_r2->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2); - ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True); + ret &= test_wrepl_update_one(tctx, ctx, records[i].r2.owner, wins_name_r2); + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r2.owner, wins_name_r2, true); /* overwrite the SGROUP record with unique,tombstone */ wins_name_r2->name = &records[i].name; wins_name_r2->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_TOMBSTONE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name_r2->id = ++records[i].r2.owner->max_version; wins_name_r2->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1); wins_name_r2->addresses.addresses.ips = discard_const(addresses_B_1); wins_name_r2->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, records[i].r2.owner, wins_name_r2); - ret &= test_wrepl_is_applied(ctx, records[i].r2.owner, wins_name_r2, True); + ret &= test_wrepl_update_one(tctx, ctx, records[i].r2.owner, wins_name_r2); + ret &= test_wrepl_is_applied(tctx, ctx, records[i].r2.owner, wins_name_r2, true); if (!ret) { - printf("failed in sgroup_cleanup record[%u]: %s\n", i, records[i].line); + torture_comment(tctx, "failed in sgroup_cleanup record[%u]: %s\n", i, records[i].line); return ret; } } /* the first one is a cleanup run */ - if (!ret && i == 0) ret = True; + if (!ret && i == 0) ret = true; if (!ret) { - printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line); + torture_comment(tctx, "conflict handled wrong or record[%u]: %s\n", i, records[i].line); return ret; } } @@ -4977,9 +4968,10 @@ static BOOL test_conflict_different_owner(struct test_wrepl_conflict_conn *ctx) return ret; } -static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_conn *ctx) +static bool test_conflict_owned_released_vs_replica(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct wrepl_wins_name wins_name_; struct wrepl_wins_name *wins_name = &wins_name_; @@ -4993,19 +4985,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c struct nbt_name name; struct { uint32_t nb_flags; - BOOL mhomed; + bool mhomed; uint32_t num_ips; const struct wrepl_ip *ips; - BOOL apply_expected; + bool apply_expected; } wins; struct { enum wrepl_name_type type; enum wrepl_name_state state; enum wrepl_name_node node; - BOOL is_static; + bool is_static; uint32_t num_ips; const struct wrepl_ip *ips; - BOOL apply_expected; + bool apply_expected; } replica; } records[] = { /* @@ -5019,19 +5011,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_UA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5042,19 +5034,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_UA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5065,19 +5057,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_UT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5088,19 +5080,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_UT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5114,19 +5106,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_GA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5137,19 +5129,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_GA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5160,19 +5152,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_GT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5183,19 +5175,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_GT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5209,19 +5201,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_SA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5232,19 +5224,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_SA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5255,19 +5247,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_ST_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5278,19 +5270,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_ST_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5304,19 +5296,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_MA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5327,19 +5319,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_MA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5350,19 +5342,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_MT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5373,19 +5365,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_UR_MT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5399,19 +5391,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_UA_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5422,19 +5414,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_UA_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5445,19 +5437,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_UT_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5468,19 +5460,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_UT_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5494,19 +5486,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_GA_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5517,19 +5509,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_GA_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5540,19 +5532,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_GT_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5563,19 +5555,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_GT_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5589,19 +5581,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_SA_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5612,19 +5604,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_SA_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5635,19 +5627,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_ST_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5658,19 +5650,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_ST_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5684,19 +5676,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_MA_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5707,19 +5699,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_MA_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5730,19 +5722,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_MT_SI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5753,19 +5745,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_GR_MT_DI", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -5779,19 +5771,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_UA_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5802,19 +5794,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_UA_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5825,19 +5817,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_UT_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5848,19 +5840,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_UT_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5874,19 +5866,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_GA_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5897,19 +5889,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_GA_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5920,19 +5912,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_GT_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5943,19 +5935,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_GT_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5969,19 +5961,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_SA_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -5992,19 +5984,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_SA_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6015,19 +6007,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_ST_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6038,19 +6030,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_ST_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6064,19 +6056,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_MA_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6087,19 +6079,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_MA_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6110,19 +6102,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_MT_SI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6133,19 +6125,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_SR_MT_DI", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6159,19 +6151,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_UA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6182,19 +6174,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_UA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6205,19 +6197,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_UT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6228,19 +6220,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_UT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6254,19 +6246,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_GA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6277,19 +6269,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_GA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6300,19 +6292,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_GT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6323,19 +6315,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_GT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6349,19 +6341,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_SA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6372,19 +6364,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_SA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6395,19 +6387,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_ST_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6418,19 +6410,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_ST_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6444,19 +6436,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_MA_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6467,19 +6459,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_MA_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6490,19 +6482,19 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_MT_SI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6513,27 +6505,27 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c .name = _NBT_NAME("_MR_MT_DI", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, }; - printf("Test Replica records vs. owned released records\n"); + torture_comment(tctx, "Test Replica records vs. owned released records\n"); for(i=0; ret && i < ARRAY_SIZE(records); i++) { - printf("%s => %s\n", nbt_name_string(ctx, &records[i].name), + torture_comment(tctx, "%s => %s\n", nbt_name_string(ctx, &records[i].name), (records[i].replica.apply_expected?"REPLACE":"NOT REPLACE")); /* @@ -6543,8 +6535,8 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c name_register->in.dest_addr = ctx->address; name_register->in.address = records[i].wins.ips[0].ip; name_register->in.nb_flags = records[i].wins.nb_flags; - name_register->in.register_demand= False; - name_register->in.broadcast = False; + name_register->in.register_demand= false; + name_register->in.broadcast = false; name_register->in.multi_homed = records[i].wins.mhomed; name_register->in.ttl = 300000; name_register->in.timeout = 70; @@ -6552,41 +6544,41 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c status = nbt_name_register(ctx->nbtsock, ctx, name_register); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name register\n", ctx->address); - ret = False; + torture_comment(tctx, "No response from %s for name register\n", ctx->address); + ret = false; } if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register - %s\n", + torture_comment(tctx, "Bad response from %s for name register - %s\n", ctx->address, nt_errstr(status)); - ret = False; + ret = false; } - CHECK_VALUE(name_register->out.rcode, 0); - CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address); - CHECK_VALUE(name_register->out.name.type, records[i].name.type); - CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name); - CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope); - CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[0].ip); + CHECK_VALUE(tctx, name_register->out.rcode, 0); + CHECK_VALUE_STRING(tctx, name_register->out.reply_from, ctx->address); + CHECK_VALUE(tctx, name_register->out.name.type, records[i].name.type); + CHECK_VALUE_STRING(tctx, name_register->out.name.name, records[i].name.name); + CHECK_VALUE_STRING(tctx, name_register->out.name.scope, records[i].name.scope); + CHECK_VALUE_STRING(tctx, name_register->out.reply_addr, records[i].wins.ips[0].ip); /* release the record */ release->in.name = records[i].name; release->in.dest_addr = ctx->address; release->in.address = records[i].wins.ips[0].ip; release->in.nb_flags = records[i].wins.nb_flags; - release->in.broadcast = False; + release->in.broadcast = false; release->in.timeout = 30; release->in.retries = 0; status = nbt_name_release(ctx->nbtsock, ctx, release); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", ctx->address); - return False; + torture_comment(tctx, "No response from %s for name release\n", ctx->address); + return false; } if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", + torture_comment(tctx, "Bad response from %s for name query - %s\n", ctx->address, nt_errstr(status)); - return False; + return false; } - CHECK_VALUE(release->out.rcode, 0); + CHECK_VALUE(tctx, release->out.rcode, 0); /* * Setup Replica @@ -6605,45 +6597,44 @@ static BOOL test_conflict_owned_released_vs_replica(struct test_wrepl_conflict_c } wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, records[i].replica.apply_expected); if (records[i].replica.apply_expected) { wins_name->name = &records[i].name; wins_name->flags = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE, WREPL_STATE_TOMBSTONE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name->id = ++ctx->b.max_version; wins_name->addresses.ip = addresses_B_1[0].ip; wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, true); } else { release->in.name = records[i].name; release->in.dest_addr = ctx->address; release->in.address = records[i].wins.ips[0].ip; release->in.nb_flags = records[i].wins.nb_flags; - release->in.broadcast = False; + release->in.broadcast = false; release->in.timeout = 30; release->in.retries = 0; status = nbt_name_release(ctx->nbtsock, ctx, release); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", ctx->address); - return False; + torture_comment(tctx, "No response from %s for name release\n", ctx->address); + return false; } if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", + torture_comment(tctx, "Bad response from %s for name query - %s\n", ctx->address, nt_errstr(status)); - return False; + return false; } - CHECK_VALUE(release->out.rcode, 0); + CHECK_VALUE(tctx, release->out.rcode, 0); } -done: if (!ret) { - printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line); + torture_comment(tctx, "conflict handled wrong or record[%u]: %s\n", i, records[i].line); return ret; } } @@ -6656,20 +6647,20 @@ struct test_conflict_owned_active_vs_replica_struct { const char *section; /* just better debugging */ struct nbt_name name; const char *comment; - BOOL skip; + bool skip; struct { uint32_t nb_flags; - BOOL mhomed; + bool mhomed; uint32_t num_ips; const struct wrepl_ip *ips; - BOOL apply_expected; + bool apply_expected; } wins; struct { uint32_t timeout; - BOOL positive; - BOOL expect_release; - BOOL late_release; - BOOL ret; + bool positive; + bool expect_release; + bool late_release; + bool ret; /* when num_ips == 0, then .wins.ips are used */ uint32_t num_ips; const struct wrepl_ip *ips; @@ -6678,12 +6669,12 @@ struct test_conflict_owned_active_vs_replica_struct { enum wrepl_name_type type; enum wrepl_name_state state; enum wrepl_name_node node; - BOOL is_static; + bool is_static; uint32_t num_ips; const struct wrepl_ip *ips; - BOOL apply_expected; - BOOL mhomed_merge; - BOOL sgroup_merge; + bool apply_expected; + bool mhomed_merge; + bool sgroup_merge; } replica; }; @@ -6691,9 +6682,10 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket struct nbt_name_packet *req_packet, struct socket_address *src); -static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_conn *ctx) +static bool test_conflict_owned_active_vs_replica(struct torture_context *tctx, + struct test_wrepl_conflict_conn *ctx) { - BOOL ret = True; + bool ret = true; NTSTATUS status; struct wrepl_wins_name wins_name_; struct wrepl_wins_name *wins_name = &wins_name_; @@ -6714,10 +6706,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UA_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -6726,10 +6718,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6740,23 +6732,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UA_DI_P", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6767,14 +6759,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UA_DI_O", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, }, @@ -6782,10 +6774,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6796,23 +6788,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UA_DI_N", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = False, + .positive = false, }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6823,10 +6815,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -6835,10 +6827,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6849,10 +6841,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_UT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -6861,10 +6853,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6878,23 +6870,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_GA_SI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6905,23 +6897,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_GA_DI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -6932,10 +6924,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_GT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -6944,10 +6936,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6958,10 +6950,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_GT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -6970,10 +6962,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -6987,23 +6979,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_SA_SI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7014,23 +7006,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_SA_DI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7041,10 +7033,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_ST_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7053,10 +7045,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7067,10 +7059,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_ST_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7079,10 +7071,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7096,10 +7088,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MA_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7108,10 +7100,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7122,10 +7114,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MA_SP_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7134,10 +7126,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7148,23 +7140,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MA_DI_P", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7175,14 +7167,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MA_DI_O", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, }, @@ -7190,10 +7182,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7204,23 +7196,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MA_DI_N", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = False, + .positive = false, }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7231,10 +7223,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7243,10 +7235,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7257,10 +7249,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_UA_MT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7269,10 +7261,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7286,10 +7278,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_UA_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7298,10 +7290,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7312,10 +7304,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_UA_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7324,10 +7316,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7338,10 +7330,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_UT_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7350,10 +7342,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7364,10 +7356,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_UT_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7376,10 +7368,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7393,10 +7385,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_GA_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7405,10 +7397,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7419,10 +7411,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_GA_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7431,10 +7423,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -7445,10 +7437,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_GT_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7457,10 +7449,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7471,10 +7463,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_GT_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7483,10 +7475,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7500,10 +7492,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_SA_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7512,10 +7504,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7526,10 +7518,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_SA_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7538,10 +7530,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7552,10 +7544,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_ST_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7564,10 +7556,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7578,10 +7570,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_ST_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7590,10 +7582,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7607,10 +7599,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_MA_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7619,10 +7611,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7633,10 +7625,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_MA_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7645,10 +7637,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7659,10 +7651,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_MT_SI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7671,10 +7663,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7685,10 +7677,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_GA_MT_DI_U", 0x00, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7697,10 +7689,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7714,10 +7706,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_UA_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7726,10 +7718,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7740,10 +7732,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_UA_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7752,10 +7744,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7766,10 +7758,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_UT_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7778,10 +7770,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7792,10 +7784,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_UT_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7804,10 +7796,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7821,10 +7813,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_GA_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7833,10 +7825,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7847,10 +7839,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_GA_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7859,10 +7851,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7873,10 +7865,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_GT_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7885,10 +7877,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7899,10 +7891,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_GT_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7911,10 +7903,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7928,10 +7920,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_MA_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7940,10 +7932,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7954,10 +7946,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_MA_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7966,10 +7958,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -7980,10 +7972,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_MT_SI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -7992,10 +7984,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8006,10 +7998,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_SA_MT_DI_U", 0x1C, NULL), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8018,10 +8010,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8035,10 +8027,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UA_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8047,10 +8039,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8061,23 +8053,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UA_DI_P", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8088,14 +8080,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UA_DI_O", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, }, @@ -8103,10 +8095,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8117,23 +8109,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UA_DI_N", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = False, + .positive = false, }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8144,10 +8136,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8156,10 +8148,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8170,10 +8162,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_UT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8182,10 +8174,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8199,23 +8191,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_GA_SI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8226,23 +8218,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_GA_DI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8253,10 +8245,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_GT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8265,10 +8257,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8279,10 +8271,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_GT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8291,10 +8283,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_GROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8308,23 +8300,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_SA_SI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8335,23 +8327,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_SA_DI_R", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .expect_release = True, + .expect_release = true, }, .replica= { .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8362,10 +8354,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_ST_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8374,10 +8366,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8388,10 +8380,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_ST_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8400,10 +8392,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_1), .ips = addresses_B_1, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8417,10 +8409,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MA_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8429,10 +8421,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8443,10 +8435,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MA_SP_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8455,10 +8447,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8469,23 +8461,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MA_DI_P", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8496,14 +8488,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MA_DI_O", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ARRAY_SIZE(addresses_A_3_4), .ips = addresses_A_3_4, }, @@ -8511,10 +8503,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8525,23 +8517,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MA_DI_N", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = False, + .positive = false, }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8552,10 +8544,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MT_SI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8564,10 +8556,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8578,10 +8570,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .name = _NBT_NAME("_MA_MT_DI_U", 0x00, NULL), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8590,10 +8582,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8610,10 +8602,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8622,10 +8614,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8638,10 +8630,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_mhomed_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8650,10 +8642,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8666,23 +8658,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_mhomed_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True + .positive = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .mhomed_merge = True + .mhomed_merge = true }, }, /* @@ -8695,14 +8687,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, }, @@ -8710,10 +8702,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .mhomed_merge = True + .mhomed_merge = true }, }, /* @@ -8728,26 +8720,26 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .late_release = True + .late_release = true }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8760,14 +8752,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, }, @@ -8775,10 +8767,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, /* @@ -8791,23 +8783,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_mhomed_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = False + .positive = false }, .replica= { .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, }, /* @@ -8824,23 +8816,23 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 2), .wins = { .nb_flags = 0, - .mhomed = True, + .mhomed = true, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .mhomed_merge = True + .mhomed_merge = true }, }, /* @@ -8855,26 +8847,26 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 2), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ctx->addresses_best2_num, .ips = ctx->addresses_best2, - .late_release = True + .late_release = true }, .replica= { .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best2_num, .ips = ctx->addresses_best2, - .apply_expected = False, + .apply_expected = false, }, }, /* @@ -8887,14 +8879,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, }, @@ -8902,10 +8894,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_UNIQUE, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best2_num, .ips = ctx->addresses_best2, - .mhomed_merge = True, + .mhomed_merge = true, }, }, /* @@ -8918,14 +8910,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = 0, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 10, - .positive = True, + .positive = true, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, }, @@ -8933,10 +8925,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_MHOMED, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best2_num, .ips = ctx->addresses_best2, - .mhomed_merge = True, + .mhomed_merge = true, }, }, /* @@ -8952,10 +8944,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8964,10 +8956,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .sgroup_merge = True + .sgroup_merge = true }, }, /* @@ -8979,10 +8971,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -8991,10 +8983,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .sgroup_merge = True + .sgroup_merge = true }, }, /* @@ -9006,10 +8998,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9018,10 +9010,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, - .sgroup_merge = True + .sgroup_merge = true }, }, /* @@ -9033,10 +9025,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9045,10 +9037,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_ACTIVE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .sgroup_merge = True + .sgroup_merge = true }, }, /* @@ -9060,10 +9052,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9072,10 +9064,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ARRAY_SIZE(addresses_B_3_4), .ips = addresses_B_3_4, - .apply_expected = False + .apply_expected = false }, }, /* @@ -9087,10 +9079,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9099,10 +9091,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = False + .apply_expected = false }, }, /* @@ -9114,10 +9106,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9126,10 +9118,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_all_num, .ips = ctx->addresses_all, - .apply_expected = False + .apply_expected = false }, }, /* @@ -9141,10 +9133,10 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .skip = (ctx->addresses_all_num < 3), .wins = { .nb_flags = NBT_NM_GROUP, - .mhomed = False, + .mhomed = false, .num_ips = ctx->addresses_mhomed_num, .ips = ctx->addresses_mhomed, - .apply_expected = True + .apply_expected = true }, .defend = { .timeout = 0, @@ -9153,21 +9145,21 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con .type = WREPL_TYPE_SGROUP, .state = WREPL_STATE_TOMBSTONE, .node = WREPL_NODE_B, - .is_static = False, + .is_static = false, .num_ips = ctx->addresses_best_num, .ips = ctx->addresses_best, - .apply_expected = False + .apply_expected = false }, }, }; if (!ctx->nbtsock_srv) { - printf("SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n", + torture_comment(tctx, "SKIP: Test Replica records vs. owned active records: not bound to port[%d]\n", lp_nbt_port()); - return True; + return true; } - printf("Test Replica records vs. owned active records\n"); + torture_comment(tctx, "Test Replica records vs. owned active records\n"); for(i=0; ret && i < ARRAY_SIZE(records); i++) { struct timeval end; @@ -9180,11 +9172,11 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con } if (records[i].section) { - printf("%s\n", records[i].section); + torture_comment(tctx, "%s\n", records[i].section); } if (records[i].skip) { - printf("%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name)); + torture_comment(tctx, "%s => SKIPPED\n", nbt_name_string(ctx, &records[i].name)); continue; } @@ -9198,7 +9190,7 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con action = "NOT REPLACE"; } - printf("%s%s%s => %s\n", + torture_comment(tctx, "%s%s%s => %s\n", nbt_name_string(ctx, &records[i].name), (records[i].comment?": ":""), (records[i].comment?records[i].comment:""), @@ -9207,7 +9199,7 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con /* Prepare for multi homed registration */ ZERO_STRUCT(records[i].defend); records[i].defend.timeout = 10; - records[i].defend.positive = True; + records[i].defend.positive = true; nbt_set_incoming_handler(ctx->nbtsock_srv, test_conflict_owned_active_vs_replica_handler, &records[i]); @@ -9227,8 +9219,8 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con name_register->in.dest_addr = ctx->address; name_register->in.address = records[i].wins.ips[j].ip; name_register->in.nb_flags = records[i].wins.nb_flags; - name_register->in.register_demand= False; - name_register->in.broadcast = False; + name_register->in.register_demand= false; + name_register->in.broadcast = false; name_register->in.multi_homed = records[i].wins.mhomed; name_register->in.ttl = 300000; name_register->in.timeout = 70; @@ -9246,7 +9238,7 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con */ if (records[i].wins.mhomed && j > 0) { end = timeval_current_ofs(records[i].defend.timeout,0); - records[i].defend.ret = True; + records[i].defend.ret = true; while (records[i].defend.timeout > 0) { event_loop_once(ctx->nbtsock_srv->event_ctx); if (timeval_expired(&end)) break; @@ -9256,20 +9248,20 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con status = nbt_name_register_recv(req, ctx, name_register); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name register\n", ctx->address); - ret = False; + torture_comment(tctx, "No response from %s for name register\n", ctx->address); + ret = false; } if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name register - %s\n", + torture_comment(tctx, "Bad response from %s for name register - %s\n", ctx->address, nt_errstr(status)); - ret = False; + ret = false; } - CHECK_VALUE(name_register->out.rcode, 0); - CHECK_VALUE_STRING(name_register->out.reply_from, ctx->address); - CHECK_VALUE(name_register->out.name.type, records[i].name.type); - CHECK_VALUE_STRING(name_register->out.name.name, records[i].name.name); - CHECK_VALUE_STRING(name_register->out.name.scope, records[i].name.scope); - CHECK_VALUE_STRING(name_register->out.reply_addr, records[i].wins.ips[j].ip); + CHECK_VALUE(tctx, name_register->out.rcode, 0); + CHECK_VALUE_STRING(tctx, name_register->out.reply_from, ctx->address); + CHECK_VALUE(tctx, name_register->out.name.type, records[i].name.type); + CHECK_VALUE_STRING(tctx, name_register->out.name.name, records[i].name.name); + CHECK_VALUE_STRING(tctx, name_register->out.name.scope, records[i].name.scope); + CHECK_VALUE_STRING(tctx, name_register->out.reply_addr, records[i].wins.ips[j].ip); } /* Prepare for the current test */ @@ -9300,14 +9292,14 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con } wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); /* * wait for the name query, which is handled in * test_conflict_owned_active_vs_replica_handler() */ end = timeval_current_ofs(records[i].defend.timeout,0); - records[i].defend.ret = True; + records[i].defend.ret = true; while (records[i].defend.timeout > 0) { event_loop_once(ctx->nbtsock_srv->event_ctx); if (timeval_expired(&end)) break; @@ -9316,13 +9308,13 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con if (records[i].defend.late_release) { records[i].defend = record.defend; - records[i].defend.expect_release = True; + records[i].defend.expect_release = true; /* * wait for the name release demand, which is handled in * test_conflict_owned_active_vs_replica_handler() */ end = timeval_current_ofs(records[i].defend.timeout,0); - records[i].defend.ret = True; + records[i].defend.ret = true; while (records[i].defend.timeout > 0) { event_loop_once(ctx->nbtsock_srv->event_ctx); if (timeval_expired(&end)) break; @@ -9331,20 +9323,20 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con } if (records[i].replica.mhomed_merge) { - ret &= test_wrepl_mhomed_merged(ctx, &ctx->c, + ret &= test_wrepl_mhomed_merged(tctx, ctx, &ctx->c, records[i].wins.num_ips, records[i].wins.ips, &ctx->b, records[i].replica.num_ips, records[i].replica.ips, wins_name); } else if (records[i].replica.sgroup_merge) { - ret &= test_wrepl_sgroup_merged(ctx, NULL, + ret &= test_wrepl_sgroup_merged(tctx, ctx, NULL, &ctx->c, records[i].wins.num_ips, records[i].wins.ips, &ctx->b, records[i].replica.num_ips, records[i].replica.ips, wins_name); } else { - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, records[i].replica.apply_expected); } @@ -9353,13 +9345,13 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con wins_name->name = &records[i].name; wins_name->flags = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE, WREPL_STATE_TOMBSTONE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name->id = ++ctx->b.max_version; wins_name->addresses.ip = addresses_B_1[0].ip; wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, true); } else { for (j=0; j < count; j++) { struct nbt_name_socket *nbtsock = ctx->nbtsock; @@ -9372,21 +9364,21 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con release->in.dest_addr = ctx->address; release->in.address = records[i].wins.ips[j].ip; release->in.nb_flags = records[i].wins.nb_flags; - release->in.broadcast = False; + release->in.broadcast = false; release->in.timeout = 30; release->in.retries = 0; status = nbt_name_release(nbtsock, ctx, release); if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("No response from %s for name release\n", ctx->address); - return False; + torture_comment(tctx, "No response from %s for name release\n", ctx->address); + return false; } if (!NT_STATUS_IS_OK(status)) { - printf("Bad response from %s for name query - %s\n", + torture_comment(tctx, "Bad response from %s for name query - %s\n", ctx->address, nt_errstr(status)); - return False; + return false; } - CHECK_VALUE(release->out.rcode, 0); + CHECK_VALUE(tctx, release->out.rcode, 0); } if (records[i].replica.sgroup_merge) { @@ -9394,41 +9386,40 @@ static BOOL test_conflict_owned_active_vs_replica(struct test_wrepl_conflict_con wins_name->name = &records[i].name; wins_name->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_ACTIVE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name->id = ++ctx->b.max_version; wins_name->addresses.addresses.num_ips = 0; wins_name->addresses.addresses.ips = NULL; wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); /* take ownership of the SGROUP record */ wins_name->name = &records[i].name; wins_name->flags = WREPL_NAME_FLAGS(WREPL_TYPE_SGROUP, WREPL_STATE_ACTIVE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name->id = ++ctx->b.max_version; wins_name->addresses.addresses.num_ips = ARRAY_SIZE(addresses_B_1); wins_name->addresses.addresses.ips = discard_const(addresses_B_1); wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, true); /* overwrite the SGROUP record with unique,tombstone */ wins_name->name = &records[i].name; wins_name->flags = WREPL_NAME_FLAGS(WREPL_TYPE_UNIQUE, WREPL_STATE_TOMBSTONE, - WREPL_NODE_B, False); + WREPL_NODE_B, false); wins_name->id = ++ctx->b.max_version; wins_name->addresses.ip = addresses_A_1[0].ip; wins_name->unknown = "255.255.255.255"; - ret &= test_wrepl_update_one(ctx, &ctx->b, wins_name); - ret &= test_wrepl_is_applied(ctx, &ctx->b, wins_name, True); + ret &= test_wrepl_update_one(tctx, ctx, &ctx->b, wins_name); + ret &= test_wrepl_is_applied(tctx, ctx, &ctx->b, wins_name, true); } } -done: if (!ret) { - printf("conflict handled wrong or record[%u]: %s\n", i, records[i].line); + torture_comment(tctx, "conflict handled wrong or record[%u]: %s\n", i, records[i].line); return ret; } } @@ -9472,7 +9463,7 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_ _NBT_ASSERT_STRING(name->name, rec->name.name); _NBT_ASSERT_STRING(name->scope, rec->name.scope); - _NBT_ASSERT(rec->defend.expect_release, False); + _NBT_ASSERT(rec->defend.expect_release, false); rep_packet = talloc_zero(nbtsock, struct nbt_name_packet); if (rep_packet == NULL) return; @@ -9546,10 +9537,11 @@ static void test_conflict_owned_active_vs_replica_handler_query(struct nbt_name_ msleep(1000); rec->defend.timeout = 0; - rec->defend.ret = True; + rec->defend.ret = true; } -static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_name_socket *nbtsock, +static void test_conflict_owned_active_vs_replica_handler_release( + struct nbt_name_socket *nbtsock, struct nbt_name_packet *req_packet, struct socket_address *src) { @@ -9567,7 +9559,7 @@ static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_nam _NBT_ASSERT_STRING(name->name, rec->name.name); _NBT_ASSERT_STRING(name->scope, rec->name.scope); - _NBT_ASSERT(rec->defend.expect_release, True); + _NBT_ASSERT(rec->defend.expect_release, true); rep_packet = talloc_zero(nbtsock, struct nbt_name_packet); if (rep_packet == NULL) return; @@ -9599,7 +9591,7 @@ static void test_conflict_owned_active_vs_replica_handler_release(struct nbt_nam msleep(1000); rec->defend.timeout = 0; - rec->defend.ret = True; + rec->defend.ret = true; } static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket *nbtsock, @@ -9608,7 +9600,7 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket { struct test_conflict_owned_active_vs_replica_struct *rec = nbtsock->incoming.private; - rec->defend.ret = False; + rec->defend.ret = false; switch (req_packet->operation & NBT_OPCODE) { case NBT_OPCODE_QUERY: @@ -9624,101 +9616,72 @@ static void test_conflict_owned_active_vs_replica_handler(struct nbt_name_socket } /* - test simple WINS replication operations + test WINS replication replica conflicts operations */ -BOOL torture_nbt_winsreplication_simple(struct torture_context *torture) +static bool torture_nbt_winsreplication_replica(struct torture_context *tctx) { + bool ret = true; + struct test_wrepl_conflict_conn *ctx; + const char *address; struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } + ctx = test_create_conflict_ctx(tctx, address); + if (!ctx) return false; - ret &= test_assoc_ctx1(mem_ctx, address); - ret &= test_assoc_ctx2(mem_ctx, address); - - ret &= test_wins_replication(mem_ctx, address); - - talloc_free(mem_ctx); + ret &= test_conflict_same_owner(tctx, ctx); + ret &= test_conflict_different_owner(tctx, ctx); return ret; } /* - test WINS replication replica conflicts operations + test WINS replication owned conflicts operations */ -BOOL torture_nbt_winsreplication_replica(struct torture_context *torture) +static bool torture_nbt_winsreplication_owned(struct torture_context *tctx) { const char *address; struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; + bool ret = true; struct test_wrepl_conflict_conn *ctx; - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ctx = test_create_conflict_ctx(mem_ctx, address); - if (!ctx) return False; + if (!torture_nbt_get_name(tctx, &name, &address)) + return false; - ret &= test_conflict_same_owner(ctx); - ret &= test_conflict_different_owner(ctx); + ctx = test_create_conflict_ctx(tctx, address); + torture_assert(tctx, ctx != NULL, "Creating context failed"); - talloc_free(mem_ctx); + ret &= test_conflict_owned_released_vs_replica(tctx, ctx); + ret &= test_conflict_owned_active_vs_replica(tctx, ctx); return ret; } /* - test WINS replication owned conflicts operations + test simple WINS replication operations */ -BOOL torture_nbt_winsreplication_owned(struct torture_context *torture) +struct torture_suite *torture_nbt_winsreplication(void) { - const char *address; - struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); - NTSTATUS status; - BOOL ret = True; - struct test_wrepl_conflict_conn *ctx; - - make_nbt_name_server(&name, lp_parm_string(-1, "torture", "host")); - - /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, NULL); - if (!NT_STATUS_IS_OK(status)) { - printf("Failed to resolve %s - %s\n", - name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; - } - - ctx = test_create_conflict_ctx(mem_ctx, address); - if (!ctx) return False; + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "WINSREPLICATION"); + torture_suite_add_simple_test(suite, "assoc_ctx1", + test_assoc_ctx1); + + torture_suite_add_simple_test(suite, "assoc_ctx2", + test_assoc_ctx2); + + torture_suite_add_simple_test(suite, "wins_replication", + test_wins_replication); - ret &= test_conflict_owned_released_vs_replica(ctx); - ret &= test_conflict_owned_active_vs_replica(ctx); + torture_suite_add_simple_test(suite, "replica", + torture_nbt_winsreplication_replica); - talloc_free(mem_ctx); + torture_suite_add_simple_test(suite, "owned", + torture_nbt_winsreplication_owned); - return ret; + return suite; } diff --git a/source4/torture/rap/rap.c b/source4/torture/rap/rap.c index b7f594a668..f05183a033 100644 --- a/source4/torture/rap/rap.c +++ b/source4/torture/rap/rap.c @@ -563,8 +563,17 @@ BOOL torture_rap_scan(struct torture_context *torture) NTSTATUS torture_rap_init(void) { - register_torture_op("RAP-BASIC", torture_rap_basic); - register_torture_op("SCAN-RAP", torture_rap_scan); + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "RAP"); + + torture_suite_add_simple_test(suite, "BASIC", torture_rap_basic); + torture_suite_add_simple_test(suite, "SCAN", torture_rap_scan); + + suite->description = talloc_strdup(suite, + "Remote Administration Protocol tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/raw/raw.c b/source4/torture/raw/raw.c index e2fdf67ca0..411430a565 100644 --- a/source4/torture/raw/raw.c +++ b/source4/torture/raw/raw.c @@ -25,37 +25,44 @@ NTSTATUS torture_raw_init(void) { + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "RAW"); /* RAW smb tests */ + torture_suite_add_simple_test(suite, "BENCH-OPLOCK", torture_bench_oplock); + torture_suite_add_simple_test(suite, "QFSINFO", torture_raw_qfsinfo); + torture_suite_add_simple_test(suite, "QFILEINFO", torture_raw_qfileinfo); + torture_suite_add_simple_test(suite, "SFILEINFO", torture_raw_sfileinfo); + torture_suite_add_simple_test(suite, "SFILEINFO-BUG", torture_raw_sfileinfo_bug); + torture_suite_add_simple_test(suite, "SEARCH", torture_raw_search); + torture_suite_add_simple_test(suite, "CLOSE", torture_raw_close); + torture_suite_add_simple_test(suite, "OPEN", torture_raw_open); + torture_suite_add_simple_test(suite, "MKDIR", torture_raw_mkdir); + torture_suite_add_simple_test(suite, "OPLOCK", torture_raw_oplock); + torture_suite_add_simple_test(suite, "NOTIFY", torture_raw_notify); + torture_suite_add_simple_test(suite, "MUX", torture_raw_mux); + torture_suite_add_simple_test(suite, "IOCTL", torture_raw_ioctl); + torture_suite_add_simple_test(suite, "CHKPATH", torture_raw_chkpath); + torture_suite_add_simple_test(suite, "UNLINK", torture_raw_unlink); + torture_suite_add_simple_test(suite, "READ", torture_raw_read); + torture_suite_add_simple_test(suite, "WRITE", torture_raw_write); + torture_suite_add_simple_test(suite, "LOCK", torture_raw_lock); + torture_suite_add_simple_test(suite, "CONTEXT", torture_raw_context); + torture_suite_add_simple_test(suite, "RENAME", torture_raw_rename); + torture_suite_add_simple_test(suite, "SEEK", torture_raw_seek); + torture_suite_add_simple_test(suite, "EAS", torture_raw_eas); + torture_suite_add_simple_test(suite, "STREAMS", torture_raw_streams); + torture_suite_add_simple_test(suite, "ACLS", torture_raw_acls); + torture_suite_add_simple_test(suite, "COMPOSITE", torture_raw_composite); + torture_suite_add_simple_test(suite, "SAMBA3HIDE", torture_samba3_hide); + torture_suite_add_simple_test(suite, "SAMBA3CHECKFSP", torture_samba3_checkfsp); + torture_suite_add_simple_test(suite, "SAMBA3BADPATH", torture_samba3_badpath); + torture_suite_add_simple_test(suite, "SCAN-EAMAX", torture_max_eas); - register_torture_op("BENCH-OPLOCK", torture_bench_oplock); - register_torture_op("RAW-QFSINFO", torture_raw_qfsinfo); - register_torture_op("RAW-QFILEINFO", torture_raw_qfileinfo); - register_torture_op("RAW-SFILEINFO", torture_raw_sfileinfo); - register_torture_op("RAW-SFILEINFO-BUG", torture_raw_sfileinfo_bug); - register_torture_op("RAW-SEARCH", torture_raw_search); - register_torture_op("RAW-CLOSE", torture_raw_close); - register_torture_op("RAW-OPEN", torture_raw_open); - register_torture_op("RAW-MKDIR", torture_raw_mkdir); - register_torture_op("RAW-OPLOCK", torture_raw_oplock); - register_torture_op("RAW-NOTIFY", torture_raw_notify); - register_torture_op("RAW-MUX", torture_raw_mux); - register_torture_op("RAW-IOCTL", torture_raw_ioctl); - register_torture_op("RAW-CHKPATH", torture_raw_chkpath); - register_torture_op("RAW-UNLINK", torture_raw_unlink); - register_torture_op("RAW-READ", torture_raw_read); - register_torture_op("RAW-WRITE", torture_raw_write); - register_torture_op("RAW-LOCK", torture_raw_lock); - register_torture_op("RAW-CONTEXT", torture_raw_context); - register_torture_op("RAW-RENAME", torture_raw_rename); - register_torture_op("RAW-SEEK", torture_raw_seek); - register_torture_op("RAW-EAS", torture_raw_eas); - register_torture_op("RAW-STREAMS", torture_raw_streams); - register_torture_op("RAW-ACLS", torture_raw_acls); - register_torture_op("RAW-COMPOSITE", torture_raw_composite); - register_torture_op("RAW-SAMBA3HIDE", torture_samba3_hide); - register_torture_op("RAW-SAMBA3CHECKFSP", torture_samba3_checkfsp); - register_torture_op("RAW-SAMBA3BADPATH", torture_samba3_badpath); - register_torture_op("SCAN-EAMAX", torture_max_eas); + suite->description = talloc_strdup(suite, + "Tests for the raw SMB interface"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/rpc/atsvc.c b/source4/torture/rpc/atsvc.c index e586a1e98f..227e56a85b 100644 --- a/source4/torture/rpc/atsvc.c +++ b/source4/torture/rpc/atsvc.c @@ -24,7 +24,7 @@ #include "librpc/gen_ndr/ndr_atsvc_c.h" #include "torture/rpc/rpc.h" -static BOOL test_JobGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t job_id) +static bool test_JobGetInfo(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t job_id) { NTSTATUS status; struct atsvc_JobGetInfo r; @@ -32,17 +32,14 @@ static BOOL test_JobGetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t r.in.servername = dcerpc_server_name(p); r.in.job_id = job_id; - status = dcerpc_atsvc_JobGetInfo(p, mem_ctx, &r); + status = dcerpc_atsvc_JobGetInfo(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("JobGetInfo failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "JobGetInfo failed"); - return True; + return true; } -static BOOL test_JobDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t min_job_id, +static bool test_JobDel(struct dcerpc_pipe *p, struct torture_context *tctx, uint32_t min_job_id, uint32_t max_job_id) { NTSTATUS status; @@ -52,25 +49,20 @@ static BOOL test_JobDel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint32_t min r.in.min_job_id = min_job_id; r.in.max_job_id = max_job_id; - status = dcerpc_atsvc_JobDel(p, mem_ctx, &r); + status = dcerpc_atsvc_JobDel(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("JobDel failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "JobDel failed"); - return True; + return true; } -static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_JobEnum(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct atsvc_JobEnum r; struct atsvc_enum_ctr ctr; uint32_t resume_handle = 0, i; - BOOL ret = True; - - printf("\ntesting JobEnum\n"); + bool ret = true; r.in.servername = dcerpc_server_name(p); ctr.entries_read = 0; @@ -79,15 +71,12 @@ static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.preferred_max_len = 0xffffffff; r.in.resume_handle = r.out.resume_handle = &resume_handle; - status = dcerpc_atsvc_JobEnum(p, mem_ctx, &r); + status = dcerpc_atsvc_JobEnum(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("JobEnum failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "JobEnum failed"); for (i = 0; i < r.out.ctr->entries_read; i++) { - if (!test_JobGetInfo(p, mem_ctx, r.out.ctr->first_entry[i].job_id)) { + if (!test_JobGetInfo(p, tctx, r.out.ctr->first_entry[i].job_id)) { ret = False; } } @@ -95,14 +84,12 @@ static BOOL test_JobEnum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) return ret; } -static BOOL test_JobAdd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_JobAdd(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct atsvc_JobAdd r; struct atsvc_JobInfo info; - printf("\ntesting JobAdd\n"); - r.in.servername = dcerpc_server_name(p); info.job_time = 0x050ae4c0; /* 11:30pm */ info.days_of_month = 0; /* n/a */ @@ -111,56 +98,39 @@ static BOOL test_JobAdd(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) info.command = "foo.exe"; r.in.job_info = &info; - status = dcerpc_atsvc_JobAdd(p, mem_ctx, &r); + status = dcerpc_atsvc_JobAdd(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("JobAdd failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "JobAdd failed"); /* Run EnumJobs again in case there were no jobs to begin with */ - if (!test_JobEnum(p, mem_ctx)) { - return False; + if (!test_JobEnum(tctx, p)) { + return false; } - if (!test_JobGetInfo(p, mem_ctx, r.out.job_id)) { - return False; + if (!test_JobGetInfo(p, tctx, r.out.job_id)) { + return false; } - if (!test_JobDel(p, mem_ctx, r.out.job_id, r.out.job_id)) { - return False; + if (!test_JobDel(p, tctx, r.out.job_id, r.out.job_id)) { + return false; } - return True; + return true; } -BOOL torture_rpc_atsvc(struct torture_context *torture) +struct torture_suite *torture_rpc_atsvc(void) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_atsvc"); - - status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_atsvc); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - if (!test_JobEnum(p, mem_ctx)) { - talloc_free(mem_ctx); - return False; - } - - if (!test_JobAdd(p, mem_ctx)) { - talloc_free(mem_ctx); - return False; - } - - talloc_free(mem_ctx); - - return ret; + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "ATSVC"); + struct torture_tcase *tcase; + + tcase = torture_suite_add_rpc_iface_tcase(suite, "atsvc", + &dcerpc_table_atsvc); + + torture_rpc_tcase_add_test(tcase, "JobEnum", test_JobEnum); + torture_rpc_tcase_add_test(tcase, "JobAdd", test_JobAdd); + + return suite; } diff --git a/source4/torture/rpc/dfs.c b/source4/torture/rpc/dfs.c index 3eebfc5e5d..6af65e4f44 100644 --- a/source4/torture/rpc/dfs.c +++ b/source4/torture/rpc/dfs.c @@ -30,6 +30,8 @@ #include "libcli/libcli.h" #include "lib/cmdline/popt_common.h" +#if 0 + #define SMBTORTURE_DFS_SHARENAME "smbtorture_dfs_share" #define SMBTORTURE_DFS_DIRNAME "\\smbtorture_dfs_dir" #define SMBTORTURE_DFS_PATHNAME "C:"SMBTORTURE_DFS_DIRNAME @@ -139,23 +141,20 @@ static BOOL test_DeleteDir(struct smbcli_state *cli, const char *dir) return True; } -static BOOL test_GetManagerVersion(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, enum dfs_ManagerVersion *version) +static BOOL test_GetManagerVersion(struct torture_context *tctx, struct dcerpc_pipe *p, enum dfs_ManagerVersion *version) { NTSTATUS status; struct dfs_GetManagerVersion r; r.out.version = version; - status = dcerpc_dfs_GetManagerVersion(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetManagerVersion failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_dfs_GetManagerVersion(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "GetManagerVersion failed"); - return True; + return true; } -static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *host) +static BOOL test_ManagerInitialize(struct torture_context *tctx, struct dcerpc_pipe *p, const char *host) { NTSTATUS status; enum dfs_ManagerVersion version; @@ -163,14 +162,14 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c printf("Testing ManagerInitialize\n"); - if (!test_GetManagerVersion(p, mem_ctx, &version)) { + if (!test_GetManagerVersion(tctx, p, &version)) { return False; } r.in.servername = host; r.in.flags = 0; - status = dcerpc_dfs_ManagerInitialize(p, mem_ctx, &r); + status = dcerpc_dfs_ManagerInitialize(p, tctx, &r); if (!NT_STATUS_IS_OK(status)) { printf("ManagerInitialize failed - %s\n", nt_errstr(status)); return False; @@ -183,33 +182,31 @@ static BOOL test_ManagerInitialize(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, c return True; } -static BOOL test_GetInfoLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t level, - const char *root) +static BOOL test_GetInfoLevel(struct torture_context *tctx, struct dcerpc_pipe *p, uint16_t level, const char *root) { NTSTATUS status; struct dfs_GetInfo r; - printf("Testing GetInfo level %u on '%s'\n", level, root); + torture_comment(tctx, + talloc_asprintf(tctx, "Testing GetInfo level %u on '%s'\n", level, root)); - r.in.dfs_entry_path = talloc_strdup(mem_ctx, root); + r.in.dfs_entry_path = talloc_strdup(tctx, root); r.in.servername = NULL; r.in.sharename = NULL; r.in.level = level; - status = dcerpc_dfs_GetInfo(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("GetInfo failed - %s\n", nt_errstr(status)); - return False; - } else if (!W_ERROR_IS_OK(r.out.result) && - !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { - printf("dfs_GetInfo failed - %s\n", win_errstr(r.out.result)); - return False; - } + status = dcerpc_dfs_GetInfo(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "Info failed"); + torture_assert(tctx, W_ERROR_IS_OK(r.out.result) || + W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result), + talloc_asprintf(tctx, + "dfs_GetInfo failed - %s", win_errstr(r.out.result))); return True; } -static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char *root) +static bool test_Info(struct torture_context *tctx, + struct dcerpc_pipe *p, const char *root) { BOOL ret = True; /* 103, 104, 105, 106 is only available on Set */ @@ -217,14 +214,15 @@ static BOOL test_GetInfo(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, const char int i; for (i=0;is = &s; s.path = NULL; - printf("Testing Enum level %u\n", level); - - status = dcerpc_dfs_Enum(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("Enum failed - %s\n", nt_errstr(status)); - return False; - } else if (!W_ERROR_IS_OK(r.out.result) && - !W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result)) { - printf("dfs_Enum failed - %s\n", win_errstr(r.out.result)); - return False; - } + status = dcerpc_dfs_Enum(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "Enum failed - %s\n", + nt_errstr(status)); + torture_assert(tctx, W_ERROR_IS_OK(r.out.result) || + W_ERROR_EQUAL(WERR_NO_MORE_ITEMS, r.out.result), + "dfs_Enum failed - %s", win_errstr(r.out.result)); if (level == 1 && r.out.total) { int i; for (i=0;i<*r.out.total;i++) { const char *root = r.out.info->e.info1->s[i].path; - if (!test_GetInfo(p, mem_ctx, root)) { + if (!test_GetInfo(tctx, p, root)) { ret = False; } } @@ -332,15 +325,16 @@ static BOOL test_EnumLevel(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, uint16_t } -static BOOL test_Enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_Enum(struct torture_context *tctx, + struct dcerpc_pipe *p) { BOOL ret = True; uint16_t levels[] = {1, 2, 3, 4, 200, 300}; int i; for (i=0;iconn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) { len = 1 + (random() % 500); } else { len = 1 + (random() % 5000); } - printf("\nTesting EchoData\n"); - - data_in = talloc_size(mem_ctx, len); - data_out = talloc_size(mem_ctx, len); + data_in = talloc_size(tctx, len); + data_out = talloc_size(tctx, len); for (i=0;iconn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) { len = 100 + (random() % 500); } else { len = 200000 + (random() % 5000); } - printf("\nTesting SourceData\n"); - r.in.len = len; - status = dcerpc_echo_SourceData(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("SourceData(%d) failed - %s\n", len, nt_errstr(status)); - return False; - } + status = dcerpc_echo_SourceData(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, talloc_asprintf(tctx, + "SourceData(%d) failed", len)); for (i=0;iconn->flags & DCERPC_DEBUG_VALIDATE_BOTH)) { len = 100 + (random() % 5000); } else { len = 200000 + (random() % 5000); } - printf("\nTesting SinkData\n"); - - data_in = talloc_size(mem_ctx, len); + data_in = talloc_size(tctx, len); for (i=0;istate == RPC_REQUEST_DONE) { total_done++; @@ -302,46 +263,39 @@ static BOOL test_sleep(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) rcv[i] = timeval_current(); diff[i] = timeval_until(&snd[i], &rcv[i]); status = dcerpc_ndr_request_recv(req[i]); - if (!NT_STATUS_IS_OK(status)) { - printf("TestSleep(%d) failed - %s\n", - i, nt_errstr(status)); - ret = False; - } else if (r[i].out.result != r[i].in.seconds) { - printf("Failed - Asked to sleep for %u seconds (server replied with %u seconds and the reply takes only %u seconds)\n", - r[i].out.result, r[i].in.seconds, (uint_t)diff[i].tv_sec); - ret = False; + torture_assert_ntstatus_ok(tctx, status, + talloc_asprintf(tctx, "TestSleep(%d) failed", i)); + torture_assert(tctx, r[i].out.result == r[i].in.seconds, + talloc_asprintf(tctx, "Failed - Asked to sleep for %u seconds (server replied with %u seconds and the reply takes only %u seconds)", + r[i].out.result, r[i].in.seconds, (uint_t)diff[i].tv_sec)); + torture_assert(tctx, r[i].out.result <= diff[i].tv_sec, + talloc_asprintf(tctx, "Failed - Slept for %u seconds (but reply takes only %u.%06u seconds)", + r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec)); + if (r[i].out.result+1 == diff[i].tv_sec) { + torture_comment(tctx, "Slept for %u seconds (but reply takes %u.%06u seconds - busy server?)\n", + r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); + } else if (r[i].out.result == diff[i].tv_sec) { + torture_comment(tctx, "Slept for %u seconds (reply takes %u.%06u seconds - ok)\n", + r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); } else { - if (r[i].out.result > diff[i].tv_sec) { - printf("Failed - Slept for %u seconds (but reply takes only %u.%06u seconds)\n", - r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); - } else if (r[i].out.result+1 == diff[i].tv_sec) { - printf("Slept for %u seconds (but reply takes %u.%06u seconds - busy server?)\n", - r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); - } else if (r[i].out.result == diff[i].tv_sec) { - printf("Slept for %u seconds (reply takes %u.%06u seconds - ok)\n", - r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); - } else { - printf("(Failed) - Not async - Slept for %u seconds (but reply takes %u.%06u seconds)\n", - r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); - /* TODO: let the test fail here, when we support async rpc on ncacn_np - ret = False;*/ - } + torture_comment(tctx, "(Failed) - Not async - Slept for %u seconds (but reply takes %u.%06u seconds)", + r[i].out.result, (uint_t)diff[i].tv_sec, (uint_t)diff[i].tv_usec); + /* TODO: let the test fail here, when we support async rpc on ncacn_np */ } } } } - - return ret; + return true; } /* test enum handling */ -static BOOL test_enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_enum(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct echo_TestEnum r; - BOOL ret = True; enum echo_Enum1 v = ECHO_ENUM1; struct echo_Enum2 e2; union echo_Enum3 e3; @@ -357,56 +311,45 @@ static BOOL test_enum(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) e2.e2 = ECHO_ENUM1_32; e3.e1 = ECHO_ENUM2; - printf("\nTesting TestEnum\n"); - status = dcerpc_echo_TestEnum(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("TestEnum failed - %s\n", nt_errstr(status)); - ret = False; - } - - return ret; + status = dcerpc_echo_TestEnum(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "TestEnum failed"); + return true; } /* test surrounding conformant array handling */ -static BOOL test_surrounding(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_surrounding(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct echo_TestSurrounding r; - BOOL ret = True; ZERO_STRUCT(r); - r.in.data = talloc(mem_ctx, struct echo_Surrounding); + r.in.data = talloc(tctx, struct echo_Surrounding); r.in.data->x = 20; - r.in.data->surrounding = talloc_zero_array(mem_ctx, uint16_t, r.in.data->x); + r.in.data->surrounding = talloc_zero_array(tctx, uint16_t, r.in.data->x); - r.out.data = talloc(mem_ctx, struct echo_Surrounding); + r.out.data = talloc(tctx, struct echo_Surrounding); - printf("\nTesting TestSurrounding\n"); - status = dcerpc_echo_TestSurrounding(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("TestSurrounding failed - %s\n", nt_errstr(status)); - return False; - } + status = dcerpc_echo_TestSurrounding(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "TestSurrounding failed"); - if (r.out.data->x != 2 * r.in.data->x) { - printf("TestSurrounding did not make the array twice as large\n"); - ret = False; - } + torture_assert(tctx, r.out.data->x == 2 * r.in.data->x, + "TestSurrounding did not make the array twice as large"); - return ret; + return true; } /* test multiple levels of pointers */ -static BOOL test_doublepointer(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_doublepointer(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct echo_TestDoublePointer r; - BOOL ret = True; uint16_t value = 12; uint16_t *pvalue = &value; uint16_t **ppvalue = &pvalue; @@ -414,112 +357,88 @@ static BOOL test_doublepointer(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) ZERO_STRUCT(r); r.in.data = &ppvalue; - printf("\nTesting TestDoublePointer\n"); - status = dcerpc_echo_TestDoublePointer(p, mem_ctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("TestDoublePointer failed - %s\n", nt_errstr(status)); - ret = False; - } + status = dcerpc_echo_TestDoublePointer(p, tctx, &r); + torture_assert_ntstatus_ok(tctx, status, "TestDoublePointer failed"); - if (value != r.out.result) { - printf("TestDoublePointer did not return original value (%d != %d)\n", value, r.out.result); - ret = False; - } - - return ret; + torture_assert_int_equal(tctx, value, r.out.result, + "TestDoublePointer did not return original value"); + return true; } /* test request timeouts */ -static BOOL test_timeout(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_timeout(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct rpc_request *req; struct echo_TestSleep r; int timeout_saved = p->request_timeout; - if (lp_parm_bool(-1, "torture", "quick", False)) { - printf("timeout testing disabled - use \"torture:quick=no\" to enable\n"); - return True; + if (torture_setting_bool(tctx, "quick", false)) { + torture_skip(tctx, "timeout testing disabled - use \"torture:quick=no\" to enable\n"); } - printf("testing request timeouts\n"); + torture_comment(tctx, "testing request timeouts\n"); r.in.seconds = 2; p->request_timeout = 1; - req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); - if (!req) { - printf("Failed to send async sleep request\n"); - goto failed; - } + torture_assert(tctx, req = dcerpc_echo_TestSleep_send(p, tctx, &r), + "Failed to send async sleep request"); status = dcerpc_ndr_request_recv(req); - if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("request should have timed out - %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT, + "request should have timed out"); - printf("testing request destruction\n"); - req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); + torture_comment(tctx, "testing request destruction\n"); + req = dcerpc_echo_TestSleep_send(p, tctx, &r); if (!req) { - printf("Failed to send async sleep request\n"); + torture_comment(tctx, "Failed to send async sleep request\n"); goto failed; } talloc_free(req); - req = dcerpc_echo_TestSleep_send(p, mem_ctx, &r); + req = dcerpc_echo_TestSleep_send(p, tctx, &r); if (!req) { - printf("Failed to send async sleep request\n"); + torture_comment(tctx, "Failed to send async sleep request\n"); goto failed; } status = dcerpc_ndr_request_recv(req); - if (!NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT)) { - printf("request should have timed out - %s\n", nt_errstr(status)); - goto failed; - } + torture_assert_ntstatus_equal(tctx, status, NT_STATUS_IO_TIMEOUT, + "request should have timed out"); p->request_timeout = timeout_saved; - return test_addone(p, mem_ctx); + + return test_addone(tctx, p); failed: p->request_timeout = timeout_saved; - return False; + return false; } -BOOL torture_rpc_echo(struct torture_context *torture) +struct torture_suite *torture_rpc_echo(void) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_echo"); - - status = torture_rpc_connection(mem_ctx, - &p, - &dcerpc_table_rpcecho); - if (!NT_STATUS_IS_OK(status)) { - return False; - } - - ret &= test_addone(p, mem_ctx); - ret &= test_sinkdata(p, mem_ctx); - ret &= test_echodata(p, mem_ctx); - ret &= test_sourcedata(p, mem_ctx); - ret &= test_testcall(p, mem_ctx); - ret &= test_testcall2(p, mem_ctx); - ret &= test_enum(p, mem_ctx); - ret &= test_surrounding(p, mem_ctx); - ret &= test_doublepointer(p, mem_ctx); - ret &= test_sleep(p, mem_ctx); - ret &= test_timeout(p, mem_ctx); - - printf("\n"); - - talloc_free(mem_ctx); - - return ret; + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), "ECHO"); + struct torture_tcase *tcase; + + tcase = torture_suite_add_rpc_iface_tcase(suite, "echo", + &dcerpc_table_rpcecho); + + torture_rpc_tcase_add_test(tcase, "addone", test_addone); + torture_rpc_tcase_add_test(tcase, "sinkdata", test_sinkdata); + torture_rpc_tcase_add_test(tcase, "echodata", test_echodata); + torture_rpc_tcase_add_test(tcase, "sourcedata", test_sourcedata); + torture_rpc_tcase_add_test(tcase, "testcall", test_testcall); + torture_rpc_tcase_add_test(tcase, "testcall2", test_testcall2); + torture_rpc_tcase_add_test(tcase, "enum", test_enum); + torture_rpc_tcase_add_test(tcase, "surrounding", test_surrounding); + torture_rpc_tcase_add_test(tcase, "doublepointer", test_doublepointer); + torture_rpc_tcase_add_test(tcase, "sleep", test_sleep); + torture_rpc_tcase_add_test(tcase, "timeout", test_timeout); + + return suite; } diff --git a/source4/torture/rpc/eventlog.c b/source4/torture/rpc/eventlog.c index 381b34a49c..3ecc1a422b 100644 --- a/source4/torture/rpc/eventlog.c +++ b/source4/torture/rpc/eventlog.c @@ -34,38 +34,72 @@ static void init_lsa_String(struct lsa_String *name, const char *s) name->size = name->length; } -static BOOL test_GetNumRecords(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool get_policy_handle(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + struct eventlog_OpenEventLogW r; + struct eventlog_OpenUnknown0 unknown0; + + unknown0.unknown0 = 0x005c; + unknown0.unknown1 = 0x0001; + + r.in.unknown0 = &unknown0; + init_lsa_String(&r.in.logname, "dns server"); + init_lsa_String(&r.in.servername, NULL); + r.in.unknown2 = 0x00000001; + r.in.unknown3 = 0x00000001; + r.out.handle = handle; + + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_OpenEventLogW(p, tctx, &r), + "OpenEventLog failed"); + + torture_assert_ntstatus_ok(tctx, r.out.result, "OpenEventLog failed"); + + return true; +} + + + +static bool test_GetNumRecords(struct torture_context *tctx, struct dcerpc_pipe *p) { - NTSTATUS status; struct eventlog_GetNumRecords r; + struct eventlog_CloseEventLog cr; + struct policy_handle handle; - printf("\ntesting GetNumRecords\n"); + if (!get_policy_handle(tctx, p, &handle)) + return false; - r.in.handle = handle; + r.in.handle = &handle; - status = dcerpc_eventlog_GetNumRecords(p, mem_ctx, &r); + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_GetNumRecords(p, tctx, &r), + "GetNumRecords failed"); - if (!NT_STATUS_IS_OK(status)) { - printf("GetNumRecords failed - %s\n", nt_errstr(status)); - return False; - } + torture_comment(tctx, talloc_asprintf(tctx, "%d records\n", r.out.number)); - printf("%d records\n", r.out.number); + cr.in.handle = cr.out.handle = &handle; - return True; + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_CloseEventLog(p, tctx, &cr), + "CloseEventLog failed"); + return true; } -static BOOL test_ReadEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_ReadEventLog(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct eventlog_ReadEventLogW r; + struct eventlog_CloseEventLog cr; + struct policy_handle handle; - printf("\ntesting ReadEventLog\n"); + if (!get_policy_handle(tctx, p, &handle)) + return false; r.in.offset = 0; - r.in.handle = handle; + r.in.handle = &handle; r.in.flags = EVENTLOG_BACKWARDS_READ|EVENTLOG_SEQUENTIAL_READ; while (1) { @@ -78,185 +112,142 @@ static BOOL test_ReadEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, r.in.number_of_bytes = 0; r.out.data = NULL; - status = dcerpc_eventlog_ReadEventLogW(p, mem_ctx, &r); + status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r); if (NT_STATUS_EQUAL(r.out.result, NT_STATUS_END_OF_FILE)) { break; } - if (!NT_STATUS_EQUAL(r.out.result, NT_STATUS_BUFFER_TOO_SMALL)) { - printf("ReadEventLog failed - %s\n", nt_errstr(r.out.result)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed"); + + torture_assert_ntstatus_equal(tctx, r.out.result, NT_STATUS_BUFFER_TOO_SMALL, + "ReadEventLog failed"); /* Now read the actual record */ r.in.number_of_bytes = r.out.real_size; - r.out.data = talloc_size(mem_ctx, r.in.number_of_bytes); + r.out.data = talloc_size(tctx, r.in.number_of_bytes); - status = dcerpc_eventlog_ReadEventLogW(p, mem_ctx, &r); + status = dcerpc_eventlog_ReadEventLogW(p, tctx, &r); - if (!NT_STATUS_IS_OK(status)) { - printf("ReadEventLog failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, "ReadEventLog failed"); /* Decode a user-marshalled record */ blob.length = r.out.sent_size; - blob.data = talloc_steal(mem_ctx, r.out.data); + blob.data = talloc_steal(tctx, r.out.data); - ndr = ndr_pull_init_blob(&blob, mem_ctx); + ndr = ndr_pull_init_blob(&blob, tctx); status = ndr_pull_eventlog_Record( ndr, NDR_SCALARS|NDR_BUFFERS, &rec); NDR_PRINT_DEBUG(eventlog_Record, &rec); - if (!NT_STATUS_IS_OK(status)) { - printf("ReadEventLog failed parsing event log record " - "- %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, status, + "ReadEventLog failed parsing event log record"); r.in.offset++; } - return True; -} - -static BOOL test_CloseEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) -{ - NTSTATUS status; - struct eventlog_CloseEventLog r; + cr.in.handle = cr.out.handle = &handle; - r.in.handle = r.out.handle = handle; - - printf("Testing CloseEventLog\n"); - - status = dcerpc_eventlog_CloseEventLog(p, mem_ctx, &r); - - if (!NT_STATUS_IS_OK(status)) { - printf("CloseEventLog failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_CloseEventLog(p, tctx, &cr), + "CloseEventLog failed"); - return True; + return true; } -static BOOL test_FlushEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_FlushEventLog(struct torture_context *tctx, + struct dcerpc_pipe *p) { - NTSTATUS status; struct eventlog_FlushEventLog r; + struct eventlog_CloseEventLog cr; + struct policy_handle handle; - r.in.handle = handle; - - printf("Testing FlushEventLog\n"); + if (!get_policy_handle(tctx, p, &handle)) + return false; - status = dcerpc_eventlog_FlushEventLog(p, mem_ctx, &r); + r.in.handle = &handle; /* Huh? Does this RPC always return access denied? */ + torture_assert_ntstatus_equal(tctx, + dcerpc_eventlog_FlushEventLog(p, tctx, &r), + NT_STATUS_ACCESS_DENIED, + "FlushEventLog failed"); - if (!NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { - printf("FlushEventLog failed - %s\n", nt_errstr(status)); - return False; - } + cr.in.handle = cr.out.handle = &handle; + + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_CloseEventLog(p, tctx, &cr), + "CloseEventLog failed"); - return True; + return true; } -static BOOL test_ClearEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_ClearEventLog(struct dcerpc_pipe *p, TALLOC_CTX *tctx) { - NTSTATUS status; struct eventlog_ClearEventLogW r; + struct eventlog_CloseEventLog cr; + struct policy_handle handle; - r.in.handle = handle; + if (!get_policy_handle(tctx, p, &handle)) + return false; + + r.in.handle = &handle; r.in.unknown = NULL; - printf("Testing ClearEventLog\n"); + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_ClearEventLogW(p, tctx, &r), + "ClearEventLog failed"); - status = dcerpc_eventlog_ClearEventLogW(p, mem_ctx, &r); + cr.in.handle = cr.out.handle = &handle; - if (!NT_STATUS_IS_OK(status)) { - printf("ClearEventLog failed - %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_CloseEventLog(p, tctx, &cr), + "CloseEventLog failed"); - return True; + return true; } -static BOOL test_OpenEventLog(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx, - struct policy_handle *handle) +static bool test_OpenEventLog(struct torture_context *tctx, + struct dcerpc_pipe *p) { - NTSTATUS status; - struct eventlog_OpenEventLogW r; - struct eventlog_OpenUnknown0 unknown0; - - printf("\ntesting OpenEventLog\n"); - - unknown0.unknown0 = 0x005c; - unknown0.unknown1 = 0x0001; - - r.in.unknown0 = &unknown0; - init_lsa_String(&r.in.logname, "dns server"); - init_lsa_String(&r.in.servername, NULL); - r.in.unknown2 = 0x00000001; - r.in.unknown3 = 0x00000001; - r.out.handle = handle; + struct policy_handle handle; + struct eventlog_CloseEventLog cr; - status = dcerpc_eventlog_OpenEventLogW(p, mem_ctx, &r); + if (!get_policy_handle(tctx, p, &handle)) + return false; - if (!NT_STATUS_IS_OK(status)) { - printf("OpenEventLog failed - %s\n", nt_errstr(status)); - return False; - } + cr.in.handle = cr.out.handle = &handle; - if (!NT_STATUS_IS_OK(r.out.result)) { - printf("OpenEventLog failed - %s\n", nt_errstr(r.out.result)); - return False; - } + torture_assert_ntstatus_ok(tctx, + dcerpc_eventlog_CloseEventLog(p, tctx, &cr), + "CloseEventLog failed"); - return True; + return true; } -BOOL torture_rpc_eventlog(struct torture_context *torture) +struct torture_suite *torture_rpc_eventlog(void) { - NTSTATUS status; - struct dcerpc_pipe *p; - struct policy_handle handle; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_atsvc"); + struct torture_suite *suite; + struct torture_tcase *tcase; - status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_eventlog); + suite = torture_suite_create(talloc_autofree_context(), "EVENTLOG"); + tcase = torture_suite_add_rpc_iface_tcase(suite, "eventlog", + &dcerpc_table_eventlog); - if (!NT_STATUS_IS_OK(status)) { - talloc_free(mem_ctx); - return False; - } - - if (!test_OpenEventLog(p, mem_ctx, &handle)) { - talloc_free(mem_ctx); - return False; - } + torture_rpc_tcase_add_test(tcase, "OpenEventLog", test_OpenEventLog); #if 0 - ret &= test_ClearEventLog(p, mem_ctx, &handle); /* Destructive test */ + /* Destructive test */ + torture_rpc_tcase_add_test(tcase, "ClearEventLog", test_ClearEventLog); #endif - ret &= test_GetNumRecords(p, mem_ctx, &handle); - - ret &= test_ReadEventLog(p, mem_ctx, &handle); - - ret &= test_FlushEventLog(p, mem_ctx, &handle); - - ret &= test_CloseEventLog(p, mem_ctx, &handle); - - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "GetNumRecords", test_GetNumRecords); + torture_rpc_tcase_add_test(tcase, "ReadEventLog", test_ReadEventLog); + torture_rpc_tcase_add_test(tcase, "FlushEventLog", test_FlushEventLog); - return ret; + return suite; } diff --git a/source4/torture/rpc/rpc.c b/source4/torture/rpc/rpc.c index 754633e51b..6d3031ede9 100644 --- a/source4/torture/rpc/rpc.c +++ b/source4/torture/rpc/rpc.c @@ -26,6 +26,7 @@ #include "torture/rpc/rpc.h" #include "torture/torture.h" #include "librpc/rpc/dcerpc_table.h" +#include "lib/util/dlinklist.h" /* open a rpc connection to the chosen binding string */ _PUBLIC_ NTSTATUS torture_rpc_connection(TALLOC_CTX *parent_ctx, @@ -89,64 +90,136 @@ NTSTATUS torture_rpc_connection_transport(TALLOC_CTX *parent_ctx, return status; } +static bool torture_rpc_setup (struct torture_context *tctx, void **data) +{ + NTSTATUS status; + + status = torture_rpc_connection(tctx, + (struct dcerpc_pipe **)data, + (const struct dcerpc_interface_table *)tctx->active_tcase->data); + + torture_assert_ntstatus_ok(tctx, status, "Error connecting to server"); + + return true; +} + +static bool torture_rpc_teardown (struct torture_context *tcase, void *data) +{ + talloc_free(data); + return true; +} + +_PUBLIC_ struct torture_tcase *torture_suite_add_rpc_iface_tcase(struct torture_suite *suite, + const char *name, + const struct dcerpc_interface_table *table) +{ + struct torture_tcase *tcase = torture_suite_add_tcase(suite, name); + + tcase->setup = torture_rpc_setup; + tcase->teardown = torture_rpc_teardown; + tcase->data = table; + + return tcase; +} + +static bool torture_rpc_wrap_test(struct torture_context *tctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct dcerpc_pipe *); + + fn = test->fn; + + return fn(tctx, (struct dcerpc_pipe *)tcase->data); +} + +_PUBLIC_ struct torture_test *torture_rpc_tcase_add_test( + struct torture_tcase *tcase, + const char *name, + bool (*fn) (struct torture_context *, struct dcerpc_pipe *)) +{ + struct torture_test *test; + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = torture_rpc_wrap_test; + test->dangerous = false; + test->data = NULL; + test->fn = fn; + + DLIST_ADD(tcase->tests, test); + + return test; +} + NTSTATUS torture_rpc_init(void) { + struct torture_suite *suite = torture_suite_create( + talloc_autofree_context(), + "RPC"); dcerpc_init(); dcerpc_table_init(); - register_torture_op("RPC-LSA", torture_rpc_lsa); - register_torture_op("RPC-LSALOOKUP", torture_rpc_lsa_lookup); - register_torture_op("RPC-LSA-GETUSER", torture_rpc_lsa_get_user); - register_torture_op("RPC-SECRETS", torture_rpc_lsa_secrets); - register_torture_op("RPC-ECHO", torture_rpc_echo); - register_torture_op("RPC-DFS", torture_rpc_dfs); - register_torture_op("RPC-SPOOLSS", torture_rpc_spoolss); - register_torture_op("RPC-SAMR", torture_rpc_samr); - register_torture_op("RPC-SAMR-USERS", torture_rpc_samr_users); - register_torture_op("RPC-SAMR-PASSWORDS", torture_rpc_samr_passwords); - register_torture_op("RPC-UNIXINFO", torture_rpc_unixinfo); - register_torture_op("RPC-NETLOGON", torture_rpc_netlogon); - register_torture_op("RPC-SAMLOGON", torture_rpc_samlogon); - register_torture_op("RPC-SAMSYNC", torture_rpc_samsync); - register_torture_op("RPC-SCHANNEL", torture_rpc_schannel); - register_torture_op("RPC-WKSSVC", torture_rpc_wkssvc); - register_torture_op("RPC-SRVSVC", torture_rpc_srvsvc); - register_torture_op("RPC-SVCCTL", torture_rpc_svcctl); - register_torture_op("RPC-ATSVC", torture_rpc_atsvc); - register_torture_op("RPC-EVENTLOG", torture_rpc_eventlog); - register_torture_op("RPC-EPMAPPER", torture_rpc_epmapper); - register_torture_op("RPC-WINREG", torture_rpc_winreg); - register_torture_op("RPC-INITSHUTDOWN", torture_rpc_initshutdown); - register_torture_op("RPC-OXIDRESOLVE", torture_rpc_oxidresolve); - register_torture_op("RPC-REMACT", torture_rpc_remact); - register_torture_op("RPC-MGMT", torture_rpc_mgmt); - register_torture_op("RPC-SCANNER", torture_rpc_scanner); - register_torture_op("RPC-AUTOIDL", torture_rpc_autoidl); - register_torture_op("RPC-COUNTCALLS", torture_rpc_countcalls); - register_torture_op("RPC-MULTIBIND", torture_multi_bind); - register_torture_op("RPC-AUTHCONTEXT", torture_bind_authcontext); - register_torture_op("RPC-BINDSAMBA3", torture_bind_samba3); - register_torture_op("RPC-NETLOGSAMBA3", torture_netlogon_samba3); - register_torture_op("RPC-SAMBA3SESSIONKEY", torture_samba3_sessionkey); - register_torture_op("RPC-SAMBA3-SRVSVC", torture_samba3_rpc_srvsvc); - register_torture_op("RPC-SAMBA3-SHARESEC", + torture_suite_add_simple_test(suite, "LSA", torture_rpc_lsa); + torture_suite_add_simple_test(suite, "LSALOOKUP", torture_rpc_lsa_lookup); + torture_suite_add_simple_test(suite, "LSA-GETUSER", torture_rpc_lsa_get_user); + torture_suite_add_simple_test(suite, "SECRETS", torture_rpc_lsa_secrets); + torture_suite_add_suite(suite, torture_rpc_echo()); + torture_suite_add_suite(suite, torture_rpc_dfs()); + torture_suite_add_suite(suite, torture_rpc_unixinfo()); + torture_suite_add_suite(suite, torture_rpc_eventlog()); + torture_suite_add_suite(suite, torture_rpc_atsvc()); + torture_suite_add_suite(suite, torture_rpc_wkssvc()); + torture_suite_add_simple_test(suite, "SPOOLSS", torture_rpc_spoolss); + torture_suite_add_simple_test(suite, "SAMR", torture_rpc_samr); + torture_suite_add_simple_test(suite, "SAMR-USERS", torture_rpc_samr_users); + torture_suite_add_simple_test(suite, "SAMR-PASSWORDS", torture_rpc_samr_passwords); + torture_suite_add_simple_test(suite, "NETLOGON", torture_rpc_netlogon); + torture_suite_add_simple_test(suite, "SAMLOGON", torture_rpc_samlogon); + torture_suite_add_simple_test(suite, "SAMSYNC", torture_rpc_samsync); + torture_suite_add_simple_test(suite, "SCHANNEL", torture_rpc_schannel); + torture_suite_add_simple_test(suite, "SRVSVC", torture_rpc_srvsvc); + torture_suite_add_simple_test(suite, "SVCCTL", torture_rpc_svcctl); + torture_suite_add_simple_test(suite, "EPMAPPER", torture_rpc_epmapper); + torture_suite_add_simple_test(suite, "WINREG", torture_rpc_winreg); + torture_suite_add_simple_test(suite, "INITSHUTDOWN", torture_rpc_initshutdown); + torture_suite_add_simple_test(suite, "OXIDRESOLVE", torture_rpc_oxidresolve); + torture_suite_add_simple_test(suite, "REMACT", torture_rpc_remact); + torture_suite_add_simple_test(suite, "MGMT", torture_rpc_mgmt); + torture_suite_add_simple_test(suite, "SCANNER", torture_rpc_scanner); + torture_suite_add_simple_test(suite, "AUTOIDL", torture_rpc_autoidl); + torture_suite_add_simple_test(suite, "COUNTCALLS", torture_rpc_countcalls); + torture_suite_add_simple_test(suite, "MULTIBIND", torture_multi_bind); + torture_suite_add_simple_test(suite, "AUTHCONTEXT", torture_bind_authcontext); + torture_suite_add_simple_test(suite, "BINDSAMBA3", torture_bind_samba3); + torture_suite_add_simple_test(suite, "NETLOGSAMBA3", torture_netlogon_samba3); + torture_suite_add_simple_test(suite, "SAMBA3SESSIONKEY", torture_samba3_sessionkey); + torture_suite_add_simple_test(suite, "SAMBA3-SRVSVC", torture_samba3_rpc_srvsvc); + torture_suite_add_simple_test(suite, "SAMBA3-SHARESEC", torture_samba3_rpc_sharesec); - register_torture_op("RPC-SAMBA3-GETUSERNAME", + torture_suite_add_simple_test(suite, "SAMBA3-GETUSERNAME", torture_samba3_rpc_getusername); - register_torture_op("RPC-SAMBA3-LSA", torture_samba3_rpc_lsa); - register_torture_op("RPC-SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss); - register_torture_op("RPC-SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc); - register_torture_op("RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg); - register_torture_op("RPC-DRSUAPI", torture_rpc_drsuapi); - register_torture_op("RPC-CRACKNAMES", torture_rpc_drsuapi_cracknames); - register_torture_op("RPC-ROT", torture_rpc_rot); - register_torture_op("RPC-DSSETUP", torture_rpc_dssetup); - register_torture_op("RPC-ALTERCONTEXT", torture_rpc_alter_context); - register_torture_op("RPC-JOIN", torture_rpc_join); - register_torture_op("RPC-DSSYNC", torture_rpc_dssync); - register_torture_op("BENCH-RPC", torture_bench_rpc); - register_torture_op("RPC-ASYNCBIND", torture_async_bind); + torture_suite_add_simple_test(suite, "SAMBA3-LSA", torture_samba3_rpc_lsa); + torture_suite_add_simple_test(suite, "SAMBA3-SPOOLSS", torture_samba3_rpc_spoolss); + torture_suite_add_simple_test(suite, "SAMBA3-WKSSVC", torture_samba3_rpc_wkssvc); + torture_suite_add_simple_test(suite, "RPC-SAMBA3-WINREG", torture_samba3_rpc_winreg); + torture_suite_add_simple_test(suite, "DRSUAPI", torture_rpc_drsuapi); + torture_suite_add_simple_test(suite, "CRACKNAMES", torture_rpc_drsuapi_cracknames); + torture_suite_add_simple_test(suite, "ROT", torture_rpc_rot); + torture_suite_add_simple_test(suite, "DSSETUP", torture_rpc_dssetup); + torture_suite_add_simple_test(suite, "ALTERCONTEXT", torture_rpc_alter_context); + torture_suite_add_simple_test(suite, "JOIN", torture_rpc_join); + torture_suite_add_simple_test(suite, "DSSYNC", torture_rpc_dssync); + torture_suite_add_simple_test(suite, "BENCH-RPC", torture_bench_rpc); + torture_suite_add_simple_test(suite, "ASYNCBIND", torture_async_bind); + + suite->description = talloc_strdup(suite, + "DCE/RPC protocol and interface tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/rpc/rpc.h b/source4/torture/rpc/rpc.h index 6d020bde88..934e1a214d 100644 --- a/source4/torture/rpc/rpc.h +++ b/source4/torture/rpc/rpc.h @@ -29,5 +29,6 @@ #include "librpc/rpc/dcerpc.h" #include "libcli/raw/libcliraw.h" #include "torture/rpc/proto.h" +#include "torture/ui.h" #endif /* __TORTURE_RPC_H__ */ diff --git a/source4/torture/rpc/unixinfo.c b/source4/torture/rpc/unixinfo.c index 4bf27b916b..567a85fd44 100644 --- a/source4/torture/rpc/unixinfo.c +++ b/source4/torture/rpc/unixinfo.c @@ -51,24 +51,21 @@ static BOOL test_sidtouid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* test the UidToSid interface */ -static BOOL test_uidtosid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_uidtosid(struct torture_context *tctx, + struct dcerpc_pipe *p) { - NTSTATUS status; struct unixinfo_UidToSid r; r.in.uid = 1000; - status = dcerpc_unixinfo_UidToSid(p, mem_ctx, &r); - if (NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_USER, status)) { - } else if (!NT_STATUS_IS_OK(status)) { - printf("UidToSid failed == %s\n", nt_errstr(status)); - return False; - } + torture_assert_ntstatus_ok(tctx, dcerpc_unixinfo_UidToSid(p, tctx, &r), + "UidToSid failed"); - return True; + return true; } -static BOOL test_getpwuid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static bool test_getpwuid(struct torture_context *tctx, + struct dcerpc_pipe *p) { uint64_t uids[512]; uint32_t num_uids = ARRAY_SIZE(uids); @@ -83,11 +80,13 @@ static BOOL test_getpwuid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) r.in.count = &num_uids; r.in.uids = uids; r.out.count = &num_uids; - r.out.infos = talloc_array(mem_ctx, struct unixinfo_GetPWUidInfo, num_uids); + r.out.infos = talloc_array(tctx, struct unixinfo_GetPWUidInfo, num_uids); - result = dcerpc_unixinfo_GetPWUid(p, mem_ctx, &r); + result = dcerpc_unixinfo_GetPWUid(p, tctx, &r); - return NT_STATUS_IS_OK(result); + torture_assert_ntstatus_ok(tctx, result, "GetPWUid failed"); + + return true; } /* @@ -115,44 +114,32 @@ static BOOL test_sidtogid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) /* test the GidToSid interface */ -static BOOL test_gidtosid(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx) +static BOOL test_gidtosid(struct torture_context *tctx, struct dcerpc_pipe *p) { NTSTATUS status; struct unixinfo_GidToSid r; r.in.gid = 1000; - status = dcerpc_unixinfo_GidToSid(p, mem_ctx, &r); + status = dcerpc_unixinfo_GidToSid(p, tctx, &r); if (NT_STATUS_EQUAL(NT_STATUS_NO_SUCH_GROUP, status)) { - } else if (!NT_STATUS_IS_OK(status)) { - printf("GidToSid failed == %s\n", nt_errstr(status)); - return False; - } + } else torture_assert_ntstatus_ok(tctx, status, "GidToSid failed"); - return True; + return true; } -BOOL torture_rpc_unixinfo(struct torture_context *torture) +struct torture_suite *torture_rpc_unixinfo(void) { - NTSTATUS status; - struct dcerpc_pipe *p; - TALLOC_CTX *mem_ctx; - BOOL ret = True; - - mem_ctx = talloc_init("torture_rpc_unixinfo"); + struct torture_suite *suite; + struct torture_tcase *tcase; - status = torture_rpc_connection(mem_ctx, &p, &dcerpc_table_unixinfo); - if (!NT_STATUS_IS_OK(status)) { - return False; - } + suite = torture_suite_create(talloc_autofree_context(), "UNIXINFO"); + tcase = torture_suite_add_rpc_iface_tcase(suite, "unixinfo", + &dcerpc_table_unixinfo); - ret &= test_uidtosid(p, mem_ctx); - ret &= test_getpwuid(p, mem_ctx); - ret &= test_gidtosid(p, mem_ctx); - - printf("\n"); - - talloc_free(mem_ctx); + torture_rpc_tcase_add_test(tcase, "uidtosid", test_uidtosid); + torture_rpc_tcase_add_test(tcase, "getpwuid", test_getpwuid); + torture_rpc_tcase_add_test(tcase, "gidtosid", test_gidtosid); - return ret; + return suite; } diff --git a/source4/torture/rpc/wkssvc.c b/source4/torture/rpc/wkssvc.c index 4526b3f91b..e99cdada28 100644 --- a/source4/torture/rpc/wkssvc.c +++ b/source4/torture/rpc/wkssvc.c @@ -24,43 +24,37 @@ #include "librpc/gen_ndr/ndr_wkssvc_c.h" #include "torture/rpc/rpc.h" - -static BOOL test_NetWkstaGetInfo(struct dcerpc_pipe *p, - TALLOC_CTX *mem_ctx) +static bool test_NetWkstaGetInfo(struct torture_context *tctx, + struct dcerpc_pipe *p) { NTSTATUS status; struct wkssvc_NetWkstaGetInfo r; union wkssvc_NetWkstaInfo info; uint16_t levels[] = {100, 101, 102, 502}; int i; - BOOL ret = True; r.in.server_name = dcerpc_server_name(p); r.out.info = &info; for (i=0;idescription = talloc_strdup(suite, + "SMB2-specific tests"); + + torture_register_suite(suite); return NT_STATUS_OK; } diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index 5570e3999c..4c2cfa5524 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -33,35 +33,85 @@ #include "lib/util/dlinklist.h" #include "librpc/rpc/dcerpc.h" +static bool run_matching(struct torture_context *torture, + const char *prefix, + const char *expr, + struct torture_suite *suite, + bool *matched) +{ + bool ret = true; + + if (suite == NULL) { + struct torture_suite_list *o; + + for (o = torture_suites; o; o = o->next) { + if (gen_fnmatch(expr, o->suite->name) == 0) { + *matched = true; + init_iconv(); + ret &= torture_run_suite(torture, o->suite); + continue; + } + + ret &= run_matching(torture, + o->suite->name, expr, o->suite, matched); + } + } else { + char *name; + struct torture_suite *c; + struct torture_tcase *t; + + for (c = suite->children; c; c = c->next) { + asprintf(&name, "%s-%s", prefix, c->name); + if (gen_fnmatch(expr, name) == 0) { + *matched = true; + init_iconv(); + ret &= torture_run_suite(torture, c); + free(name); + continue; + } + + ret &= run_matching(torture, name, expr, c, matched); + + free(name); + } + + for (t = suite->testcases; t; t = t->next) { + asprintf(&name, "%s-%s", prefix, t->name); + if (gen_fnmatch(expr, name) == 0) { + *matched = true; + init_iconv(); + ret &= torture_run_tcase(torture, t); + } + free(name); + } + } + + return ret; +} + #define MAX_COLS 80 /* FIXME: Determine this at run-time */ /**************************************************************************** run a specified test or "ALL" ****************************************************************************/ -static BOOL run_test(struct torture_context *torture, const char *name) +static bool run_test(struct torture_context *torture, const char *name) { - BOOL ret = True; + bool ret = true; + bool matched = false; struct torture_suite_list *o; - BOOL matched = False; - if (strequal(name,"ALL")) { + if (strequal(name, "ALL")) { for (o = torture_suites; o; o = o->next) { ret &= torture_run_suite(torture, o->suite); } return ret; } - for (o = torture_suites; o; o = o->next) { - if (gen_fnmatch(name, o->suite->name) == 0) { - matched = True; - init_iconv(); - ret &= torture_run_suite(torture, o->suite); - } - } + ret = run_matching(torture, NULL, name, NULL, &matched); if (!matched) { printf("Unknown torture operation '%s'\n", name); - ret = False; + return false; } return ret; @@ -110,7 +160,8 @@ static void parse_dns(const char *dns) static void usage(poptContext pc) { struct torture_suite_list *o; - char last_prefix[64]; + struct torture_suite *s; + struct torture_tcase *t; int i; poptPrintUsage(pc, stdout, 0); @@ -165,35 +216,35 @@ static void usage(poptContext pc) printf("Tests are:"); - i = 0; - last_prefix[0] = '\0'; for (o = torture_suites; o; o = o->next) { - const char * sep; - - if ((sep = strchr(o->suite->name, '-'))) { - if (strncmp(o->suite->name, last_prefix, sep-o->suite->name) != 0) { - strncpy(last_prefix, o->suite->name, - MIN(sizeof(last_prefix), - sep - o->suite->name)); - printf("\n\n "); + printf("\n%s (%s):\n ", o->suite->description, o->suite->name); + + i = 0; + for (s = o->suite->children; s; s = s->next) { + if (i + strlen(o->suite->name) + strlen(s->name) >= (MAX_COLS - 3)) { + printf("\n "); i = 0; } + i+=printf("%s-%s ", o->suite->name, s->name); } - if (i + strlen(o->suite->name) >= (MAX_COLS - 2)) { - printf("\n "); - i = 0; + for (t = o->suite->testcases; t; t = t->next) { + if (i + strlen(o->suite->name) + strlen(t->name) >= (MAX_COLS - 3)) { + printf("\n "); + i = 0; + } + i+=printf("%s-%s ", o->suite->name, t->name); } - i+=printf("%s ", o->suite->name); + + if (i) printf("\n"); } - printf("\n\n"); - printf("The default test is ALL.\n"); + printf("\nThe default test is ALL.\n"); exit(1); } -static BOOL is_binding_string(const char *binding_string) +static bool is_binding_string(const char *binding_string) { TALLOC_CTX *mem_ctx = talloc_named_const(NULL, 0, "is_binding_string"); struct dcerpc_binding *binding_struct; @@ -249,9 +300,10 @@ static void simple_test_result (struct torture_context *context, } } -static void simple_comment (struct torture_context *test, const char *comment) +static void simple_comment (struct torture_context *test, + const char *comment) { - printf("# %s\n", comment); + printf("%s", comment); } const static struct torture_ui_ops std_ui_ops = { @@ -288,9 +340,11 @@ static void subunit_test_result (struct torture_context *context, } } -static void subunit_comment (struct torture_context *test, const char *comment) +static void subunit_comment (struct torture_context *test, + const char *comment) { - printf("# %s\n", comment); + /* FIXME Add # sign before each line */ + printf("%s", comment); } const static struct torture_ui_ops subunit_ui_ops = { @@ -324,7 +378,8 @@ static void harness_test_result (struct torture_context *context, } } -static void harness_comment (struct torture_context *test, const char *comment) +static void harness_comment (struct torture_context *test, + const char *comment) { printf("# %s\n", comment); } @@ -338,7 +393,11 @@ const static struct torture_ui_ops harness_ui_ops = { static void quiet_suite_start(struct torture_context *ctx, struct torture_suite *suite) { + int i; + ctx->quiet = true; + for (i = 1; i < ctx->level; i++) putchar('\t'); printf("%s: ", suite->name); + fflush(stdout); } static void quiet_suite_finish(struct torture_context *ctx, @@ -348,8 +407,9 @@ static void quiet_suite_finish(struct torture_context *ctx, } static void quiet_test_result (struct torture_context *context, - enum torture_result res, const char *reason) + enum torture_result res, const char *reason) { + fflush(stdout); switch (res) { case TORTURE_OK: putchar('.'); break; case TORTURE_FAIL: putchar('E'); break; @@ -371,7 +431,7 @@ const static struct torture_ui_ops quiet_ui_ops = { int main(int argc,char *argv[]) { int opt, i; - BOOL correct = True; + bool correct = true; int max_runtime=0; int argc_new; struct torture_context *torture; @@ -390,7 +450,6 @@ const static struct torture_ui_ops quiet_ui_ops = { {"num-progs", 0, POPT_ARG_INT, &torture_nprocs, 0, "num progs", NULL}, {"num-ops", 0, POPT_ARG_INT, &torture_numops, 0, "num ops", NULL}, {"entries", 0, POPT_ARG_INT, &torture_entries, 0, "entries", NULL}, - {"use-oplocks", 'L', POPT_ARG_NONE, &use_oplocks, 0, "use oplocks", NULL}, {"show-all", 0, POPT_ARG_NONE, &torture_showall, 0, "show all", NULL}, {"loadfile", 0, POPT_ARG_STRING, NULL, OPT_LOADFILE, "loadfile", NULL}, {"unclist", 0, POPT_ARG_STRING, NULL, OPT_UNCLIST, "unclist", NULL}, @@ -416,7 +475,7 @@ const static struct torture_ui_ops quiet_ui_ops = { setlinebuf(stdout); /* we are never interested in SIGPIPE */ - BlockSignals(True,SIGPIPE); + BlockSignals(true,SIGPIPE); pc = poptGetContext("smbtorture", argc, (const char **) argv, long_options, POPT_CONTEXT_KEEP_FIRST); @@ -513,7 +572,7 @@ const static struct torture_ui_ops quiet_ui_ops = { lp_set_cmdline("torture:binding", binding); } - torture = talloc_zero(NULL, struct torture_context); + torture = talloc_zero(talloc_autofree_context(), struct torture_context); if (!strcmp(ui_ops_name, "simple")) { torture->ui_ops = &std_ui_ops; } else if (!strcmp(ui_ops_name, "subunit")) { @@ -534,15 +593,19 @@ const static struct torture_ui_ops quiet_ui_ops = { double rate; for (i=2;iskipped+torture->success+torture->failed; - rate = ((total - torture->failed) * (100.0 / total)); - printf("Tests: %d, Errors: %d, Skipped: %d. Success rate: %.2f%%\n", + if (total == 0) { + printf("No tests run.\n"); + } else { + rate = ((total - torture->failed) * (100.0 / total)); + printf("Tests: %d, Errors: %d, Skipped: %d. Success rate: %.2f%%\n", total, torture->failed, torture->skipped, rate); + } } talloc_free(torture); diff --git a/source4/torture/torture.c b/source4/torture/torture.c index c332f2286a..d5cb0511f7 100644 --- a/source4/torture/torture.c +++ b/source4/torture/torture.c @@ -31,13 +31,11 @@ _PUBLIC_ int torture_entries=1000; _PUBLIC_ int torture_failures=1; _PUBLIC_ int torture_seed=0; _PUBLIC_ int torture_numasync=100; -_PUBLIC_ BOOL use_oplocks; -_PUBLIC_ BOOL use_level_II_oplocks; -_PUBLIC_ BOOL torture_showall = False; +_PUBLIC_ bool torture_showall = false; struct torture_suite_list *torture_suites = NULL; -_PUBLIC_ NTSTATUS torture_register_suite(struct torture_suite *suite) +NTSTATUS torture_register_suite(struct torture_suite *suite) { struct torture_suite_list *p, *n; @@ -62,26 +60,7 @@ _PUBLIC_ NTSTATUS torture_register_suite(struct torture_suite *suite) } } - DLIST_ADD(torture_suites, n); - - return NT_STATUS_OK; -} - -static BOOL wrap_old_torture_fn(struct torture_context *torture, const void *_fn) -{ - BOOL (*fn)(struct torture_context *) = _fn; - return fn(torture); -} - - -/* Backwards compatibility wrapper */ -_PUBLIC_ NTSTATUS register_torture_op(const char *name, BOOL (*fn)(struct torture_context *)) -{ - struct torture_suite *suite; - suite = torture_suite_create(talloc_autofree_context(), name); - - torture_suite_add_simple_tcase(suite, name, wrap_old_torture_fn, fn); - torture_register_suite(suite); + DLIST_ADD_END(torture_suites, n, struct torture_suite_list *); return NT_STATUS_OK; } diff --git a/source4/torture/ui.c b/source4/torture/ui.c index 4abc3339d4..c105f4ec9d 100644 --- a/source4/torture/ui.c +++ b/source4/torture/ui.c @@ -23,7 +23,8 @@ #include "torture/ui.h" #include "lib/util/dlinklist.h" -void torture_comment(struct torture_context *context, const char *comment, ...) +void torture_comment(struct torture_context *context, + const char *comment, ...) { va_list ap; char *tmp; @@ -39,7 +40,8 @@ void torture_comment(struct torture_context *context, const char *comment, ...) talloc_free(tmp); } -void torture_fail(struct torture_context *context, const char *fmt, ...) +void _torture_fail_ext(struct torture_context *context, + const char *fmt, ...) { va_list ap; @@ -51,7 +53,8 @@ void torture_fail(struct torture_context *context, const char *fmt, ...) context->last_result = TORTURE_FAIL; } -void torture_skip(struct torture_context *context, const char *fmt, ...) +void _torture_skip_ext(struct torture_context *context, + const char *fmt, ...) { va_list ap; context->skipped++; @@ -68,6 +71,7 @@ struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name) suite->name = talloc_strdup(suite, name); suite->testcases = NULL; + suite->children = NULL; return suite; } @@ -80,9 +84,22 @@ void torture_tcase_set_fixture(struct torture_tcase *tcase, tcase->teardown = teardown; } +static bool wrap_test_with_testcase(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, + const void *tcase_data, + const void *test_data); + + fn = test->fn; + + return fn(torture_ctx, tcase->data, test->data); +} + struct torture_test *torture_tcase_add_test(struct torture_tcase *tcase, const char *name, - BOOL (*run) (struct torture_context *, + bool (*run) (struct torture_context *, const void *tcase_data, const void *test_data), const void *data) @@ -91,7 +108,8 @@ struct torture_test *torture_tcase_add_test(struct torture_tcase *tcase, test->name = talloc_strdup(test, name); test->description = NULL; - test->run = run; + test->run = wrap_test_with_testcase; + test->fn = run; test->dangerous = False; test->data = data; @@ -112,7 +130,7 @@ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, tcase->fixture_persistent = True; tcase->tests = NULL; - DLIST_ADD(suite->testcases, tcase); + DLIST_ADD_END(suite->testcases, tcase, struct torture_tcase *); return tcase; } @@ -122,7 +140,9 @@ BOOL torture_run_suite(struct torture_context *context, { BOOL ret = True; struct torture_tcase *tcase; + struct torture_suite *tsuite; + context->level++; if (context->ui_ops->suite_start) context->ui_ops->suite_start(context, suite); @@ -130,8 +150,14 @@ BOOL torture_run_suite(struct torture_context *context, ret &= torture_run_tcase(context, tcase); } + for (tsuite = suite->children; tsuite; tsuite = tsuite->next) { + ret &= torture_run_suite(context, tsuite); + } + if (context->ui_ops->suite_finish) context->ui_ops->suite_finish(context, suite); + + context->level--; return ret; } @@ -139,19 +165,18 @@ BOOL torture_run_suite(struct torture_context *context, static BOOL internal_torture_run_test(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test, - BOOL already_setup, - const void *tcase_data) + BOOL already_setup) { BOOL ret; - void *data = NULL; - if (test->dangerous && !lp_parm_bool(-1, "torture", "dangerous", False)) { - torture_skip(context, "disabled %s - enable dangerous tests to use", - test->name); + if (test->dangerous && !torture_setting_bool(context, "dangerous", False)) { + _torture_skip_ext(context, + "disabled %s - enable dangerous tests to use", test->name); return True; } - if (!already_setup && tcase->setup && !tcase->setup(context, &data)) + if (!already_setup && tcase->setup && + !tcase->setup(context, &(tcase->data))) return False; context->active_tcase = tcase; @@ -163,14 +188,16 @@ static BOOL internal_torture_run_test(struct torture_context *context, context->last_reason = NULL; context->last_result = TORTURE_OK; - ret = test->run(context, !already_setup?data:tcase_data, test->data); + ret = test->run(context, tcase, test); if (!ret) { - context->last_reason = talloc_strdup(context, "..."); + if (context->last_reason == NULL) + context->last_reason = talloc_strdup(context, "..."); context->last_result = TORTURE_FAIL; } if (context->ui_ops->test_result) - context->ui_ops->test_result(context, context->last_result, + context->ui_ops->test_result(context, + context->last_result, context->last_reason); @@ -186,7 +213,7 @@ static BOOL internal_torture_run_test(struct torture_context *context, context->active_test = NULL; context->active_tcase = NULL; - if (!already_setup && tcase->teardown && !tcase->teardown(context, data)) + if (!already_setup && tcase->teardown && !tcase->teardown(context, tcase->data)) return False; return ret; @@ -196,27 +223,27 @@ BOOL torture_run_tcase(struct torture_context *context, struct torture_tcase *tcase) { BOOL ret = True; - void *data = NULL; struct torture_test *test; + context->level++; + context->active_tcase = tcase; if (context->ui_ops->tcase_start) context->ui_ops->tcase_start(context, tcase); if (tcase->fixture_persistent && tcase->setup - && !tcase->setup(context, &data)) { + && !tcase->setup(context, &tcase->data)) { ret = False; goto done; } for (test = tcase->tests; test; test = test->next) { ret &= internal_torture_run_test(context, tcase, test, - tcase->fixture_persistent, - (tcase->setup?data:tcase->data)); + tcase->fixture_persistent); } if (tcase->fixture_persistent && tcase->teardown && - !tcase->teardown(context, data)) + !tcase->teardown(context, tcase->data)) ret = False; done: @@ -225,6 +252,8 @@ done: if (context->ui_ops->tcase_finish) context->ui_ops->tcase_finish(context, tcase); + context->level--; + return ret; } @@ -232,10 +261,22 @@ BOOL torture_run_test(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test) { - return internal_torture_run_test(context, tcase, test, False, NULL); + return internal_torture_run_test(context, tcase, test, False); } -const char *torture_setting(struct torture_context *test, const char *name, +int torture_setting_int(struct torture_context *test, const char *name, + int default_value) +{ + return lp_parm_int(-1, "torture", name, default_value); +} + +bool torture_setting_bool(struct torture_context *test, const char *name, + bool default_value) +{ + return lp_parm_bool(-1, "torture", name, default_value); +} + +const char *torture_setting_string(struct torture_context *test, const char *name, const char *default_value) { const char *ret = lp_parm_string(-1, "torture", name); @@ -246,27 +287,72 @@ const char *torture_setting(struct torture_context *test, const char *name, return ret; } -static BOOL simple_tcase_helper(struct torture_context *test, - const void *tcase_data, - const void *test_data) +static bool wrap_test_with_simple_tcase(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) { - BOOL (*run) (struct torture_context *, const void *) = test_data; + bool (*fn) (struct torture_context *, const void *tcase_data); + + fn = test->fn; - return run(test, tcase_data); + return fn(torture_ctx, test->data); } struct torture_tcase *torture_suite_add_simple_tcase( struct torture_suite *suite, const char *name, - BOOL (*run) (struct torture_context *test, const void *), + bool (*run) (struct torture_context *test, const void *), const void *data) { struct torture_tcase *tcase; + struct torture_test *test; tcase = torture_suite_add_tcase(suite, name); - tcase->data = data; - torture_tcase_add_test(tcase, name, simple_tcase_helper, run); + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_test_with_simple_tcase; + test->fn = run; + test->data = data; + test->dangerous = False; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return tcase; +} + +static bool wrap_simple_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *); + + fn = test->fn; + + return fn(torture_ctx); +} + +struct torture_tcase *torture_suite_add_simple_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *test)) +{ + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_simple_test; + test->fn = run; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); return tcase; } @@ -275,3 +361,26 @@ BOOL torture_teardown_free(struct torture_context *torture, void *data) { return talloc_free(data); } + + +bool torture_suite_add_suite(struct torture_suite *suite, + struct torture_suite *child) +{ + if (child == NULL) + return false; + + DLIST_ADD_END(suite->children, child, struct torture_suite *); + + /* FIXME: Check for duplicates and return false if the + * added suite already exists as a child */ + + return true; +} + + +struct torture_suite *torture_find_suite(const char *name) +{ + /* FIXME */ + + return NULL; +} diff --git a/source4/torture/ui.h b/source4/torture/ui.h index 006e2b99ef..36457e6a84 100644 --- a/source4/torture/ui.h +++ b/source4/torture/ui.h @@ -34,6 +34,10 @@ enum torture_result { TORTURE_SKIP=3 }; +/* + * These callbacks should be implemented by any backend that wishes + * to listen to reports from the torture tests. + */ struct torture_ui_ops { void (*comment) (struct torture_context *, const char *); @@ -44,10 +48,20 @@ struct torture_ui_ops void (*test_start) (struct torture_context *, struct torture_tcase *, struct torture_test *); - void (*test_result) (struct torture_context *, enum torture_result, - const char *reason); + void (*test_result) (struct torture_context *, + enum torture_result, const char *reason); }; +/* + * Holds information about a specific run of the testsuite. + * The data in this structure should be considered private to + * the torture tests and should only be used directly by the torture + * code and the ui backends. + * + * Torture tests should instead call the torture_*() macros and functions + * specified below. + */ + struct torture_context { const struct torture_ui_ops *ui_ops; @@ -61,124 +75,214 @@ struct torture_context int success; int failed; + bool quiet; /* Whether tests should avoid writing output to stdout */ + enum torture_result last_result; char *last_reason; char *outputdir; + int level; +}; + +/* + * Describes a particular torture test + */ +struct torture_test { + const char *name; + const char *description; + bool dangerous; + /* Function to call to run this test */ + bool (*run) (struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test); + + struct torture_test *prev, *next; + + /* Pointer to the actual test function. This is run by the + * run() function above. */ + void *fn; + const void *data; +}; + +/* + * Describes a particular test case. + */ +struct torture_tcase { + const char *name; + const char *description; + bool (*setup) (struct torture_context *tcase, void **data); + bool (*teardown) (struct torture_context *tcase, void *data); + bool fixture_persistent; + void *data; + struct torture_test *tests; + struct torture_tcase *prev, *next; }; struct torture_suite { const char *name; const char *description; - struct torture_tcase { - const char *name; - const char *description; - BOOL (*setup) (struct torture_context *tcase, void **data); - BOOL (*teardown) (struct torture_context *tcase, void *data); - BOOL fixture_persistent; - const void *data; - struct torture_test { - const char *name; - const char *description; - const void *data; - BOOL dangerous; - BOOL (*run) (struct torture_context *test, - const void *tcase_data, - const void *test_data); - struct torture_test *prev, *next; - } *tests; - struct torture_tcase *prev, *next; - } *testcases; + struct torture_tcase *testcases; + struct torture_suite *children; + + /* Pointers to siblings of this torture suite */ + struct torture_suite *prev, *next; }; -struct torture_suite *torture_suite_create(TALLOC_CTX *ctx, const char *name); +/** Create a new torture suite */ +struct torture_suite *torture_suite_create(TALLOC_CTX *mem_ctx, + const char *name); + +/** Change the setup and teardown functions for a testcase */ void torture_tcase_set_fixture(struct torture_tcase *tcase, - BOOL (*setup) (struct torture_context *, void **), - BOOL (*teardown) (struct torture_context *, void *)); + bool (*setup) (struct torture_context *, void **), + bool (*teardown) (struct torture_context *, void *)); + +/* Add another test to run for a particular testcase */ struct torture_test *torture_tcase_add_test(struct torture_tcase *tcase, const char *name, - BOOL (*run) (struct torture_context *test, const void *tcase_data, + bool (*run) (struct torture_context *test, const void *tcase_data, const void *test_data), const void *test_data); + +/* Add a testcase to a testsuite */ struct torture_tcase *torture_suite_add_tcase(struct torture_suite *suite, const char *name); + +/* Convenience wrapper that adds a testcase against only one + * test will be run */ struct torture_tcase *torture_suite_add_simple_tcase( struct torture_suite *suite, const char *name, - BOOL (*run) (struct torture_context *test, const void *test_data), + bool (*run) (struct torture_context *test, const void *test_data), const void *data); -BOOL torture_run_suite(struct torture_context *context, +/* Convenience wrapper that adds a test that doesn't need any + * testcase data */ +struct torture_tcase *torture_suite_add_simple_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *test)); + +/* Add a child testsuite to an existing testsuite */ +bool torture_suite_add_suite(struct torture_suite *suite, + struct torture_suite *child); + +/* Run the specified testsuite recursively */ +bool torture_run_suite(struct torture_context *context, struct torture_suite *suite); -BOOL torture_run_tcase(struct torture_context *context, +/* Run the specified testcase */ +bool torture_run_tcase(struct torture_context *context, struct torture_tcase *tcase); -BOOL torture_run_test(struct torture_context *context, +/* Run the specified test */ +bool torture_run_test(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test); -#define torture_assert(ctx,expr,string) \ +void _torture_fail_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3); +void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3); +void _torture_skip_ext(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3); + +#define torture_assert(torture_ctx,expr,cmt) \ if (!(expr)) { \ - torture_fail(ctx, "%s:%d (%s): %s", __FILE__, __LINE__, string, \ - __STRING(expr)); \ - return False; \ + torture_comment(torture_ctx, __location__": Expression `%s' failed\n", __STRING(expr)); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ } -#define torture_assert_werr_equal(ctx,got,expected,string) \ +#define torture_assert_werr_equal(torture_ctx, got, expected, cmt) \ do { WERROR __got = got, __expected = expected; \ if (!W_ERROR_EQUAL(__got, __expected)) { \ - torture_fail(ctx, "%s:%d (%s): got %s, expected %s", __FILE__, \ - __LINE__, string, win_errstr(__got), win_errstr(__expected)); \ - return False; \ + torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \ + win_errstr(__got), win_errstr(__expected)); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ } \ } while (0) -#define torture_assert_ntstatus_equal(ctx,got,expected,string) \ +#define torture_assert_ntstatus_equal(torture_ctx,got,expected,cmt) \ do { NTSTATUS __got = got, __expected = expected; \ if (!NT_STATUS_EQUAL(__got, __expected)) { \ - torture_fail(ctx, "%s:%d (%s): got %s, expected %s", __FILE__, \ - __LINE__, string, nt_errstr(__got), nt_errstr(__expected)); \ - return False; \ + torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", \ + nt_errstr(__got), nt_errstr(__expected)); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ }\ } while(0) -#define torture_assert_casestr_equal(ctx,got,expected,string) \ - do { const char *__got = got, *__expected = expected; \ - if (strcasecmp(__got, __expected) != 0) { \ - torture_fail(ctx, "%s:%d (%s): got %s, expected %s", __FILE__, \ - __LINE__, string, got, expected); \ - return False; \ +#define torture_assert_casestr_equal(torture_ctx,got,expected,cmt) \ + do { const char *__got = (got), *__expected = (expected); \ + if (!strequal(__got, __expected)) { \ + torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ } \ } while(0) -#define torture_assert_str_equal(ctx,got,expected,string) \ - do { const char *__got = got, *__expected = expected; \ - if (strcmp(__got, __expected) != 0) { \ - torture_fail(ctx, "%s:%d (%s): got %s, expected %s", __FILE__, \ - __LINE__, string, __got, __expected); \ - return False; \ +#define torture_assert_str_equal(torture_ctx,got,expected,cmt)\ + do { const char *__got = (got), *__expected = (expected); \ + if (strcmp_safe(__got, __expected) != 0) { \ + torture_comment(torture_ctx, __location__": "#got" was %s, expected %s\n", __got, __expected); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ } \ } while(0) +#define torture_assert_int_equal(torture_ctx,got,expected,cmt)\ + do { int __got = (got), __expected = (expected); \ + if (__got != __expected) { \ + torture_comment(torture_ctx, __location__": "#got" was %d, expected %d\n", __got, __expected); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ + } \ + } while(0) + +#define torture_assert_errno_equal(torture_ctx,expected,cmt)\ + do { int __expected = (expected); \ + if (errno != __expected) { \ + torture_comment(torture_ctx, __location__": errno was %d, expected %s\n", errno, strerror(__expected)); \ + _torture_fail_ext(torture_ctx, __location__": %s", cmt); \ + return false; \ + } \ + } while(0) + + + +#define torture_skip(torture_ctx,cmt) do {\ + _torture_skip_ext(torture_ctx, __location__": %s", cmt);\ + return true; \ + } while(0) +#define torture_fail(torture_ctx,cmt) do {\ + _torture_fail_ext(torture_ctx, __location__": %s", cmt);\ + return false; \ + } while (0) + +#define torture_out stderr /* Convenience macros */ +#define torture_assert_ntstatus_ok(torture_ctx,expr,cmt) \ + torture_assert_ntstatus_equal(torture_ctx,expr,NT_STATUS_OK,cmt) -#define torture_assert_ntstatus_ok(ctx,expr,string) \ - torture_assert_ntstatus_equal(ctx,expr,NT_STATUS_OK,string) +#define torture_assert_werr_ok(torture_ctx,expr,cmt) \ + torture_assert_werr_equal(torture_ctx,expr,WERR_OK,cmt) -#define torture_assert_werr_ok(ctx,expr,string) \ - torture_assert_werr_equal(ctx,expr,WERR_OK,string) +/* Getting settings */ +const char *torture_setting_string(struct torture_context *test, \ + const char *name, + const char *default_value); -void torture_comment(struct torture_context *test, const char *comment, ...) PRINTF_ATTRIBUTE(2,3); -void torture_fail(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3); -void torture_skip(struct torture_context *test, const char *reason, ...) PRINTF_ATTRIBUTE(2,3); -const char *torture_setting(struct torture_context *test, const char *name, - const char *default_value); +int torture_setting_int(struct torture_context *test, + const char *name, + int default_value); + +bool torture_setting_bool(struct torture_context *test, + const char *name, + bool default_value); /* Helper function commonly used */ -BOOL torture_teardown_free(struct torture_context *torture, void *data); +bool torture_teardown_free(struct torture_context *torture, void *data); #endif /* __TORTURE_UI_H__ */ diff --git a/source4/torture/util_smb.c b/source4/torture/util_smb.c index b823e69b75..0fee43f602 100644 --- a/source4/torture/util_smb.c +++ b/source4/torture/util_smb.c @@ -2,6 +2,7 @@ Unix SMB/CIFS implementation. SMB torture tester utility functions Copyright (C) Andrew Tridgell 2003 + Copyright (C) Jelmer Vernooij 2006 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -27,13 +28,15 @@ #include "system/shmem.h" #include "system/wait.h" #include "system/time.h" +#include "torture/ui.h" #include "torture/torture.h" +#include "util/dlinklist.h" /** setup a directory ready for a test */ -_PUBLIC_ BOOL torture_setup_dir(struct smbcli_state *cli, const char *dname) +_PUBLIC_ bool torture_setup_dir(struct smbcli_state *cli, const char *dname) { smb_raw_exit(cli->session); if (smbcli_deltree(cli->tree, dname) == -1 || @@ -279,9 +282,9 @@ 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(struct smb_wire_string *str, int flags, struct smbcli_state *cli) +bool wire_bad_flags(struct smb_wire_string *str, int flags, struct smbcli_state *cli) { - BOOL server_unicode; + bool server_unicode; int len; if (!str || !str->s) return True; len = strlen(str->s); @@ -350,7 +353,7 @@ void torture_all_info(struct smbcli_tree *tree, const char *fname) /* set a attribute on a file */ -BOOL torture_set_file_attribute(struct smbcli_tree *tree, const char *fname, uint16_t attrib) +bool torture_set_file_attribute(struct smbcli_tree *tree, const char *fname, uint16_t attrib) { union smb_setfileinfo sfinfo; NTSTATUS status; @@ -459,7 +462,7 @@ NTSTATUS torture_check_ea(struct smbcli_state *cli, return NT_STATUS_EA_CORRUPT_ERROR; } -BOOL torture_open_connection_share(TALLOC_CTX *mem_ctx, +bool torture_open_connection_share(TALLOC_CTX *mem_ctx, struct smbcli_state **c, const char *hostname, const char *sharename, @@ -475,13 +478,15 @@ BOOL torture_open_connection_share(TALLOC_CTX *mem_ctx, return False; } - (*c)->transport->options.use_oplocks = use_oplocks; - (*c)->transport->options.use_level2_oplocks = use_level_II_oplocks; + (*c)->transport->options.use_oplocks = lp_parm_bool(-1, "torture", + "use_oplocks", False); + (*c)->transport->options.use_level2_oplocks = lp_parm_bool(-1, "torture", + "use_level2_oplocks", False); return True; } -_PUBLIC_ BOOL torture_open_connection(struct smbcli_state **c, int conn_index) +_PUBLIC_ bool torture_open_connection(struct smbcli_state **c, int conn_index) { const char *host = lp_parm_string(-1, "torture", "host"); const char *share = lp_parm_string(-1, "torture", "share"); @@ -511,7 +516,7 @@ _PUBLIC_ BOOL torture_open_connection(struct smbcli_state **c, int conn_index) return torture_open_connection_share(NULL, c, host, share, NULL); } -_PUBLIC_ BOOL torture_open_connection_ev(struct smbcli_state **c, +_PUBLIC_ bool torture_open_connection_ev(struct smbcli_state **c, int conn_index, struct event_context *ev) { @@ -546,9 +551,9 @@ _PUBLIC_ BOOL torture_open_connection_ev(struct smbcli_state **c, -_PUBLIC_ BOOL torture_close_connection(struct smbcli_state *c) +_PUBLIC_ bool torture_close_connection(struct smbcli_state *c) { - BOOL ret = True; + bool ret = True; if (!c) return True; if (NT_STATUS_IS_ERR(smbcli_tdis(c))) { printf("tdis failed (%s)\n", smbcli_errstr(c->tree)); @@ -560,7 +565,7 @@ _PUBLIC_ BOOL torture_close_connection(struct smbcli_state *c) /* check if the server produced the expected error code */ -_PUBLIC_ BOOL check_error(const char *location, struct smbcli_state *c, +_PUBLIC_ bool check_error(const char *location, struct smbcli_state *c, uint8_t eclass, uint32_t ecode, NTSTATUS nterr) { NTSTATUS status; @@ -595,11 +600,12 @@ static void sigcont(int sig) { } -double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result) +double torture_create_procs(struct torture_context *tctx, + bool (*fn)(struct torture_context *, struct smbcli_state *, int), bool *result) { int i, status; volatile pid_t *child_status; - volatile BOOL *child_status_out; + volatile bool *child_status_out; int synccount; int tries = 8; double start_time_limit = 10 + (torture_nprocs * 1.5); @@ -617,7 +623,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result return -1; } - child_status_out = (volatile BOOL *)shm_setup(sizeof(BOOL)*torture_nprocs); + child_status_out = (volatile bool *)shm_setup(sizeof(bool)*torture_nprocs); if (!child_status_out) { printf("Failed to setup result status shared memory\n"); return -1; @@ -664,7 +670,7 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result _exit(1); } - child_status_out[i] = fn(current_cli, i); + child_status_out[i] = fn(tctx, current_cli, i); _exit(0); } } @@ -714,30 +720,139 @@ double torture_create_procs(BOOL (*fn)(struct smbcli_state *, int), BOOL *result return timeval_elapsed(&tv); } -static BOOL wrap_old_torture_multifn(struct torture_context *torture, - const void *_fn) +static bool wrap_smb_multi_test(struct torture_context *torture, + struct torture_tcase *tcase, + struct torture_test *test) { - BOOL (*fn)(struct smbcli_state *, int ) = _fn; - BOOL result; + bool (*fn)(struct torture_context *, struct smbcli_state *, int ) = test->fn; + bool result; - torture_create_procs(fn, &result); + torture_create_procs(torture, fn, &result); return result; } -_PUBLIC_ NTSTATUS register_torture_multi_op(const char *name, - BOOL (*multi_fn)(struct smbcli_state *, int )) +_PUBLIC_ struct torture_test *torture_suite_add_smb_multi_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *, + struct smbcli_state *, + int i)) { - struct torture_suite *suite; + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_smb_multi_test; + test->fn = run; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; + +} + +static bool wrap_simple_2smb_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct smbcli_state *, + struct smbcli_state *); + bool ret; + + struct smbcli_state *cli1, *cli2; + + if (!torture_open_connection(&cli1, 0) || + !torture_open_connection(&cli2, 1)) + return false; + + fn = test->fn; + + ret = fn(torture_ctx, cli1, cli2); + + talloc_free(cli1); + talloc_free(cli2); + + return ret; +} + + + +_PUBLIC_ struct torture_test *torture_suite_add_2smb_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *, + struct smbcli_state *, + struct smbcli_state *)) +{ + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); + + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_simple_2smb_test; + test->fn = run; + test->dangerous = false; + + DLIST_ADD_END(tcase->tests, test, struct torture_test *); + + return test; + +} + +static bool wrap_simple_1smb_test(struct torture_context *torture_ctx, + struct torture_tcase *tcase, + struct torture_test *test) +{ + bool (*fn) (struct torture_context *, struct smbcli_state *); + bool ret; + + struct smbcli_state *cli1; + + if (!torture_open_connection(&cli1, 0)) + return false; + + fn = test->fn; + + ret = fn(torture_ctx, cli1); + + talloc_free(cli1); + + return ret; +} + +_PUBLIC_ struct torture_test *torture_suite_add_1smb_test( + struct torture_suite *suite, + const char *name, + bool (*run) (struct torture_context *, + struct smbcli_state *)) +{ + struct torture_test *test; + struct torture_tcase *tcase; + + tcase = torture_suite_add_tcase(suite, name); + + test = talloc(tcase, struct torture_test); - suite = torture_suite_create(talloc_autofree_context(), name); + test->name = talloc_strdup(test, name); + test->description = NULL; + test->run = wrap_simple_1smb_test; + test->fn = run; + test->dangerous = false; - torture_suite_add_simple_tcase(suite, name, - wrap_old_torture_multifn, - multi_fn); - torture_register_suite(suite); + DLIST_ADD_END(tcase->tests, test, struct torture_test *); - return NT_STATUS_OK; + return test; } -- cgit