From ca02ed000beec22dc0f4dc0c1e9c045f01f47118 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20=C4=8Cerm=C3=A1k?= Date: Tue, 21 Jan 2025 16:55:49 +0100 Subject: [PATCH] Add check for tainted kernel to automatic tests (#3814) Add test that the kernel isn't tainted at the end of the basic and supervisor test suites, allowing us to catch e.g. kernel warnings that may left unnoticed if dmesg isn't checked. There is no other source of tainting, so the value should be always zero. --- tests/smoke_test/test_basic.py | 8 ++++++++ tests/supervisor_test/test_supervisor.py | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/tests/smoke_test/test_basic.py b/tests/smoke_test/test_basic.py index 9e466e198..615695ff4 100644 --- a/tests/smoke_test/test_basic.py +++ b/tests/smoke_test/test_basic.py @@ -76,3 +76,11 @@ def test_systemctl_status(shell): def test_systemctl_check_no_failed(shell): output = shell.run_check("systemctl --no-pager -l list-units --state=failed") assert "0 loaded units listed." in output, f"Some units failed:\n{"\n".join(output)}" + + +@pytest.mark.dependency(depends=["test_init"]) +def test_kernel_not_tainted(shell): + """Check if the kernel is not tainted - do it at the end of the + test suite to increase the chance of catching issues.""" + output = shell.run_check("cat /proc/sys/kernel/tainted") + assert output == "0\n", f"Kernel tainted: {output}" diff --git a/tests/supervisor_test/test_supervisor.py b/tests/supervisor_test/test_supervisor.py index c7621ea4f..92623e327 100644 --- a/tests/supervisor_test/test_supervisor.py +++ b/tests/supervisor_test/test_supervisor.py @@ -190,3 +190,11 @@ def test_restore_ssl_directory(shell_json, stash): result = shell_json(f"ha backups restore {stash.get('slug')} --folders ssl --no-progress --raw-json") assert result.get("result") == "ok", f"Backup restore failed: {result}" logger.info("Backup restore result: %s", result) + + +@pytest.mark.dependency(depends=["test_start_supervisor"]) +def test_kernel_not_tainted(shell): + """Check if the kernel is not tainted - do it at the end of the + test suite to increase the chance of catching issues.""" + output = shell.run_check("cat /proc/sys/kernel/tainted") + assert output == "0\n", f"Kernel tainted: {output}"