~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source3/selftest/wscript

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env python
 
2
# vim: expandtab ft=python
 
3
 
 
4
# selftest main code.
 
5
 
 
6
import Scripting, os, Options, Utils, Environment, optparse, sys
 
7
from samba_utils import *
 
8
from samba_autoconf import *
 
9
 
 
10
def set_options(opt):
 
11
 
 
12
    opt.add_option('--enable-selftest',
 
13
                   help=("enable options necessary for selftest (default=no)"),
 
14
                   action="store_true", dest='enable_selftest', default=False)
 
15
    opt.add_option('--with-selftest-prefix',
 
16
                   help=("specify location of selftest directory (default=./st)"),
 
17
                   action="store", dest='SELFTEST_PREFIX', default='./st')
 
18
 
 
19
    opt.ADD_COMMAND('test', cmd_test)
 
20
    opt.ADD_COMMAND('testonly', cmd_testonly)
 
21
 
 
22
    gr = opt.add_option_group('test options')
 
23
 
 
24
    gr.add_option('--load-list', 
 
25
                  help=("Load a test id list from a text file"),
 
26
                  action="store", dest='LOAD_LIST', default=None)
 
27
    gr.add_option('--list', 
 
28
                  help=("List available tests"),
 
29
                  action="store_true", dest='LIST', default=False)
 
30
    gr.add_option('--tests',
 
31
                  help=("wildcard pattern of tests to run"),
 
32
                  action="store", dest='TESTS', default='')
 
33
    gr.add_option('--filtered-subunit',
 
34
                  help=("output (xfail) filtered subunit"),
 
35
                  action="store_true", dest='FILTERED_SUBUNIT', default=False)
 
36
    gr.add_option('--quick',
 
37
                  help=("enable only quick tests"),
 
38
                  action="store_true", dest='QUICKTEST', default=False)
 
39
    gr.add_option('--slow',
 
40
                  help=("enable the really slow tests"),
 
41
                  action="store_true", dest='SLOWTEST', default=False)
 
42
    gr.add_option('--testenv',
 
43
                  help=("start a terminal with the test environment setup"),
 
44
                  action="store_true", dest='TESTENV', default=False)
 
45
    gr.add_option('--valgrind',
 
46
                  help=("use valgrind on client programs in the tests"),
 
47
                  action="store_true", dest='VALGRIND', default=False)
 
48
    gr.add_option('--valgrind-log',
 
49
                  help=("where to put the valgrind log"),
 
50
                  action="store", dest='VALGRINDLOG', default=None)
 
51
    gr.add_option('--valgrind-server',
 
52
                  help=("use valgrind on the server in the tests (opens an xterm)"),
 
53
                  action="store_true", dest='VALGRIND_SERVER', default=False)
 
54
    gr.add_option('--screen',
 
55
                  help=("run the samba servers in screen sessions"),
 
56
                  action="store_true", dest='SCREEN', default=False)
 
57
    gr.add_option('--gdbtest',
 
58
                  help=("run the servers within a gdb window"),
 
59
                  action="store_true", dest='GDBTEST', default=False)
 
60
    gr.add_option('--fail-immediately',
 
61
                  help=("stop tests on first failure"),
 
62
                  action="store_true", dest='FAIL_IMMEDIATELY', default=False)
 
63
    gr.add_option('--socket-wrapper-pcap',
 
64
                  help=("create a pcap file for each failing test"),
 
65
                  action="store_true", dest='SOCKET_WRAPPER_PCAP', default=False)
 
66
    gr.add_option('--socket-wrapper-keep-pcap',
 
67
                  help=("create a pcap file for all individual test"),
 
68
                  action="store_true", dest='SOCKET_WRAPPER_KEEP_PCAP', default=False)
 
69
 
 
70
def configure(conf):
 
71
    conf.env.SELFTEST_PREFIX = Options.options.SELFTEST_PREFIX
 
72
 
 
73
def cmd_testonly(opt):
 
74
    '''run tests without doing a build first'''
 
75
    env = LOAD_ENVIRONMENT()
 
76
    opt.env = env
 
77
 
 
78
    if (not CONFIG_SET(opt, 'NSS_WRAPPER') or
 
79
#        not CONFIG_SET(opt, 'UID_WRAPPER') or
 
80
        not CONFIG_SET(opt, 'SOCKET_WRAPPER')):
 
81
        print("ERROR: You must use --enable-selftest to enable selftest")
 
82
        sys.exit(1)
 
83
 
 
84
    os.environ['SAMBA_SELFTEST'] = '1'
 
85
 
 
86
    env.TESTS  = Options.options.TESTS
 
87
 
 
88
    env.SUBUNIT_FORMATTER = os.getenv('SUBUNIT_FORMATTER')
 
89
    if not env.SUBUNIT_FORMATTER:
 
90
        env.SUBUNIT_FORMATTER = '${PYTHON} -u ${srcdir}/selftest/format-subunit --prefix=${SELFTEST_PREFIX} --immediate'
 
91
    env.FILTER_XFAIL = '${PYTHON} -u ${srcdir}/selftest/filter-subunit --expected-failures=${srcdir}/source3/selftest/knownfail'
 
92
 
 
93
    if Options.options.FAIL_IMMEDIATELY:
 
94
        env.FILTER_XFAIL += ' --fail-immediately'
 
95
 
 
96
    env.FORMAT_TEST_OUTPUT = '${SUBUNIT_FORMATTER}'
 
97
 
 
98
    # clean any previous temporary files
 
99
    os.system("rm -rf %s/tmp" % env.SELFTEST_PREFIX);
 
100
 
 
101
    # put all command line options in the environment as TESTENV_*=*
 
102
    for o in dir(Options.options):
 
103
        if o[0:1] != '_':
 
104
            os.environ['TESTENV_%s' % o.upper()] = str(getattr(Options.options, o, ''))
 
105
 
 
106
    env.OPTIONS = ''
 
107
    if not Options.options.SLOWTEST:
 
108
        env.OPTIONS += ' --exclude=${srcdir}/source3/selftest/slow'
 
109
    if Options.options.QUICKTEST:
 
110
        env.OPTIONS += ' --quick --include=${srcdir}/source3/selftest/quick'
 
111
    if Options.options.LOAD_LIST:
 
112
        env.OPTIONS += ' --load-list=%s' % Options.options.LOAD_LIST
 
113
    if Options.options.TESTENV:
 
114
        env.OPTIONS += ' --testenv'
 
115
    if Options.options.SOCKET_WRAPPER_PCAP:
 
116
        env.OPTIONS += ' --socket-wrapper-pcap'
 
117
    if Options.options.SOCKET_WRAPPER_KEEP_PCAP:
 
118
        env.OPTIONS += ' --socket-wrapper-keep-pcap'
 
119
    if Options.options.LIST:
 
120
        env.OPTIONS += ' --list'
 
121
    if os.environ.get('RUN_FROM_BUILD_FARM') is not None:
 
122
        env.FILTER_OPTIONS = '${FILTER_XFAIL} --strip-passed-output'
 
123
    else:
 
124
        env.FILTER_OPTIONS = '${FILTER_XFAIL}'
 
125
 
 
126
    if Options.options.VALGRIND:
 
127
        os.environ['VALGRIND'] = 'valgrind -q --num-callers=30'
 
128
        if Options.options.VALGRINDLOG is not None:
 
129
            os.environ['VALGRIND'] += ' --log-file=%s' % Options.options.VALGRINDLOG
 
130
 
 
131
    server_wrapper=''
 
132
 
 
133
    if Options.options.VALGRIND_SERVER:
 
134
        server_wrapper = '${srcdir}/selftest/valgrind_run _DUMMY=X'
 
135
    elif Options.options.GDBTEST:
 
136
        server_wrapper = '${srcdir}/selftest/gdb_run _DUMMY=X'
 
137
 
 
138
    if Options.options.SCREEN:
 
139
        server_wrapper = '${srcdir}/selftest/in_screen %s' % server_wrapper
 
140
        os.environ['TERMINAL'] = EXPAND_VARIABLES(opt, '${srcdir}/selftest/in_screen')
 
141
    elif server_wrapper != '':
 
142
        server_wrapper = 'xterm -n server -l -e %s' % server_wrapper
 
143
 
 
144
    if server_wrapper != '':
 
145
        os.environ['SAMBA_VALGRIND'] = EXPAND_VARIABLES(opt, server_wrapper)
 
146
 
 
147
    # this is needed for systems without rpath, or with rpath disabled
 
148
    ADD_LD_LIBRARY_PATH('bin/shared')
 
149
    ADD_LD_LIBRARY_PATH('bin/shared/private')
 
150
 
 
151
    # if we are using a system version of ldb then we need to tell it to
 
152
    # load modules from our modules path
 
153
    if env.USING_SYSTEM_LDB:
 
154
        os.environ['LDB_MODULES_PATH'] = 'bin/modules/ldb'
 
155
 
 
156
    # tell build system where to find config.h
 
157
    os.environ['CONFIG_H'] = 'bin/default/source3/include/config.h'
 
158
    os.environ['VFSLIBDIR'] = os.path.abspath('bin/modules/vfs')
 
159
    os.environ['NSS_WRAPPER_WINBIND_SO_PATH'] = os.path.abspath('bin/default/nsswitch/libnss-winbind.so')
 
160
 
 
161
    st_done = os.path.join(env.SELFTEST_PREFIX, 'st_done')
 
162
    if os.path.exists(st_done):
 
163
        os.unlink(st_done)
 
164
 
 
165
    if not os.path.isdir(env.SELFTEST_PREFIX):
 
166
        os.makedirs(env.SELFTEST_PREFIX, int('755', 8))
 
167
 
 
168
    # We use the full path rather than relative path because it cause problems on some plateforms (ie. solaris 8).
 
169
    cmd = '(${PERL} ${srcdir}/selftest/selftest.pl --target=samba3 --prefix=${SELFTEST_PREFIX} --builddir=. --srcdir=${srcdir} --exclude=${srcdir}/source3/selftest/skip --testlist="${srcdir}/source3/selftest/tests.py|" ${OPTIONS} --socket-wrapper ${TESTS} && touch ${SELFTEST_PREFIX}/st_done) | ${FILTER_OPTIONS} | tee ${SELFTEST_PREFIX}/subunit'
 
170
    if os.environ.get('RUN_FROM_BUILD_FARM') is None and not Options.options.FILTERED_SUBUNIT:
 
171
        cmd += ' | ${FORMAT_TEST_OUTPUT}'
 
172
    else:
 
173
        cmd += ' | ${PYTHON} -u ${srcdir}/selftest/filter-subunit'
 
174
    cmd = EXPAND_VARIABLES(opt, cmd)
 
175
 
 
176
    print("test: running %s" % cmd)
 
177
    ret = RUN_COMMAND(cmd, env=env)
 
178
    if os.path.exists(".testrepository"):
 
179
        # "testr load -q" isn't
 
180
        cmd = 'testr load -q < ${SELFTEST_PREFIX}/subunit > /dev/null'
 
181
        cmd = EXPAND_VARIABLES(opt, cmd)
 
182
        RUN_COMMAND(cmd, env=env)
 
183
 
 
184
    if ret != 0:
 
185
        print("ERROR: test failed with exit code %d" % ret)
 
186
        sys.exit(ret)
 
187
 
 
188
    if not os.path.exists(st_done):
 
189
        print("ERROR: test command failed to complete")
 
190
        sys.exit(1)
 
191
 
 
192
 
 
193
########################################################################
 
194
# main test entry point
 
195
def cmd_test(opt):
 
196
    '''Run the test suite (see test options below)'''
 
197
    Scripting.commands.append('build')
 
198
    Scripting.commands.append('testonly')