Skip to content

Commit

Permalink
[tests] applied pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
hugsy committed Aug 7, 2023
1 parent 6e8ea2c commit eb2e2cf
Show file tree
Hide file tree
Showing 22 changed files with 5 additions and 29 deletions.
1 change: 0 additions & 1 deletion tests/api/deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,3 @@ def test_deprecated_elf_values(self):
self.assertNoException(res)
if not record:
pytest.fail(f"Expected a warning for '{item}'!")

1 change: 0 additions & 1 deletion tests/api/gef_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

2 changes: 1 addition & 1 deletion tests/binaries/nested.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ void f4(){ f5(); }
void f3(){ f4(); }
void f2(){ f3(); }
void f1(){ f2(); }
int main(){ f1(); return 0;}
int main(){ f1(); return 0;}
2 changes: 1 addition & 1 deletion tests/binaries/nested2.c
Original file line number Diff line number Diff line change
@@ -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); }
int main(){ return f1(0); }
1 change: 0 additions & 1 deletion tests/commands/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,3 @@ def test_cmd_functions(self):
res = gdb_run_cmd(cmd)
self.assertNoException(res)
self.assertIn("$_heap", res)

1 change: 0 additions & 1 deletion tests/commands/gef.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:]

1 change: 0 additions & 1 deletion tests/commands/gef_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

1 change: 0 additions & 1 deletion tests/commands/got.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

1 change: 0 additions & 1 deletion tests/commands/heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

1 change: 0 additions & 1 deletion tests/commands/heap_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

3 changes: 0 additions & 3 deletions tests/commands/hexdump.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)



1 change: 0 additions & 1 deletion tests/commands/name_break.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ def test_cmd_name_break(self):

res = gdb_start_silent_cmd("nb foobar")
self.assertNoException(res)

1 change: 0 additions & 1 deletion tests/commands/pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

1 change: 0 additions & 1 deletion tests/commands/pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

2 changes: 0 additions & 2 deletions tests/commands/process_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


1 change: 0 additions & 1 deletion tests/commands/registers.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,3 @@ def test_cmd_registers(self):
elif ARCH in ("i686", ):
self.assertIn("$eax", res)
self.assertIn("$eflags", res)

2 changes: 0 additions & 2 deletions tests/commands/reset_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ class ResetCacheCommand(GefUnitTestGeneric):
def test_cmd_reset_cache(self):
res = gdb_start_silent_cmd("reset-cache")
self.assertNoException(res)


1 change: 0 additions & 1 deletion tests/commands/scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

6 changes: 2 additions & 4 deletions tests/commands/search_pattern.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


1 change: 0 additions & 1 deletion tests/commands/skipi.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,3 @@ def test_cmd_skipi_two_instructions_from_location(self):
)
self.assertNoException(res)
self.assertIn(r"\x90\x90", res) # 2 nops

2 changes: 1 addition & 1 deletion tests/commands/stub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
self.assertNotIn("Hello World!", res)
1 change: 0 additions & 1 deletion tests/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ def test_config_show_opcodes_size(self):
# output format: 0xaddress opcode <symbol+offset> mnemo [operands, ...]
# example: 0x5555555546b2 897dec <main+8> mov DWORD PTR [rbp-0x14], edi
self.assertRegex(res, r"(0x([0-9a-f]{2})+)\s+(([0-9a-f]{2})+)\s+<[^>]+>\s+(.*)")

0 comments on commit eb2e2cf

Please sign in to comment.