From 7681e0f2c14f97443a97317695839db55b089a5b Mon Sep 17 00:00:00 2001 From: ValekoZ Date: Sun, 2 Jun 2024 18:05:31 +0200 Subject: [PATCH] Add tests --- tests/commands/arch.py | 48 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 tests/commands/arch.py diff --git a/tests/commands/arch.py b/tests/commands/arch.py new file mode 100644 index 000000000..4b4322893 --- /dev/null +++ b/tests/commands/arch.py @@ -0,0 +1,48 @@ +""" +Arch commands test module +""" + +from tests.base import RemoteGefUnitTestGeneric +from tests.utils import ( + ARCH, + ERROR_INACTIVE_SESSION_MESSAGE, + debug_target, + findlines, + is_32b, + is_64b, +) + + +class ArchCommand(RemoteGefUnitTestGeneric): + """Generic class for command testing, that defines all helpers""" + + def setUp(self) -> None: + return super().setUp() + + def test_cmd_arch_get(self): + gdb = self._gdb + + res = gdb.execute("arch get", to_string=True) + self.assertIn(" Architecture(Generic, None, LITTLE_ENDIAN)", res) + self.assertIn(" This default architecture", res) + + def test_cmd_arch_set(self): + gdb = self._gdb + + res = gdb.execute("arch get", to_string=True) + self.assertIn(" Architecture(Generic, None, LITTLE_ENDIAN)", res) + self.assertIn(" This default architecture", res) + + gdb.execute("arch set X86") + + res = gdb.execute("arch get", to_string=True) + self.assertIn(" Architecture(Generic, None, LITTLE_ENDIAN)", res) + self.assertIn(" The architecture has been set manually", res) + + def test_cmd_arch_list(self): + gdb = self._gdb + + res = gdb.execute("arch list", to_string=True) + self.assertIn("- GenericArchitecture", res) + self.assertIn("- X86", res) + self.assertIn("- X86_64", res)