return
mkdir_p(os.path.dirname(dir))
os.mkdir(dir)
+
+
+def RUN_COMMAND(cmd,
+ env=None,
+ shell=False):
+ '''run a external command, return exit code or signal'''
+ # recursively expand variables
+ if env:
+ while cmd.find('${') != -1:
+ cmd = Utils.subst_vars(cmd, env)
+
+ status = os.system(cmd)
+ if os.WIFEXITED(status):
+ return os.WEXITSTATUS(status)
+ if os.WIFSIGNALED(status):
+ return - os.WTERMSIG(status)
+ print "Unknown exit reason %d for command: %s" (status, cmd)
+ return -1
# selftest main code.
import Scripting, os, Options, Utils, Environment, optparse, sys
+from samba_utils import RUN_COMMAND
def set_options(opt):
opt.ADD_COMMAND('test', cmd_test)
if os.path.exists(st_done):
os.unlink(st_done)
- cmd = '(PYTHON=/usr/bin/python perl -W ../selftest/selftest.pl --prefix=./st --builddir=. --srcdir=. --exclude=./selftest/skip --testlist="./selftest/tests.sh|" ${OPTIONS} --socket-wrapper ${TESTS} && touch st/st_done) | ${FILTER_OPTIONS}'
-
- # recursively expand variables
- while cmd.find('${') != -1:
- cmd = Utils.subst_vars(cmd, env)
+ cmd = '(PYTHON=/usr/bin/python perl -W ../selftest/selftest.pl --prefix=./st --builddir=. --srcdir=. --exclude=./selftest/skip --testlist="./selftest/tests.sh|" ${OPTIONS} --socket-wrapper ${TESTS} && touch st/st_done) | tee st/test.out | ${FILTER_OPTIONS}'
print "test: running %s" % cmd
- ret = os.system(cmd)
+ ret = RUN_COMMAND(cmd, env=env)
if ret != 0:
print("ERROR: test failed with exit code %d" % ret)
sys.exit(ret)