Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add prototype of unit tests for pwndbg * Add test for pwndbg [filter] * Fix isort, e2e tests, add pytest requirement * Add comment about not handling exceptions for unittests * Fixes after rebase * Fix test_loads_without_crashing * e2e tests: no colors & loading pwndbg tests * Fix isort * Add example of no file loaded test * Move tests to unit_tests, add binary, add memory tests * Isort fixes * Move from e2e/unit tests to tests * Add info about tests to DEVELOPING.md * Fix tests * review fixes * commands filtering test: check for contents, not for equality * Add tests launcher bash script * Change tests launcher name from unittests to pytests * Cleanup; better test file paths * Add theme param to disable colors * Better test_loads * Skip some tests locally that can run on travis * Fix test_loads according to travis * Fix travis tests
- Loading branch information
1 parent
f7eee8f
commit e225ba9
Showing
26 changed files
with
391 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
from __future__ import print_function | ||
from __future__ import division | ||
from __future__ import absolute_import | ||
from __future__ import unicode_literals | ||
|
||
import os | ||
import pytest | ||
import sys | ||
print(sys.argv) | ||
|
||
sys._pwndbg_unittest_run = True | ||
|
||
TESTS_PATH = os.path.join( | ||
os.path.dirname(os.path.realpath(__file__)), | ||
'tests' | ||
) | ||
|
||
# If you want to debug tests locally, add '--pdb' here | ||
args = [TESTS_PATH, '-vvv', '-s', '--showlocals', '--color=yes'] | ||
|
||
print('Launching pytest with args: %s' % args) | ||
|
||
return_code = pytest.main(args) | ||
|
||
if return_code != 0: | ||
print('-' * 80) | ||
print('If you want to debug tests locally, modify tests_launcher.py and add --pdb to its args') | ||
print('-' * 80) | ||
|
||
sys.exit(return_code) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
|
||
PWNDBG_DISABLE_COLORS=1 gdb --silent --nx --nh --command gdbinit.py --command pytests_launcher.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,6 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
from . import binaries |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import os | ||
|
||
from . import old_bash | ||
|
||
path = os.path.dirname(__file__) | ||
|
||
def get(x): | ||
return os.path.join(path, x) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
CC = gcc | ||
DEBUG = 1 | ||
CFLAGS += -Wall | ||
SOURCES = $(wildcard *.c) | ||
COMPILED = $(SOURCES:.c=.o) | ||
LINKED = $(SOURCES:.c=.out) | ||
LDFLAGS = | ||
EXTRA_FLAGS = | ||
|
||
ifeq ($(TARGET), x86) | ||
CFLAGS += -m32 | ||
endif | ||
|
||
ifeq ($(DEBUG), 1) | ||
CFLAGS += -DDEBUG=1 -ggdb -O0 | ||
else | ||
CFLAGS += -O1 | ||
endif | ||
|
||
|
||
.PHONY : all clean | ||
|
||
all: $(LINKED) | ||
|
||
|
||
%.out : %.c | ||
@echo "[+] Building '$@'" | ||
@$(CC) $(CFLAGS) $(EXTRA_FLAGS) -o $@ $? $(LDFLAGS) | ||
|
||
clean : | ||
@echo "[+] Cleaning stuff" | ||
@rm -f $(COMPILED) $(LINKED) | ||
|
||
|
||
reference-binary.out: EXTRA_FLAGS := -Dexample=1 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import os | ||
|
||
path = os.path.dirname(__file__) | ||
|
||
def get(x): | ||
return os.path.join(path, x) |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <stdio.h> | ||
|
||
void foo() {} | ||
|
||
int main() { | ||
puts("Hello world"); | ||
foo(); | ||
} |
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
""" | ||
This file should consist of global test fixtures. | ||
""" | ||
from __future__ import absolute_import | ||
from __future__ import division | ||
from __future__ import print_function | ||
from __future__ import unicode_literals | ||
|
||
import gdb | ||
import pytest | ||
|
||
|
||
@pytest.fixture | ||
def entry_binary(): | ||
""" | ||
Returns function that launches given binary with 'entry' command | ||
""" | ||
def _entry_binary(name): | ||
gdb.execute('file ./tests/binaries/' + name) | ||
gdb.execute('entry') | ||
|
||
return _entry_binary |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.