diff options
author | Leah Rumancik <leah.rumancik@gmail.com> | 2023-01-30 13:39:44 -0800 |
---|---|---|
committer | Leah Rumancik <leah.rumancik@gmail.com> | 2023-01-30 13:45:33 -0800 |
commit | 6b67339800853ffae2c143dddd17ece7dca1e4de (patch) | |
tree | bf02cbf9a391f5c792cf3ace66d09378c6c0b6f9 | |
parent | 1e153eaa2f320467b56c2ec2254bdc46a144d54d (diff) | |
download | xfstests-bld-6b67339800853ffae2c143dddd17ece7dca1e4de.tar.gz |
results: add helper script to record test with error
Create a python script to add an error testcase at the end of a result
xml file. This will be used by the ltm auto resume code to record when
a test caused a crash/hang.
Signed-off-by: Leah Rumancik <leah.rumancik@gmail.com>
-rw-r--r-- | test-appliance/files/usr/lib/python3/dist-packages/junitparser/__init__.py | 1 | ||||
-rwxr-xr-x | test-appliance/files/usr/local/bin/add_error_xunit | 48 |
2 files changed, 49 insertions, 0 deletions
diff --git a/test-appliance/files/usr/lib/python3/dist-packages/junitparser/__init__.py b/test-appliance/files/usr/lib/python3/dist-packages/junitparser/__init__.py index e3d8da0c..55b9ddbc 100644 --- a/test-appliance/files/usr/lib/python3/dist-packages/junitparser/__init__.py +++ b/test-appliance/files/usr/lib/python3/dist-packages/junitparser/__init__.py @@ -8,6 +8,7 @@ from .junitparser import ( Skipped, Failure, Error, + Result, TestCase, Properties, IntAttr, diff --git a/test-appliance/files/usr/local/bin/add_error_xunit b/test-appliance/files/usr/local/bin/add_error_xunit new file mode 100755 index 00000000..0f12e983 --- /dev/null +++ b/test-appliance/files/usr/local/bin/add_error_xunit @@ -0,0 +1,48 @@ +#!/usr/bin/python3 +import argparse +import os +import sys +from junitparser import JUnitXml, TestSuite, TestCase, Result, Error + +def get_test_suite(filename): + if not os.path.exists(filename): + ts = TestSuite() + else: + try: + ts = JUnitXml.fromfile(filename) + except IOError as e: + sys.exit("Couldn't open %s: %s" % (filename, e[1])) + + if type(ts) != TestSuite: + sys.exit('%s is not a xUnit report file' % filename) + return ts + + +parser = argparse.ArgumentParser() +parser.add_argument('input_file', help='input xUnit result file') +parser.add_argument('testname', help='name of test causing error') +parser.add_argument('classname', help='classname for test case') +args = parser.parse_args() + +ts = get_test_suite(args.input_file) + +result = Result() + +error = Error(result) +error.message='Machine rebooted (crash or test timeout)' +error.type='TestFail' + +tc = TestCase() +tc.classname=args.classname +tc.name=args.testname +tc.time = 0 +tc.result = [error] + +# this also updates the statistics +ts.add_testcase(tc) + +ts.write(args.input_file + '.new', pretty=True) +if os.path.exists(args.input_file): + os.rename(args.input_file, args.input_file + '.error.bak') +os.rename(args.input_file + '.new' , args.input_file) + |