summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2020-12-16 00:19:28 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2020-12-16 00:19:28 -0800
commit706451d47b3716c24e0553dfdefba11d202effc1 (patch)
tree3731cabc5c2f9e99d01f7c3e3309bdc78e8600c4 /tools
parent7194850efa47c8dac6e805087dd23c7b03af019d (diff)
parent5f6b99d0287de2c2d0b5e7abcb0092d553ad804a (diff)
downloadlinux-706451d47b3716c24e0553dfdefba11d202effc1.tar.bz2
Merge tag 'linux-kselftest-kunit-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest
Pull Kunit updates from Shuah Khan: - documentation update and fix to kunit_tool to parse diagnostic messages correctly from David Gow - Support for Parameterized Testing and fs/ext4 test updates to use KUnit parameterized testing feature from Arpitha Raghunandan - Helper to derive file names depending on --build_dir argument from Andy Shevchenko * tag 'linux-kselftest-kunit-5.11-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/shuah/linux-kselftest: fs: ext4: Modify inode-test.c to use KUnit parameterized testing feature kunit: Support for Parameterized Testing kunit: kunit_tool: Correctly parse diagnostic messages Documentation: kunit: provide guidance for testing many inputs kunit: Introduce get_file_path() helper
Diffstat (limited to 'tools')
-rw-r--r--tools/testing/kunit/kunit_kernel.py24
-rw-r--r--tools/testing/kunit/kunit_parser.py7
2 files changed, 13 insertions, 18 deletions
diff --git a/tools/testing/kunit/kunit_kernel.py b/tools/testing/kunit/kunit_kernel.py
index 2e3cc0fac726..57c1724b7e5d 100644
--- a/tools/testing/kunit/kunit_kernel.py
+++ b/tools/testing/kunit/kunit_kernel.py
@@ -23,6 +23,11 @@ DEFAULT_KUNITCONFIG_PATH = 'arch/um/configs/kunit_defconfig'
BROKEN_ALLCONFIG_PATH = 'tools/testing/kunit/configs/broken_on_uml.config'
OUTFILE_PATH = 'test.log'
+def get_file_path(build_dir, default):
+ if build_dir:
+ default = os.path.join(build_dir, default)
+ return default
+
class ConfigError(Exception):
"""Represents an error trying to configure the Linux kernel."""
@@ -97,9 +102,7 @@ class LinuxSourceTreeOperations(object):
def linux_bin(self, params, timeout, build_dir):
"""Runs the Linux UML binary. Must be named 'linux'."""
- linux_bin = './linux'
- if build_dir:
- linux_bin = os.path.join(build_dir, 'linux')
+ linux_bin = get_file_path(build_dir, 'linux')
outfile = get_outfile_path(build_dir)
with open(outfile, 'w') as output:
process = subprocess.Popen([linux_bin] + params,
@@ -108,22 +111,13 @@ class LinuxSourceTreeOperations(object):
process.wait(timeout)
def get_kconfig_path(build_dir):
- kconfig_path = KCONFIG_PATH
- if build_dir:
- kconfig_path = os.path.join(build_dir, KCONFIG_PATH)
- return kconfig_path
+ return get_file_path(build_dir, KCONFIG_PATH)
def get_kunitconfig_path(build_dir):
- kunitconfig_path = KUNITCONFIG_PATH
- if build_dir:
- kunitconfig_path = os.path.join(build_dir, KUNITCONFIG_PATH)
- return kunitconfig_path
+ return get_file_path(build_dir, KUNITCONFIG_PATH)
def get_outfile_path(build_dir):
- outfile_path = OUTFILE_PATH
- if build_dir:
- outfile_path = os.path.join(build_dir, OUTFILE_PATH)
- return outfile_path
+ return get_file_path(build_dir, OUTFILE_PATH)
class LinuxSourceTree(object):
"""Represents a Linux kernel source tree with KUnit tests."""
diff --git a/tools/testing/kunit/kunit_parser.py b/tools/testing/kunit/kunit_parser.py
index bbfe1b4e4c1c..6614ec4d0898 100644
--- a/tools/testing/kunit/kunit_parser.py
+++ b/tools/testing/kunit/kunit_parser.py
@@ -135,8 +135,8 @@ def parse_ok_not_ok_test_case(lines: List[str], test_case: TestCase) -> bool:
else:
return False
-SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# .*?: (.*)$')
-DIAGNOSTIC_CRASH_MESSAGE = 'kunit test case crashed!'
+SUBTEST_DIAGNOSTIC = re.compile(r'^[\s]+# (.*)$')
+DIAGNOSTIC_CRASH_MESSAGE = re.compile(r'^[\s]+# .*?: kunit test case crashed!$')
def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
save_non_diagnositic(lines, test_case)
@@ -146,7 +146,8 @@ def parse_diagnostic(lines: List[str], test_case: TestCase) -> bool:
match = SUBTEST_DIAGNOSTIC.match(line)
if match:
test_case.log.append(lines.pop(0))
- if match.group(1) == DIAGNOSTIC_CRASH_MESSAGE:
+ crash_match = DIAGNOSTIC_CRASH_MESSAGE.match(line)
+ if crash_match:
test_case.status = TestStatus.TEST_CRASHED
return True
else: