test_acpica.py 3.2 KB

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