Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Grazfather committed Aug 26, 2023
1 parent 1178f8c commit f58ed9a
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,29 @@
Test GEF configuration parameters.
"""


from tests.utils import gdb_run_cmd
from tests.utils import GefUnitTestGeneric


class TestGefConfigUnit(GefUnitTestGeneric):
"""Test GEF configuration paramaters."""
"""Test GEF configuration parameters."""


def test_config_show_opcodes_size(self):
"""Check opcodes are correctly shown"""
"""Check opcodes are correctly shown."""
res = gdb_run_cmd("entry-break", before=["gef config context.show_opcodes_size 4"])
self.assertNoException(res)
self.assertGreater(len(res.splitlines()), 1)

# 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+(.*)")

def test_config_validator(self):
"""Check that a GefSetting hook can prevent setting a config."""
res = gdb_run_cmd("gef config gef.tempdir '/tmp/path with space'")
self.assertException(res)
self.assertRegex(res, r".+Cannot set.+setting cannot contain spaces")

res = gdb_run_cmd("gef config gef.tempdir '/tmp/valid-path'")
self.assertNoException(res)

0 comments on commit f58ed9a

Please sign in to comment.