2018-04-05 05:10:23 +08:00
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2022-09-09 10:46:46 +08:00
|
|
|
import pytest
|
|
|
|
|
2022-08-30 08:53:00 +08:00
|
|
|
use_pdb = os.environ.get("USE_PDB") == "1"
|
2022-08-24 06:05:57 +08:00
|
|
|
|
2018-04-05 05:10:23 +08:00
|
|
|
sys._pwndbg_unittest_run = True
|
|
|
|
|
2018-07-09 01:03:03 +08:00
|
|
|
CURRENT_DIR = os.path.dirname(os.path.realpath(__file__))
|
|
|
|
|
2022-08-30 08:53:00 +08:00
|
|
|
test = os.environ["PWNDBG_LAUNCH_TEST"]
|
2018-07-09 01:03:03 +08:00
|
|
|
|
|
|
|
test = os.path.join(CURRENT_DIR, test)
|
2018-04-05 05:10:23 +08:00
|
|
|
|
2022-08-30 08:53:00 +08:00
|
|
|
args = [test, "-vvv", "-s", "--showlocals", "--color=yes"]
|
2018-04-05 05:10:23 +08:00
|
|
|
|
2022-08-24 06:05:57 +08:00
|
|
|
if use_pdb:
|
2022-08-30 08:53:00 +08:00
|
|
|
args.append("--pdb")
|
2022-08-24 06:05:57 +08:00
|
|
|
|
2022-08-30 08:53:00 +08:00
|
|
|
print("Launching pytest with args: %s" % args)
|
2018-04-05 05:10:23 +08:00
|
|
|
|
|
|
|
return_code = pytest.main(args)
|
|
|
|
|
|
|
|
if return_code != 0:
|
2022-08-30 08:53:00 +08:00
|
|
|
print("-" * 80)
|
|
|
|
print(
|
|
|
|
"If you want to debug tests locally, modify {} and add --pdb to its args".format(__file__)
|
|
|
|
)
|
|
|
|
print("-" * 80)
|
2018-04-05 05:10:23 +08:00
|
|
|
|
|
|
|
sys.exit(return_code)
|