From 9eaf559743ec642d3466a4f9520242caf5784f4f Mon Sep 17 00:00:00 2001 From: me Date: Fri, 24 Feb 2023 15:03:26 -0500 Subject: [PATCH] added tests to assert history has length, and to test the case where you want to filter history from multiple shared objects --- tests/test_history.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/test_history.py b/tests/test_history.py index 6ad2d84d..1aaf6dba 100644 --- a/tests/test_history.py +++ b/tests/test_history.py @@ -62,6 +62,17 @@ class HistoryTest(unittest.TestCase): map_for_ins = history.get_mem_map_from_addr(block) self.assertNotRegex(map_for_ins[3], ".*libc.so.*") + assert len(non_libc_blocks) > 0 + + non_libc_blocks_and_ld = history.get_ins_exclude_lib([".*libc.so.*", "ld-linux.*"]) + + for block in non_libc_blocks_and_ld: + map_for_ins = history.get_mem_map_from_addr(block) + self.assertNotRegex(map_for_ins[3], ".*libc.so.*|ld-linux.*") + + assert len(non_libc_blocks_and_ld) > 0 + + def test_get_ins_only_lib(self): ql = Qiling(["../examples/rootfs/x8664_linux/bin/x8664_hello"], "../examples/rootfs/x8664_linux", verbose=QL_VERBOSE.OFF) history = History(ql) @@ -75,5 +86,15 @@ class HistoryTest(unittest.TestCase): map_for_ins = history.get_mem_map_from_addr(block) self.assertRegex(map_for_ins[3], ".*libc.so.*") + assert len(non_libc_blocks) > 0 + + non_libc_blocks_and_ld = history.get_ins_only_lib([".*libc.so.*", "ld-linux.*"]) + + for block in non_libc_blocks_and_ld : + map_for_ins = history.get_mem_map_from_addr(block) + self.assertRegex(map_for_ins[3], ".*libc.so.*|.*ld-linux.*") + + assert len(non_libc_blocks_and_ld) > 0 + if __name__ == "__main__": unittest.main() \ No newline at end of file