test_strace.py 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import os
  2. import infra.basetest
  3. class TestStrace(infra.basetest.BRTest):
  4. config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
  5. """
  6. BR2_PACKAGE_STRACE=y
  7. BR2_TARGET_ROOTFS_CPIO=y
  8. # BR2_TARGET_ROOTFS_TAR is not set
  9. """
  10. def test_run(self):
  11. cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
  12. self.emulator.boot(arch="armv5",
  13. kernel="builtin",
  14. options=["-initrd", cpio_file])
  15. self.emulator.login()
  16. # Check the program can execute.
  17. self.assertRunOk("strace --version")
  18. test_file = "buildroot-strace-test.txt"
  19. test_file_mode = "0600"
  20. strace_log = "strace.log"
  21. # Create a test file.
  22. self.assertRunOk(f"touch {test_file}")
  23. # Run strace on a chmod
  24. cmd = f"strace -o {strace_log} chmod {test_file_mode} {test_file}"
  25. self.assertRunOk(cmd)
  26. # Check the strace log contain a call to chmod()
  27. expected_str = f"chmod(\"{test_file}\", {test_file_mode}) = 0"
  28. self.assertRunOk(f"grep -F '{expected_str}' {strace_log}")