test_dmidecode.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. import os
  2. import infra.basetest
  3. class TestDmidecode(infra.basetest.BRTest):
  4. # We use a x86_64 arch for this dmidecode test because aarch64
  5. # SMBIOS is not supported in non-UEFI use-cases (and using a UEFI
  6. # aarch64 would make the test longer).
  7. config = \
  8. """
  9. BR2_x86_64=y
  10. BR2_x86_corei7=y
  11. BR2_TOOLCHAIN_EXTERNAL=y
  12. BR2_LINUX_KERNEL=y
  13. BR2_LINUX_KERNEL_CUSTOM_VERSION=y
  14. BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE="6.6.39"
  15. BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
  16. BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
  17. BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
  18. BR2_PACKAGE_DMIDECODE=y
  19. BR2_TARGET_ROOTFS_CPIO=y
  20. BR2_TARGET_ROOTFS_CPIO_GZIP=y
  21. # BR2_TARGET_ROOTFS_TAR is not set
  22. """
  23. def test_run(self):
  24. # An arbitrary SMBIOS OEM string for the test
  25. oem_string = "Hello Buildroot SMBIOS"
  26. kernel = os.path.join(self.builddir, "images", "bzImage")
  27. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio.gz")
  28. self.emulator.boot(
  29. arch="x86_64",
  30. kernel=kernel,
  31. kernel_cmdline=["console=ttyS0"],
  32. options=["-cpu", "Nehalem", "-m", "256", "-initrd", cpio_file,
  33. "-smbios", f"type=11,value={oem_string}"],
  34. )
  35. self.emulator.login()
  36. # Check the program can run
  37. cmd = "dmidecode --version"
  38. self.assertRunOk(cmd)
  39. # Check a simple invocation of "dmidecode"
  40. self.assertRunOk("dmidecode")
  41. # Check a simple invocation of "biosdecode"
  42. self.assertRunOk("biosdecode")
  43. # Check dmidecode detects SMBIOS
  44. cmd = "dmidecode | grep -E '^SMBIOS .* present\\.$'"
  45. self.assertRunOk(cmd)
  46. # Check the system-manufacturer is QEMU
  47. cmd = "dmidecode -s system-manufacturer"
  48. output, exit_code = self.emulator.run(cmd)
  49. self.assertEqual(exit_code, 0)
  50. self.assertEqual(output[0], "QEMU")
  51. # Check we read back our OEM string
  52. cmd = "dmidecode --oem-string 1"
  53. output, exit_code = self.emulator.run(cmd)
  54. self.assertEqual(exit_code, 0)
  55. self.assertEqual(output[0], oem_string)