1import os 2 3import infra.basetest 4 5 6class TestAcpica(infra.basetest.BRTest): 7 config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ 8 """ 9 BR2_PACKAGE_ACPICA=y 10 BR2_ROOTFS_OVERLAY="{}" 11 BR2_TARGET_ROOTFS_CPIO=y 12 # BR2_TARGET_ROOTFS_TAR is not set 13 """.format( 14 # overlay to add an ASL source file 15 infra.filepath("tests/package/test_acpica/rootfs-overlay")) 16 17 def test_run(self): 18 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 19 self.emulator.boot(arch="armv5", 20 kernel="builtin", 21 options=["-initrd", cpio_file]) 22 self.emulator.login() 23 24 # Check a program can execute 25 self.assertRunOk("iasl -v") 26 27 # Check "acpiexamples" demo is running 28 self.assertRunOk("acpiexamples") 29 30 # Check "acpihelp" convert error code 0x1 to AE_ERROR 31 self.assertRunOk("acpihelp -e 1 | grep -F AE_ERROR") 32 33 # Check "acpihelp" convert 0xA3 opcode to NoOpOp 34 self.assertRunOk("acpihelp -o 0xA3 | grep -F NoOpOp") 35 36 # Compile a simple ASL file 37 # The output file is automatically set to "dsdt.aml" 38 self.assertRunOk("iasl dsdt.asl") 39 40 # Evaluate the AML with acpiexec 41 # STR0 is expected to be "Hello Buildroot!" 42 cmd = "acpiexec -b 'evaluate STR0' dsdt.aml" 43 cmd += " | grep -F '\"Hello Buildroot!\"'" 44 self.assertRunOk(cmd) 45 46 # INT1 is exepcted to be 12345678 47 cmd = "acpiexec -b 'evaluate INT1' dsdt.aml" 48 cmd += " | grep -F 12345678" 49 self.assertRunOk(cmd) 50 51 # Evalute the TEST method which prints its argument 52 cmd = "acpiexec -b 'evaluate TST2 \"Hello World\"' dsdt.aml" 53 cmd += " | grep -F 'Arg0=Hello World'" 54 self.assertRunOk(cmd) 55 56 # dump aml to text 57 self.assertRunOk("acpidump -f dsdt.aml -o dsdt.dump") 58 59 # Rebuild dump to binary with acpixtract 60 # Output is implicitly into the dsdt.dat file 61 self.assertRunOk("acpixtract -a dsdt.dump") 62 63 # Compare with acpibin 64 # The rebuilt dsdt.dat is expected to be the same 65 cmd = "acpibin -a dsdt.aml dsdt.dat" 66 cmd += " | grep -F 'Files compare exactly'" 67 self.assertRunOk(cmd) 68 69 # Compare with cmp, to check acpibin 70 self.assertRunOk("cmp dsdt.aml dsdt.dat") 71 72 # Disassemble the compiled ASL 73 # Output file is implicitly "dsdt.dsl", we rename it to 74 # "disa.dsl" to make sure it will not clash with the original 75 # file, when recompiling. 76 self.assertRunOk("iasl dsdt.aml && mv -v dsdt.dsl disa.dsl") 77 78 # Disassembled output should contain our string 79 self.assertRunOk("grep STR0 disa.dsl | grep '\"Hello Buildroot!\"'") 80 81 # Recompile the disassembled file 82 self.assertRunOk("iasl disa.dsl") 83 84 # Compare the first compiled file with the one recompiled from 85 # the disassembly. There are expected to be identical. 86 cmd = "acpibin -a dsdt.aml disa.aml" 87 cmd += " | grep -F 'Files compare exactly'" 88 self.assertRunOk(cmd) 89 90 # Also compare with "cmp" 91 self.assertRunOk("cmp dsdt.aml disa.aml") 92