Skip to content
This repository was archived by the owner on Dec 27, 2023. It is now read-only.

Commit 49f18b3

Browse files
committed
Save test execution messages in SUT /dev/kmsg
With this patch we will save test execution messages inside the SUT /dev/kmsg, instead of host /dev/kmsg. Signed-off-by: Andrea Cervesato <[email protected]> Reviewed-by: Petr Vorel <[email protected]> Tested-by: Petr Vorel <[email protected]> Fixes: #5
1 parent f097797 commit 49f18b3

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

ltp/dispatcher.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -329,19 +329,20 @@ def _write_kmsg(self, test: Test) -> None:
329329
"""
330330
self._logger.info("Writing test information on /dev/kmsg")
331331

332-
if os.geteuid() != 0:
332+
ret = self._sut.run_command("id -u", timeout=10)
333+
if ret["stdout"] != "0\n":
333334
self._logger.info("Can't write on /dev/kmsg from user")
334335
return
335336

336-
with open('/dev/kmsg', 'w', encoding='utf-8') as kmsg:
337-
cmd = f"{test.command}"
338-
if len(test.arguments) > 0:
339-
cmd += ' '
340-
cmd += ' '.join(test.arguments)
337+
cmd = f"{test.command}"
338+
if len(test.arguments) > 0:
339+
cmd += ' '
340+
cmd += ' '.join(test.arguments)
341341

342-
kmsg.write(
343-
f'{sys.argv[0]}[{os.getpid()}]: '
344-
f'starting test {test.name} ({cmd})\n')
342+
message = f'{sys.argv[0]}[{os.getpid()}]: ' \
343+
f'starting test {test.name} ({cmd})\n'
344+
345+
self._sut.run_command(f'echo -n "{message}" > /dev/kmsg', timeout=10)
345346

346347
def _run_test(self, test: Test) -> TestResults:
347348
"""

0 commit comments

Comments
 (0)