summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManuel Traut <manut@linutronix.de>2017-12-04 15:54:53 +0100
committerManuel Traut <manut@linutronix.de>2017-12-04 15:54:53 +0100
commitaf357c5cfbadb82e9884d086b2d6a84b2820f0db (patch)
tree0316172ab4da5bb64fbc675071554de867ce37b8
parentfa630bd7e37771933624cf0c2e65391aa85a27b9 (diff)
add --class parameter
to specify classname of a testcase, if not given it defaults to 'sh' Signed-off-by: Manuel Traut <manut@linutronix.de>
-rwxr-xr-xpyjutest11
1 files changed, 7 insertions, 4 deletions
diff --git a/pyjutest b/pyjutest
index b3ca92d..5c3f60a 100755
--- a/pyjutest
+++ b/pyjutest
@@ -21,6 +21,7 @@ from pyju.version import pyju_version
oparser = OptionParser(usage="usage: %prog [options] \'mycmd param1 param2\'")
oparser.add_option("--version", dest="version", action="store_true", default=False)
+oparser.add_option("--class", dest="uclass", default="sh")
(opt,args) = oparser.parse_args(sys.argv)
@@ -32,6 +33,8 @@ if len(args) != 2:
oparser.print_help()
sys.exit(-1)
+cmd = args[1]
+
if os.path.exists('pyjutest.dat'):
with open('pyjutest.dat', 'rb') as dat:
tss = load(dat)
@@ -40,12 +43,12 @@ else:
start = time.time()
-p = Popen(sys.argv[1], shell=True, stdout=PIPE, stderr=PIPE)
+p = Popen(cmd, shell=True, stdout=PIPE, stderr=PIPE)
out,err = p.communicate()
duration = time.time() - start
-tc = TestCase(sys.argv[1], 'sh', duration, out[:-1].decode('utf-8'),
+tc = TestCase(cmd, opt.uclass, duration, out[:-1].decode('utf-8'),
err[:-1].decode('utf-8'))
if p.returncode:
@@ -59,9 +62,9 @@ with open('pyjutest.dat', 'wb') as dat:
with open('pyjutest.xml', 'w') as xml:
TestSuite.to_file(xml, tss, prettyprint=True)
-print("%s STDOUT:" % sys.argv[1])
+print("%s STDOUT:" % cmd)
for l in out.decode().split("\n"):
print(l)
-print("%s STDERR:" % sys.argv[1])
+print("%s STDERR:" % cmd)
for l in err.decode().split("\n"):
print(l, file=sys.stderr)