aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authoraqua <aqua@iserlohn-fortress.net>2023-03-12 21:16:21 +0200
committeraqua <aqua@iserlohn-fortress.net>2023-03-12 21:16:21 +0200
commit30fd1dcbe128778d00b6677a3dc00c119c000e83 (patch)
tree76ee3d0843018e9fdbc5b6c1f7e2c5ca74997abd /scripts
parentsrc/Makefile: generate conf.h if it doesn't exist (diff)
downloadkernel-30fd1dcbe128778d00b6677a3dc00c119c000e83.tar.xz
Add scripts/test_runner.py
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/test_runner.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/scripts/test_runner.py b/scripts/test_runner.py
new file mode 100755
index 0000000..80c3e30
--- /dev/null
+++ b/scripts/test_runner.py
@@ -0,0 +1,38 @@
+#!/usr/bin/env python3
+
+""" Test runner """
+
+import argparse
+import os
+import subprocess
+
+def main():
+ """ Main function"""
+
+ parser = argparse.ArgumentParser(description='Run test executables')
+ parser.add_argument('-v', '--verbose', action='store_true', help='Show test stdout/stderr')
+ parser.add_argument('--valgrind', action='store_true', help='Run tests under valgrind')
+ parser.add_argument('test', type=str, nargs='+', help='test executable to run')
+ args = parser.parse_args()
+
+ cwd = os.getcwd()
+ fail_count = 0
+
+ for test in args.test:
+ cmd = []
+ if args.valgrind:
+ cmd += [ 'valgrind', '--leak-check=full', '--error-exitcode=128' ]
+ cmd.append(os.path.join(cwd, test))
+ #print(cmd)
+
+ print(f' {test:.<48}', end='')
+ result = subprocess.run(cmd, capture_output=not args.verbose, check=False)
+ print('ok' if result.returncode == 0 else 'failed')
+ if result.returncode != 0:
+ fail_count += 1
+
+ print(f' Ran {len(args.test)} tests, {fail_count} failed')
+
+
+if __name__ == '__main__':
+ main()