Run tests in parallel with GNU parallel (#1332)

pull/1336/head
Gulshan Singh 3 years ago committed by GitHub
parent 125a06001d
commit f94bc27cb1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -33,7 +33,8 @@ install_apt() {
libc6-dev \ libc6-dev \
curl \ curl \
build-essential \ build-essential \
gdb gdb \
parallel
if [[ "$1" == "22.04" ]]; then if [[ "$1" == "22.04" ]]; then
sudo apt install shfmt sudo apt install shfmt

@ -68,14 +68,11 @@ if [ $? -eq 1 ]; then
exit 1 exit 1
fi fi
TESTS_LIST=$(echo -E "$TESTS_COLLECT_OUTPUT" | grep -o "tests/.*::.*" | grep "${TEST_NAME_FILTER}") TESTS_LIST=($(echo -E "$TESTS_COLLECT_OUTPUT" | grep -o "tests/.*::.*" | grep "${TEST_NAME_FILTER}"))
tests_passed_or_skipped=0 run_test() {
tests_failed=0 test_case="$1"
declare -a FAILED_TESTS
for test_case in ${TESTS_LIST}; do
gdb_args=(--command $GDB_INIT_PATH --command pytests_launcher.py) gdb_args=(--command $GDB_INIT_PATH --command pytests_launcher.py)
if [ ${RUN_CODECOV} -ne 0 ]; then if [ ${RUN_CODECOV} -ne 0 ]; then
gdb_args=(-ex 'py import coverage;coverage.process_startup()' "${gdb_args[@]}") gdb_args=(-ex 'py import coverage;coverage.process_startup()' "${gdb_args[@]}")
@ -88,23 +85,28 @@ for test_case in ${TESTS_LIST}; do
PWNDBG_DISABLE_COLORS=1 \ PWNDBG_DISABLE_COLORS=1 \
run_gdb "${gdb_args[@]}" run_gdb "${gdb_args[@]}"
exit_status=$? exit $?
if [ ${exit_status} -eq 0 ]; then }
((++tests_passed_or_skipped)) JOBLOG_PATH="$(mktemp)"
else echo "Joblog: $JOBLOG_PATH"
((++tests_failed))
FAILED_TESTS+=(${test_case}) . $(which env_parallel.bash)
fi env_parallel --joblog $JOBLOG_PATH run_test ::: "${TESTS_LIST[@]}"
done
# The seventh column in the joblog is the exit value and the tenth is the test name
FAILED_TESTS=($(awk '$7 == "1" { print $10 }' "${JOBLOG_PATH}"))
num_tests_failed=${#FAILED_TESTS[@]}
num_tests_passed_or_skipped=$((${#TESTS_LIST[@]} - $num_tests_failed))
echo "" echo ""
echo "*********************************" echo "*********************************"
echo "********* TESTS SUMMARY *********" echo "********* TESTS SUMMARY *********"
echo "*********************************" echo "*********************************"
echo "Tests passed or skipped: ${tests_passed_or_skipped}" echo "Tests passed or skipped: ${num_tests_passed_or_skipped}"
echo "Tests failed: ${tests_failed}" echo "Tests failed: ${num_tests_failed}"
if [ "${tests_failed}" -ne 0 ]; then if [ "${num_tests_failed}" -ne 0 ]; then
echo "" echo ""
echo "Failing tests: ${FAILED_TESTS[@]}" echo "Failing tests: ${FAILED_TESTS[@]}"
exit 1 exit 1

@ -1,6 +1,7 @@
import os import os
import re import re
import subprocess import subprocess
import tempfile
import pytest import pytest
@ -24,7 +25,7 @@ REASON_CANNOT_ATTACH = (
@pytest.fixture @pytest.fixture
def launched_bash_binary(): def launched_bash_binary():
path = "/tmp/pwndbg_test_bash" path = tempfile.mktemp()
subprocess.check_output(["cp", "/bin/bash", path]) subprocess.check_output(["cp", "/bin/bash", path])
process = subprocess.Popen([path], stdout=subprocess.PIPE, stdin=subprocess.PIPE) process = subprocess.Popen([path], stdout=subprocess.PIPE, stdin=subprocess.PIPE)

@ -1,3 +1,5 @@
import tempfile
import gdb import gdb
import pwndbg import pwndbg
@ -79,7 +81,7 @@ def test_command_vmmap_on_coredump_on_crash_simple_binary(start_binary):
assert vmmaps == expected_maps assert vmmaps == expected_maps
# Now, generate core file, so we can then test coredump vmmap # Now, generate core file, so we can then test coredump vmmap
core = "/tmp/test_command_vmmap_on_coredump_on_crash_simple_binary" core = tempfile.mktemp()
gdb.execute("generate-core-file %s" % core) gdb.execute("generate-core-file %s" % core)
#### TEST COREDUMP VMMAP #### TEST COREDUMP VMMAP

@ -32,8 +32,13 @@ def test_context_disasm_show_fd_filepath(start_binary):
assert "call read@plt" in line_call_read assert "call read@plt" in line_call_read
# When running tests with GNU Parallel, sometimes the file name looks
# '/tmp/parZ4YC4.par', and occasionally '(deleted)' is present after the
# filename
line_fd = line_fd.strip() line_fd = line_fd.strip()
assert re.match(r"fd:\s+0x1 \((/dev/pts/\d+|pipe:\[\d+\])\)", line_fd) assert re.match(
r"fd:\s+0x1 \((/dev/pts/\d+|/tmp/par.+\.par(?: \(deleted\))?|pipe:\[\d+\])\)", line_fd
)
line_buf = line_buf.strip() line_buf = line_buf.strip()
assert re.match(r"buf:\s+0x[0-9a-f]+ ◂— 0x0", line_buf) assert re.match(r"buf:\s+0x[0-9a-f]+ ◂— 0x0", line_buf)

Loading…
Cancel
Save