mirror of https://github.com/pwndbg/pwndbg.git
Run each test in a separate GDB session (#498)
* it would be cool to have tests that run within GDB so that we don't have to parse GDB output and deal with weird problems * we can't run all tests in one GDB session as `file x; entry; <some pwndbg command>; file y; entry; <some wndbg command>;` may have different results - it seems either us or GDB fails to cleanup everything properlypull/500/head
parent
5b9671f284
commit
87aa167599
@ -0,0 +1,36 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import division
|
||||||
|
from __future__ import absolute_import
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
TESTS_PATH = os.path.join(
|
||||||
|
os.path.dirname(os.path.realpath(__file__)),
|
||||||
|
'tests'
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
class CollectTestFunctionNames:
|
||||||
|
"""See https://github.com/pytest-dev/pytest/issues/2039#issuecomment-257753269"""
|
||||||
|
def __init__(self):
|
||||||
|
self.collected = []
|
||||||
|
|
||||||
|
def pytest_collection_modifyitems(self, items):
|
||||||
|
for item in items:
|
||||||
|
self.collected.append(item.nodeid)
|
||||||
|
|
||||||
|
|
||||||
|
collector = CollectTestFunctionNames()
|
||||||
|
pytest.main(['--collect-only', TESTS_PATH], plugins=[collector])
|
||||||
|
|
||||||
|
print('Listing collected tests:')
|
||||||
|
for nodeid in collector.collected:
|
||||||
|
print('Test:', nodeid)
|
||||||
|
|
||||||
|
# easy way to exit GDB session
|
||||||
|
sys.exit(0)
|
||||||
@ -1,3 +1,10 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
PWNDBG_DISABLE_COLORS=1 gdb --silent --nx --nh --command gdbinit.py --command pytests_launcher.py
|
|
||||||
|
# NOTE: We run tests under GDB sessions and because of some cleanup/tests dependencies problems
|
||||||
|
# we decided to run each test in a separate GDB session
|
||||||
|
TESTS_LIST=$(gdb --silent --nx --nh --command gdbinit.py --command pytests_collect.py | grep -o "tests/.*::.*")
|
||||||
|
|
||||||
|
for test_case in ${TESTS_LIST}; do
|
||||||
|
PWNDBG_LAUNCH_TEST="${test_case}" PWNDBG_DISABLE_COLORS=1 gdb --silent --nx --nh --command gdbinit.py --command pytests_launcher.py
|
||||||
|
done
|
||||||
Loading…
Reference in new issue