From patchwork Sun Jun 11 10:45:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Olivain X-Patchwork-Id: 1793532 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4QfBLJ1ckCz20XR for ; Sun, 11 Jun 2023 20:45:44 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id E5D2160E3A; Sun, 11 Jun 2023 10:45:41 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org E5D2160E3A X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YEoB0XFy-2pU; Sun, 11 Jun 2023 10:45:40 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id D8C3060C07; Sun, 11 Jun 2023 10:45:39 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org D8C3060C07 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 1243A1BF389 for ; Sun, 11 Jun 2023 10:45:38 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id EB27483C59 for ; Sun, 11 Jun 2023 10:45:37 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org EB27483C59 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WS57CBVFLSBt for ; Sun, 11 Jun 2023 10:45:36 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 4F27783C51 Received: from smtp6-g21.free.fr (smtp6-g21.free.fr [IPv6:2a01:e0c:1:1599::15]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4F27783C51 for ; Sun, 11 Jun 2023 10:45:36 +0000 (UTC) Received: from b52572-12.ea.freescale.net.net (unknown [37.166.161.219]) (Authenticated sender: ju.o@free.fr) by smtp6-g21.free.fr (Postfix) with ESMTPSA id 3D15178035B; Sun, 11 Jun 2023 12:45:30 +0200 (CEST) From: Julien Olivain To: buildroot@buildroot.org Date: Sun, 11 Jun 2023 12:45:16 +0200 Message-ID: <20230611104518.337528-1-ju.o@free.fr> X-Mailer: git-send-email 2.41.0 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1686480333; bh=HZmyXO8/2VuK4nEpzQ6bvM5DkGTYhSrtp1yYUEmJsRQ=; h=From:To:Cc:Subject:Date:From; b=mU+OZOjbOyN1tTjhvKtpLDxfEY/HW5eYwHdczOgNZiV51umTFYNkN/SlFoMFDvGAu QT4ema7jWZ4ACGnbX1s8ycGjBHI9KgHp4KvHg3SkfjoEoAAwkywRsl/o0EqVxIUzE2 2lUjW+q5QD28XQaQ/k6U45uVkkcFbfKMYGpmuCQmeE+zpc5cl09z8uo1L0jYJvZrky mae8zORoJ6txnq6Qj2vGDQM8vf1mrMkSkf/W9BBHU7jXsdm5n9M00BBAmOCSfroapi Mz78qkdqMbcAkrBHwN1Qu6E6U3v1CzQFYjV6N8s0oxDlCMGzK5faualnLiZZkCPpI+ PH1aumvo/9g3A== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=free.fr header.i=@free.fr header.a=rsa-sha256 header.s=smtp-20201208 header.b=mU+OZOjb Subject: [Buildroot] [PATCH v2 1/3] support/testing/infra/emulator.py: change the shell prompt before running tests X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Olivain , Ricardo Martincoski Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" If a program has the string '# ' (i.e. the default shell prompt) in its output, the test execution in the Buildroot runtime test infra is failing. This can be reproduced by adding a single line in a package test script: self.assertRunOk("echo ### this is a string with hashes ###") When executed with, for example, the command: support/testing/run-tests \ -d dl -o output_folder tests.package.test_sometest The test will fail with output: Traceback (most recent call last): File "/buildroot/support/testing/tests/package/test_sometest.py", line 20, in test_run self.assertRunOk("echo ### this is a string with hashes ###") File "/buildroot/support/testing/infra/basetest.py", line 94, in assertRunOk out, exit_code = self.emulator.run(cmd, timeout) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/buildroot/support/testing/infra/emulator.py", line 121, in run exit_code = int(exit_code) ^^^^^^^^^^^^^^ ValueError: invalid literal for int() with base 10: '' This issue has been seen with real softwares, for example while writing tests for the dieharder package, which creates report tables formatted with hash characters. See: https://github.com/eddelbuettel/dieharder/blob/3.31.1.4/libdieharder/version.c#L34 See also the output produced by a program invocation with command "dieharder -d 0". This issue has also been seen with dmidecode, producing comments in its output (when simply invoked with "dmidecode"). See: https://git.savannah.gnu.org/cgit/dmidecode.git/tree/dmioutput.c?h=dmidecode-3-5#n30 This issue could technically be seen with program producing MarkDown formatted output (for example "# Header 1"). This issue happen because the test infra emulator.run() method expect the prompt "# " after running a command and while getting the return code. See: https://git.buildroot.org/buildroot/tree/support/testing/infra/emulator.py?h=2023.05#n113 Since the string "# " is quite common, this patch changes the prompt after the emulator.login(), by setting the PS1 variable to a string which is less likely to appear in a normal program output. A small caveat: since there is a command echo, the command setting the new prompt needs to be protected to make sure it will not be detected as an actual shell prompt. The prompt is encoded by single-quoting each character (e.g. abc -> 'a''b''c'). Signed-off-by: Julien Olivain --- Changes v1 -> v2: - reworded commit log, to mention this issue was also seen while writing a test for the dmidecode package - the patch series also introduce the new test for dmidecode --- support/testing/infra/emulator.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/support/testing/infra/emulator.py b/support/testing/infra/emulator.py index 02cf486128..390c582e9d 100644 --- a/support/testing/infra/emulator.py +++ b/support/testing/infra/emulator.py @@ -13,6 +13,7 @@ class Emulator(object): # can take a long time to run the emulator. Use a timeout multiplier # when running the tests to avoid sporadic failures. self.timeout_multiplier = timeout_multiplier + self.shell_prompt = "#BRTEST# " # Start Qemu to boot the system # @@ -100,6 +101,15 @@ class Emulator(object): index = self.qemu.expect(["# ", pexpect.TIMEOUT]) if index != 0: raise SystemError("Cannot login") + # Set a special shell prompt while testing. Since the standard + # prompt '# ' is quite generic, a normal process output could + # contain that string and confuse expect. When changing the + # prompt, we also need to encode or escape it in some way to + # make sure the command echo will not be seen as a prompt + # itself. The prompt is encoded by single-quoting each + # character (e.g. abc -> 'a''b''c'). + encoded_prompt = "''".join(self.shell_prompt) + self.run("export PS1='{}'".format(encoded_prompt)) self.run("dmesg -n 1") # Prevent the shell from wrapping the commands at 80 columns. self.run("stty columns 29999") @@ -110,13 +120,13 @@ class Emulator(object): self.qemu.sendline(cmd) if timeout != -1: timeout *= self.timeout_multiplier - self.qemu.expect("# ", timeout=timeout) + self.qemu.expect(self.shell_prompt, timeout=timeout) # Remove double carriage return from qemu stdout so str.splitlines() # works as expected. output = self.qemu.before.replace("\r\r", "\r").splitlines()[1:] self.qemu.sendline("echo $?") - self.qemu.expect("# ") + self.qemu.expect(self.shell_prompt) exit_code = self.qemu.before.splitlines()[2] exit_code = int(exit_code) From patchwork Mon Jun 26 20:00:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Olivain X-Patchwork-Id: 1800178 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqdy65tkkz20XS for ; Tue, 27 Jun 2023 06:01:01 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 6A757410E0; Mon, 26 Jun 2023 20:00:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 6A757410E0 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MJEIFqRDXEQS; Mon, 26 Jun 2023 20:00:57 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id 56AD5409EA; Mon, 26 Jun 2023 20:00:56 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org 56AD5409EA X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 21EE61BF378 for ; Mon, 26 Jun 2023 20:00:55 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 07B83607B5 for ; Mon, 26 Jun 2023 20:00:55 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 07B83607B5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id JtQxbR4Y4cmV for ; Mon, 26 Jun 2023 20:00:54 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4F71B607D6 Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [IPv6:2a01:e0c:1:1599::11]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4F71B607D6 for ; Mon, 26 Jun 2023 20:00:54 +0000 (UTC) Received: from home.juju.sh (unknown [37.171.207.173]) (Authenticated sender: ju.o@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id C9A52200589; Mon, 26 Jun 2023 22:00:49 +0200 (CEST) From: Julien Olivain To: buildroot@buildroot.org Date: Mon, 26 Jun 2023 22:00:40 +0200 Message-ID: <20230626200040.12432-1-ju.o@free.fr> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230611104518.337528-1-ju.o@free.fr> References: <20230611104518.337528-1-ju.o@free.fr> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1687809651; bh=Mlefe1/yMM48OkdMdWK0M3KChBa9SOmXhlPvmRcSWvs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fArcjubuaEIVIT/AF3YpdI34faEw5SFrlf5NTzX7Yzh1Bbqr1S13xeTIQOh7fdCYA HeJYwOq0qyvmWuWB2LAk75w4h9YCgJfpyjB9Gg/ECTaQPrNOTWGGNarGgBQeHruIsp 8JwequzRZo9h41Diej3h3oIJbVIzKcwjWpo6g8Wgx3heh69SL3IRtNE4JdTKOSGKdk H1SxnuXyBnEtiUMGLXxm83GWTX7gNwLvchMnyGKCY2ewaYPYyfFQV05haYdLEgnjYE UfThUmHmgGdYuQ4S2cSBSMtwCUkX27pO8+s2LHZY7C9aLruYEnSdCjWKBTlIfsl+I/ fJWMI4GIcanJg== X-Mailman-Original-Authentication-Results: smtp3.osuosl.org; dkim=pass (2048-bit key) header.d=free.fr header.i=@free.fr header.a=rsa-sha256 header.s=smtp-20201208 header.b=fArcjubu Subject: [Buildroot] [PATCH v2 2/3] support/testing/tests/package/test_dieharder.py: new runtime test X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Olivain Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Signed-off-by: Julien Olivain --- DEVELOPERS | 1 + .../testing/tests/package/test_dieharder.py | 40 +++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 support/testing/tests/package/test_dieharder.py diff --git a/DEVELOPERS b/DEVELOPERS index 7aa5980df7..1bf1969ac6 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1737,6 +1737,7 @@ F: support/testing/tests/package/sample_python_pyalsa.py F: support/testing/tests/package/sample_python_spake2.py F: support/testing/tests/package/test_ddrescue.py F: support/testing/tests/package/test_ddrescue/ +F: support/testing/tests/package/test_dieharder.py F: support/testing/tests/package/test_gnupg2.py F: support/testing/tests/package/test_highway.py F: support/testing/tests/package/test_hwloc.py diff --git a/support/testing/tests/package/test_dieharder.py b/support/testing/tests/package/test_dieharder.py new file mode 100644 index 0000000000..d324a34557 --- /dev/null +++ b/support/testing/tests/package/test_dieharder.py @@ -0,0 +1,40 @@ +import os + +import infra.basetest + + +class TestDieharder(infra.basetest.BRTest): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_PACKAGE_DIEHARDER=y + BR2_TARGET_ROOTFS_CPIO=y + # BR2_TARGET_ROOTFS_TAR is not set + """ + + def test_run(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + # Check the program can run (by showing its version) + self.assertRunOk("dieharder -V") + + # The birthdays test on small number (1) of sample is expected to fail + cmd = "dieharder -g /dev/urandom -d diehard_birthdays -t 1" + output, exit_code = self.emulator.run(cmd) + self.assertEqual(exit_code, 0) + self.assertIn("FAILED", '\n'.join(output)) + + # The birthdays test on higher number (25) of sample is expected to succeed + cmd = "dieharder -g mt19937 -d diehard_birthdays -t 25" + output, exit_code = self.emulator.run(cmd, timeout=10) + self.assertEqual(exit_code, 0) + self.assertIn("PASSED", '\n'.join(output)) + + # The birthdays test on file /dev/zero is expected to fail + cmd = "dieharder -g file_input_raw -f /dev/zero -d diehard_birthdays -t 25" + output, exit_code = self.emulator.run(cmd, timeout=40) + self.assertEqual(exit_code, 0) + self.assertIn("FAILED", '\n'.join(output)) From patchwork Mon Jun 26 20:01:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Olivain X-Patchwork-Id: 1800179 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::137; helo=smtp4.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Qqdyd64rKz20XS for ; Tue, 27 Jun 2023 06:01:29 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id D829340971; Mon, 26 Jun 2023 20:01:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org D829340971 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id E1Iqfg__22iQ; Mon, 26 Jun 2023 20:01:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp4.osuosl.org (Postfix) with ESMTP id BBD2040967; Mon, 26 Jun 2023 20:01:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp4.osuosl.org BBD2040967 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id E6C4C1BF951 for ; Mon, 26 Jun 2023 20:01:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id C10888183D for ; Mon, 26 Jun 2023 20:01:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org C10888183D X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id eeUSdIPPcMWX for ; Mon, 26 Jun 2023 20:01:18 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 0835380C16 Received: from smtp2-g21.free.fr (smtp2-g21.free.fr [IPv6:2a01:e0c:1:1599::11]) by smtp1.osuosl.org (Postfix) with ESMTPS id 0835380C16 for ; Mon, 26 Jun 2023 20:01:17 +0000 (UTC) Received: from home.juju.sh (unknown [37.171.207.173]) (Authenticated sender: ju.o@free.fr) by smtp2-g21.free.fr (Postfix) with ESMTPSA id C93A92003D6; Mon, 26 Jun 2023 22:01:14 +0200 (CEST) From: Julien Olivain To: buildroot@buildroot.org Date: Mon, 26 Jun 2023 22:01:08 +0200 Message-ID: <20230626200108.12517-1-ju.o@free.fr> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230611104518.337528-1-ju.o@free.fr> References: <20230611104518.337528-1-ju.o@free.fr> MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=free.fr; s=smtp-20201208; t=1687809676; bh=SpG1RGkY7+Hk2xs4ZvM3B176SQ+7zphezD2mZyMYVkk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DflUWroV7UFqkjbQXm8lQ6m9Am/ylLD9wGarY8myKRGnsota8VibPZWQ73rto0Oa0 fCFLK8JCkmqL0+oi7bZWnH7gBxhNobf2qC24s4+pukVO/qGwShev50f1Z+zMSaBZsj ZpI/UxYXHewW9c47WZYon5RSkEKE/w4prvbM9D1MOmW+Z2rRZV3bPKGKVcr2tJ6liR i2Sovk4PxSNzxaGnCcemFs1iGQz72We5kEPuI5AZbPff2dW6AAb2pmEgGSZbdtCWnQ AGam9htJIgnamRkLqsvPMABYsZPQfX3iRDc0eDvxBubBEUmfXZb19tqFzLrFEnOHIW SUG1SlWqgboWQ== X-Mailman-Original-Authentication-Results: smtp1.osuosl.org; dkim=pass (2048-bit key) header.d=free.fr header.i=@free.fr header.a=rsa-sha256 header.s=smtp-20201208 header.b=DflUWroV Subject: [Buildroot] [PATCH v2 3/3] support/testing/tests/package/test_dmidecode.py: new runtime test X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Olivain Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Signed-off-by: Julien Olivain --- 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 1bf1969ac6..a9475ec689 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -1738,6 +1738,7 @@ F: support/testing/tests/package/sample_python_spake2.py F: support/testing/tests/package/test_ddrescue.py F: support/testing/tests/package/test_ddrescue/ F: support/testing/tests/package/test_dieharder.py +F: support/testing/tests/package/test_dmidecode.py F: support/testing/tests/package/test_gnupg2.py F: support/testing/tests/package/test_highway.py F: support/testing/tests/package/test_hwloc.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..2363470e22 --- /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.1.33" + 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)