mirror of
https://git.busybox.net/buildroot.git
synced 2024-11-23 13:33:28 +08:00
support/testing: add test for msr-tools
Add a simple test to verify that msr-tools are working. The test needs to build a custom x86_64 kernel with support for CPUID and MSR. As the TSC_AUX MSR is emulated on qemu we can use it to test that a value written with wrmsr can indeed be read back with rdmsr. Signed-off-by: Vincent Stehlé <vincent.stehle@laposte.net> Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
parent
49fde7057e
commit
019d4b312d
@ -2917,6 +2917,7 @@ F: configs/uevm5432_defconfig
|
||||
F: package/i7z/
|
||||
F: package/msr-tools/
|
||||
F: package/pixz/
|
||||
F: support/testing/tests/package/test_msr_tools*
|
||||
F: support/testing/tests/package/test_pixz.py
|
||||
|
||||
N: Vinicius Tinti <viniciustinti@gmail.com>
|
||||
|
50
support/testing/tests/package/test_msr_tools.py
Normal file
50
support/testing/tests/package/test_msr_tools.py
Normal file
@ -0,0 +1,50 @@
|
||||
import os
|
||||
|
||||
import infra.basetest
|
||||
|
||||
|
||||
class TestMsrTools(infra.basetest.BRTest):
|
||||
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="5.15.55"
|
||||
BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y
|
||||
BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE="board/qemu/x86_64/linux.config"
|
||||
BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES="{}"
|
||||
BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y
|
||||
BR2_PACKAGE_MSR_TOOLS=y
|
||||
BR2_TARGET_ROOTFS_CPIO=y
|
||||
# BR2_TARGET_ROOTFS_TAR is not set
|
||||
""".format(
|
||||
infra.filepath("tests/package/test_msr_tools/linux.config"))
|
||||
|
||||
def test_run(self):
|
||||
kernel = os.path.join(self.builddir, "images", "bzImage")
|
||||
cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
|
||||
self.emulator.boot(
|
||||
arch="x86_64",
|
||||
kernel=kernel, kernel_cmdline=["console=ttyS0"],
|
||||
options=["-cpu", "Nehalem", "-m", "320", "-initrd", cpio_file]
|
||||
)
|
||||
self.emulator.login()
|
||||
|
||||
# CPU ID.
|
||||
cmd = "cpuid"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
# Write MSR.
|
||||
# We write to TSC_AUX.
|
||||
cmd = "wrmsr 0xc0000103 0x1234567812345678"
|
||||
self.assertRunOk(cmd)
|
||||
|
||||
# Read MSR.
|
||||
# We read back the TSC_AUX and we verify that we read back the correct
|
||||
# value.
|
||||
cmd = "rdmsr 0xc0000103"
|
||||
output, exit_code = self.emulator.run(cmd)
|
||||
self.assertEqual(exit_code, 0)
|
||||
self.assertEqual(output[0], "1234567812345678")
|
@ -0,0 +1,2 @@
|
||||
CONFIG_X86_CPUID=y
|
||||
CONFIG_X86_MSR=y
|
Loading…
Reference in New Issue
Block a user