1import os 2 3import infra.basetest 4 5 6class TestLtrace(infra.basetest.BRTest): 7 config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ 8 """ 9 BR2_PACKAGE_LTRACE=y 10 BR2_TARGET_ROOTFS_CPIO=y 11 # BR2_TARGET_ROOTFS_TAR is not set 12 """ 13 14 def test_run(self): 15 cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") 16 self.emulator.boot(arch="armv5", 17 kernel="builtin", 18 options=["-initrd", cpio_file]) 19 self.emulator.login() 20 21 # Check the program can execute 22 self.assertRunOk("ltrace --version") 23 24 # Run ltrace on a ls 25 cmd = "ltrace -a 0 -o ltrace.log ls /" 26 self.assertRunOk(cmd) 27 28 # Check the ltrace log contains occurrences of libc malloc() 29 cmd = "grep -Ec 'malloc\\([0-9]+\\)' ltrace.log" 30 out, ret = self.emulator.run(cmd) 31 self.assertEqual(ret, 0) 32 self.assertGreater(int(out[0]), 0) 33