test_dtc.py 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import os
  2. import infra.basetest
  3. class TestDtc(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_DTC=y
  7. BR2_PACKAGE_DTC_PROGRAMS=y
  8. BR2_ROOTFS_OVERLAY="{}"
  9. # BR2_TARGET_ROOTFS_TAR is not set
  10. BR2_TARGET_ROOTFS_CPIO=y
  11. """.format(
  12. # overlay to add a bats test suite
  13. infra.filepath("tests/package/test_dtc/rootfs-overlay"))
  14. def test_run(self):
  15. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  16. self.emulator.boot(arch="armv7",
  17. kernel="builtin",
  18. options=["-initrd", cpio_file])
  19. self.emulator.login()
  20. # Test 'dtc'
  21. self.assertRunOk("dtc -I dts -O dtb -o /tmp/test_tree1.dtb /test_tree1.dts")
  22. # Test 'fdtdump'
  23. self.assertRunOk("fdtdump /tmp/test_tree1.dtb")
  24. # Test 'fdtget'
  25. out, exit_code = self.emulator.run("fdtget -t s /tmp/test_tree1.dtb / compatible")
  26. self.assertEqual(out[0].strip(), "test_tree1")
  27. # Test 'fdtput'
  28. self.assertRunOk("fdtput -t s /tmp/test_tree1.dtb / compatible 'test set compatible'")
  29. out, exit_code = self.emulator.run("fdtget -t s /tmp/test_tree1.dtb / compatible")
  30. self.assertEqual(out[0].strip(), "test set compatible")