diff --git a/tests/config/__init__.py b/tests/config/__init__.py index 891742c96..ada70e2a5 100644 --- a/tests/config/__init__.py +++ b/tests/config/__init__.py @@ -2,17 +2,16 @@ 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) @@ -20,3 +19,12 @@ 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+(.*)") + + def test_config_validator(self): + """Check that a GefSetting hook can prevent setting a config.""" + res = gdb_run_cmd("gef config get.tempdir '/tmp/path with space'") + self.assertException(res) + self.assertRegex(res, r".+Cannot set.+setting cannot contain spaces") + + res = gdb_run_cmd("gef config get.tempdir '/tmp/valid-path'") + self.assertNoException(res)