1import os 2 3import infra.basetest 4 5 6class TestMsrTools(infra.basetest.BRTest): 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="5.15.55" 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_CONFIG_FRAGMENT_FILES="{}" 18 BR2_LINUX_KERNEL_NEEDS_HOST_LIBELF=y 19 BR2_PACKAGE_MSR_TOOLS=y 20 BR2_TARGET_ROOTFS_CPIO=y 21 # BR2_TARGET_ROOTFS_TAR is not set 22 """.format( 23 infra.filepath("tests/package/test_msr_tools/linux.config")) 24 25 def test_run(self): 26 kernel = os.path.join(self.builddir, "images", "bzImage") 27 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 28 self.emulator.boot( 29 arch="x86_64", 30 kernel=kernel, kernel_cmdline=["console=ttyS0"], 31 options=["-cpu", "Nehalem", "-m", "320", "-initrd", cpio_file] 32 ) 33 self.emulator.login() 34 35 # CPU ID. 36 cmd = "cpuid" 37 self.assertRunOk(cmd) 38 39 # Write MSR. 40 # We write to TSC_AUX. 41 cmd = "wrmsr 0xc0000103 0x1234567812345678" 42 self.assertRunOk(cmd) 43 44 # Read MSR. 45 # We read back the TSC_AUX and we verify that we read back the correct 46 # value. 47 cmd = "rdmsr 0xc0000103" 48 output, exit_code = self.emulator.run(cmd) 49 self.assertEqual(exit_code, 0) 50 self.assertEqual(output[0], "1234567812345678") 51