Skip to content

Commit

Permalink
Clean tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ValekoZ committed Jun 2, 2024
1 parent bef498b commit 54a5a32
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions tests/commands/arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,44 @@
Arch commands test module
"""

import pytest

from tests.base import RemoteGefUnitTestGeneric
from tests.utils import ARCH
import pytest


class ArchCommand(RemoteGefUnitTestGeneric):
"""Generic class for command testing, that defines all helpers"""

def setUp(self) -> None:
return super().setUp()
"""Class for `arch` command testing."""

@pytest.mark.skipif(ARCH != "x86_64", reason=f"Skipped for {ARCH}")
def test_cmd_arch_get(self):
gdb = self._gdb

res = gdb.execute("arch get", to_string=True)
self.assertIn(" Architecture(X86, 64, LITTLE_ENDIAN)", res)
self.assertIn(" The architecture has been detected via the ELF headers", res)
assert " Architecture(X86, 64, LITTLE_ENDIAN)" in res
assert " The architecture has been detected via the ELF headers" in res

def test_cmd_arch_set(self):
gdb = self._gdb

gdb.execute("arch set X86")

res = gdb.execute("arch get", to_string=True)
self.assertIn(" Architecture(X86, 32, LITTLE_ENDIAN)", res)
self.assertIn(" The architecture has been set manually", res)
assert " Architecture(X86, 32, LITTLE_ENDIAN)" in res
assert " The architecture has been set manually" in res


gdb.execute("arch set ppc")

res = gdb.execute("arch get", to_string=True)
self.assertIn(" Architecture(PPC, PPC32, LITTLE_ENDIAN)", res)
self.assertIn(" The architecture has been set manually", res)
assert " Architecture(PPC, PPC32, LITTLE_ENDIAN)" in res
assert " The architecture has been set manually" in res

def test_cmd_arch_list(self):
gdb = self._gdb

res = gdb.execute("arch list", to_string=True)
self.assertNotIn("- GenericArchitecture", res)
self.assertIn(" Architecture(X86, 64, LITTLE_ENDIAN)", res)
self.assertIn(" X86", res)
self.assertIn(" X86_64", res)
assert "- GenericArchitecture" not in res
assert " Architecture(X86, 64, LITTLE_ENDIAN)" in res
assert " X86" in res
assert " X86_64" in res

0 comments on commit 54a5a32

Please sign in to comment.