From 9d0bb0e67bb878858d359101dfdc0aebe8fd2179 Mon Sep 17 00:00:00 2001 From: Julien Olivain Date: Sun, 14 Jul 2024 18:55:27 +0200 Subject: [PATCH] support/testing: new dmidecode runtime test Note: this test was not working in Buildroot test infrastructure before commit [1] was merged, because dmidecode has the string "# " in its output. [1] https://gitlab.com/buildroot.org/buildroot/-/commit/0cad947b964be5612a182413da136fcf0dc5a1f2 Signed-off-by: Julien Olivain Signed-off-by: Arnout Vandecappelle --- DEVELOPERS | 1 + .../testing/tests/package/test_dmidecode.py | 67 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 support/testing/tests/package/test_dmidecode.py diff --git a/DEVELOPERS b/DEVELOPERS index 2650fb7f48..552f02e515 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1837,6 +1837,7 @@ F: support/testing/tests/package/test_cryptsetup.py F: support/testing/tests/package/test_cryptsetup/ F: support/testing/tests/package/test_ddrescue.py F: support/testing/tests/package/test_ddrescue/ +F: support/testing/tests/package/test_dmidecode.py F: support/testing/tests/package/test_dos2unix.py F: support/testing/tests/package/test_ed.py F: support/testing/tests/package/test_ethtool.py diff --git a/support/testing/tests/package/test_dmidecode.py b/support/testing/tests/package/test_dmidecode.py new file mode 100644 index 0000000000..33c19f0d96 --- /dev/null +++ b/support/testing/tests/package/test_dmidecode.py @@ -0,0 +1,67 @@ +import os + +import infra.basetest + + +class TestDmidecode(infra.basetest.BRTest): + # We use a x86_64 arch for this dmidecode test because aarch64 + # SMBIOS is not supported in non-UEFI use-cases (and using a UEFI + # aarch64 would make the test longer). + config = \ + """ + BR2_x86_64=y + BR2_x86_corei7=y + BR2_TOOLCHAIN_EXTERNAL=y + BR2_LINUX_KERNEL=y + BR2_LINUX_KERNEL_CUSTOM_VERSION=y + BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.39" + BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y + BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config" + BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y + BR2_PACKAGE_DMIDECODE=y + BR2_TARGET_ROOTFS_CPIO=y + BR2_TARGET_ROOTFS_CPIO_GZIP=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + + # An arbitrary SMBIOS OEM string for the test + oem_string = "Hello Buildroot SMBIOS" + + kernel = os.path.join(self.builddir, "images", "bzImage") + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio.gz") + self.emulator.boot( + arch="x86_64", + kernel=kernel, + kernel_cmdline=["console=ttyS0"], + options=["-cpu", "Nehalem", "-m", "256", "-initrd", cpio_file, + "-smbios", f"type=11,value={oem_string}"], + ) + self.emulator.login() + + # Check the program can run + cmd = "dmidecode --version" + self.assertRunOk(cmd) + + # Check a simple invocation of "dmidecode" + self.assertRunOk("dmidecode") + + # Check a simple invocation of "biosdecode" + self.assertRunOk("biosdecode") + + # Check dmidecode detects SMBIOS + cmd = "dmidecode | grep -E '^SMBIOS .* present\\.$'" + self.assertRunOk(cmd) + + # Check the system-manufacturer is QEMU + cmd = "dmidecode -s system-manufacturer" + output, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + self.assertEqual(output[0], "QEMU") + + # Check we read back our OEM string + cmd = "dmidecode --oem-string 1" + output, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + self.assertEqual(output[0], oem_string)