From eb2e2cf72d04c18dfbd7fb767b636f02d53a1369 Mon Sep 17 00:00:00 2001 From: hugsy Date: Sun, 6 Aug 2023 17:53:58 -0700 Subject: [PATCH] [tests] applied `pre-commit` checks --- tests/api/deprecated.py | 1 - tests/api/gef_heap.py | 1 - tests/binaries/nested.c | 2 +- tests/binaries/nested2.c | 2 +- tests/commands/functions.py | 1 - tests/commands/gef.py | 1 - tests/commands/gef_remote.py | 1 - tests/commands/got.py | 1 - tests/commands/heap.py | 1 - tests/commands/heap_analysis.py | 1 - tests/commands/hexdump.py | 3 --- tests/commands/name_break.py | 1 - tests/commands/pattern.py | 1 - tests/commands/pie.py | 1 - tests/commands/process_status.py | 2 -- tests/commands/registers.py | 1 - tests/commands/reset_cache.py | 2 -- tests/commands/scan.py | 1 - tests/commands/search_pattern.py | 6 ++---- tests/commands/skipi.py | 1 - tests/commands/stub.py | 2 +- tests/config/__init__.py | 1 - 22 files changed, 5 insertions(+), 29 deletions(-) diff --git a/tests/api/deprecated.py b/tests/api/deprecated.py index d341e9a33..319a58cc0 100644 --- a/tests/api/deprecated.py +++ b/tests/api/deprecated.py @@ -33,4 +33,3 @@ def test_deprecated_elf_values(self): self.assertNoException(res) if not record: pytest.fail(f"Expected a warning for '{item}'!") - diff --git a/tests/api/gef_heap.py b/tests/api/gef_heap.py index b3825e158..f4bef66d1 100644 --- a/tests/api/gef_heap.py +++ b/tests/api/gef_heap.py @@ -76,4 +76,3 @@ def test_class_glibcarena_main_arena(self): addr3 = result_as_int("int(gef.heap.main_arena)") self.assertEqual(addr1, addr2) self.assertEqual(addr2, addr3) - diff --git a/tests/binaries/nested.c b/tests/binaries/nested.c index 4324e3180..bb645c1d3 100644 --- a/tests/binaries/nested.c +++ b/tests/binaries/nested.c @@ -9,4 +9,4 @@ void f4(){ f5(); } void f3(){ f4(); } void f2(){ f3(); } void f1(){ f2(); } -int main(){ f1(); return 0;} \ No newline at end of file +int main(){ f1(); return 0;} diff --git a/tests/binaries/nested2.c b/tests/binaries/nested2.c index a81399dea..4b8af6275 100644 --- a/tests/binaries/nested2.c +++ b/tests/binaries/nested2.c @@ -1,3 +1,3 @@ #include "utils.h" int f1(int i){ if(i==10) {DebugBreak(); return 0;} return f1(++i); } -int main(){ return f1(0); } \ No newline at end of file +int main(){ return f1(0); } diff --git a/tests/commands/functions.py b/tests/commands/functions.py index 9f3d925d1..dbdd7fe7e 100644 --- a/tests/commands/functions.py +++ b/tests/commands/functions.py @@ -16,4 +16,3 @@ def test_cmd_functions(self): res = gdb_run_cmd(cmd) self.assertNoException(res) self.assertIn("$_heap", res) - diff --git a/tests/commands/gef.py b/tests/commands/gef.py index 17465d472..e35ba20cd 100644 --- a/tests/commands/gef.py +++ b/tests/commands/gef.py @@ -120,4 +120,3 @@ def test_cmd_gef_install(self): self.assertNotEqual(-1, idx, f"Check {i}/{3} failed: missing '{pattern}' in\n{res}") self.assertIn("new command(s) available", res) res = res[idx:] - diff --git a/tests/commands/gef_remote.py b/tests/commands/gef_remote.py index eceb2ecdc..e46eb94ec 100644 --- a/tests/commands/gef_remote.py +++ b/tests/commands/gef_remote.py @@ -37,4 +37,3 @@ def test_cmd_gef_remote_qemu_user(self): self.assertIn( f"RemoteSession(target='{GDBSERVER_PREFERED_HOST}:{port}', local='/tmp/", res) self.assertIn(", qemu_user=True)", res) - diff --git a/tests/commands/got.py b/tests/commands/got.py index 3399ba766..01c1cb23d 100644 --- a/tests/commands/got.py +++ b/tests/commands/got.py @@ -29,4 +29,3 @@ def test_cmd_got(self): res = gdb_start_silent_cmd("got printf", target=target) self.assertIn("printf", res) self.assertNotIn("strcpy", res) - diff --git a/tests/commands/heap.py b/tests/commands/heap.py index b624a0eda..983d4a0ea 100644 --- a/tests/commands/heap.py +++ b/tests/commands/heap.py @@ -178,4 +178,3 @@ def test_cmd_heap_bins_unsorted(self): self.assertIn("Found 1 chunks in unsorted bin", res) self.assertIn("Chunk(addr=", res) self.assertIn(f"size={self.expected_unsorted_bin_size:#x}", res) - diff --git a/tests/commands/heap_analysis.py b/tests/commands/heap_analysis.py index 826f34182..13fe6b1e7 100644 --- a/tests/commands/heap_analysis.py +++ b/tests/commands/heap_analysis.py @@ -24,4 +24,3 @@ def test_cmd_heap_analysis(self): addr = int(res.split("calloc(32)=")[1].split("\n")[0], 0) self.assertRegex(res, r"realloc\(.+, 48") self.assertIn(f"free({addr:#x}", res) - diff --git a/tests/commands/hexdump.py b/tests/commands/hexdump.py index 1e14a5010..fb51cd3f6 100644 --- a/tests/commands/hexdump.py +++ b/tests/commands/hexdump.py @@ -21,6 +21,3 @@ def test_cmd_hexdump(self): self.assertNoException(res) res = gdb_start_silent_cmd("hexdump byte $sp -s 32") self.assertNoException(res) - - - diff --git a/tests/commands/name_break.py b/tests/commands/name_break.py index 8119bf5ed..d7f0b1de9 100644 --- a/tests/commands/name_break.py +++ b/tests/commands/name_break.py @@ -21,4 +21,3 @@ def test_cmd_name_break(self): res = gdb_start_silent_cmd("nb foobar") self.assertNoException(res) - diff --git a/tests/commands/pattern.py b/tests/commands/pattern.py index 172830784..ddf827db6 100644 --- a/tests/commands/pattern.py +++ b/tests/commands/pattern.py @@ -77,4 +77,3 @@ def test_cmd_pattern_search(self): res = gdb_run_cmd(cmd, before=before, target=target) self.assertNoException(res) self.assertIn(f"not found", res) - diff --git a/tests/commands/pie.py b/tests/commands/pie.py index 1bcb1e95e..185c4fab2 100644 --- a/tests/commands/pie.py +++ b/tests/commands/pie.py @@ -52,4 +52,3 @@ def test_cmd_pie_breakpoint_run(self): # check the mask of the breakpoint address address = int(res.split()[0], 16) self.assertEqual(address & self.pie_offset, self.pie_offset) - diff --git a/tests/commands/process_status.py b/tests/commands/process_status.py index 97247e526..1a7d91e06 100644 --- a/tests/commands/process_status.py +++ b/tests/commands/process_status.py @@ -18,5 +18,3 @@ def test_cmd_process_status(self): self.assertIn("Process Information", res) self.assertIn("No child process", res) self.assertIn("No open connections", res) - - diff --git a/tests/commands/registers.py b/tests/commands/registers.py index 5dc35262c..3e9e3da36 100644 --- a/tests/commands/registers.py +++ b/tests/commands/registers.py @@ -30,4 +30,3 @@ def test_cmd_registers(self): elif ARCH in ("i686", ): self.assertIn("$eax", res) self.assertIn("$eflags", res) - diff --git a/tests/commands/reset_cache.py b/tests/commands/reset_cache.py index 6979edecf..fda8d4106 100644 --- a/tests/commands/reset_cache.py +++ b/tests/commands/reset_cache.py @@ -13,5 +13,3 @@ class ResetCacheCommand(GefUnitTestGeneric): def test_cmd_reset_cache(self): res = gdb_start_silent_cmd("reset-cache") self.assertNoException(res) - - diff --git a/tests/commands/scan.py b/tests/commands/scan.py index c4590b645..5be7e4bd3 100644 --- a/tests/commands/scan.py +++ b/tests/commands/scan.py @@ -21,4 +21,3 @@ def test_cmd_scan(self): res = gdb_start_silent_cmd("scan binary libc") self.assertNoException(res) self.assertIn("__libc_start_main", res) - diff --git a/tests/commands/search_pattern.py b/tests/commands/search_pattern.py index deb29d17c..c8c3be6d1 100644 --- a/tests/commands/search_pattern.py +++ b/tests/commands/search_pattern.py @@ -17,14 +17,12 @@ def test_cmd_search_pattern(self): self.assertIn("0x", res) def test_cmd_search_pattern_regex(self): - res = gdb_start_silent_cmd_last_line("set {char[6]} $sp = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x00 }", + res = gdb_start_silent_cmd_last_line("set {char[6]} $sp = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x00 }", after=[r"search-pattern --regex $sp $sp+7 ([\\x20-\\x7E]{2,})(?=\\x00)",]) self.assertNoException(res) self.assertTrue(r"b'ABCDE'" in res) # this should not match because binary string is not null ended: - res = gdb_start_silent_cmd_last_line("set {char[6]} $sp = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x03 }", + res = gdb_start_silent_cmd_last_line("set {char[6]} $sp = { 0x41, 0x42, 0x43, 0x44, 0x45, 0x03 }", after=[r"search-pattern --regex $sp $sp+7 ([\\x20-\\x7E]{2,})(?=\\x00)",]) self.assertNoException(res) self.assertTrue(r"b'ABCDE'" not in res) - - diff --git a/tests/commands/skipi.py b/tests/commands/skipi.py index 268b2aed8..6c07a905d 100644 --- a/tests/commands/skipi.py +++ b/tests/commands/skipi.py @@ -60,4 +60,3 @@ def test_cmd_skipi_two_instructions_from_location(self): ) self.assertNoException(res) self.assertIn(r"\x90\x90", res) # 2 nops - diff --git a/tests/commands/stub.py b/tests/commands/stub.py index f813eff6f..b87db50f7 100644 --- a/tests/commands/stub.py +++ b/tests/commands/stub.py @@ -19,4 +19,4 @@ def test_cmd_stub(self): self.assertIn("Hello World!", res) res = gdb_start_silent_cmd(cmds, after=["continue"]) self.assertNoException(res) - self.assertNotIn("Hello World!", res) \ No newline at end of file + self.assertNotIn("Hello World!", res) diff --git a/tests/config/__init__.py b/tests/config/__init__.py index 76b4a9e17..891742c96 100644 --- a/tests/config/__init__.py +++ b/tests/config/__init__.py @@ -20,4 +20,3 @@ def test_config_show_opcodes_size(self): # output format: 0xaddress opcode mnemo [operands, ...] # example: 0x5555555546b2 897dec mov DWORD PTR [rbp-0x14], edi self.assertRegex(res, r"(0x([0-9a-f]{2})+)\s+(([0-9a-f]{2})+)\s+<[^>]+>\s+(.*)") -