diff options
author | Tony Hutter <[email protected]> | 2022-03-23 08:15:02 -0700 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-23 09:15:02 -0600 |
commit | b73505c7e056417cba73dcf51b49062c84fd2b59 (patch) | |
tree | 8d4a3b6d2c5d708717f7a2166baa0992dcf4f6e1 /tests | |
parent | 6b444cb9711a8c0a089612dc3ac67e45c4a4e108 (diff) |
ZTS: Log test name to /dev/kmsg on Linux
Add a -K option to the test suite to log each test name to /dev/kmsg
(on Linux), so if there's a kernel warning we'll be able to match
it up to a particular test.
Reviewed-by: John Kennedy <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #13227
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/test-runner/bin/test-runner.py.in | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/tests/test-runner/bin/test-runner.py.in b/tests/test-runner/bin/test-runner.py.in index c644745b4..5c868d945 100755 --- a/tests/test-runner/bin/test-runner.py.in +++ b/tests/test-runner/bin/test-runner.py.in @@ -34,6 +34,7 @@ from subprocess import Popen from subprocess import check_output from threading import Timer from time import time, CLOCK_MONOTONIC +from os.path import exists BASEDIR = '/var/tmp/test_results' TESTDIR = '/usr/share/zfs/' @@ -256,7 +257,7 @@ User: %s return out.lines, err.lines - def run(self, dryrun, kmemleak): + def run(self, dryrun, kmemleak, kmsg): """ This is the main function that runs each individual test. Determine whether or not the command requires sudo, and modify it @@ -275,6 +276,18 @@ User: %s except OSError as e: fail('%s' % e) + """ + Log each test we run to /dev/kmsg (on Linux), so if there's a kernel + warning we'll be able to match it up to a particular test. + """ + if kmsg is True and exists("/dev/kmsg"): + try: + kp = Popen([SUDO, "sh", "-c", + f"echo ZTS run {self.pathname} > /dev/kmsg"]) + kp.wait() + except Exception: + pass + self.result.starttime = monotonic_time() if kmemleak: @@ -459,14 +472,14 @@ Tags: %s cont = True if len(pretest.pathname): - pretest.run(options.dryrun, False) + pretest.run(options.dryrun, False, options.kmsg) cont = pretest.result.result == 'PASS' pretest.log(options) if cont: - test.run(options.dryrun, options.kmemleak) + test.run(options.dryrun, options.kmemleak, options.kmsg) if test.result.result == 'KILLED' and len(failsafe.pathname): - failsafe.run(options.dryrun, False) + failsafe.run(options.dryrun, False, options.kmsg) failsafe.log(options, suppress_console=True) else: test.skip() @@ -474,7 +487,7 @@ Tags: %s test.log(options) if len(posttest.pathname): - posttest.run(options.dryrun, False) + posttest.run(options.dryrun, False, options.kmsg) posttest.log(options) @@ -577,7 +590,7 @@ Tags: %s cont = True if len(pretest.pathname): - pretest.run(options.dryrun, False) + pretest.run(options.dryrun, False, options.kmsg) cont = pretest.result.result == 'PASS' pretest.log(options) @@ -590,9 +603,9 @@ Tags: %s failsafe = Cmd(self.failsafe, outputdir=odir, timeout=self.timeout, user=self.failsafe_user, identifier=self.identifier) if cont: - test.run(options.dryrun, options.kmemleak) + test.run(options.dryrun, options.kmemleak, options.kmsg) if test.result.result == 'KILLED' and len(failsafe.pathname): - failsafe.run(options.dryrun, False) + failsafe.run(options.dryrun, False, options.kmsg) failsafe.log(options, suppress_console=True) else: test.skip() @@ -600,7 +613,7 @@ Tags: %s test.log(options) if len(posttest.pathname): - posttest.run(options.dryrun, False) + posttest.run(options.dryrun, False, options.kmsg) posttest.log(options) @@ -1060,6 +1073,8 @@ def parse_args(): parser.add_option('-i', action='callback', callback=options_cb, default=TESTDIR, dest='testdir', type='string', metavar='testdir', help='Specify a test directory.') + parser.add_option('-K', action='store_true', default=False, dest='kmsg', + help='Log tests names to /dev/kmsg') parser.add_option('-m', action='callback', callback=kmemleak_cb, default=False, dest='kmemleak', help='Enable kmemleak reporting (Linux only)') |