build: Remove unused mkbuildoptions.awk
[obnox/samba/samba-obnox.git] / selftest / selftesthelpers.py
index 66402903b78ae144cb19b73e46b5a1aedd29b83d..cdbe9751f31b69441a19314b103ae30be88037b9 100644 (file)
@@ -18,6 +18,7 @@
 # three separated by newlines. All other lines in the output are considered
 # comments.
 
+import errno
 import os
 import subprocess
 import sys
@@ -28,6 +29,9 @@ def srcdir():
 def source4dir():
     return os.path.normpath(os.path.join(srcdir(), "source4"))
 
+def source3dir():
+    return os.path.normpath(os.path.join(srcdir(), "source3"))
+
 def bindir():
     return os.path.normpath(os.getenv("BINDIR", "./bin"))
 
@@ -64,15 +68,17 @@ else:
 
 python = os.getenv("PYTHON", "python")
 
-#Set a default value, overridden if we find a working one on the system
+# Set a default value, overridden if we find a working one on the system
 tap2subunit = "PYTHONPATH=%s/lib/subunit/python:%s/lib/testtools %s %s/lib/subunit/filters/tap2subunit" % (srcdir(), srcdir(), python, srcdir())
 
-sub = subprocess.Popen("tap2subunit 2> /dev/null", stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
+sub = subprocess.Popen("tap2subunit", stdin=subprocess.PIPE,
+    stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
 sub.communicate("")
 
 if sub.returncode == 0:
-    cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
-    sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
+    cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit | grep skip"
+    sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE,
+        stderr=subprocess.PIPE, shell=True)
     if sub.returncode == 0:
         tap2subunit = "tap2subunit"
 
@@ -179,19 +185,52 @@ def planpythontestsuite(env, module, name=None, extra_path=[]):
     plantestsuite_idlist(name, env, args)
 
 
+def get_env_torture_options():
+    ret = []
+    if not os.getenv("SELFTEST_VERBOSE"):
+        ret.append("--option=torture:progress=no")
+    if os.getenv("SELFTEST_QUICK"):
+        ret.append("--option=torture:quick=yes")
+    return ret
+
+
 samba4srcdir = source4dir()
+samba3srcdir = source3dir()
 bbdir = os.path.join(srcdir(), "testprogs/blackbox")
 configuration = "--configfile=$SMB_CONF_PATH"
 
 smbtorture4 = binpath("smbtorture4")
 smbtorture4_testsuite_list = subprocess.Popen([smbtorture4, "--list-suites"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate("")[0].splitlines()
 
+smbtorture4_options = [
+    configuration,
+    "--maximum-runtime=$SELFTEST_MAXTIME",
+    "--basedir=$SELFTEST_TMPDIR",
+    "--format=subunit"
+    ] + get_env_torture_options()
+
+
+def print_smbtorture4_version():
+    """Print the version of Samba smbtorture4 comes from.
 
-def plansmbtorture4testsuite(name, env, options, modname=None):
+    :return: Whether smbtorture4 was successfully run
+    """
+    try:
+        sub = subprocess.Popen([smbtorture4, "-V"], stdout=sys.stderr)
+    except OSError, e:
+        if e.errno == errno.ENOENT:
+            return False
+        raise
+    sub.communicate("")
+    return (sub.returncode == 0)
+
+
+def plansmbtorture4testsuite(name, env, options, target, modname=None):
     if modname is None:
         modname = "samba4.%s" % name
     if isinstance(options, list):
         options = " ".join(options)
+    options = " ".join(smbtorture4_options + ["--target=%s" % target]) + " " + options
     cmdline = "%s $LISTOPT %s %s" % (valgrindify(smbtorture4), options, name)
     plantestsuite_loadlist(modname, env, cmdline)
 
@@ -200,12 +239,12 @@ def smbtorture4_testsuites(prefix):
     return filter(lambda x: x.startswith(prefix), smbtorture4_testsuite_list)
 
 
-def get_env_torture_options():
-    ret = []
-    if not os.getenv("SELFTEST_VERBOSE"):
-        ret.append("--option=torture:progress=no")
-    if os.getenv("SELFTEST_QUICK"):
-        ret.append("--option=torture:quick=yes")
-    return ret
-
+smbclient3 = binpath('smbclient3')
+smbtorture3 = binpath('smbtorture3')
+ntlm_auth3 = binpath('ntlm_auth3')
+net = binpath('net')
+scriptdir = os.path.join(srcdir(), "script/tests")
 
+wbinfo = binpath('wbinfo')
+dbwrap_tool = binpath('dbwrap_tool')
+vfstest = binpath('vfstest')