summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2010-03-19 14:25:50 +1100
committerAndrew Tridgell <tridge@samba.org>2010-04-06 20:26:53 +1000
commit3ff3a11c33a8a3d9fbacf76fcf59c8c4d929e4a5 (patch)
treec05f5d35671675d5fbc6bfa67e98309a7be45b87
parent6e550ac4c7f2c2a2a14ed0816e439824e8c898aa (diff)
downloadsamba-3ff3a11c33a8a3d9fbacf76fcf59c8c4d929e4a5.tar.gz
samba-3ff3a11c33a8a3d9fbacf76fcf59c8c4d929e4a5.tar.bz2
samba-3ff3a11c33a8a3d9fbacf76fcf59c8c4d929e4a5.zip
build: use RUN_COMMAND() to wrap os.system()
-rw-r--r--buildtools/wafsamba/samba_utils.py18
-rw-r--r--source4/selftest/wscript9
2 files changed, 21 insertions, 6 deletions
diff --git a/buildtools/wafsamba/samba_utils.py b/buildtools/wafsamba/samba_utils.py
index a5d42e4f7f..cb055043a7 100644
--- a/buildtools/wafsamba/samba_utils.py
+++ b/buildtools/wafsamba/samba_utils.py
@@ -296,3 +296,21 @@ def mkdir_p(dir):
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
diff --git a/source4/selftest/wscript b/source4/selftest/wscript
index e1a59aceed..4fea799ecf 100644
--- a/source4/selftest/wscript
+++ b/source4/selftest/wscript
@@ -1,6 +1,7 @@
# 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)
@@ -70,14 +71,10 @@ def cmd_testonly(opt):
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)