selftest: add --list option.
authorJelmer Vernooij <jelmer@samba.org>
Thu, 9 Dec 2010 13:46:09 +0000 (14:46 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Fri, 10 Dec 2010 02:04:06 +0000 (03:04 +0100)
selftest/selftest.pl
source4/selftest/wscript

index 568850189db266ad5621cb5b6616603a8a73b393..2ba68d284b6fb9e7bb397252fafab3cf045a34d4 100755 (executable)
@@ -153,6 +153,7 @@ my @opt_include = ();
 my $opt_verbose = 0;
 my $opt_image = undef;
 my $opt_testenv = 0;
+my $opt_list = 0;
 my $ldap = undef;
 my $opt_resetup_env = undef;
 my $opt_bindir = undef;
@@ -326,6 +327,7 @@ Behaviour:
  --one                      abort when the first test fails
  --verbose                  be verbose
  --testenv                  run a shell in the requested test environment
+ --list                     list available tests
 ";
        exit(0);
 }
@@ -346,6 +348,7 @@ my $result = GetOptions (
                'exeext=s' => \$exeext,
                'verbose' => \$opt_verbose,
                'testenv' => \$opt_testenv,
+               'list' => \$opt_list,
                'ldap:s' => \$ldap,
                'resetup-environment' => \$opt_resetup_env,
                'bindir:s' => \$opt_bindir,
@@ -358,6 +361,8 @@ exit(1) if (not $result);
 
 ShowHelp() if ($opt_help);
 
+die("--list and --testenv are mutually exclusive") if ($opt_list and $opt_testenv);
+
 # we want unbuffered output
 $| = 1;
 
@@ -940,6 +945,21 @@ SMB_CONF_PATH=\$SMB_CONF_PATH
 $envvarstr
 \" && LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH} bash'");
        teardown_env($testenv_name);
+} elsif ($opt_list) {
+       foreach (@todo) {
+               my $cmd = $$_[2];
+               my $name = $$_[0];
+               my $envname = $$_[1];
+
+               unless($cmd =~ /\$LIST/) {
+                       warn("Unable to list tests in $name");
+                       next;
+               }
+
+               $cmd =~ s/\$LIST/--list/;
+
+               system($cmd);
+       }
 } else {
        foreach (@todo) {
                $i++;
index e6b75d10f4b52eede993ec8400b1eda43668d714..7020779baf53e7a2d93a9a8ad06199a9b759ebbf 100644 (file)
@@ -24,6 +24,9 @@ def set_options(opt):
     gr.add_option('--load-list', 
                   help=("Load a test id list from a text file"),
                   action="store", dest='LOAD_LIST', default=None)
+    gr.add_option('--list', 
+                  help=("List available tests"),
+                  action="store_true", dest='LIST', default=False)
     gr.add_option('--tests',
                   help=("wildcard pattern of tests to run"),
                   action="store", dest='TESTS', default='')
@@ -111,7 +114,8 @@ def cmd_testonly(opt):
         env.OPTIONS += ' --socket-wrapper-pcap'
     if Options.options.SOCKET_WRAPPER_KEEP_PCAP:
         env.OPTIONS += ' --socket-wrapper-keep-pcap'
-
+    if Options.options.LIST:
+        env.OPTIONS += ' --list'
     if os.environ.get('RUN_FROM_BUILD_FARM') is not None:
         env.FILTER_OPTIONS = '${FILTER_XFAIL} --strip-passed-output'
     else: