Repository navigation
lib: add dmesg fallback for kernel log access on non-systemd systems - #1368
Conversation
The test framework assumed systemd: kernel logs were read with journalctl, so it could not be used on distributions without it, such as Artix Linux, Gentoo with OpenRC, Yocto or other embedded OSes. Rename journalctl_cmd() to kernel_logger_cmd(). It still uses "journalctl -k" when journalctl is available. Otherwise it falls back to "dmesg -k", mapping --priority to the dmesg equivalent --level. Use the wrapper everywhere kernel logs are read, including fw_relfilepath_from_klogs(), which called journalctl directly, and the callers in verify-sof-firmware-load.sh and sof-kernel-log-check.sh. Also save the kernel messages collected since KERNEL_CHECKPOINT (or all of them if the checkpoint is disabled) to dmesg.txt in the exit handler. Flush the logs to disk with sync in case the DUT is power reset. Call "sudo true" in setup_kernel_check_point() so the sudo credentials are cached before the log commands run. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
marc-hb
left a comment
There was a problem hiding this comment.
Renaming the function seems unncessary.
| mapped_args+=("${arg/--priority/--level}") | ||
| done | ||
|
|
||
| sudo dmesg -k --nopager "${mapped_args[@]}" |
There was a problem hiding this comment.
-
This is dropping the important
--sinceargument: exactly whydmesgis unsuitable for testing. -
Other obvious reason why is: unknown ring buffer size and losing logs at very verbose levels.
Embedded systems like Yocto aside, "systemd-free" distros have /var/log/something that should have been used instead of dmesg. It would have avoided at least issue 2.
At least it does not seem to affect systems that do have journalctl....
There was a problem hiding this comment.
- it is not dropping the since:
$ dmesg -h | grep since
--since <time> display the lines since the specified time
and this is compatible with systemd thing.
since util-linux 80e9e8ca9bba6dfd0884e0d7707d398c2ac9101d and fef9b04dafd297dbb080c8ccbbcb6800184a9616 (2022, September)
- yes, that is true, which is also haunting systemd logging.
There was a problem hiding this comment.
dmesg -h | grep since
Nice! Thanks for correcting me.
yes, that is true, which is also haunting systemd logging.
? Unlike dmesg, journalctl saves logs to disk by default, not RAM. There is some log rotation happening on most distros but the space available is several orders of magnitude bigger than dmesg: practically unlimited. I know because I spent way too much time sifting those :-)
Famous last words: |
The test framework assumed systemd: kernel logs were read with journalctl, so it could not be used on distributions without it, such as Artix Linux, Gentoo with OpenRC, Yocto or other embedded OSes.
Rename journalctl_cmd() to kernel_logger_cmd(). It still uses "journalctl -k" when journalctl is available. Otherwise it falls back to "dmesg -k", mapping --priority to the dmesg equivalent --level.
Use the wrapper everywhere kernel logs are read, including fw_relfilepath_from_klogs(), which called journalctl directly, and the callers in verify-sof-firmware-load.sh and sof-kernel-log-check.sh.
Also save the kernel messages collected since KERNEL_CHECKPOINT (or all of them if the checkpoint is disabled) to dmesg.txt in the exit handler. Flush the logs to disk with sync in case the DUT is power reset.
Call "sudo true" in setup_kernel_check_point() so the sudo credentials are cached before the log commands run.