Skip to content

Commit

Permalink
- added ci test for glibcarena
Browse files Browse the repository at this point in the history
- fixed `theme` missing comma (original PR #808 by @mrshu )
- added missing values for `theme`
  • Loading branch information
hugsy committed Jan 31, 2022
1 parent de824b8 commit 1a4c061
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
12 changes: 10 additions & 2 deletions tests/api/gef_heap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
import pytest
import random

from tests.utils import ARCH, gdb_test_python_method, is_64b
from tests.utils import ARCH, _target, gdb_test_python_method, is_64b
from tests.utils import GefUnitTestGeneric


def result_as_int(res: str) -> int:
return int(gdb_test_python_method(res).splitlines()[-1])
return int(gdb_test_python_method(res, target=_target("heap")).splitlines()[-1])

TCACHE_BINS = 64

Expand Down Expand Up @@ -69,3 +69,11 @@ def test_func_gef_heap_malloc_align_address(self):
res = result_as_int(f"gef.heap.malloc_align_address({x})")
self.assertEqual(res, y)


def test_class_glibcarena_main_arena(self):
addr1 = result_as_int("GlibcArena('main_arena').addr")
addr2 = result_as_int("search_for_main_arena()")
addr3 = result_as_int("int(gef.heap.main_arena)")
self.assertEqual(addr1, addr2)
self.assertEqual(addr2, addr3)

2 changes: 1 addition & 1 deletion tests/api/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ def test_func_download_file(self):

@pytest.mark.slow
@pytest.mark.online
@pytest.mark.skip
def test_func_update_gef(self):
bkp_home = os.environ["HOME"]
for branch in ("master", "dev"):
Expand All @@ -56,7 +57,6 @@ def test_func_update_gef(self):
os.environ["HOME"] = str(dirpath.absolute())
ref = subprocess.check_output(f"""wget -q -O- https://api.github.com/repos/hugsy/gef/git/ref/heads/{branch} | grep '"sha"' | tr -s ' ' | cut -d ' ' -f 3 | tr -d ',' | tr -d '"' """, shell=True).decode("utf-8").strip()
res = gdb_test_python_method(f"update_gef(['--{branch}'])")
self.assertNoException(res)
retcode = int(res.splitlines()[-1])
self.assertEqual(retcode, 0)
home = pathlib.Path().home()
Expand Down
2 changes: 1 addition & 1 deletion tests/commands/pie.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def setUp(self) -> None:
# we assume `_target` is `default.out` and is (should be) a PIE binary
res = gdb_run_cmd("disassemble main")
start_str = "Dump of assembler code for function main:\n"
end_str = "End of assembler dump.\n"
end_str = "End of assembler dump."
lines = removeuntil(start_str, res[:res.find(end_str)]).splitlines()
self.assertGreater(len(lines), 1)
idx = random.randint(0, len(lines)-1)
Expand Down
29 changes: 18 additions & 11 deletions tests/commands/theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,30 @@ class ThemeCommand(GefUnitTestGeneric):
def test_cmd_theme(self):
res = gdb_run_cmd("theme")
self.assertNoException(res)
possible_themes = [
"context_title_line"
"dereference_base_address"
"context_title_message"
"disable_color"
"dereference_code"
"dereference_string"
possible_themes = (
"context_title_line",
"context_title_message",
"default_title_line",
"default_title_message",
"default_title_line"
"table_heading",
"old_context",
"disassemble_current_instruction",
"dereference_string",
"dereference_code",
"dereference_base_address",
"dereference_register_value",
"xinfo_title_message",
]
"registers_register_name",
"registers_value_changed",
"address_stack",
"address_heap",
"address_code",
"source_current_line",
)
for t in possible_themes:
# testing command viewing
res = gdb_run_cmd(f"theme {t}")
self.assertNoException(res)
self.assertNotIn("Invalid key", res)
self.assertNotIn("Invalid key", res, f"Invalid key '{t}'")

# testing command setting
v = "blue blah 10 -1 0xfff bold"
Expand Down

0 comments on commit 1a4c061

Please sign in to comment.