-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
run-gnu-test.sh
executable file
·89 lines (72 loc) · 3.49 KB
/
run-gnu-test.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env bash
# `run-gnu-test.bash [TEST]`
# run GNU test (or all tests if TEST is missing/null)
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE ; (utils) shellcheck gnproc greadlink
# ref: [How the GNU coreutils are tested](https://www.pixelbeat.org/docs/coreutils-testing.html) @@ <https://archive.is/p2ITW>
# * note: to run a single test => `make check TESTS=PATH/TO/TEST/SCRIPT SUBDIRS=. VERBOSE=yes`
# Use GNU version for make, nproc, readlink on *BSD
case "$OSTYPE" in
*bsd*)
MAKE="gmake"
NPROC="gnproc"
READLINK="greadlink"
;;
*)
MAKE="make"
NPROC="nproc"
READLINK="readlink"
;;
esac
ME_dir="$(dirname -- "$("${READLINK}" -fm -- "$0")")"
REPO_main_dir="$(dirname -- "${ME_dir}")"
echo "ME_dir='${ME_dir}'"
echo "REPO_main_dir='${REPO_main_dir}'"
set -e
### * config (from environment with fallback defaults); note: GNU and GNULIB are expected to be sibling repo directories
path_UUTILS=${path_UUTILS:-${REPO_main_dir}}
path_GNU="$("${READLINK}" -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
echo "path_UUTILS='${path_UUTILS}'"
echo "path_GNU='${path_GNU}'"
###
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
export RUST_BACKTRACE=1
if test "$1" != "run-root"; then
if test $# -ge 1; then
# if set, run only the tests passed
SPECIFIC_TESTS=""
for t in "$@"; do
# Construct the full path
full_path="$path_GNU/$t"
# Check if the file exists with .sh, .pl extension or without any extension in the $path_GNU directory
if [ -f "$full_path" ] || [ -f "$full_path.sh" ] || [ -f "$full_path.pl" ]; then
SPECIFIC_TESTS="$SPECIFIC_TESTS $t"
else
echo "Error: Test file $full_path, $full_path.sh, or $full_path.pl does not exist!"
exit 1
fi
done
# trim it
SPECIFIC_TESTS=$(echo "$SPECIFIC_TESTS" | xargs)
echo "Running specific tests: $SPECIFIC_TESTS"
fi
fi
# * timeout used to kill occasionally errant/"stuck" processes (note: 'release' testing takes ~1 hour; 'debug' testing takes ~2.5 hours)
# * `gl_public_submodule_commit=` disables testing for use of a "public" gnulib commit (which will fail when using shallow gnulib checkouts)
# * `srcdir=..` specifies the GNU source directory for tests (fixing failing/confused 'tests/factor/tNN.sh' tests and causing no harm to other tests)
#shellcheck disable=SC2086
if test "$1" != "run-root"; then
# run the regular tests
if test $# -ge 1; then
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check TESTS="$SPECIFIC_TESTS" SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
else
timeout -sKILL 4h "${MAKE}" -j "$("${NPROC}")" check SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" || : # Kill after 4 hours in case something gets stuck in make
fi
else
# in case we would like to run tests requiring root
if test -z "$1" -o "$1" == "run-root"; then
if test -n "$CI"; then
echo "Running check-root to run only root tests"
sudo "${MAKE}" -j "$("${NPROC}")" check-root SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no gl_public_submodule_commit="" srcdir="${path_GNU}" TEST_SUITE_LOG="tests/test-suite-root.log" || :
fi
fi
fi