Skip to content

lib: add dmesg fallback for kernel log access on non-systemd systems - #1368

Merged
lgirdwood merged 1 commit into
thesofproject:mainfrom
ujfalusi:peter/pr/dmesg_support
Nov 27, 2026
Merged

lgirdwood merged 1 commit into
thesofproject:mainfrom
ujfalusi:peter/pr/dmesg_support

Conversation

@ujfalusi

Copy link
Copy Markdown
Contributor

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.

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>
@ujfalusi
ujfalusi requested review from dbaluta and kv2019i November 24, 2026 13:36
@ujfalusi
ujfalusi requested review from a team, lgirdwood and marc-hb as code owners November 24, 2026 13:36

@marc-hb marc-hb left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Renaming the function seems unncessary.

@lgirdwood
lgirdwood merged commit 5756dbe into thesofproject:main Nov 27, 2026
3 checks passed
Comment thread case-lib/lib.sh
mapped_args+=("${arg/--priority/--level}")
done

sudo dmesg -k --nopager "${mapped_args[@]}"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. This is dropping the important --since argument: exactly why dmesg is unsuitable for testing.

  2. 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....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants