mirror of
https://github.com/coreutils/coreutils.git
synced 2026-10-28 09:44:34 +08:00
tests: avoid use of $abs_top_builddir where possible
* init.cfg (single_binary_build_): An abstraction to check if the current build is a functional --enable-single-binary build. (require_safe_builddir_): Also add an abstraction to check for whitespace in $abs_top_builddir. * tests/misc/proc-self-comm.sh: Just warn about a non functional dispatch binary. * tests/install/basic-1.sh: Use the abstraction which is more accurate when a stub src/coreutils binary is present. Also fix up an incorrect skip_ edge case. * tests/misc/responsive.sh: Use require_safe_builddir_. * tests/misc/stdbuf.sh: Likewise. * tests/misc/exec-bad-unicode.sh: Clarify a comment.
This commit is contained in:
1 parent
54e1938105
commit
ad7e743cff
6 files changed
+33
-28
No files matched your search
@@ -354,6 +354,13 @@ require_built_()
|
||||
test $skip_ = yes && skip_ "required program(s) not built"
|
||||
}
|
||||
|
||||
# Return true if the just-built coreutils can run a built-in program.
|
||||
single_binary_build_()
|
||||
{
|
||||
"$abs_top_builddir/src/coreutils$EXEEXT" --coreutils-prog=true \
|
||||
> /dev/null 2>&1
|
||||
}
|
||||
|
||||
# Return the file for a command.
|
||||
# Warn and fail if not found.
|
||||
cmd_exe()
|
||||
@@ -368,6 +375,18 @@ cmd_exe()
|
||||
{ warn_ "unable to find $1 command"; return 1; }
|
||||
}
|
||||
|
||||
# Skip if whitespace in $abs_top_builddir
|
||||
# as that impacts tokenization in shebangs or LD_PRELOAD for example.
|
||||
require_safe_builddir_()
|
||||
{
|
||||
lf='
|
||||
'
|
||||
case $abs_top_builddir in
|
||||
*[\\\"\#\$\&\'\`$lf\ \ ]*)
|
||||
skip_ "unsafe absolute build directory name: $abs_top_builddir";;
|
||||
esac
|
||||
}
|
||||
|
||||
require_file_system_bytes_free_()
|
||||
{
|
||||
local req=$1
|
||||
|
||||
@@ -54,17 +54,15 @@ dd2=dd2$EXEEXT
|
||||
|
||||
just_built_dd=$abs_top_builddir/src/$dd
|
||||
|
||||
test -r "$just_built_dd" \
|
||||
|| warn_ "WARNING!!! Your just-built dd binary, $just_built_dd
|
||||
is not readable, so skipping the remaining tests in this file."
|
||||
test -r "$just_built_dd" || skip_ "Missing $just_built_dd binary"
|
||||
|
||||
cp "$just_built_dd" . || fail=1
|
||||
cp $dd $dd2 || fail=1
|
||||
cp "$just_built_dd" . &&
|
||||
cp $dd $dd2 || framework_failure_
|
||||
|
||||
strip=-s
|
||||
if ! strip $dd2; then
|
||||
! test -e $abs_top_builddir/src/coreutils \
|
||||
&& warn_ "WARNING!!! Your strip command doesn't seem to work,
|
||||
! single_binary_build_ \
|
||||
&& warn_ "Warning: Your strip command doesn't seem to work,
|
||||
so skipping the test of install's --strip option."
|
||||
strip=
|
||||
fi
|
||||
|
||||
@@ -27,9 +27,10 @@ printf '#!%s\n' "$(cmd_exe echo)" >"$script" ||
|
||||
skip_ 'bad unicode not supported in shell or file system'
|
||||
chmod u+x "$script" || framework_failure_
|
||||
|
||||
# Check that it can be executed, which is not the case if there are
|
||||
# spaces in $abs_top_builddir. Such spaces also preclude stdbuf's
|
||||
# LD_PRELOAD from operating correctly.
|
||||
# Check that it can be executed, which is also not the case if
|
||||
# spaces in the path. Such spaces also preclude stdbuf's
|
||||
# LD_PRELOAD from operating correctly. This is a more direct
|
||||
# check than using require_safe_builddir_.
|
||||
./"$script" "$script" >exp \
|
||||
|| skip_ 'cannot execute a file name with invalid unicode'
|
||||
|
||||
|
||||
@@ -24,13 +24,10 @@ test -f /proc/self/comm || skip_ '/proc/self/comm is required'
|
||||
# Set up variables to execute 'cat' from its absolute path and,
|
||||
# if available, through the single binary.
|
||||
abs_cat=$(cmd_exe cat) || framework_failure_
|
||||
single_binary="$abs_top_builddir/src/coreutils$EXEEXT"
|
||||
single_binary=$(cmd_exe coreutils)
|
||||
|
||||
if ! test -x "$single_binary"; then
|
||||
single_binary=
|
||||
elif test -n "$single_binary" &&
|
||||
! "$single_binary" --coreutils-prog=cat /dev/null 2>err; then
|
||||
grep "^coreutils: unknown program 'cat'$" err || framework_failure_
|
||||
if test -n "$single_binary" && ! single_binary_build_; then
|
||||
warn_ "Warning: ignoring single binary dispatcher: $single_binary"
|
||||
single_binary=
|
||||
fi
|
||||
|
||||
|
||||
@@ -21,12 +21,7 @@ print_ver_ stdbuf
|
||||
|
||||
# stdbuf fails when the absolute top build dir name contains e.g.,
|
||||
# space, TAB, NL
|
||||
lf='
|
||||
'
|
||||
case $abs_top_builddir in
|
||||
*[\\\"\#\$\&\'\`$lf\ \ ]*)
|
||||
skip_ "unsafe absolute build directory name: $abs_top_builddir";;
|
||||
esac
|
||||
require_safe_builddir_
|
||||
|
||||
stdbuf -oL true || skip_ 'stdbuf not supported'
|
||||
|
||||
|
||||
@@ -23,12 +23,7 @@ getlimits_
|
||||
|
||||
# stdbuf fails when the absolute top build dir name contains e.g.,
|
||||
# space, TAB, NL
|
||||
lf='
|
||||
'
|
||||
case $abs_top_builddir in
|
||||
*[\\\"\#\$\&\'\`$lf\ \ ]*)
|
||||
skip_ "unsafe absolute build directory name: $abs_top_builddir";;
|
||||
esac
|
||||
require_safe_builddir_
|
||||
|
||||
# Use a fifo rather than a pipe in the tests below
|
||||
# so that the producer (uniq) will wait until the
|
||||
|
||||
Reference in new issue
Block a user