s4:dsdb/acl_read: enable acl checking on search by default (bug #8620)
[nivanova/samba-autobuild/.git] / selftest / wscript
index 2bc2d4005b8411c823fc3ce537f3d9864f29de38..4733dc17cd1d4ddd257b4cdcbe914e8baa4365b7 100644 (file)
@@ -12,6 +12,9 @@ def set_options(opt):
     opt.add_option('--enable-selftest',
                    help=("enable options necessary for selftest (default=no)"),
                    action="store_true", dest='enable_selftest', default=False)
+    opt.add_option('--enable-coverage',
+                   help=("enable options necessary for code coverage reporting on selftest (default=no)"),
+                   action="store_true", dest='enable_coverage', default=False)
     opt.add_option('--with-selftest-prefix',
                    help=("specify location of selftest directory (default=./st)"),
                    action="store", dest='SELFTEST_PREFIX', default='./st')
@@ -66,9 +69,19 @@ def set_options(opt):
     gr.add_option('--socket-wrapper-keep-pcap',
                   help=("create a pcap file for all individual test"),
                   action="store_true", dest='SOCKET_WRAPPER_KEEP_PCAP', default=False)
+    gr.add_option('--random-order', dest='RANDOM_ORDER', default=False,
+                  action="store_true", help="Run testsuites in random order")
 
 def configure(conf):
     conf.env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
+    conf.env.enable_coverage = Options.options.enable_coverage
+    if conf.env.enable_coverage:
+        conf.ADD_LDFLAGS('-lgcov', testflags=True)
+        conf.ADD_CFLAGS('--coverage')
+
+    if Options.options.enable_selftest or Options.options.developer:
+        conf.DEFINE('ENABLE_SELFTEST', 1)
+
 
 def cmd_testonly(opt):
     '''run tests without doing a build first'''
@@ -88,7 +101,7 @@ def cmd_testonly(opt):
     env.SUBUNIT_FORMATTER = os.getenv('SUBUNIT_FORMATTER')
     if not env.SUBUNIT_FORMATTER:
         env.SUBUNIT_FORMATTER = '${PYTHON} -u ${srcdir}/selftest/format-subunit --prefix=${SELFTEST_PREFIX} --immediate'
-    env.FILTER_XFAIL = '${PYTHON} -u ${srcdir}/selftest/filter-subunit --expected-failures=${srcdir}/source4/selftest/knownfail'
+    env.FILTER_XFAIL = '${PYTHON} -u ${srcdir}/selftest/filter-subunit --expected-failures=${srcdir}/selftest/knownfail --flapping=${srcdir}/selftest/flapping'
 
     if Options.options.FAIL_IMMEDIATELY:
         env.FILTER_XFAIL += ' --fail-immediately'
@@ -103,11 +116,18 @@ def cmd_testonly(opt):
         if o[0:1] != '_':
             os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, ''))
 
-    env.OPTIONS = '--binary-mapping=smbtorture4:smbtorture'
+    binary_mapping = ('nmblookup3:nmblookup,' +
+                      'nmblookup4:nmblookup4,' +
+                      'smbclient3:smbclient,' +
+                      'smbclient4:smbclient4,' +
+                      'smbtorture4:smbtorture,' + 
+                      'ntlm_auth3:ntlm_auth')
+
+    env.OPTIONS = '--binary-mapping=%s' % binary_mapping 
     if not Options.options.SLOWTEST:
-        env.OPTIONS += ' --exclude=${srcdir}/source4/selftest/slow'
+        env.OPTIONS += ' --exclude=${srcdir}/selftest/slow'
     if Options.options.QUICKTEST:
-        env.OPTIONS += ' --quick --include=${srcdir}/source4/selftest/quick'
+        env.OPTIONS += ' --quick --include=${srcdir}/selftest/quick'
     if Options.options.LOAD_LIST:
         env.OPTIONS += ' --load-list=%s' % Options.options.LOAD_LIST
     if Options.options.TESTENV:
@@ -116,8 +136,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 Options.options.RANDOM_ORDER:
+        env.OPTIONS += ' --random-order'
     if os.environ.get('RUN_FROM_BUILD_FARM') is not None:
         env.FILTER_OPTIONS = '${FILTER_XFAIL} --strip-passed-output'
     else:
@@ -154,12 +174,8 @@ def cmd_testonly(opt):
         os.environ['LDB_MODULES_PATH'] = 'bin/modules/ldb'
 
     # tell build system where to find config.h
-    config_paths = [ 'bin/default/source4/include/config.h',
-                     'bin/default/include/config.h' ]
-    for p in config_paths:
-        if os.path.exists(p):
-            os.environ['CONFIG_H'] = p
-            break
+    os.environ['VFSLIBDIR'] = os.path.abspath('bin/modules/vfs')
+    os.environ['CONFIG_H'] = 'bin/default/include/config.h'
 
     st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done')
     if os.path.exists(st_done):
@@ -168,27 +184,42 @@ def cmd_testonly(opt):
     if not os.path.isdir(env.SELFTEST_PREFIX):
         os.makedirs(env.SELFTEST_PREFIX, int('755', 8))
 
-    # We use the full path rather than relative path because it cause problems on some plateforms (ie. solaris 8).
-    cmd = '(${PERL} ${srcdir}/selftest/selftest.pl --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/source4/selftest/skip --testlist="${PYTHON} ${srcdir}/source4/selftest/tests.py|" ${OPTIONS} --socket-wrapper ${TESTS} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS} | tee ${SELFTEST_PREFIX}/subunit'
-    if os.environ.get('RUN_FROM_BUILD_FARM') is None and not Options.options.FILTERED_SUBUNIT:
-        cmd += ' | ${FORMAT_TEST_OUTPUT}'
+    env.TESTLISTS = ('--testlist="${PYTHON} ${srcdir}/selftest/tests.py|" ' +
+                     '--testlist="${PYTHON} ${srcdir}/source3/selftest/tests.py|" ' +
+                     '--testlist="${PYTHON} ${srcdir}/source4/selftest/tests.py|"')
+
+    if CONFIG_SET(opt, 'AD_DC_BUILD_IS_ENABLED'):
+        env.SELFTEST_TARGET="samba"
     else:
-        cmd += ' | ${PYTHON} -u ${srcdir}/selftest/filter-subunit'
-    cmd = EXPAND_VARIABLES(opt, cmd)
+        env.SELFTEST_TARGET="samba3"
 
-    print("test: running %s" % cmd)
+    # We use the full path rather than relative path because it cause problems on some plateforms (ie. solaris 8).
+    env.CORE_COMMAND = '${PERL} ${srcdir}/selftest/selftest.pl --target=${SELFTEST_TARGET} --prefix=${SELFTEST_PREFIX} --srcdir=${srcdir} --exclude=${srcdir}/selftest/skip ${TESTLISTS} ${OPTIONS} ${TESTS}'
+    if Options.options.LIST:
+        cmd = '${CORE_COMMAND} --list'
+    else:
+        env.OPTIONS += ' --socket-wrapper'
+        cmd = '(${CORE_COMMAND} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS}'
+        if (os.environ.get('RUN_FROM_BUILD_FARM') is None and
+            not Options.options.FILTERED_SUBUNIT):
+            cmd += ' | tee ${SELFTEST_PREFIX}/subunit | ${FORMAT_TEST_OUTPUT}'
+        else:
+            cmd += ' | ${FILTER_OPTIONS}'
+    runcmd = EXPAND_VARIABLES(opt, cmd)
+
+    print("test: running %s" % runcmd)
     ret = RUN_COMMAND(cmd, env=env)
-    if os.path.exists(".testrepository"):
-        # "testr load -q" isn't
-        cmd = 'testr load -q < ${SELFTEST_PREFIX}/subunit > /dev/null'
-        cmd = EXPAND_VARIABLES(opt, cmd)
-        RUN_COMMAND(cmd, env=env)
+
+    if os.path.exists(".testrepository") and not Options.options.LIST:
+        testrcmd = 'testr load -q < ${SELFTEST_PREFIX}/subunit > /dev/null'
+        runcmd = EXPAND_VARIABLES(opt, testrcmd)
+        RUN_COMMAND(runcmd, env=env)
 
     if ret != 0:
         print("ERROR: test failed with exit code %d" % ret)
         sys.exit(ret)
 
-    if not os.path.exists(st_done):
+    if not Options.options.LIST and not os.path.exists(st_done):
         print("ERROR: test command failed to complete")
         sys.exit(1)
 
@@ -197,5 +228,12 @@ def cmd_testonly(opt):
 # main test entry point
 def cmd_test(opt):
     '''Run the test suite (see test options below)'''
+
+    # if running all tests, then force a symbol check
+    env = LOAD_ENVIRONMENT()
+    CHECK_MAKEFLAGS(env)
+    if not Options.options.TESTS and not Options.options.TESTENV:
+        Options.options.DUP_SYMBOLCHECK = True
+
     Scripting.commands.append('build')
     Scripting.commands.append('testonly')