From 1f42ff27a406376ffa6491c77f50d58455c4f1cd Mon Sep 17 00:00:00 2001 From: Petr Vorel Date: Thu, 19 Feb 2026 21:37:13 +0100 Subject: [PATCH] libkirk: Print /proc/cmdline /proc/cmdline is crucial for some tests, print it in the test summary. Signed-off-by: Petr Vorel --- libkirk/export.py | 1 + libkirk/monitor.py | 1 + libkirk/results.py | 13 +++++++++++++ libkirk/scheduler.py | 1 + libkirk/sut.py | 13 ++++++++++++- libkirk/tests/test_export.py | 2 ++ libkirk/tests/test_scheduler.py | 1 + libkirk/tests/test_sut.py | 1 + libkirk/ui.py | 29 +++++++++++++++-------------- 9 files changed, 47 insertions(+), 15 deletions(-) diff --git a/libkirk/export.py b/libkirk/export.py index 9bf0fc1..2b1f8d3 100644 --- a/libkirk/export.py +++ b/libkirk/export.py @@ -107,6 +107,7 @@ async def save_file(self, results: List[SuiteResults], path: str) -> None: "distribution": results[0].distro, "distribution_version": results[0].distro_ver, "kernel": results[0].kernel, + "cmdline": results[0].cmdline, "arch": results[0].arch, "cpu": results[0].cpu, "swap": results[0].swap, diff --git a/libkirk/monitor.py b/libkirk/monitor.py index 0ba3391..7d2b147 100644 --- a/libkirk/monitor.py +++ b/libkirk/monitor.py @@ -197,6 +197,7 @@ async def suite_completed(self, results: SuiteResults, exec_time: float) -> None "broken": results.broken, "warnings": results.warnings, "kernel_version": results.kernel, + "cmdline": results.cmdline, "cpu": results.cpu, "arch": results.arch, "ram": results.ram, diff --git a/libkirk/results.py b/libkirk/results.py index d75ba14..e38e5fa 100644 --- a/libkirk/results.py +++ b/libkirk/results.py @@ -242,6 +242,7 @@ def __init__( distro: Optional[str] = None, distro_ver: Optional[str] = None, kernel: Optional[str] = None, + cmdline: Optional[str] = None, arch: Optional[str] = None, cpu: Optional[str] = None, swap: Optional[str] = None, @@ -258,6 +259,8 @@ def __init__( :type distro_ver: str :param kernel: Kernel version. :type kernel: str + :param cmdline: /proc/cmdline. + :type cmdline: str :param arch: OS architecture. :type arch: str :param cpu: CPU type info. @@ -275,6 +278,7 @@ def __init__( self._distro = distro self._distro_ver = distro_ver self._kernel = kernel + self._cmdline = cmdline self._arch = arch self._cpu = cpu self._swap = swap @@ -287,6 +291,7 @@ def __repr__(self) -> str: f"distro: {self._distro}, " f"distro_ver: {self._distro_ver}, " f"kernel: {self._kernel}, " + f"cmdline: {self._cmdline}, " f"arch: {self._arch}, " f"cpu: {self._cpu}, " f"swap: {self._swap}, " @@ -343,6 +348,14 @@ def kernel(self) -> Optional[str]: """ return self._kernel + @property + def cmdline(self) -> Optional[str]: + """ + :return: /proc/cmdline. + :rtype: str | None + """ + return self._cmdline + @property def arch(self) -> Optional[str]: """ diff --git a/libkirk/scheduler.py b/libkirk/scheduler.py index 2702eda..38350ce 100644 --- a/libkirk/scheduler.py +++ b/libkirk/scheduler.py @@ -584,6 +584,7 @@ async def _run_suite(self, suite: Suite) -> None: distro=info["distro"], distro_ver=info["distro_ver"], kernel=info["kernel"], + cmdline=info["cmdline"], arch=info["arch"], cpu=info["cpu"], swap=info["swap"], diff --git a/libkirk/sut.py b/libkirk/sut.py index f41a81e..872c79d 100644 --- a/libkirk/sut.py +++ b/libkirk/sut.py @@ -155,6 +155,12 @@ async def _get_kernel(self) -> str: """ return await self._run_cmd("uname -s -r -v") + async def _get_cmdline(self) -> str: + """ + Return /proc/cmdline content. + """ + return await self._run_cmd("cat /proc/cmdline") + async def _get_arch(self) -> str: """ Return the architecture name. @@ -185,6 +191,7 @@ async def get_info(self) -> Dict[str, str]: "distro": str, "distro_ver": str, "kernel": str, + "cmdline": str, "arch": str, "cpu" : str, "swap" : str, @@ -199,17 +206,19 @@ async def get_info(self) -> Dict[str, str]: distro = "" distro_ver = "" kernel = "" + cmdline = "" arch = "" cpu = "" meminfo = "" if self.optimize: # pyrefly: ignore[bad-unpacking] - distro, distro_ver, kernel, arch, cpu, meminfo = await asyncio.gather( + distro, distro_ver, kernel, cmdline, arch, cpu, meminfo = await asyncio.gather( *[ self._get_distro(), self._get_distro_ver(), self._get_kernel(), + self._get_cmdline(), self._get_arch(), self._get_cpu(), self._get_meminfo(), @@ -219,6 +228,7 @@ async def get_info(self) -> Dict[str, str]: distro = await self._get_distro() distro_ver = await self._get_distro_ver() kernel = await self._get_kernel() + cmdline = await self._get_cmdline() arch = await self._get_arch() cpu = await self._get_cpu() meminfo = await self._get_meminfo() @@ -239,6 +249,7 @@ async def get_info(self) -> Dict[str, str]: "distro": distro, "distro_ver": distro_ver, "kernel": kernel, + "cmdline": cmdline, "arch": arch, "cpu": cpu, "ram": memory, diff --git a/libkirk/tests/test_export.py b/libkirk/tests/test_export.py index 0bead66..6844094 100644 --- a/libkirk/tests/test_export.py +++ b/libkirk/tests/test_export.py @@ -91,6 +91,7 @@ async def test_save_file(self, tmpdir): distro="openSUSE-Leap", distro_ver="15.3", kernel="5.17", + cmdline="security=selinux selinux=1 enforcing=1 ima_policy=tcb", arch="x86_64", cpu="x86_64", swap="10 kB", @@ -171,6 +172,7 @@ async def test_save_file(self, tmpdir): "distribution_version": "15.3", "distribution": "openSUSE-Leap", "kernel": "5.17", + "cmdline": "security=selinux selinux=1 enforcing=1 ima_policy=tcb", "arch": "x86_64", "cpu": "x86_64", "swap": "10 kB", diff --git a/libkirk/tests/test_scheduler.py b/libkirk/tests/test_scheduler.py index 30ca281..3326a1e 100644 --- a/libkirk/tests/test_scheduler.py +++ b/libkirk/tests/test_scheduler.py @@ -27,6 +27,7 @@ async def get_info(self) -> dict: "distro": "openSUSE", "distro_ver": "15.3", "kernel": "5.10", + "cmdline": "ima_policy=tcb", "arch": "x86_64", "cpu": "x86_64", "swap": "0", diff --git a/libkirk/tests/test_sut.py b/libkirk/tests/test_sut.py index 8633a84..0443e6e 100644 --- a/libkirk/tests/test_sut.py +++ b/libkirk/tests/test_sut.py @@ -88,6 +88,7 @@ async def test_get_info(self, sut): assert info["distro"] assert info["distro_ver"] assert info["kernel"] + assert info["cmdline"] assert info["arch"] async def test_get_tainted_info(self, sut): diff --git a/libkirk/ui.py b/libkirk/ui.py index 816902e..0b62886 100644 --- a/libkirk/ui.py +++ b/libkirk/ui.py @@ -160,20 +160,21 @@ async def suite_completed(self, results: SuiteResults, exec_time: float) -> None message = ( f"{' ' * 128}\n" f"Execution time: {exec_time_uf}\n\n" - f"\tSuite: {results.suite.name}\n" - f"\tTotal runs: {len(results.suite.tests)}\n" - f"\tRuntime: {duration}\n" - f"\tPassed: {results.passed}\n" - f"\tFailed: {results.failed}\n" - f"\tSkipped: {results.skipped}\n" - f"\tBroken: {results.broken}\n" - f"\tWarnings: {results.warnings}\n" - f"\tKernel: {results.kernel}\n" - f"\tMachine: {results.cpu}\n" - f"\tArch: {results.arch}\n" - f"\tRAM: {results.ram}\n" - f"\tSwap: {results.swap}\n" - f"\tDistro: {results.distro} {results.distro_ver}" + f"\tSuite: {results.suite.name}\n" + f"\tTotal runs: {len(results.suite.tests)}\n" + f"\tRuntime: {duration}\n" + f"\tPassed: {results.passed}\n" + f"\tFailed: {results.failed}\n" + f"\tSkipped: {results.skipped}\n" + f"\tBroken: {results.broken}\n" + f"\tWarnings: {results.warnings}\n" + f"\tKernel: {results.kernel}\n" + f"\t/proc/cmdline: {results.cmdline}\n" + f"\tMachine: {results.cpu}\n" + f"\tArch: {results.arch}\n" + f"\tRAM: {results.ram}\n" + f"\tSwap: {results.swap}\n" + f"\tDistro: {results.distro} {results.distro_ver}" ) await self._print(message)