Add smoke test (#1113)

pull/1115/head
Gulshan Singh 3 years ago committed by GitHub
parent 099c766342
commit 2d483fcb12
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -10,7 +10,7 @@ import pwndbg.commands
import pwndbg.which
pwncmds = ["asm", "constgrep", "cyclic", "disasm", "pwn", "unhex"]
shellcmds = [
shellcmd_names = [
"awk",
"bash",
"cat",
@ -63,7 +63,7 @@ shellcmds = [
]
pwncmds = filter(pwndbg.which.which, pwncmds)
shellcmds = filter(pwndbg.which.which, shellcmds)
shellcmds = filter(pwndbg.which.which, shellcmd_names)
def register_shell_function(cmd, deprecated=False):

@ -16,6 +16,7 @@ def start_binary():
def _start_binary(path, *args):
gdb.execute("file " + path)
gdb.execute("set exception-verbose on")
gdb.execute("starti " + " ".join(args))
global _start_binary_called

@ -0,0 +1,55 @@
import gdb
import pytest
import tests
from pwndbg.commands import command_names
from pwndbg.commands import commands
from pwndbg.commands.shell import shellcmd_names
BINARY = tests.binaries.get("heap_bins.out")
# TODO: See if we can reduce the number of commands we need to skip
blacklisted_commands = set(
[
"disasm",
"unhex",
"bugreport",
"try_free",
"errno",
"nextproginstr",
]
)
# Don't run any shell commands
blacklisted_commands.update(shellcmd_names)
# TODO: Figure out why these are being thrown and then remove this
whitelisted_exceptions = [
"Cannot access memory at address",
"Cannot insert breakpoint",
"Warning:",
"The program is not being run",
]
@pytest.mark.skip(reason="flaky test")
def test_commands(start_binary):
for name in command_names:
print("Running command", name)
try:
start_binary(BINARY)
if name in blacklisted_commands:
continue
gdb.execute(name)
except gdb.error as e:
ignore = False
for ex in whitelisted_exceptions:
if ex in str(e):
ignore = True
print("Ignoring exception in command", name)
break
if not ignore:
raise e
Loading…
Cancel
Save