Skip to content

Commit

Permalink
Rename _target to debug_target.
Browse files Browse the repository at this point in the history
  • Loading branch information
r12f committed Dec 21, 2023
1 parent 023b1a9 commit b05fced
Show file tree
Hide file tree
Showing 24 changed files with 87 additions and 87 deletions.
6 changes: 3 additions & 3 deletions tests/api/gef_disasemble.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import pytest

from tests.utils import ARCH, _target, gdb_run_silent_cmd
from tests.utils import ARCH, debug_target, gdb_run_silent_cmd
from tests.utils import GefUnitTestGeneric


Expand All @@ -14,7 +14,7 @@ class GefDisassembleApiFunction(GefUnitTestGeneric):
@pytest.mark.skipif(ARCH not in ("x86_64", "i686"), reason=f"Skipped for {ARCH}")
def test_func_gef_disassemble(self):
cmd = "gef_disassemble(0x2337100, 4, 4)"
res = gdb_run_silent_cmd(f"pi os.linesep.join([str(i) for i in {cmd}])", target=_target("mmap-known-address"))
res = gdb_run_silent_cmd(f"pi os.linesep.join([str(i) for i in {cmd}])", target=debug_target("mmap-known-address"))
self.assertNoException(res)
self.assertIn(
' 0x23370fc int3 \\n 0x23370fd int3 \\n 0x23370fe int3 \\n 0x23370ff int3 \\n 0x2337100 int3 \\n 0x2337101 int3 \\n 0x2337102 int3 \\n 0x2337103 int3 ', res)
Expand All @@ -24,7 +24,7 @@ def test_func_gef_disassemble_page_border(self):
# Regression test for issue #922
cmd = "gef_disassemble(0x2337000, 4, 4)"
res = gdb_run_silent_cmd(
f"pi os.linesep.join([str(i) for i in {cmd}])", target=_target("mmap-known-address"))
f"pi os.linesep.join([str(i) for i in {cmd}])", target=debug_target("mmap-known-address"))
self.assertNoException(res)
self.assertIn(
'0x2337000 int3 \\n 0x2337001 int3 \\n 0x2337002 int3 \\n 0x2337003 int3 ', res)
4 changes: 2 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, _target, gdb_test_python_method, is_64b
from tests.utils import ARCH, debug_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, target=_target("heap")).splitlines()[-1])
return int(gdb_test_python_method(res, target=debug_target("heap")).splitlines()[-1])

TCACHE_BINS = 64

Expand Down
18 changes: 9 additions & 9 deletions tests/api/gef_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from tests.utils import (
TMPDIR,
gdb_test_python_method,
_target,
debug_target,
GefUnitTestGeneric,
gdbserver_session,
gdb_run_cmd,
Expand All @@ -23,24 +23,24 @@ class GefSessionApi(GefUnitTestGeneric):
"""`gef.session` test module."""

def test_func_get_filepath(self):
res = gdb_test_python_method("gef.session.file", target=_target("default"))
res = gdb_test_python_method("gef.session.file", target=debug_target("default"))
self.assertNoException(res)
target = TMPDIR / "foo bar"
subprocess.call(["cp", _target("default"), target])
subprocess.call(["cp", debug_target("default"), target])
res = gdb_test_python_method("gef.session.file", target=target)
self.assertNoException(res)
subprocess.call(["rm", target])


def test_func_get_pid(self):
res = gdb_test_python_method("gef.session.pid", target=_target("default"))
res = gdb_test_python_method("gef.session.pid", target=debug_target("default"))
self.assertNoException(res)
self.assertTrue(int(res.splitlines()[-1]))


def test_func_auxiliary_vector(self):
func = "gef.session.auxiliary_vector"
res = gdb_test_python_method(func, target=_target("default"))
res = gdb_test_python_method(func, target=debug_target("default"))
self.assertNoException(res)
# we need at least ("AT_PLATFORM", "AT_EXECFN") right now
self.assertTrue("'AT_PLATFORM'" in res)
Expand All @@ -49,7 +49,7 @@ def test_func_auxiliary_vector(self):

def test_root_dir_local(self):
func = "(s.st_dev, s.st_ino)"
res = gdb_test_python_method(func, target=_target("default"), before="s=os.stat(gef.session.root)")
res = gdb_test_python_method(func, target=debug_target("default"), before="s=os.stat(gef.session.root)")
self.assertNoException(res)
st_dev, st_ino = eval(res.split("\n")[-1])
stat_root = os.stat("/")
Expand All @@ -63,7 +63,7 @@ def test_root_dir_remote(self):
port = random.randint(1025, 65535)
before = [f"gef-remote {host} {port}", "pi s=os.stat(gef.session.root)"]
with gdbserver_session(port=port):
res = gdb_run_cmd(f"pi {func}", target=_target("default"), before=before)
res = gdb_run_cmd(f"pi {func}", target=debug_target("default"), before=before)
self.assertNoException(res)
st_dev, st_ino = eval(res.split("\n")[-1])
assert (stat_root.st_dev == st_dev) and (stat_root.st_ino == st_ino)
Expand All @@ -72,9 +72,9 @@ def test_root_dir_qemu(self):
host = GDBSERVER_DEFAULT_HOST
port = random.randint(1025, 65535)
with qemuuser_session(port=port):
target = _target("default")
target = debug_target("default")
before = [
f"gef-remote --qemu-user --qemu-binary {target} {host} {port}"]
res = gdb_run_cmd(f"pi gef.session.root", target=_target("default"), before=before)
res = gdb_run_cmd(f"pi gef.session.root", target=debug_target("default"), before=before)
self.assertNoException(res)
assert re.search(r"\/proc\/[0-9]+/root", res)
6 changes: 3 additions & 3 deletions tests/api/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import pytest

from tests.utils import (
_target,
debug_target,
gdb_start_silent_cmd,
gdb_test_python_method,
gdb_run_cmd,
Expand All @@ -33,7 +33,7 @@ def test_func_which(self):

def test_func_gef_convenience(self):
func = "gef_convenience('meh')"
res = gdb_test_python_method(func, target=_target("default"))
res = gdb_test_python_method(func, target=debug_target("default"))
self.assertNoException(res)

def test_func_parse_address(self):
Expand Down Expand Up @@ -86,7 +86,7 @@ def test_func_parse_maps(self):
# When in a gef-remote qemu-user session `parse_gdb_info_sections`
# should work to query the memory maps
port = GDBSERVER_DEFAULT_PORT + 2
target = _target("default")
target = debug_target("default")
before = [
f"gef-remote --qemu-user --qemu-binary {target} {GDBSERVER_DEFAULT_HOST} {port}"]
with qemuuser_session(port=port) as _:
Expand Down
6 changes: 3 additions & 3 deletions tests/commands/canary.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""


from tests.utils import gdb_start_silent_cmd, gdb_run_cmd, _target, gdb_test_python_method
from tests.utils import gdb_start_silent_cmd, gdb_run_cmd, debug_target, gdb_test_python_method
from tests.utils import GefUnitTestGeneric
import pytest
import platform
Expand All @@ -16,7 +16,7 @@ class CanaryCommand(GefUnitTestGeneric):

def test_cmd_canary(self):
self.assertFailIfInactiveSession(gdb_run_cmd("canary"))
res = gdb_start_silent_cmd("canary", target=_target("canary"))
res = gdb_start_silent_cmd("canary", target=debug_target("canary"))
self.assertNoException(res)
self.assertIn("The canary of process", res)
res = gdb_test_python_method("gef.session.canary[0] == gef.session.original_canary[0]")
Expand All @@ -26,6 +26,6 @@ def test_cmd_canary(self):
@pytest.mark.skipif(ARCH != "x86_64", reason=f"Not implemented for {ARCH}")
def test_overwrite_canary(self):
patch = r"pi gef.memory.write(gef.arch.canary_address(), p64(0xdeadbeef))"
res = gdb_start_silent_cmd(patch, target=_target("canary"), after=["canary"])
res = gdb_start_silent_cmd(patch, target=debug_target("canary"), after=["canary"])
self.assertNoException(res)
self.assertIn("0xdeadbeef", res)
8 changes: 4 additions & 4 deletions tests/commands/checksec.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from tests.utils import (
gdb_run_cmd,
_target,
debug_target,
GefUnitTestGeneric
)

Expand All @@ -17,14 +17,14 @@ def test_cmd_checksec(self):
res = gdb_run_cmd(cmd)
self.assertNoException(res)

target = _target("checksec-no-canary")
target = debug_target("checksec-no-canary")
res = gdb_run_cmd(cmd, target=target)
self.assertIn("Canary : ✘", res)

target = _target("checksec-no-nx")
target = debug_target("checksec-no-nx")
res = gdb_run_cmd(cmd, target=target)
self.assertIn("NX : ✘", res)

target = _target("checksec-no-pie")
target = debug_target("checksec-no-pie")
res = gdb_run_cmd(cmd, target=target)
self.assertIn("PIE : ✘", res)
4 changes: 2 additions & 2 deletions tests/commands/format_string_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""


from tests.utils import _target, gdb_run_cmd
from tests.utils import debug_target, gdb_run_cmd
from tests.utils import GefUnitTestGeneric


Expand All @@ -13,7 +13,7 @@ class FormatStringHelperCommand(GefUnitTestGeneric):

def test_cmd_format_string_helper(self):
cmd = "format-string-helper"
target = _target("format-string-helper")
target = debug_target("format-string-helper")
res = gdb_run_cmd(cmd,
after=["set args testtest",
"run",],
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/gef_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from tests.utils import (
GefUnitTestGeneric,
_target,
debug_target,
gdb_run_cmd,
gdbserver_session,
qemuuser_session,
Expand All @@ -31,7 +31,7 @@ def test_cmd_gef_remote(self):

def test_cmd_gef_remote_qemu_user(self):
port = GDBSERVER_DEFAULT_PORT + 2
target = _target("default")
target = debug_target("default")
before = [
f"gef-remote --qemu-user --qemu-binary {target} {GDBSERVER_DEFAULT_HOST} {port}"]
with qemuuser_session(port=port) as _:
Expand Down
4 changes: 2 additions & 2 deletions tests/commands/got.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from tests.utils import (
ARCH,
_target,
debug_target,
gdb_run_cmd,
gdb_start_silent_cmd,
GefUnitTestGeneric,
Expand All @@ -20,7 +20,7 @@ class GotCommand(GefUnitTestGeneric):

def test_cmd_got(self):
cmd = "got"
target = _target("format-string-helper")
target = debug_target("format-string-helper")
self.assertFailIfInactiveSession(gdb_run_cmd(cmd, target=target))
res = gdb_start_silent_cmd(cmd, target=target)
self.assertIn("printf", res)
Expand Down
Loading

0 comments on commit b05fced

Please sign in to comment.