diff --git a/util/build-gnu.sh b/util/build-gnu.sh index 626400d6a57..33b172fa06d 100755 --- a/util/build-gnu.sh +++ b/util/build-gnu.sh @@ -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) @@ -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 diff --git a/util/run-gnu-test.sh b/util/run-gnu-test.sh index 43eb25f66c5..6d0edee5f14 100755 --- a/util/run-gnu-test.sh +++ b/util/run-gnu-test.sh @@ -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) @@ # * 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}")" @@ -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}' ]" @@ -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 @@ -105,9 +98,9 @@ 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 @@ -115,10 +108,10 @@ else 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