Skip to content

Commit a33c944

Browse files
authored
GnuTests: Reduce GNU deps on BSD (#9644)
Co-authored-by: oech3 <>
1 parent f9ac29d commit a33c944

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

util/build-gnu.sh

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@
33
#
44

55
# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW
6-
# spell-checker:ignore baddecode submodules xstrtol distros ; (vars/env) SRCDIR vdir rcexp xpart dired OSTYPE ; (utils) gnproc greadlink gsed multihardlink texinfo CARGOFLAGS
6+
# spell-checker:ignore baddecode submodules xstrtol distros ; (vars/env) SRCDIR vdir rcexp xpart dired OSTYPE ; (utils) greadlink gsed multihardlink texinfo CARGOFLAGS
77
# spell-checker:ignore openat TOCTOU CFLAGS
88
# spell-checker:ignore hfsplus casefold chattr
99

1010
set -e
1111

12-
# Use system's GNU version for make, nproc, readlink and sed on *BSD and macOS
12+
# Use GNU make, readlink and sed on *BSD and macOS
1313
MAKE=$(command -v gmake||command -v make)
14-
NPROC=$(command -v gnproc||command -v nproc)
15-
READLINK=$(command -v greadlink||command -v readlink)
14+
READLINK=$(command -v greadlink||command -v readlink) # Use our readlink to remove a dependency
1615
SED=$(command -v gsed||command -v sed)
1716

1817
SYSTEM_TIMEOUT=$(command -v timeout)
@@ -141,7 +140,8 @@ else
141140
"${SED}" -i 's|^"\$@|'"${SYSTEM_TIMEOUT}"' 600 "\$@|' build-aux/test-driver
142141
# Use a better diff
143142
"${SED}" -i 's|diff -c|diff -u|g' tests/Coreutils.pm
144-
"${MAKE}" -j "$("${NPROC}")"
143+
# Use our nproc for *BSD and macOS
144+
"${MAKE}" -j "$("${UU_BUILD_DIR}/nproc")"
145145

146146
# Handle generated factor tests
147147
t_first=00

util/run-gnu-test.sh

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,14 @@
22
# `run-gnu-test.bash [TEST]`
33
# run GNU test (or all tests if TEST is missing/null)
44

5-
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE ; (utils) shellcheck gnproc greadlink
5+
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE MAKEFLAGS; (utils) shellcheck greadlink
66

77
# ref: [How the GNU coreutils are tested](https://www.pixelbeat.org/docs/coreutils-testing.html) @@ <https://archive.is/p2ITW>
88
# * note: to run a single test => `make check TESTS=PATH/TO/TEST/SCRIPT SUBDIRS=. VERBOSE=yes`
99

10-
# Use GNU version for make, nproc, readlink on *BSD
11-
case "$OSTYPE" in
12-
*bsd*)
13-
MAKE="gmake"
14-
NPROC="gnproc"
15-
READLINK="greadlink"
16-
;;
17-
*)
18-
MAKE="make"
19-
NPROC="nproc"
20-
READLINK="readlink"
21-
;;
22-
esac
10+
# Use GNU make, readlink on *BSD
11+
MAKE=$(command -v gmake||command -v make)
12+
READLINK=$(command -v greadlink||command -v readlink) # Use our readlink to remove a dependency
2313

2414
ME_dir="$(dirname -- "$("${READLINK}" -fm -- "$0")")"
2515
REPO_main_dir="$(dirname -- "${ME_dir}")"
@@ -37,6 +27,9 @@ path_GNU="$("${READLINK}" -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
3727
echo "path_UUTILS='${path_UUTILS}'"
3828
echo "path_GNU='${path_GNU}'"
3929

30+
# Use GNU nproc for *BSD
31+
MAKEFLAGS="${MAKEFLAGS} -j $(${path_GNU}/src/nproc)"
32+
export MAKEFLAGS
4033
###
4134

4235
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
@@ -71,7 +64,7 @@ elif [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
7164
if test -n "$CI"; then
7265
echo "Running SELinux tests as root"
7366
# Don't use check-root here as the upstream root tests is hardcoded
74-
sudo "${MAKE}" -j "$("${NPROC}")" check TESTS="$*" 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" || :
67+
sudo "${MAKE}" check TESTS="$*" 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" || :
7568
fi
7669
exit 0
7770
elif test "$1" != "run-root" && test "$1" != "run-tty"; then
@@ -105,20 +98,20 @@ fi
10598
if test "$1" != "run-root" && test "$1" != "run-tty"; then
10699
# run the regular tests
107100
if test $# -ge 1; then
108-
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
101+
timeout -sKILL 4h "${MAKE}" 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
109102
else
110-
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
103+
timeout -sKILL 4h "${MAKE}" 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
111104
fi
112105
else
113106
# in case we would like to run tests requiring root
114107
if test -z "$1" -o "$1" == "run-root"; then
115108
if test -n "$CI"; then
116109
if test $# -ge 2; then
117110
echo "Running check-root to run only root tests"
118-
sudo "${MAKE}" -j "$("${NPROC}")" check-root TESTS="$2" 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" || :
111+
sudo "${MAKE}" check-root TESTS="$2" 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" || :
119112
else
120113
echo "Running check-root to run only root tests"
121-
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" || :
114+
sudo "${MAKE}" 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" || :
122115
fi
123116
fi
124117
fi

0 commit comments

Comments
 (0)