mirror of
https://github.com/uutils/coreutils
synced 2024-07-21 09:54:42 +00:00
maint/util ~ improve/refactor 'build-gnu' & 'run-gnu-test'
- add more logging for better fault tracking - generalize for use in either RELEASE or DEBUG build mode (default to 'release') - improve variable naming precision/specificity
This commit is contained in:
parent
29679ba337
commit
c2e17e5f37
|
@ -1,48 +1,73 @@
|
|||
#!/bin/bash
|
||||
# `build-gnu.bash` ~ builds GNU coreutils (from supplied sources)
|
||||
#
|
||||
# UU_MAKE_PROFILE == 'debug' | 'release' ## build profile for *uutils* build; may be supplied by caller, defaults to 'debug'
|
||||
|
||||
# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode submodules ; (vars/env) BUILDDIR SRCDIR
|
||||
# spell-checker:ignore (paths) abmon deref discrim eacces getlimits getopt ginstall gnulib inacc infloop inotify reflink ; (misc) INT_OFLOW OFLOW baddecode submodules ; (vars/env) SRCDIR
|
||||
|
||||
set -e
|
||||
if test ! -d ../gnu; then
|
||||
echo "Could not find ../gnu"
|
||||
echo "git clone https://github.com/coreutils/coreutils.git gnu"
|
||||
exit 1
|
||||
fi
|
||||
if test ! -d ../gnulib; then
|
||||
echo "Could not find ../gnulib"
|
||||
echo "git clone https://github.com/coreutils/gnulib.git gnulib"
|
||||
|
||||
ME="${0}"
|
||||
ME_dir="$(dirname -- "$(readlink -fm -- "${ME}")")"
|
||||
REPO_main_dir="$(dirname -- "${ME_dir}")"
|
||||
|
||||
echo "ME='${ME}'"
|
||||
echo "ME_dir='${ME_dir}'"
|
||||
echo "REPO_main_dir='${REPO_main_dir}'"
|
||||
|
||||
### * 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}'"
|
||||
|
||||
###
|
||||
|
||||
if test ! -d "${path_GNU}"; then
|
||||
echo "Could not find GNU (expected at '${path_GNU}')"
|
||||
echo "git clone --recurse-submodules https://github.com/coreutils/coreutils.git \"${path_GNU}\""
|
||||
exit 1
|
||||
fi
|
||||
|
||||
pushd "$PWD"
|
||||
make PROFILE=release
|
||||
BUILDDIR="$PWD/target/release/"
|
||||
cp "${BUILDDIR}/install" "${BUILDDIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
|
||||
###
|
||||
|
||||
UU_MAKE_PROFILE=${UU_MAKE_PROFILE:-release}
|
||||
echo "UU_MAKE_PROFILE='${UU_MAKE_PROFILE}'"
|
||||
|
||||
UU_BUILD_DIR="${path_UUTILS}/target/${UU_MAKE_PROFILE}"
|
||||
echo "UU_BUILD_DIR='${UU_BUILD_DIR}'"
|
||||
|
||||
cd "${path_UUTILS}" && echo "[ pwd:'${PWD}' ]"
|
||||
make PROFILE="${UU_MAKE_PROFILE}"
|
||||
cp "${UU_BUILD_DIR}/install" "${UU_BUILD_DIR}/ginstall" # The GNU tests rename this script before running, to avoid confusion with the make target
|
||||
# Create *sum binaries
|
||||
for sum in b2sum b3sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum; do
|
||||
sum_path="${BUILDDIR}/${sum}"
|
||||
test -f "${sum_path}" || cp "${BUILDDIR}/hashsum" "${sum_path}"
|
||||
for sum in b2sum md5sum sha1sum sha224sum sha256sum sha384sum sha512sum; do
|
||||
sum_path="${UU_BUILD_DIR}/${sum}"
|
||||
test -f "${sum_path}" || cp "${UU_BUILD_DIR}/hashsum" "${sum_path}"
|
||||
done
|
||||
test -f "${BUILDDIR}/[" || cp "${BUILDDIR}/test" "${BUILDDIR}/["
|
||||
popd
|
||||
GNULIB_SRCDIR="$PWD/../gnulib"
|
||||
pushd ../gnu/
|
||||
test -f "${UU_BUILD_DIR}/[" || cp "${UU_BUILD_DIR}/test" "${UU_BUILD_DIR}/["
|
||||
|
||||
##
|
||||
|
||||
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
|
||||
|
||||
# Any binaries that aren't built become `false` so their tests fail
|
||||
for binary in $(./build-aux/gen-lists-of-programs.sh --list-progs); do
|
||||
bin_path="${BUILDDIR}/${binary}"
|
||||
bin_path="${UU_BUILD_DIR}/${binary}"
|
||||
test -f "${bin_path}" || {
|
||||
echo "'${binary}' was not built with uutils, using the 'false' program"
|
||||
cp "${BUILDDIR}/false" "${bin_path}"
|
||||
cp "${UU_BUILD_DIR}/false" "${bin_path}"
|
||||
}
|
||||
done
|
||||
|
||||
./bootstrap --gnulib-srcdir="$GNULIB_SRCDIR"
|
||||
./bootstrap
|
||||
./configure --quiet --disable-gcc-warnings
|
||||
#Add timeout to to protect against hangs
|
||||
sed -i 's|^"\$@|/usr/bin/timeout 600 "\$@|' build-aux/test-driver
|
||||
# Change the PATH in the Makefile to test the uutils coreutils instead of the GNU coreutils
|
||||
sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${BUILDDIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile
|
||||
sed -i "s/^[[:blank:]]*PATH=.*/ PATH='${UU_BUILD_DIR//\//\\/}\$(PATH_SEPARATOR)'\"\$\$PATH\" \\\/" Makefile
|
||||
sed -i 's| tr | /usr/bin/tr |' tests/init.sh
|
||||
make -j "$(nproc)"
|
||||
# Generate the factor tests, so they can be fixed
|
||||
|
@ -112,7 +137,7 @@ sed -i -e "s|rm: cannot remove 'a/1'|rm: cannot remove 'a'|g" tests/rm/rm2.sh
|
|||
|
||||
sed -i -e "s|removed directory 'a/'|removed directory 'a'|g" tests/rm/v-slash.sh
|
||||
|
||||
test -f "${BUILDDIR}/getlimits" || cp src/getlimits "${BUILDDIR}"
|
||||
test -f "${UU_BUILD_DIR}/getlimits" || cp src/getlimits "${UU_BUILD_DIR}"
|
||||
|
||||
# When decoding an invalid base32/64 string, gnu writes everything it was able to decode until
|
||||
# it hit the decode error, while we don't write anything if the input is invalid.
|
||||
|
|
|
@ -1,28 +1,30 @@
|
|||
#!/bin/bash
|
||||
# `$0 [TEST]`
|
||||
#!/bin/sh
|
||||
# `run-gnu-test.bash [TEST]`
|
||||
# run GNU test (or all tests if TEST is missing/null)
|
||||
# spell-checker:ignore (env/vars) GNULIB SUBDIRS ; (utils) shellcheck
|
||||
#
|
||||
# UU_MAKE_PROFILE == 'debug' | 'release' ## build profile used for *uutils* build; may be supplied by caller, defaults to 'debug'
|
||||
|
||||
# spell-checker:ignore (env/vars) GNULIB SRCDIR SUBDIRS ; (utils) shellcheck
|
||||
|
||||
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)
|
||||
### * 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=${path_GNU:-${path_UUTILS}/../gnu}
|
||||
path_GNULIB=${path_GNULIB:-${path_UUTILS}/../gnulib}
|
||||
path_GNU="$(readlink -fm -- "${path_GNU:-${path_UUTILS}/../gnu}")"
|
||||
|
||||
echo "path_UUTILS='${path_UUTILS}'"
|
||||
echo "path_GNU='${path_GNU}'"
|
||||
|
||||
###
|
||||
|
||||
BUILD_DIR="$(realpath -- "${path_UUTILS}/target/release")"
|
||||
GNULIB_DIR="$(realpath -- "${path_GNULIB}")"
|
||||
|
||||
export BUILD_DIR
|
||||
export GNULIB_DIR
|
||||
|
||||
pushd "$(realpath -- "${path_GNU}")"
|
||||
cd "${path_GNU}" && echo "[ pwd:'${PWD}' ]"
|
||||
|
||||
export RUST_BACKTRACE=1
|
||||
|
||||
|
@ -31,5 +33,8 @@ if test -n "$1"; then
|
|||
export RUN_TEST="TESTS=$1"
|
||||
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
|
||||
timeout -sKILL 2h make -j "$(nproc)" check $RUN_TEST SUBDIRS=. RUN_EXPENSIVE_TESTS=yes RUN_VERY_EXPENSIVE_TESTS=yes VERBOSE=no || : # Kill after 4 hours in case something gets stuck in make
|
||||
timeout -sKILL 2h make -j "$(nproc)" check ${RUN_TEST} 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
|
||||
|
|
Loading…
Reference in a new issue