Ignore:
Timestamp:
Nov 24, 2016, 1:14:11 PM (9 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to version 4.4.3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/selftest/selftesthelpers.py

    r740 r988  
    2121import os
    2222import subprocess
     23import sys
    2324
    2425def srcdir():
    25     return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
     26    return os.path.normpath(os.getenv("SRCDIR", os.path.join(os.path.dirname(os.path.abspath(__file__)), "..")))
    2627
    2728def source4dir():
    28     return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../source4"))
     29    return os.path.normpath(os.path.join(srcdir(), "source4"))
     30
     31def source3dir():
     32    return os.path.normpath(os.path.join(srcdir(), "source3"))
    2933
    3034def bindir():
    31     return os.path.normpath(os.path.join(os.getenv("BUILDDIR", "."), "bin"))
     35    return os.path.normpath(os.getenv("BINDIR", "./bin"))
    3236
    3337def binpath(name):
    34     return os.path.join(bindir(), "%s%s" % (name, os.getenv("EXEEXT", "")))
     38    return os.path.join(bindir(), name)
    3539
    36 perl = os.getenv("PERL", "perl")
    37 perl = perl.split()
     40# Split perl variable to allow $PERL to be set to e.g. "perl -W"
     41perl = os.getenv("PERL", "perl").split()
    3842
    3943if subprocess.call(perl + ["-e", "eval require Test::More;"]) == 0:
     
    4246    has_perl_test_more = False
    4347
    44 try:
    45     from subunit.run import TestProgram
    46 except ImportError:
    47     has_system_subunit_run = False
    48 else:
    49     has_system_subunit_run = True
    50 
    5148python = os.getenv("PYTHON", "python")
    5249
    53 #Set a default value, overridden if we find a working one on the system
    54 tap2subunit = "PYTHONPATH=%s/lib/subunit/python:%s/lib/testtools %s %s/lib/subunit/filters/tap2subunit" % (srcdir(), srcdir(), python, srcdir())
     50tap2subunit = python + " " + os.path.join(srcdir(), "selftest", "tap2subunit")
    5551
    56 sub = subprocess.Popen("tap2subunit 2> /dev/null", stdout=subprocess.PIPE, stdin=subprocess.PIPE, shell=True)
    57 sub.communicate("")
    58 
    59 if sub.returncode == 0:
    60     cmd = "echo -ne \"1..1\nok 1 # skip doesn't seem to work yet\n\" | tap2subunit 2> /dev/null | grep skip"
    61     sub = subprocess.Popen(cmd, stdout=subprocess.PIPE, stdin=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
    62     if sub.returncode == 0:
    63         tap2subunit = "tap2subunit"
    6452
    6553def valgrindify(cmdline):
     
    7159
    7260
    73 def plantestsuite(name, env, cmdline, allow_empty_output=False):
     61def plantestsuite(name, env, cmdline):
    7462    """Plan a test suite.
    7563
     
    8371    if isinstance(cmdline, list):
    8472        cmdline = " ".join(cmdline)
    85     filter_subunit_args = []
    86     if not allow_empty_output:
    87         filter_subunit_args.append("--fail-on-empty")
    8873    if "$LISTOPT" in cmdline:
    89         filter_subunit_args.append("$LISTOPT")
    90     print "%s 2>&1 | %s/selftest/filter-subunit %s --prefix=\"%s.\"" % (cmdline,
    91                                                                         srcdir(),
    92                                                                         " ".join(filter_subunit_args),
    93                                                                         name)
    94     if allow_empty_output:
    95         print "WARNING: allowing empty subunit output from %s" % name
     74        raise AssertionError("test %s supports --list, but not --load-list" % name)
     75    print cmdline + " 2>&1 " + " | " + add_prefix(name, env)
    9676
    9777
    98 def add_prefix(prefix, support_list=False):
     78def add_prefix(prefix, env, support_list=False):
    9979    if support_list:
    10080        listopt = "$LISTOPT "
    10181    else:
    10282        listopt = ""
    103     return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\"" % (srcdir(), listopt, prefix)
     83    return "%s/selftest/filter-subunit %s--fail-on-empty --prefix=\"%s.\" --suffix=\"(%s)\"" % (srcdir(), listopt, prefix, env)
    10484
    10585
     
    11595        cmdline = " ".join(cmdline)
    11696    support_list = ("$LISTOPT" in cmdline)
    117     print "%s $LOADLIST 2>&1 | %s" % (cmdline, add_prefix(name, support_list))
    118 
    119 
    120 def plantestsuite_idlist(name, env, cmdline):
    121     print "-- TEST-IDLIST --"
    122     print name
    123     print env
    124     if isinstance(cmdline, list):
    125         cmdline = " ".join(cmdline)
    126     print cmdline
     97    if not "$LISTOPT" in cmdline:
     98        raise AssertionError("loadlist test %s does not support not --list" % name)
     99    if not "$LOADLIST" in cmdline:
     100        raise AssertionError("loadlist test %s does not support --load-list" % name)
     101    print ("%s | %s" % (cmdline.replace("$LOADLIST", ""), add_prefix(name, env, support_list))).replace("$LISTOPT", "--list")
     102    print cmdline.replace("$LISTOPT", "") + " 2>&1 " + " | " + add_prefix(name, env, False)
    127103
    128104
     
    134110    """
    135111    # FIXME: Report this using subunit, but re-adjust the testsuite count somehow
    136     print "skipping %s (%s)" % (name, reason)
     112    print >>sys.stderr, "skipping %s (%s)" % (name, reason)
    137113
    138114
     
    149125
    150126
    151 def planpythontestsuite(env, module):
    152     if has_system_subunit_run:
    153         plantestsuite_idlist(module, env, [python, "-m", "subunit.run", "$LISTOPT", module])
    154     else:
    155         plantestsuite_idlist(module, env, "PYTHONPATH=$PYTHONPATH:%s/lib/subunit/python:%s/lib/testtools %s -m subunit.run $LISTOPT %s" % (srcdir(), srcdir(), python, module))
     127def planpythontestsuite(env, module, name=None, extra_path=[]):
     128    if name is None:
     129        name = module
     130    pypath = list(extra_path)
     131    args = [python, "-m", "samba.subunit.run", "$LISTOPT", "$LOADLIST", module]
     132    if pypath:
     133        args.insert(0, "PYTHONPATH=%s" % ":".join(["$PYTHONPATH"] + pypath))
     134    plantestsuite_loadlist(name, env, args)
    156135
    157136
     137def get_env_torture_options():
     138    ret = []
     139    if not os.getenv("SELFTEST_VERBOSE"):
     140        ret.append("--option=torture:progress=no")
     141    if os.getenv("SELFTEST_QUICK"):
     142        ret.append("--option=torture:quick=yes")
     143    return ret
     144
     145
     146samba4srcdir = source4dir()
     147samba3srcdir = source3dir()
     148bbdir = os.path.join(srcdir(), "testprogs/blackbox")
     149configuration = "--configfile=$SMB_CONF_PATH"
     150
     151smbtorture4 = binpath("smbtorture")
     152smbtorture4_testsuite_list = subprocess.Popen([smbtorture4, "--list-suites"], stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate("")[0].splitlines()
     153
     154smbtorture4_options = [
     155    configuration,
     156    "--option=\'fss:sequence timeout=1\'",
     157    "--maximum-runtime=$SELFTEST_MAXTIME",
     158    "--basedir=$SELFTEST_TMPDIR",
     159    "--format=subunit"
     160    ] + get_env_torture_options()
     161
     162
     163def plansmbtorture4testsuite(name, env, options, target, modname=None):
     164    if modname is None:
     165        modname = "samba4.%s" % name
     166    if isinstance(options, list):
     167        options = " ".join(options)
     168    options = " ".join(smbtorture4_options + ["--target=%s" % target]) + " " + options
     169    cmdline = "%s $LISTOPT $LOADLIST %s %s" % (valgrindify(smbtorture4), options, name)
     170    plantestsuite_loadlist(modname, env, cmdline)
     171
     172
     173def smbtorture4_testsuites(prefix):
     174    return filter(lambda x: x.startswith(prefix), smbtorture4_testsuite_list)
     175
     176
     177smbclient3 = binpath('smbclient')
     178smbtorture3 = binpath('smbtorture3')
     179ntlm_auth3 = binpath('ntlm_auth')
     180net = binpath('net')
     181scriptdir = os.path.join(srcdir(), "script/tests")
     182
     183wbinfo = binpath('wbinfo')
     184dbwrap_tool = binpath('dbwrap_tool')
     185vfstest = binpath('vfstest')
     186smbcquotas = binpath('smbcquotas')
     187smbget = binpath('smbget')
Note: See TracChangeset for help on using the changeset viewer.