mirror of
https://github.com/samba-team/samba.git
synced 2025-03-23 06:50:21 +03:00
r24728: Use more stock torture functions.
(This used to be commit da3a7ee407a2b41bd01f45072cad12bf29250b33)
This commit is contained in:
parent
f8c373fd6a
commit
2fefa818a9
@ -556,7 +556,7 @@ static NTSTATUS benchrw_readwrite(struct torture_context *tctx,
|
||||
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 ;
|
||||
|
@ -48,17 +48,17 @@ static void request_handler(struct cldap_request *req)
|
||||
/*
|
||||
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 @@ static BOOL bench_cldap(TALLOC_CTX *mem_ctx, const char *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);
|
||||
@ -104,28 +104,24 @@ static BOOL bench_cldap(TALLOC_CTX *mem_ctx, const char *address)
|
||||
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;
|
||||
}
|
||||
|
@ -763,7 +763,7 @@ BOOL torture_net_become_dc(struct torture_context *torture)
|
||||
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 @@ cleanup:
|
||||
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);
|
||||
|
@ -120,8 +120,7 @@ static BOOL test_opendomain_lsa(struct dcerpc_pipe *p, TALLOC_CTX *mem_ctx,
|
||||
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;
|
||||
|
@ -64,7 +64,7 @@ static BOOL run_netbench(struct torture_context *tctx, struct smbcli_state *cli,
|
||||
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 @@ BOOL torture_nbench(struct torture_context *torture)
|
||||
|
||||
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) {
|
||||
|
@ -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;
|
||||
|
@ -101,13 +101,13 @@ BOOL torture_raw_close(struct torture_context *torture)
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -351,7 +351,7 @@ BOOL torture_bench_open(struct torture_context *torture)
|
||||
|
||||
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);
|
||||
|
||||
|
@ -538,13 +538,13 @@ BOOL torture_samba3_badpath(struct torture_context *torture)
|
||||
|
||||
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));
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ static bool test_handles_lsa_shared(struct torture_context *torture)
|
||||
|
||||
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 @@ static bool test_handles_mixed_shared(struct torture_context *torture)
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ BOOL torture_rpc_join(struct torture_context *torture)
|
||||
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,
|
||||
|
@ -1409,7 +1409,7 @@ BOOL torture_rpc_samsync(struct torture_context *torture)
|
||||
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;
|
||||
|
@ -497,7 +497,7 @@ BOOL torture_rpc_schannel2(struct torture_context *torture)
|
||||
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;
|
||||
|
@ -382,41 +382,6 @@ const static struct torture_ui_ops subunit_ui_ops = {
|
||||
.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 @@ int main(int argc,char *argv[])
|
||||
|
||||
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 @@ int main(int argc,char *argv[])
|
||||
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 {
|
||||
|
@ -320,6 +320,12 @@ int torture_setting_int(struct torture_context *test, const char *name,
|
||||
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)
|
||||
{
|
||||
|
@ -343,6 +343,10 @@ int torture_setting_int(struct torture_context *test,
|
||||
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);
|
||||
|
@ -46,15 +46,15 @@ struct unix_info2 {
|
||||
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 @@ BOOL unix_torture_unix_info2(struct torture_context *torture)
|
||||
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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user