new file mode 100755
@@ -0,0 +1,40 @@
+#!/usr/bin/python3
+# SPDX-License-Identifier: GPL-2.0
+
+# A thin wrapper on top of the KUnit Kernel
+
+import argparse
+import sys
+import os
+
+import kunit_config
+import kunit_kernel
+import kunit_parser
+
+parser = argparse.ArgumentParser(description='Runs KUnit tests.')
+
+parser.add_argument('--raw_output', help='don\'t format output from kernel',
+ action='store_true')
+
+parser.add_argument('--timeout', help='maximum number of seconds to allow for '
+ 'all tests to run. This does not include time taken to '
+ 'build the tests.', type=int, default=300,
+ metavar='timeout')
+
+cli_args = parser.parse_args()
+linux = kunit_kernel.LinuxSourceTree()
+
+success = linux.build_reconfig()
+if not success:
+ quit()
+
+print('Building KUnit Kernel ...')
+success = linux.build_um_kernel()
+if not success:
+ quit()
+
+print('Starting KUnit Kernel ...')
+if cli_args.raw_output:
+ kunit_parser.raw_output(linux.run_kernel(timeout=cli_args.timeout))
+else:
+ kunit_parser.parse_run_tests(linux.run_kernel(timeout=cli_args.timeout))
@@ -113,8 +113,7 @@ class LinuxSourceTree(object):
return False
return True
- def run_kernel(self, args=[]):
- timeout = None
+ def run_kernel(self, args=[], timeout=None):
args.extend(['mem=256M'])
process = self._ops.linux_bin(args, timeout)
with open('test.log', 'w') as f:
new file mode 100644
@@ -0,0 +1,24 @@
+# SPDX-License-Identifier: GPL-2.0
+
+import re
+
+kunit_start_re = re.compile('console .* enabled')
+kunit_end_re = re.compile('List of all partitions:')
+
+def isolate_kunit_output(kernel_output):
+ started = False
+ for line in kernel_output:
+ if kunit_start_re.match(line):
+ started = True
+ elif kunit_end_re.match(line):
+ break
+ elif started:
+ yield line
+
+def raw_output(kernel_output):
+ for line in kernel_output:
+ print(line)
+
+def parse_run_tests(kernel_output):
+ for output in isolate_kunit_output(kernel_output):
+ print(output)