[Buildroot] [git commit] support/testing/tests/package/test_acpica.py: run runtime test

Thomas Petazzoni thomas.petazzoni at bootlin.com
Thu Jul 13 20:27:22 UTC 2023


commit: https://git.buildroot.net/buildroot/commit/?id=d3534eca22827e69872f2cb7280bb6b0ccd0962d
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

Signed-off-by: Julien Olivain <ju.o at free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni at bootlin.com>
---
 DEVELOPERS                                         |  2 +
 support/testing/tests/package/test_acpica.py       | 91 ++++++++++++++++++++++
 .../test_acpica/rootfs-overlay/root/dsdt.asl       |  9 +++
 3 files changed, 102 insertions(+)

diff --git a/DEVELOPERS b/DEVELOPERS
index c3c5a7022d..476f092a16 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1728,6 +1728,8 @@ F:	support/testing/tests/package/sample_python_gnupg.py
 F:	support/testing/tests/package/sample_python_hwdata.py
 F:	support/testing/tests/package/sample_python_pyalsa.py
 F:	support/testing/tests/package/sample_python_spake2.py
+F:	support/testing/tests/package/test_acpica.py
+F:	support/testing/tests/package/test_acpica/
 F:	support/testing/tests/package/test_bzip2.py
 F:	support/testing/tests/package/test_compressor_base.py
 F:	support/testing/tests/package/test_ddrescue.py
diff --git a/support/testing/tests/package/test_acpica.py b/support/testing/tests/package/test_acpica.py
new file mode 100644
index 0000000000..f7dd64d7f0
--- /dev/null
+++ b/support/testing/tests/package/test_acpica.py
@@ -0,0 +1,91 @@
+import os
+
+import infra.basetest
+
+
+class TestAcpica(infra.basetest.BRTest):
+    config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
+        """
+        BR2_PACKAGE_ACPICA=y
+        BR2_ROOTFS_OVERLAY="{}"
+        BR2_TARGET_ROOTFS_CPIO=y
+        # BR2_TARGET_ROOTFS_TAR is not set
+        """.format(
+           # overlay to add an ASL source file
+           infra.filepath("tests/package/test_acpica/rootfs-overlay"))
+
+    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 a program can execute
+        self.assertRunOk("iasl -v")
+
+        # Check "acpiexamples" demo is running
+        self.assertRunOk("acpiexamples")
+
+        # Check "acpihelp" convert error code 0x1 to AE_ERROR
+        self.assertRunOk("acpihelp -e 1 | grep -F AE_ERROR")
+
+        # Check "acpihelp" convert 0xA3 opcode to NoOpOp
+        self.assertRunOk("acpihelp -o 0xA3 | grep -F NoOpOp")
+
+        # Compile a simple ASL file
+        # The output file is automatically set to "dsdt.aml"
+        self.assertRunOk("iasl dsdt.asl")
+
+        # Evaluate the AML with acpiexec
+        # STR0 is expected to be "Hello Buildroot!"
+        cmd = "acpiexec -b 'evaluate STR0' dsdt.aml"
+        cmd += " | grep -F '\"Hello Buildroot!\"'"
+        self.assertRunOk(cmd)
+
+        # INT1 is exepcted to be 12345678
+        cmd = "acpiexec -b 'evaluate INT1' dsdt.aml"
+        cmd += " | grep -F 12345678"
+        self.assertRunOk(cmd)
+
+        # Evalute the TEST method which prints its argument
+        cmd = "acpiexec -b 'evaluate TST2 \"Hello World\"' dsdt.aml"
+        cmd += " | grep -F 'Arg0=Hello World'"
+        self.assertRunOk(cmd)
+
+        # dump aml to text
+        self.assertRunOk("acpidump -f dsdt.aml -o dsdt.dump")
+
+        # Rebuild dump to binary with acpixtract
+        # Output is implicitly into the dsdt.dat file
+        self.assertRunOk("acpixtract -a dsdt.dump")
+
+        # Compare with acpibin
+        # The rebuilt dsdt.dat is expected to be the same
+        cmd = "acpibin -a dsdt.aml dsdt.dat"
+        cmd += " | grep -F 'Files compare exactly'"
+        self.assertRunOk(cmd)
+
+        # Compare with cmp, to check acpibin
+        self.assertRunOk("cmp dsdt.aml dsdt.dat")
+
+        # Disassemble the compiled ASL
+        # Output file is implicitly "dsdt.dsl", we rename it to
+        # "disa.dsl" to make sure it will not clash with the original
+        # file, when recompiling.
+        self.assertRunOk("iasl dsdt.aml && mv -v dsdt.dsl disa.dsl")
+
+        # Disassembled output should contain our string
+        self.assertRunOk("grep STR0 disa.dsl | grep '\"Hello Buildroot!\"'")
+
+        # Recompile the disassembled file
+        self.assertRunOk("iasl disa.dsl")
+
+        # Compare the first compiled file with the one recompiled from
+        # the disassembly. There are expected to be identical.
+        cmd = "acpibin -a dsdt.aml disa.aml"
+        cmd += " | grep -F 'Files compare exactly'"
+        self.assertRunOk(cmd)
+
+        # Also compare with "cmp"
+        self.assertRunOk("cmp dsdt.aml disa.aml")
diff --git a/support/testing/tests/package/test_acpica/rootfs-overlay/root/dsdt.asl b/support/testing/tests/package/test_acpica/rootfs-overlay/root/dsdt.asl
new file mode 100644
index 0000000000..24f51565be
--- /dev/null
+++ b/support/testing/tests/package/test_acpica/rootfs-overlay/root/dsdt.asl
@@ -0,0 +1,9 @@
+DefinitionBlock ("", "DSDT", 2, "", "", 0x0)
+{
+    Name (STR0, "Hello Buildroot!")
+    Name (INT1, 0x12345678)
+    Method (TST2, 1)
+    {
+        printf ("Arg0=%o", Arg0)
+    }
+}



More information about the buildroot mailing list