Author: jelmer Date: 2007-08-28 00:16:58 +0000 (Tue, 28 Aug 2007) New Revision: 24728
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=24728 Log: Use more stock torture functions. Modified: branches/SAMBA_4_0/ branches/SAMBA_4_0/source/torture/basic/misc.c branches/SAMBA_4_0/source/torture/ldap/cldapbench.c branches/SAMBA_4_0/source/torture/libnet/libnet_BecomeDC.c branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c branches/SAMBA_4_0/source/torture/nbench/nbench.c branches/SAMBA_4_0/source/torture/nbt/browse.c branches/SAMBA_4_0/source/torture/raw/close.c branches/SAMBA_4_0/source/torture/raw/openbench.c branches/SAMBA_4_0/source/torture/raw/samba3misc.c branches/SAMBA_4_0/source/torture/rpc/handles.c branches/SAMBA_4_0/source/torture/rpc/join.c branches/SAMBA_4_0/source/torture/rpc/samsync.c branches/SAMBA_4_0/source/torture/rpc/schannel.c branches/SAMBA_4_0/source/torture/smbtorture.c branches/SAMBA_4_0/source/torture/ui.c branches/SAMBA_4_0/source/torture/ui.h branches/SAMBA_4_0/source/torture/unix/unix_info2.c Changeset: Property changes on: branches/SAMBA_4_0 ___________________________________________________________________ Name: bzr:revision-info ...skipped... Name: bzr:revision-id:v3-trunk0 ...skipped... Modified: branches/SAMBA_4_0/source/torture/basic/misc.c =================================================================== --- branches/SAMBA_4_0/source/torture/basic/misc.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/basic/misc.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -556,7 +556,7 @@ union smb_write wr; /* randomize between writes and reads*/ - if ( random() % state->lp_params->writeratio == 0) { + if (random() % 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 ; Modified: branches/SAMBA_4_0/source/torture/ldap/cldapbench.c =================================================================== --- branches/SAMBA_4_0/source/torture/ldap/cldapbench.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/ldap/cldapbench.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -48,17 +48,17 @@ /* benchmark cldap calls */ -static BOOL bench_cldap(TALLOC_CTX *mem_ctx, const char *address) +static bool bench_cldap(struct torture_context *tctx, const char *address) { - struct cldap_socket *cldap = cldap_socket_init(mem_ctx, NULL); + struct cldap_socket *cldap = cldap_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); + int timelimit = torture_setting_int(tctx, "timelimit", 10); struct cldap_netlogon search; struct bench_state *state; - state = talloc_zero(mem_ctx, struct bench_state); + state = talloc_zero(tctx, struct bench_state); ZERO_STRUCT(search); search.in.dest_address = address; @@ -75,7 +75,7 @@ req->async.fn = request_handler; num_sent++; if (num_sent % 50 == 0) { - if (lp_parm_bool(-1, "torture", "progress", true)) { + if (torture_setting_bool(tctx, "progress", true)) { printf("%.1f queries per second (%d failures) \r", state->pass_count / timeval_elapsed(&tv), state->fail_count); @@ -104,28 +104,24 @@ benchmark how fast a CLDAP server can respond to a series of parallel requests */ -BOOL torture_bench_cldap(struct torture_context *torture) +bool torture_bench_cldap(struct torture_context *torture) { const char *address; struct nbt_name name; - TALLOC_CTX *mem_ctx = talloc_new(NULL); NTSTATUS status; - BOOL ret = True; + bool ret = true; make_nbt_name_server(&name, torture_setting_string(torture, "host", NULL)); /* do an initial name resolution to find its IP */ - status = resolve_name(&name, mem_ctx, &address, event_context_find(mem_ctx)); + status = resolve_name(&name, torture, &address, event_context_find(torture)); if (!NT_STATUS_IS_OK(status)) { printf("Failed to resolve %s - %s\n", name.name, nt_errstr(status)); - talloc_free(mem_ctx); - return False; + return false; } - ret &= bench_cldap(mem_ctx, address); + ret &= bench_cldap(torture, address); - talloc_free(mem_ctx); - return ret; } Modified: branches/SAMBA_4_0/source/torture/libnet/libnet_BecomeDC.c =================================================================== --- branches/SAMBA_4_0/source/torture/libnet/libnet_BecomeDC.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/libnet/libnet_BecomeDC.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -763,7 +763,7 @@ b.in.domain_dns_name = torture_join_dom_dns_name(s->tj); b.in.domain_netbios_name = torture_join_dom_netbios_name(s->tj); b.in.domain_sid = torture_join_sid(s->tj); - b.in.source_dsa_address = lp_parm_string(-1, "torture", "host"); + b.in.source_dsa_address = torture_setting_string(torture, "host", NULL); b.in.dest_dsa_netbios_name = s->netbios_name; b.in.callbacks.private_data = s; @@ -843,7 +843,7 @@ ZERO_STRUCT(u); u.in.domain_dns_name = torture_join_dom_dns_name(s->tj); u.in.domain_netbios_name = torture_join_dom_netbios_name(s->tj); - u.in.source_dsa_address = lp_parm_string(-1, "torture", "host"); + u.in.source_dsa_address = torture_setting_string(torture, "host", NULL); u.in.dest_dsa_netbios_name = s->netbios_name; status = libnet_UnbecomeDC(s->ctx, s, &u); Modified: branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c =================================================================== --- branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/libnet/libnet_domain.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -120,8 +120,7 @@ return True; } - -BOOL torture_domain_open_lsa(struct torture_context *torture) +bool torture_domain_open_lsa(struct torture_context *torture) { NTSTATUS status; BOOL ret = True; Modified: branches/SAMBA_4_0/source/torture/nbench/nbench.c =================================================================== --- branches/SAMBA_4_0/source/torture/nbench/nbench.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/nbench/nbench.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -64,7 +64,7 @@ char *cname; FILE *f; BOOL correct = True; - double target_rate = lp_parm_double(-1, "torture", "targetrate", 0); + double target_rate = torture_setting_double(tctx, "targetrate", 0); int n; if (target_rate != 0 && client == 0) { @@ -229,7 +229,7 @@ read_only = torture_setting_bool(torture, "readonly", False); - nb_max_retries = lp_parm_int(-1, "torture", "nretries", 1); + nb_max_retries = torture_setting_int(torture, "nretries", 1); p = torture_setting_string(torture, "timelimit", NULL); if (p && *p) { Modified: branches/SAMBA_4_0/source/torture/nbt/browse.c =================================================================== --- branches/SAMBA_4_0/source/torture/nbt/browse.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/nbt/browse.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -27,7 +27,7 @@ /* test nbt dgram operations */ -BOOL torture_nbt_browse(struct torture_context *torture) +bool torture_nbt_browse(struct torture_context *torture) { const char *address; struct nbt_name name; Modified: branches/SAMBA_4_0/source/torture/raw/close.c =================================================================== --- branches/SAMBA_4_0/source/torture/raw/close.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/raw/close.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -101,13 +101,13 @@ printf("Incorrect times after close - only write time should be set\n"); dump_all_info(mem_ctx, &finfo); - if (!lp_parm_bool(-1, "torture", "samba3", False)) { + if (!torture_setting_bool(torture, "samba3", false)) { /* * In Samba3 as of 3.0.23d we don't yet support all * file times, so don't mark this as a critical * failure */ - ret = False; + ret = false; } } Modified: branches/SAMBA_4_0/source/torture/raw/openbench.c =================================================================== --- branches/SAMBA_4_0/source/torture/raw/openbench.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/raw/openbench.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -351,7 +351,7 @@ progress = torture_setting_bool(torture, "progress", true); - nprocs = lp_parm_int(-1, "torture", "nprocs", 4); + nprocs = torture_setting_int(torture, "nprocs", 4); state = talloc_zero_array(mem_ctx, struct benchopen_state, nprocs); Modified: branches/SAMBA_4_0/source/torture/raw/samba3misc.c =================================================================== --- branches/SAMBA_4_0/source/torture/raw/samba3misc.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/raw/samba3misc.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -538,13 +538,13 @@ status = raw_smbcli_t2open(cli_nt->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); if (!NT_STATUS_EQUAL(status, NT_STATUS_EAS_NOT_SUPPORTED) - || !lp_parm_bool(-1, "torture", "samba3", False)) { + || !torture_setting_bool(torture, "samba3", false)) { /* Against samba3, treat EAS_NOT_SUPPORTED as acceptable */ CHECK_STATUS(status, NT_STATUS_OBJECT_NAME_COLLISION); } status = raw_smbcli_t2open(cli_dos->tree, fpath, O_RDONLY | O_CREAT| O_EXCL, DENY_NONE, NULL); if (!NT_STATUS_EQUAL(status, NT_STATUS_DOS(ERRDOS,ERReasnotsupported)) - || !lp_parm_bool(-1, "torture", "samba3", False)) { + || !torture_setting_bool(torture, "samba3", false)) { /* Against samba3, treat EAS_NOT_SUPPORTED as acceptable */ CHECK_STATUS(status, NT_STATUS_DOS(ERRDOS,ERRfilexists)); } Modified: branches/SAMBA_4_0/source/torture/rpc/handles.c =================================================================== --- branches/SAMBA_4_0/source/torture/rpc/handles.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/rpc/handles.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -116,7 +116,7 @@ torture_comment(torture, "RPC-HANDLE-LSARPC-SHARED\n"); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (torture_setting_bool(torture, "samba4", false)) { torture_comment(torture, "LSA shared-policy-handle test against Samba4 - skipping\n"); return true; } @@ -399,7 +399,7 @@ torture_comment(torture, "RPC-HANDLE-MIXED-SHARED\n"); - if (lp_parm_bool(-1, "torture", "samba4", False)) { + if (torture_setting_bool(torture, "samba4", false)) { torture_comment(torture, "Mixed shared-policy-handle test against Samba4 - skipping\n"); return true; } Modified: branches/SAMBA_4_0/source/torture/rpc/join.c =================================================================== --- branches/SAMBA_4_0/source/torture/rpc/join.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/rpc/join.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -14,7 +14,7 @@ struct test_join *tj; struct cli_credentials *machine_account; struct smbcli_state *cli; - const char *host = lp_parm_string(-1, "torture", "host"); + const char *host = torture_setting_string(torture, "host", NULL); /* Join domain as a member server. */ tj = torture_join_domain(TORTURE_NETBIOS_NAME, Modified: branches/SAMBA_4_0/source/torture/rpc/samsync.c =================================================================== --- branches/SAMBA_4_0/source/torture/rpc/samsync.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/rpc/samsync.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -1409,7 +1409,7 @@ struct test_join *user_ctx; const char *machine_password; const char *wksta_machine_password; - const char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = torture_setting_string(torture, "binding", NULL); struct dcerpc_binding *b; struct dcerpc_binding *b_netlogon_wksta; struct samr_Connect c; Modified: branches/SAMBA_4_0/source/torture/rpc/schannel.c =================================================================== --- branches/SAMBA_4_0/source/torture/rpc/schannel.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/rpc/schannel.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -497,7 +497,7 @@ TALLOC_CTX *mem_ctx = talloc_new(torture); struct test_join *join_ctx; NTSTATUS status; - const char *binding = lp_parm_string(-1, "torture", "binding"); + const char *binding = torture_setting_string(torture, "binding", NULL); struct dcerpc_binding *b; struct dcerpc_pipe *p1 = NULL, *p2 = NULL; struct cli_credentials *credentials1, *credentials2; Modified: branches/SAMBA_4_0/source/torture/smbtorture.c =================================================================== --- branches/SAMBA_4_0/source/torture/smbtorture.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/smbtorture.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -382,41 +382,6 @@ .suite_start = subunit_suite_start }; -static void harness_test_start (struct torture_context *ctx, - struct torture_tcase *tcase, - struct torture_test *test) -{ -} - -static void harness_test_result (struct torture_context *context, - enum torture_result res, const char *reason) -{ - switch (res) { - case TORTURE_OK: - printf("ok %s - %s\n", context->active_test->name, reason); - break; - case TORTURE_FAIL: - case TORTURE_ERROR: - printf("not ok %s - %s\n", context->active_test->name, reason); - break; - case TORTURE_SKIP: - printf("skip %s - %s\n", context->active_test->name, reason); - break; - } -} - -static void harness_comment (struct torture_context *test, - const char *comment) -{ - printf("# %s\n", comment); -} - -const static struct torture_ui_ops harness_ui_ops = { - .comment = harness_comment, - .test_start = harness_test_start, - .test_result = harness_test_result -}; - static void quiet_suite_start(struct torture_context *ctx, struct torture_suite *suite) { @@ -520,7 +485,7 @@ struct poptOption long_options[] = { POPT_AUTOHELP - {"format", 0, POPT_ARG_STRING, &ui_ops_name, 0, "Output format (one of: simple, subunit, harness)", NULL }, + {"format", 0, POPT_ARG_STRING, &ui_ops_name, 0, "Output format (one of: simple, subunit)", NULL }, {"smb-ports", 'p', POPT_ARG_STRING, NULL, OPT_SMB_PORTS, "SMB ports", NULL}, {"basedir", 0, POPT_ARG_STRING, NULL, OPT_BASEDIR, "base directory", "BSAEDIR" }, {"seed", 0, POPT_ARG_INT, &torture_seed, 0, "seed", NULL}, @@ -662,8 +627,6 @@ ui_ops = &std_ui_ops; } else if (!strcmp(ui_ops_name, "subunit")) { ui_ops = &subunit_ui_ops; - } else if (!strcmp(ui_ops_name, "harness")) { - ui_ops = &harness_ui_ops; } else if (!strcmp(ui_ops_name, "quiet")) { ui_ops = &quiet_ui_ops; } else { Modified: branches/SAMBA_4_0/source/torture/ui.c =================================================================== --- branches/SAMBA_4_0/source/torture/ui.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/ui.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -320,6 +320,12 @@ return lp_parm_int(-1, "torture", name, default_value); } +double torture_setting_double(struct torture_context *test, const char *name, + double default_value) +{ + return lp_parm_double(-1, "torture", name, default_value); +} + bool torture_setting_bool(struct torture_context *test, const char *name, bool default_value) { Modified: branches/SAMBA_4_0/source/torture/ui.h =================================================================== --- branches/SAMBA_4_0/source/torture/ui.h 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/ui.h 2007-08-28 00:16:58 UTC (rev 24728) @@ -343,6 +343,10 @@ const char *name, int default_value); +double torture_setting_double(struct torture_context *test, + const char *name, + double default_value); + bool torture_setting_bool(struct torture_context *test, const char *name, bool default_value); Modified: branches/SAMBA_4_0/source/torture/unix/unix_info2.c =================================================================== --- branches/SAMBA_4_0/source/torture/unix/unix_info2.c 2007-08-27 22:18:16 UTC (rev 24727) +++ branches/SAMBA_4_0/source/torture/unix/unix_info2.c 2007-08-28 00:16:58 UTC (rev 24728) @@ -46,15 +46,15 @@ uint32_t flags_mask; }; -static struct smbcli_state *connect_to_server(void *mem_ctx) +static struct smbcli_state *connect_to_server(struct torture_context *tctx) { NTSTATUS status; struct smbcli_state *cli; - const char *host = lp_parm_string(-1, "torture", "host"); - const char *share = lp_parm_string(-1, "torture", "share"); + const char *host = torture_setting_string(tctx, "host", NULL); + const char *share = torture_setting_string(tctx, "share", NULL); - status = smbcli_full_connection(mem_ctx, &cli, + status = smbcli_full_connection(tctx, &cli, host, share, NULL, cmdline_credentials, NULL); @@ -399,7 +399,7 @@ mem_ctx = talloc_init("smb_query_unix_info2"); torture_assert(torture, mem_ctx != NULL, "out of memory"); - if (!(cli = connect_to_server(mem_ctx))) { + if (!(cli = connect_to_server(torture))) { talloc_free(mem_ctx); return False; }