Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions util/build-gnu.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,15 @@
#

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

set -e

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

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

# Handle generated factor tests
t_first=00
Expand Down
31 changes: 12 additions & 19 deletions util/run-gnu-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@
# `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
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS OSTYPE MAKEFLAGS; (utils) shellcheck 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
# Use GNU make, readlink on *BSD
MAKE=$(command -v gmake||command -v make)
READLINK=$(command -v greadlink||command -v readlink) # Use our readlink to remove a dependency

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

# Use GNU nproc for *BSD
MAKEFLAGS="${MAKEFLAGS} -j $(${path_GNU}/src/nproc)"
export MAKEFLAGS
###

cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
Expand Down Expand Up @@ -71,7 +64,7 @@ elif [[ "$1" == "run-root" && "$has_selinux_tests" == true ]]; then
if test -n "$CI"; then
echo "Running SELinux tests as root"
# Don't use check-root here as the upstream root tests is hardcoded
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" || :
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" || :
fi
exit 0
elif test "$1" != "run-root" && test "$1" != "run-tty"; then
Expand Down Expand Up @@ -105,20 +98,20 @@ fi
if test "$1" != "run-root" && test "$1" != "run-tty"; 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
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
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
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
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
if test $# -ge 2; then
echo "Running check-root to run only root tests"
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" || :
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" || :
else
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" || :
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" || :
fi
fi
fi
Expand Down
Loading