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 ;
/*
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;
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);
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);
-
- talloc_free(mem_ctx);
+ ret &= bench_cldap(torture, address);
return ret;
}
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;
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);
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;
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) {
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) {
/*
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;
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;
}
}
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);
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));
}
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;
}
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;
}
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,
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;
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;
.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)
{
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},
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 {
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)
{
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);
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);
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;
}