From 303700fce9c2757ee7e391f1bf91074cc10186ae Mon Sep 17 00:00:00 2001 From: Thomas Habets Date: Thu, 13 Jun 2024 20:57:36 +0100 Subject: [PATCH] workflow: Make sleep time a variable --- .github/workflows/c-cpp.yml | 2 +- src/arping.c | 2 +- tests/run | 14 +++++++------- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index b248d3b..b4858fe 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -38,4 +38,4 @@ jobs: - name: make distcheck with optional deps run: make distcheck - name: end to end tests - run: sudo bash -x ./tests/run + run: sudo bash -x ./tests/run 10 diff --git a/src/arping.c b/src/arping.c index eadef38..6522bed 100644 --- a/src/arping.c +++ b/src/arping.c @@ -427,7 +427,7 @@ drop_fs_root() struct passwd *pw; errno = 0; if (!(pw = getpwnam(chroot_user))) { - if (verbose) { + if (verbose > 1) { printf("arping: getpwnam(%s): %s\n", chroot_user, strerror(errno)); } diff --git a/tests/run b/tests/run index 5352c79..7cf474b 100755 --- a/tests/run +++ b/tests/run @@ -56,7 +56,7 @@ run_test() { PID=$! # wait for tcpdump to wake up. - sleep 10 + sleep "${SLEEP?}" # Run arping. set +e @@ -77,16 +77,15 @@ run_test() { echo "FAIL: wrong output:" echo "----" echo "${OUT?}" - echo "${OUT?}" > a + #echo "${OUT?}" > a echo "---- Should match -----" cat "tests/${NAME?}.out" exit 1 fi - - sleep 10 + + # Wait for tcpdump to see the packets. + sleep "${SLEEP?}" kill -INT "${PID?}" - sleep 10 - kill -9 "${PID?}" || true wait "${PID?}" || true TXT="$(mktemp)" @@ -170,6 +169,7 @@ run_tests() { main() { cd "$(dirname $0)/.." + SLEEP="${1:-0.1}" setup run_tests @@ -178,4 +178,4 @@ main() { echo "All OK" } -main +main "$@"