Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Yann E. MORIN" <yann.morin.1998@free.fr>
To: "Vincent Stehlé" <vincent.stehle@laposte.net>
Cc: buildroot@buildroot.org
Subject: Re: [Buildroot] [PATCH] support/testing: add test for msr-tools
Date: Sun, 17 Jul 2022 00:01:15 +0200	[thread overview]
Message-ID: <20220716220115.GL2543@scaer> (raw)
In-Reply-To: <20220715095925.12881-1-vincent.stehle@laposte.net>

Vincent, All,

On 2022-07-15 11:59 +0200, Vincent Stehlé via buildroot spake thusly:
> 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>

Applied to master, thanks.

[--SNIP--]
> I have verified that this test works fine locally and on gitlab.

Worked here too.

> It is expected to have a trivial conflict with this previous patch[1] on the
> DEVELOPERS file.

Oh, the sneaky way to incite a maintainer to apply another patch! ;-)
(I'll go there now)

Regards,
Yann E. MORIN.

> Best regards,
> Vincent.
> 
> [1]: https://lists.buildroot.org/pipermail/buildroot/2022-July/646008.html
> 
> 
>  DEVELOPERS                                    |  1 +
>  .../testing/tests/package/test_msr_tools.py   | 50 +++++++++++++++++++
>  .../tests/package/test_msr_tools/linux.config |  2 +
>  3 files changed, 53 insertions(+)
>  create mode 100644 support/testing/tests/package/test_msr_tools.py
>  create mode 100644 support/testing/tests/package/test_msr_tools/linux.config
> 
> diff --git a/DEVELOPERS b/DEVELOPERS
> index 0afd697b6c..8753f0c17e 100644
> --- a/DEVELOPERS
> +++ b/DEVELOPERS
> @@ -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*
>  
>  N:	Vinicius Tinti <viniciustinti@gmail.com>
>  F:	package/python-thrift/
> diff --git a/support/testing/tests/package/test_msr_tools.py b/support/testing/tests/package/test_msr_tools.py
> new file mode 100644
> index 0000000000..4d62742a5f
> --- /dev/null
> +++ b/support/testing/tests/package/test_msr_tools.py
> @@ -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")
> diff --git a/support/testing/tests/package/test_msr_tools/linux.config b/support/testing/tests/package/test_msr_tools/linux.config
> new file mode 100644
> index 0000000000..8fe09db87b
> --- /dev/null
> +++ b/support/testing/tests/package/test_msr_tools/linux.config
> @@ -0,0 +1,2 @@
> +CONFIG_X86_CPUID=y
> +CONFIG_X86_MSR=y
> -- 
> 2.35.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

      reply	other threads:[~2022-07-16 22:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-15  9:59 [Buildroot] [PATCH] support/testing: add test for msr-tools Vincent Stehlé via buildroot
2022-07-16 22:01 ` Yann E. MORIN [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220716220115.GL2543@scaer \
    --to=yann.morin.1998@free.fr \
    --cc=buildroot@buildroot.org \
    --cc=vincent.stehle@laposte.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox