[SCM] Samba Shared Repository - branch master updated

Andrew Bartlett abartlet at samba.org
Thu Sep 1 11:30:02 UTC 2016


The branch, master has been updated
       via  c433479 Remove unused python selftest
      from  f479b1b gc_tombstones: Typo fix

https://git.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit c4334793120faf696764c625187986a80670ecca
Author: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
Date:   Tue Aug 23 12:11:59 2016 +1200

    Remove unused python selftest
    
    It doesn't work, isn't changing, and causes a little bit of extra
    confusion.
    
    Signed-off-by: Douglas Bagnall <douglas.bagnall at catalyst.net.nz>
    Reviewed-by: Andrew Bartlett <abartlet at samba.org>
    
    Autobuild-User(master): Andrew Bartlett <abartlet at samba.org>
    Autobuild-Date(master): Thu Sep  1 13:29:46 CEST 2016 on sn-devel-144

-----------------------------------------------------------------------

Summary of changes:
 selftest/__init__.py                  |   0
 selftest/run.py                       | 134 ---------
 selftest/selftest.py                  | 525 ----------------------------------
 selftest/socket_wrapper.py            |  61 ----
 selftest/target/__init__.py           | 165 -----------
 selftest/target/samba.py              | 153 ----------
 selftest/testlist.py                  | 171 -----------
 selftest/tests.py                     |   1 -
 selftest/tests/__init__.py            |  30 --
 selftest/tests/test_run.py            | 190 ------------
 selftest/tests/test_samba.py          | 116 --------
 selftest/tests/test_socket_wrapper.py |  36 ---
 selftest/tests/test_target.py         | 129 ---------
 selftest/tests/test_testlist.py       | 148 ----------
 14 files changed, 1859 deletions(-)
 delete mode 100644 selftest/__init__.py
 delete mode 100644 selftest/run.py
 delete mode 100755 selftest/selftest.py
 delete mode 100644 selftest/socket_wrapper.py
 delete mode 100644 selftest/target/__init__.py
 delete mode 100644 selftest/target/samba.py
 delete mode 100644 selftest/testlist.py
 delete mode 100644 selftest/tests/__init__.py
 delete mode 100644 selftest/tests/test_run.py
 delete mode 100644 selftest/tests/test_samba.py
 delete mode 100644 selftest/tests/test_socket_wrapper.py
 delete mode 100644 selftest/tests/test_target.py
 delete mode 100644 selftest/tests/test_testlist.py


Changeset truncated at 500 lines:

diff --git a/selftest/__init__.py b/selftest/__init__.py
deleted file mode 100644
index e69de29..0000000
diff --git a/selftest/run.py b/selftest/run.py
deleted file mode 100644
index 8a0e7ca..0000000
--- a/selftest/run.py
+++ /dev/null
@@ -1,134 +0,0 @@
-#!/usr/bin/python -u
-# Bootstrap Samba and run a number of tests against it.
-# Copyright (C) 2012 Jelmer Vernooij <jelmer at samba.org>
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-"""Test command running."""
-
-import datetime
-import os
-import subprocess
-from samba import subunit
-from iso8601 import iso8601
-import sys
-import tempfile
-import warnings
-
-# expand strings from %ENV
-def expand_environment_strings(s, vars):
-    # we use a reverse sort so we do the longer ones first
-    for k in sorted(vars.keys(), reverse=True):
-        v = vars[k]
-        s = s.replace("$%s" % k, v)
-    return s
-
-
-def expand_command_list(cmd):
-    if not "$LISTOPT" in cmd:
-        return None
-    return cmd.replace("$LISTOPT", "--list")
-
-
-def expand_command_run(cmd, supports_loadfile, supports_idlist, subtests=None):
-    """Expand a test command.
-
-    :param cmd: Command to expand
-    :param supports_loadfile: Whether command supports loadfile
-    :param supports_idlist: Whether the command supports running specific
-        subtests
-    :param subtests: List of subtests to run - None for all subtests
-    :return: Tuple with command to run and temporary file to remove after
-        running (or None)
-    """
-    # Generate a file with the individual tests to run, if the
-    # test runner for this test suite supports it.
-    if subtests is None:
-        return (cmd.replace("$LOADLIST", ""), None)
-    if supports_loadfile:
-        (fd, listid_file) = tempfile.mkstemp()
-        f = os.fdopen(fd, 'w')
-        try:
-            for test in subtests:
-                f.write(test+"\n")
-        finally:
-            f.close()
-        return (
-            cmd.replace("$LOADLIST", "--load-list=%s" % listid_file),
-            listid_file)
-    elif supports_idlist:
-        cmd += " " + " ".join(subtests)
-        return (cmd, None)
-    else:
-        warnings.warn(
-            "Running subtests requested, but command does not support "
-            "this.")
-        return (cmd, None)
-
-
-def exported_envvars_str(vars, names):
-    out = ""
-    for n in names:
-        if not n in vars:
-            continue
-        out += "%s=%s\n" % (n, vars[n])
-    return out
-
-
-def now():
-    """Return datetime instance for current time in UTC.
-    """
-    return datetime.datetime.utcnow().replace(tzinfo=iso8601.Utc())
-
-
-def run_testsuite_command(name, cmd, subunit_ops, env=None, outf=None):
-    """Run a testsuite command.
-
-    :param name: Name of the testsuite
-    :param cmd: Command to run
-    :param subunit_ops: Subunit ops to use for reporting results
-    :param env: Environment the test is run in
-    :param outf: File-like object to write standard out to (defaults to sys.stdout)
-    :return: Exit code or None if the test failed to run completely
-    """
-    if outf is None:
-        outf = sys.stdout
-    subunit_ops.start_testsuite(name)
-    subunit_ops.progress(None, subunit.PROGRESS_PUSH)
-    subunit_ops.time(now())
-    try:
-        exitcode = subprocess.call(cmd, shell=True, stdout=outf)
-    except Exception, e:
-        subunit_ops.time(now())
-        subunit_ops.progress(None, subunit.PROGRESS_POP)
-        subunit_ops.end_testsuite(name, "error", "Unable to run %r: %s" % (cmd, e))
-        return None
-
-    subunit_ops.time(now())
-    subunit_ops.progress(None, subunit.PROGRESS_POP)
-
-    if env is not None:
-        envlog = env.get_log()
-        if envlog != "":
-            outf.write("envlog: %s\n" % envlog)
-
-    outf.write("command: %s\n" % cmd)
-    outf.write("expanded command: %s\n" % expand_environment_strings(cmd, os.environ))
-
-    if exitcode == 0:
-        subunit_ops.end_testsuite(name, "success")
-    else:
-        subunit_ops.end_testsuite(name, "failure", "Exit code was %d" % exitcode)
-
-    return exitcode
diff --git a/selftest/selftest.py b/selftest/selftest.py
deleted file mode 100755
index ef2278d..0000000
--- a/selftest/selftest.py
+++ /dev/null
@@ -1,525 +0,0 @@
-#!/usr/bin/python -u
-# Bootstrap Samba and run a number of tests against it.
-# Copyright (C) 2005-2012 Jelmer Vernooij <jelmer at samba.org>
-# Copyright (C) 2007-2009 Stefan Metzmacher <metze at samba.org>
-
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 3 of the License, or
-# (at your option) any later version.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-# You should have received a copy of the GNU General Public License
-# along with this program.  If not, see <http://www.gnu.org/licenses/>.
-
-import atexit
-from cStringIO import StringIO
-import os
-import sys
-import signal
-import subprocess
-from samba import subunit
-import traceback
-import warnings
-
-import optparse
-
-sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
-
-from selftest import (
-    socket_wrapper,
-    subunithelper,
-    testlist,
-    )
-from selftest.client import write_clientconf
-from selftest.run import (
-    expand_command_list,
-    expand_command_run,
-    exported_envvars_str,
-    now,
-    run_testsuite_command,
-    )
-from selftest.target import (
-    EnvironmentManager,
-    NoneTarget,
-    UnsupportedEnvironment,
-    )
-
-includes = ()
-excludes = ()
-
-def read_excludes(fn):
-    excludes.extend(testlist.read_test_regexes(fn))
-
-def read_includes(fn):
-    includes.extend(testlist.read_test_regexes(fn))
-
-parser = optparse.OptionParser("TEST-REGEXES")
-parser.add_option("--target", type="choice", choices=["samba", "samba3", "none"], default="samba", help="Samba version to target")
-parser.add_option("--quick", help="run quick overall test", action="store_true", default=False)
-parser.add_option("--list", help="list available tests", action="store_true", default=False)
-parser.add_option("--socket-wrapper", help="enable socket wrapper", action="store_true", default=False)
-parser.add_option("--socket-wrapper-pcap", help="save traffic to pcap directories", type="str")
-parser.add_option("--socket-wrapper-keep-pcap", help="keep all pcap files, not just those for tests that failed", action="store_true", default=False)
-parser.add_option("--one", help="abort when the first test fails", action="store_true", default=False)
-parser.add_option("--exclude", action="callback", help="Add file to exclude files", callback=read_excludes)
-parser.add_option("--include", action="callback", help="Add file to include files", callback=read_includes)
-parser.add_option("--testenv", help="run a shell in the requested test environment", action="store_true", default=False)
-parser.add_option("--resetup-environment", help="Re-setup environment", action="store_true", default=False)
-parser.add_option("--load-list", help="Load list of tests to load from a file", type=str)
-parser.add_option("--prefix", help="prefix to run tests in", type=str, default="./st")
-parser.add_option("--srcdir", type=str, default=".", help="source directory")
-parser.add_option("--bindir", type=str, default="./bin", help="binaries directory")
-parser.add_option("--testlist", type=str, action="append", help="file to read available tests from")
-parser.add_option("--ldap", help="back samba onto specified ldap server", choices=["openldap", "fedora-ds"], type="choice")
-
-opts, args = parser.parse_args()
-
-subunit_ops = subunithelper.SubunitOps(sys.stdout)
-
-def handle_signal(sig, frame):
-    sys.stderr.write("Exiting early because of signal %s.\n" % sig)
-    sys.exit(1)
-
-for sig in (signal.SIGINT, signal.SIGQUIT, signal.SIGTERM, signal.SIGPIPE):
-    signal.signal(sig, handle_signal)
-
-def skip(name):
-    return testlist.find_in_list(excludes, name)
-
-def setup_pcap(name):
-    if (not opts.socket_wrapper_pcap or
-        not os.environ.get("SOCKET_WRAPPER_PCAP_DIR")):
-        return
-
-    fname = "".join([x for x in name if x.isalnum() or x == '-'])
-
-    pcap_file = os.path.join(
-        os.environ["SOCKET_WRAPPER_PCAP_DIR"], "%s.pcap" % fname)
-
-    socket_wrapper.setup_pcap(pcap_file)
-    return pcap_file
-
-
-def cleanup_pcap(pcap_file, exit_code):
-    if not opts.socket_wrapper_pcap:
-        return
-    if opts.socket_wrapper_keep_pcap:
-        return
-    if exitcode == 0:
-        return
-    if pcap_file is None:
-        return
-
-    os.unlink(pcap_file)
-
-
-def run_testsuite(name, cmd, subunit_ops, env=None):
-    """Run a single testsuite.
-
-    :param env: Environment to run in
-    :param name: Name of the testsuite
-    :param cmd: Name of the (fully expanded) command to run
-    :return: exitcode of the command
-    """
-    pcap_file = setup_pcap(name)
-
-    exitcode = run_testsuite_command(name, cmd, subunit_ops, env)
-    if exitcode is None:
-        sys.exit(1)
-
-    cleanup_pcap(pcap_file, exitcode)
-
-    if not opts.socket_wrapper_keep_pcap and pcap_file is not None:
-        sys.stdout.write("PCAP FILE: %s\n" % pcap_file)
-
-    if exitcode != 0 and opts.one:
-        sys.exit(1)
-
-    return exitcode
-
-
-if opts.list and opts.testenv:
-    sys.stderr.write("--list and --testenv are mutually exclusive\n")
-    sys.exit(1)
-
-tests = args
-
-# quick hack to disable rpc validation when using valgrind - it is way too slow
-if not os.environ.get("VALGRIND"):
-    os.environ["VALIDATE"] = "validate"
-    os.environ["MALLOC_CHECK_"] = "3"
-
-# make all our python scripts unbuffered
-os.environ["PYTHONUNBUFFERED"] = "1"
-
-bindir_abs = os.path.abspath(opts.bindir)
-
-# Backwards compatibility:
-if os.environ.get("TEST_LDAP") == "yes":
-    if os.environ.get("FEDORA_DS_ROOT"):
-        ldap = "fedora-ds"
-    else:
-        ldap = "openldap"
-
-torture_maxtime = int(os.getenv("TORTURE_MAXTIME", "1200"))
-if opts.ldap:
-    # LDAP is slow
-    torture_maxtime *= 2
-
-prefix = os.path.normpath(opts.prefix)
-
-# Ensure we have the test prefix around.
-#
-# We need restrictive permissions on this as some subdirectories in this tree
-# will have wider permissions (ie 0777) and this would allow other users on the
-# host to subvert the test process.
-if not os.path.isdir(prefix):
-    os.mkdir(prefix, 0700)
-else:
-    os.chmod(prefix, 0700)
-
-prefix_abs = os.path.abspath(prefix)
-tmpdir_abs = os.path.abspath(os.path.join(prefix_abs, "tmp"))
-if not os.path.isdir(tmpdir_abs):
-    os.mkdir(tmpdir_abs, 0777)
-
-srcdir_abs = os.path.abspath(opts.srcdir)
-
-if prefix_abs == "/":
-    raise Exception("using '/' as absolute prefix is a bad idea")
-
-os.environ["PREFIX"] = prefix
-os.environ["KRB5CCNAME"] = os.path.join(prefix, "krb5ticket")
-os.environ["PREFIX_ABS"] = prefix_abs
-os.environ["SRCDIR"] = opts.srcdir
-os.environ["SRCDIR_ABS"] = srcdir_abs
-os.environ["BINDIR"] = bindir_abs
-
-tls_enabled = not opts.quick
-if tls_enabled:
-    os.environ["TLS_ENABLED"] = "yes"
-else:
-    os.environ["TLS_ENABLED"] = "no"
-
-def prefix_pathvar(name, newpath):
-    if name in os.environ:
-        os.environ[name] = "%s:%s" % (newpath, os.environ[name])
-    else:
-        os.environ[name] = newpath
-prefix_pathvar("PKG_CONFIG_PATH", os.path.join(bindir_abs, "pkgconfig"))
-prefix_pathvar("PYTHONPATH", os.path.join(bindir_abs, "python"))
-
-if opts.socket_wrapper_keep_pcap:
-    # Socket wrapper keep pcap implies socket wrapper pcap
-    opts.socket_wrapper_pcap = True
-
-if opts.socket_wrapper_pcap:
-    # Socket wrapper pcap implies socket wrapper
-    opts.socket_wrapper = True
-
-if opts.socket_wrapper:
-    socket_wrapper_dir = socket_wrapper.setup_dir(os.path.join(prefix_abs, "w"), opts.socket_wrapper_pcap)
-    sys.stdout.write("SOCKET_WRAPPER_DIR=%s\n" % socket_wrapper_dir)
-elif not opts.list:
-    if os.getuid() != 0:
-        warnings.warn("not using socket wrapper, but also not running as root. Will not be able to listen on proper ports")
-
-testenv_default = "none"
-
-# After this many seconds, the server will self-terminate.  All tests
-# must terminate in this time, and testenv will only stay alive this
-# long
-
-if os.environ.get("SMBD_MAXTIME", ""):
-    server_maxtime = int(os.environ["SMBD_MAXTIME"])
-else:
-    server_maxtime = 7500
-
-
-def has_socket_wrapper(bindir):
-    """Check if Samba has been built with socket wrapper support.
-    """
-    f = StringIO()
-    subprocess.check_call([os.path.join(bindir, "smbd"), "-b"], stdout=f)
-    for l in f.readlines():
-        if "SOCKET_WRAPPER" in l:
-            return True
-    return False
-
-
-if not opts.list:
-    if opts.target == "samba":
-        if opts.socket_wrapper and not has_socket_wrapper(opts.bindir):
-            sys.stderr.write("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'.  Exiting....\n")
-            sys.exit(1)
-        testenv_default = "ad_dc_ntvfs"
-        from selftest.target.samba import Samba
-        target = Samba(opts.bindir, ldap, opts.srcdir, server_maxtime)
-    elif opts.target == "samba3":
-        if opts.socket_wrapper and not has_socket_wrapper(opts.bindir):
-            sys.stderr.write("You must include --enable-socket-wrapper when compiling Samba in order to execute 'make test'.  Exiting....\n")
-            sys.exit(1)
-        testenv_default = "member"
-        from selftest.target.samba3 import Samba3
-        target = Samba3(opts.bindir, srcdir_abs, server_maxtime)
-    elif opts.target == "none":
-        testenv_default = "none"
-        target = NoneTarget()
-
-    env_manager = EnvironmentManager(target)
-    atexit.register(env_manager.teardown_all)
-
-interfaces = ",".join([
-    "127.0.0.11/8",
-    "127.0.0.12/8",
-    "127.0.0.13/8",
-    "127.0.0.14/8",
-    "127.0.0.15/8",
-    "127.0.0.16/8"])
-
-clientdir = os.path.join(prefix_abs, "client")
-
-conffile = os.path.join(clientdir, "client.conf")
-os.environ["SMB_CONF_PATH"] = conffile
-
-todo = []
-
-if not opts.testlist:
-    sys.stderr.write("No testlists specified\n")
-    sys.exit(1)
-
-os.environ["SELFTEST_PREFIX"] = prefix_abs
-os.environ["SELFTEST_TMPDIR"] = tmpdir_abs
-os.environ["TEST_DATA_PREFIX"] = tmpdir_abs
-if opts.socket_wrapper:
-    os.environ["SELFTEST_INTERFACES"] = interfaces
-else:
-    os.environ["SELFTEST_INTERFACES"] = ""
-if opts.quick:
-    os.environ["SELFTEST_QUICK"] = "1"
-else:
-    os.environ["SELFTEST_QUICK"] = ""
-os.environ["SELFTEST_MAXTIME"] = str(torture_maxtime)
-
-
-available = []
-for fn in opts.testlist:
-    for testsuite in testlist.read_testlist_file(fn):
-        if not testlist.should_run_test(tests, testsuite):
-            continue
-        name = testsuite[0]
-        if (includes is not None and
-            testlist.find_in_list(includes, name) is not None):
-            continue
-        available.append(testsuite)
-
-if opts.load_list:
-    restricted_mgr = testlist.RestrictedTestManager.from_path(opts.load_list)
-else:
-    restricted_mgr = None
-
-for testsuite in available:
-    name = testsuite[0]
-    skipreason = skip(name)
-    if restricted_mgr is not None:
-        match = restricted_mgr.should_run_testsuite(name)
-        if match == []:
-            continue
-    else:
-        match = None
-    if skipreason is not None:
-        if not opts.list:
-            subunit_ops.skip_testsuite(name, skipreason)
-    else:
-        todo.append(testsuite + (match,))
-
-if restricted_mgr is not None:
-    for name in restricted_mgr.iter_unused():
-        sys.stdout.write("No test or testsuite found matching %s\n" % name)
-if todo == []:
-    sys.stderr.write("No tests to run\n")
-    sys.exit(1)
-
-suitestotal = len(todo)
-
-if not opts.list:
-    subunit_ops.progress(suitestotal, subunit.PROGRESS_SET)


-- 
Samba Shared Repository



More information about the samba-cvs mailing list