def test_25(self): "test multiple minidumps" ffp = FFPuppet() self.addCleanup(ffp.clean_up) ffp.launch(TESTFF_BIN) md_dir = os.path.join(ffp.profile, "minidumps") if not os.path.isdir(md_dir): os.mkdir(md_dir) ffp._last_bin_path = ffp.profile # pylint: disable=protected-access sym_dir = os.path.join(ffp.profile, "symbols") # needs to exist to satisfy a check if not os.path.isdir(sym_dir): os.mkdir(sym_dir) # create "test.dmp" files with open(os.path.join(md_dir, "test1.dmp"), "w") as out_fp: out_fp.write("1a\n1b") with open(os.path.join(md_dir, "test2.dmp"), "w") as out_fp: out_fp.write("2a\n2b") with open(os.path.join(md_dir, "test3.dmp"), "w") as out_fp: out_fp.write("3a\n3b") self.assertFalse(ffp.appears_healthy()) # process .dmp file ffp.close() ffp.save_logs(self.logs) logs = os.listdir(self.logs) self.assertIn("log_minidump_01.txt", logs) self.assertIn("log_minidump_02.txt", logs) self.assertIn("log_minidump_03.txt", logs)
def test_01(self): "test basic launch and close" ffp = FFPuppet() self.addCleanup(ffp.clean_up) self.assertEqual(ffp.launches, 0) self.assertEqual(ffp.returncode, 0) ffp.launch(TESTFF_BIN, location=self.tsrv.get_addr()) self.assertEqual(len(ffp._workers), 0) # pylint: disable=protected-access self.assertEqual(ffp.launches, 1) self.assertIsNone(ffp.wait(0)) self.assertTrue(ffp.is_running()) self.assertTrue(ffp.appears_healthy()) self.assertIsNone(ffp.reason) self.assertIsNone(ffp.returncode) ffp.close() self.assertEqual(ffp.reason, ffp.RC_CLOSED) self.assertIsNotNone(ffp.returncode) self.assertIsNone(ffp._proc) # pylint: disable=protected-access self.assertFalse(ffp.is_running()) self.assertFalse(ffp.appears_healthy()) self.assertIsNone(ffp.wait(10))
def test_24(self): "test collecting and cleaning up ASan logs" ffp = FFPuppet() self.addCleanup(ffp.clean_up) ffp.launch(TESTFF_BIN) test_logs = list() asan_prefix = os.path.join(ffp._logs.working_path, ffp._logs.LOG_ASAN_PREFIX) # pylint: disable=protected-access for i in range(3): test_logs.append(".".join([asan_prefix, str(i)])) # small log with nothing interesting with open(test_logs[0], "w") as log_fp: log_fp.write("SHORT LOG\n") log_fp.write("filler line") # crash on another thread with open(test_logs[1], "w") as log_fp: log_fp.write("GOOD LOG\n") log_fp.write("==70811==ERROR: AddressSanitizer: SEGV on unknown address 0x00000BADF00D") log_fp.write(" (pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T0)\n") # must be 2nd line for _ in range(4): # pad out to 6 lines log_fp.write("filler line\n") # child log that should be ignored (created when parent crashes) with open(test_logs[2], "w") as log_fp: log_fp.write("BAD LOG\n") log_fp.write("==70811==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000") log_fp.write(" (pc 0x7f4c0bb54c67 bp 0x7f4c07bea380 sp 0x7f4c07bea360 T2)\n") # must be 2nd line for _ in range(4): # pad out to 6 lines log_fp.write("filler line\n") self.assertFalse(ffp.appears_healthy()) self.assertTrue(ffp.is_running()) ffp.close() ffp.save_logs(self.logs) dir_list = os.listdir(self.logs) self.assertEqual(len(dir_list), 5) for fname in dir_list: if not fname.startswith("log_ffp_asan_"): self.assertIn(fname, ["log_stderr.txt", "log_stdout.txt"]) continue with open(os.path.join(self.logs, fname), "r") as log_fp: self.assertIn(log_fp.readline(), ["BAD LOG\n", "GOOD LOG\n", "SHORT LOG\n"]) ffp.clean_up() for t_log in test_logs: self.assertFalse(os.path.isfile(t_log))