The branch, master has been updated via 664eacc... subunit: Don't abort when receiving test results from tests that weren't announced. via 64bf8c4... selftest: Support passing --load-list to test runners. via 4fb98b6... torture: Simplify torture suite running, call restricted test suite runner. via 6b442f4... smbtorture: Remove unused shell feature. via 24f3645... smbtorture: Support --load-list argument. from 0b7bb7f... s4:registry - "patchfile_preg.c" - use more "sizeof"s on length specification
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit 664eacc53a50415cd4f5534386501f640228f6c3 Author: Jelmer Vernooij <jel...@samba.org> Date: Sat Apr 10 22:35:57 2010 +0200 subunit: Don't abort when receiving test results from tests that weren't announced. commit 64bf8c400c8076316929cb6f06346bdf1c48d9d7 Author: Jelmer Vernooij <jel...@samba.org> Date: Sat Apr 10 22:20:12 2010 +0200 selftest: Support passing --load-list to test runners. commit 4fb98b6856fd0174d0f41f390e28027da636c307 Author: Jelmer Vernooij <jel...@samba.org> Date: Sat Apr 10 21:24:33 2010 +0200 torture: Simplify torture suite running, call restricted test suite runner. commit 6b442f43bc54555c60760eced131c2d50bf72a95 Author: Jelmer Vernooij <jel...@samba.org> Date: Fri Apr 9 01:59:01 2010 +0200 smbtorture: Remove unused shell feature. commit 24f364517b4013f3467c873e5b1877fe5f1c1941 Author: Jelmer Vernooij <jel...@samba.org> Date: Fri Apr 9 01:58:28 2010 +0200 smbtorture: Support --load-list argument. ----------------------------------------------------------------------- Summary of changes: lib/torture/torture.c | 7 ++ lib/torture/torture.h | 5 ++ selftest/selftest.pl | 20 ++++-- selftest/subunithelper.py | 43 ++++++++--- source4/selftest/tests.sh | 15 ++++ source4/torture/smbtorture.c | 162 +++++++++++++++--------------------------- 6 files changed, 130 insertions(+), 122 deletions(-) Changeset truncated at 500 lines: diff --git a/lib/torture/torture.c b/lib/torture/torture.c index 9adf681..dcb28ee 100644 --- a/lib/torture/torture.c +++ b/lib/torture/torture.c @@ -304,6 +304,13 @@ bool torture_run_suite(struct torture_context *context, return ret; } +bool torture_run_suite_restricted(struct torture_context *context, + struct torture_suite *suite, char **restricted) +{ + /* FIXME */ + return false; +} + void torture_ui_test_start(struct torture_context *context, struct torture_tcase *tcase, struct torture_test *test) diff --git a/lib/torture/torture.h b/lib/torture/torture.h index 6eb2c15..931937c 100644 --- a/lib/torture/torture.h +++ b/lib/torture/torture.h @@ -218,6 +218,11 @@ bool torture_suite_add_suite(struct torture_suite *suite, bool torture_run_suite(struct torture_context *context, struct torture_suite *suite); +/* Run the specified testsuite recursively, but only the specified + * tests */ +bool torture_run_suite_restricted(struct torture_context *context, + struct torture_suite *suite, char **restricted); + /* Run the specified testcase */ bool torture_run_tcase(struct torture_context *context, struct torture_tcase *tcase); diff --git a/selftest/selftest.pl b/selftest/selftest.pl index fb2e1a8..7bc14b1 100755 --- a/selftest/selftest.pl +++ b/selftest/selftest.pl @@ -125,6 +125,7 @@ use strict; use FindBin qw($RealBin $Script); use File::Spec; +use File::Temp qw(tempfile); use Getopt::Long; use POSIX; use Cwd qw(abs_path); @@ -224,9 +225,9 @@ sub expand_environment_strings($) return $s; } -sub run_testsuite($$$$$$) +sub run_testsuite($$$$$) { - my ($envname, $name, $cmd, $i, $totalsuites, $tests_to_run) = @_; + my ($envname, $name, $cmd, $i, $totalsuites) = @_; my $pcap_file = setup_pcap($name); Subunit::start_testsuite($name); @@ -639,7 +640,8 @@ sub read_testlist($) open(IN, $filename) or die("Unable to open $filename: $!"); while (<IN>) { - if ($_ eq "-- TEST --\n") { + if (/-- TEST(-LOADLIST)? --\n/) { + my $supports_loadlist = ($1 eq "-LOADLIST"); my $name = <IN>; $name =~ s/\n//g; my $env = <IN>; @@ -648,7 +650,7 @@ sub read_testlist($) $cmdline =~ s/\n//g; if (should_run_test($name) == 1) { $required_envs{$env} = 1; - push (@ret, [$name, $env, $cmdline]); + push (@ret, [$name, $env, $cmdline, $supports_loadlist]); } } else { print; @@ -934,8 +936,16 @@ $envvarstr next; } + if ($$_[3] and $individual_tests and $individual_tests->{$name}) { + my ($fh, $listid_file) = tempfile(UNLINK => 0); + foreach (@{$individual_tests->{$name}}) { + print $fh "$_\n"; + } + $cmd .= " --load-list=$listid_file"; + } + run_testsuite($envname, $name, $cmd, $i, $suitestotal, - ($individual_tests and $individual_tests->{$name})); + ); if (defined($opt_analyse_cmd)) { system("$opt_analyse_cmd \"$name\""); diff --git a/selftest/subunithelper.py b/selftest/subunithelper.py index 2c5fa31..545178e 100644 --- a/selftest/subunithelper.py +++ b/selftest/subunithelper.py @@ -68,18 +68,36 @@ def parse_results(msg_ops, statistics, fh): else: reason = None if result in ("success", "successful"): - open_tests.pop() #FIXME: Check that popped value == $testname - statistics['TESTS_EXPECTED_OK']+=1 - msg_ops.end_test(testname, "success", False, reason) + try: + open_tests.remove(testname) + except KeyError: + statistics['TESTS_ERROR']+=1 + msg_ops.end_test(testname, "error", True, + "Test was never started") + else: + statistics['TESTS_EXPECTED_OK']+=1 + msg_ops.end_test(testname, "success", False, reason) elif result in ("xfail", "knownfail"): - open_tests.pop() #FIXME: Check that popped value == $testname - statistics['TESTS_EXPECTED_FAIL']+=1 - msg_ops.end_test(testname, "xfail", False, reason) - expected_fail+=1 + try: + open_tests.remove(testname) + except KeyError: + statistics['TESTS_ERROR']+=1 + msg_ops.end_test(testname, "error", True, + "Test was never started") + else: + statistics['TESTS_EXPECTED_FAIL']+=1 + msg_ops.end_test(testname, "xfail", False, reason) + expected_fail+=1 elif result in ("failure", "fail"): - open_tests.pop() #FIXME: Check that popped value == $testname - statistics['TESTS_UNEXPECTED_FAIL']+=1 - msg_ops.end_test(testname, "failure", True, reason) + try: + open_tests.remove(testname) + except KeyError: + statistics['TESTS_ERROR']+=1 + msg_ops.end_test(testname, "error", True, + "Test was never started") + else: + statistics['TESTS_UNEXPECTED_FAIL']+=1 + msg_ops.end_test(testname, "failure", True, reason) elif result == "skip": statistics['TESTS_SKIP']+=1 # Allow tests to be skipped without prior announcement of test @@ -89,7 +107,10 @@ def parse_results(msg_ops, statistics, fh): msg_ops.end_test(testname, "skip", False, reason) elif result == "error": statistics['TESTS_ERROR']+=1 - open_tests.pop() #FIXME: Check that popped value == $testname + try: + open_tests.remove(testname) + except KeyError: + pass msg_ops.end_test(testname, "error", True, reason) elif result == "skip-testsuite": msg_ops.skip_testsuite(testname) diff --git a/source4/selftest/tests.sh b/source4/selftest/tests.sh index d4f7e47..da0b4e3 100755 --- a/source4/selftest/tests.sh +++ b/source4/selftest/tests.sh @@ -43,6 +43,21 @@ plantestsuite() { echo $cmdline } +plantestsuite_loadlist() { + name=$1 + env=$2 + shift 2 + cmdline="$*" + echo "-- TEST-LOADLIST --" + if [ "$env" = "none" ]; then + echo "samba4.$name" + else + echo "samba4.$name ($env)" + fi + echo $env + echo $cmdline +} + skiptestsuite() { name=$1 reason=$2 diff --git a/source4/torture/smbtorture.c b/source4/torture/smbtorture.c index d3b1fea..baa9afe 100644 --- a/source4/torture/smbtorture.c +++ b/source4/torture/smbtorture.c @@ -37,56 +37,39 @@ static bool run_matching(struct torture_context *torture, const char *prefix, const char *expr, + char **restricted, struct torture_suite *suite, bool *matched) { bool ret = true; + struct torture_suite *o; + struct torture_tcase *t; - if (suite == NULL) { - struct torture_suite *o; - - for (o = (torture_root == NULL?NULL:torture_root->children); o; o = o->next) { - if (gen_fnmatch(expr, o->name) == 0) { - *matched = true; - reload_charcnv(torture->lp_ctx); + for (o = suite->children; o; o = o->next) { + char *name = NULL; + if (prefix == NULL) + name = talloc_strdup(torture, o->name); + else + name = talloc_asprintf(torture, "%s-%s", prefix, o->name); + if (gen_fnmatch(expr, name) == 0) { + *matched = true; + reload_charcnv(torture->lp_ctx); + torture->active_testname = name; + if (restricted != NULL) + ret &= torture_run_suite_restricted(torture, o, restricted); + else ret &= torture_run_suite(torture, o); - continue; - } - - ret &= run_matching(torture, o->name, expr, o, 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; - reload_charcnv(torture->lp_ctx); - torture->active_testname = talloc_strdup(torture, prefix); - ret &= torture_run_suite(torture, c); - free(name); - continue; - } - - ret &= run_matching(torture, name, expr, c, matched); - - free(name); } + ret &= run_matching(torture, name, expr, restricted, o, matched); + } - for (t = suite->testcases; t; t = t->next) { - asprintf(&name, "%s-%s", prefix, t->name); - if (gen_fnmatch(expr, name) == 0) { - *matched = true; - reload_charcnv(torture->lp_ctx); - torture->active_testname = talloc_strdup(torture, prefix); - ret &= torture_run_tcase(torture, t); - talloc_free(torture->active_testname); - } - free(name); + for (t = suite->testcases; t; t = t->next) { + char *name = talloc_asprintf(torture, "%s-%s", prefix, t->name); + if (gen_fnmatch(expr, name) == 0) { + *matched = true; + reload_charcnv(torture->lp_ctx); + torture->active_testname = name; + ret &= torture_run_tcase(torture, t); } } @@ -98,20 +81,25 @@ static bool run_matching(struct torture_context *torture, /**************************************************************************** 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, + char **restricted) { bool ret = true; bool matched = false; struct torture_suite *o; if (strequal(name, "ALL")) { + if (restricted != NULL) { + printf("--load-list and ALL are incompatible\n"); + return false; + } for (o = torture_root->children; o; o = o->next) { ret &= torture_run_suite(torture, o); } return ret; } - ret = run_matching(torture, NULL, name, NULL, &matched); + ret = run_matching(torture, NULL, name, restricted, torture_root, &matched); if (!matched) { printf("Unknown torture operation '%s'\n", name); @@ -369,52 +357,6 @@ const static struct torture_ui_ops std_ui_ops = { }; -static void run_shell(struct torture_context *tctx) -{ - char *cline; - int argc; - const char **argv; - int ret; - - while (1) { - cline = smb_readline("torture> ", NULL, NULL); - - if (cline == NULL) - return; - - ret = poptParseArgvString(cline, &argc, &argv); - if (ret != 0) { - fprintf(stderr, "Error parsing line\n"); - continue; - } - - if (!strcmp(argv[0], "quit")) { - return; - } else if (!strcmp(argv[0], "set")) { - if (argc < 3) { - fprintf(stderr, "Usage: set <variable> <value>\n"); - } else { - char *name = talloc_asprintf(NULL, "torture:%s", argv[1]); - lp_set_cmdline(tctx->lp_ctx, name, argv[2]); - talloc_free(name); - } - } else if (!strcmp(argv[0], "help")) { - fprintf(stderr, "Available commands:\n" - " help - This help command\n" - " run - Run test\n" - " set - Change variables\n" - "\n"); - } else if (!strcmp(argv[0], "run")) { - if (argc < 2) { - fprintf(stderr, "Usage: run TEST-NAME [OPTIONS...]\n"); - } else { - run_test(tctx, argv[1]); - } - } - free(cline); - } -} - /**************************************************************************** main program ****************************************************************************/ @@ -431,15 +373,16 @@ int main(int argc,char *argv[]) poptContext pc; static const char *target = "other"; NTSTATUS status; - int shell = false; static const char *ui_ops_name = "subunit"; const char *basedir = NULL; const char *extra_module = NULL; static int list_tests = 0; int num_extra_users = 0; + char **restricted = NULL; + int num_restricted = -1; enum {OPT_LOADFILE=1000,OPT_UNCLIST,OPT_TIMELIMIT,OPT_DNS, OPT_LIST, OPT_DANGEROUS,OPT_SMB_PORTS,OPT_ASYNC,OPT_NUMPROGS, - OPT_EXTRA_USER,}; + OPT_EXTRA_USER,OPT_LOAD_LIST,}; struct poptOption long_options[] = { POPT_AUTOHELP @@ -459,7 +402,6 @@ int main(int argc,char *argv[]) {"dangerous", 'X', POPT_ARG_NONE, NULL, OPT_DANGEROUS, "run dangerous tests (eg. wiping out password database)", NULL}, {"load-module", 0, POPT_ARG_STRING, &extra_module, 0, "load tests from DSO file", "SOFILE"}, - {"shell", 0, POPT_ARG_NONE, &shell, true, "Run shell", NULL}, {"target", 'T', POPT_ARG_STRING, &target, 0, "samba3|samba4|other", NULL}, {"async", 'a', POPT_ARG_NONE, NULL, OPT_ASYNC, "run async tests", NULL}, @@ -469,6 +411,8 @@ int main(int argc,char *argv[]) "set maximum time for smbtorture to live", "seconds"}, {"extra-user", 0, POPT_ARG_STRING, NULL, OPT_EXTRA_USER, "extra user credentials", NULL}, + {"load-list", 0, POPT_ARG_STRING, NULL, OPT_LOAD_LIST, + "load a test id list from a text file", NULL}, POPT_COMMON_SAMBA POPT_COMMON_CONNECTION POPT_COMMON_CREDENTIALS @@ -521,6 +465,14 @@ int main(int argc,char *argv[]) talloc_free(option); } break; + case OPT_LOAD_LIST: + restricted = file_lines_load(optarg, &num_restricted, 0, + talloc_autofree_context()); + if (restricted == NULL) { + printf("Unable to read load list file '%s'\n", optarg); + exit(1); + } + break; default: printf("bad command line option\n"); exit(1); @@ -586,15 +538,15 @@ int main(int argc,char *argv[]) if (extra_module != NULL) { init_module_fn fn = load_module(talloc_autofree_context(), poptGetOptArg(pc)); - if (fn == NULL) - d_printf("Unable to load module from %s\n", poptGetOptArg(pc)); - else { - status = fn(); - if (NT_STATUS_IS_ERR(status)) { - d_printf("Error initializing module %s: %s\n", - poptGetOptArg(pc), nt_errstr(status)); + if (fn == NULL) + d_printf("Unable to load module from %s\n", poptGetOptArg(pc)); + else { + status = fn(); + if (NT_STATUS_IS_ERR(status)) { + d_printf("Error initializing module %s: %s\n", + poptGetOptArg(pc), nt_errstr(status)); + } } - } } else { torture_init(); } @@ -620,7 +572,7 @@ int main(int argc,char *argv[]) } } - if (!(argc_new >= 3 || (shell && argc_new >= 2))) { + if (!(argc_new >= 3)) { usage(pc); exit(1); } @@ -663,12 +615,10 @@ int main(int argc,char *argv[]) gensec_init(cmdline_lp_ctx); if (argc_new == 0) { - printf("You must specify a test to run, or 'ALL'\n"); - } else if (shell) { - run_shell(torture); + printf("You must specify a testsuite to run, or 'ALL'\n"); } else { for (i=2;i<argc_new;i++) { - if (!run_test(torture, argv_new[i])) { + if (!run_test(torture, argv_new[i], restricted)) { correct = false; } } -- Samba Shared Repository