summaryrefslogtreecommitdiffstats
path: root/tests/install
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:46:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-05 18:46:38 +0000
commita06ac93dcf311dac3943cb5d96ad47625d413c2d (patch)
tree6efda5e24896e7920ccac1f97aecc73406525040 /tests/install
parentInitial commit. (diff)
downloadcoreutils-upstream.tar.xz
coreutils-upstream.zip
Adding upstream version 8.30.upstream/8.30upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/install')
-rwxr-xr-xtests/install/basic-1.sh151
-rwxr-xr-xtests/install/create-leading.sh42
-rwxr-xr-xtests/install/d-slashdot.sh29
-rwxr-xr-xtests/install/install-C-root.sh77
-rwxr-xr-xtests/install/install-C-selinux.sh51
-rwxr-xr-xtests/install/install-C.sh115
-rwxr-xr-xtests/install/install-Z-selinux.sh57
-rwxr-xr-xtests/install/strip-program.sh40
-rwxr-xr-xtests/install/trap.sh33
9 files changed, 595 insertions, 0 deletions
diff --git a/tests/install/basic-1.sh b/tests/install/basic-1.sh
new file mode 100755
index 0000000..4a207be
--- /dev/null
+++ b/tests/install/basic-1.sh
@@ -0,0 +1,151 @@
+#!/bin/sh
+# Basic tests for "install".
+
+# Copyright (C) 1998-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+skip_if_root_
+
+dir=dir
+file=file
+
+rm -rf $dir $file || framework_failure_
+mkdir -p $dir || framework_failure_
+echo foo > $file || framework_failure_
+
+ginstall $file $dir || fail=1
+# Make sure the source file still exists.
+test -f $file || fail=1
+# Make sure the dest file has been created.
+test -f $dir/$file || fail=1
+
+# Make sure strip works.
+dd=dd$EXEEXT
+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."
+
+cp "$just_built_dd" . || fail=1
+cp $dd $dd2 || fail=1
+
+strip=-s
+if ! strip $dd2; then
+ ! test -e $abs_top_builddir/src/coreutils \
+ && warn_ "WARNING!!! Your strip command doesn't seem to work,
+so skipping the test of install's --strip option."
+ strip=
+fi
+
+# This test would fail with 3.16s when using versions of strip that
+# don't work on read-only files (the one from binutils works fine).
+ginstall $strip -c -m 555 $dd $dir || fail=1
+# Make sure the source file is still around.
+test -f $dd || fail=1
+
+# Make sure that the destination file has the requested permissions.
+mode=$(ls -l $dir/$dd|cut -b-10)
+test "$mode" = -r-xr-xr-x || fail=1
+
+# These failed in coreutils CVS from 2004-06-25 to 2004-08-11.
+ginstall -d . || fail=1
+ginstall -d newdir || fail=1
+test -d newdir || fail=1
+ginstall -d newdir1 newdir2 newdir3 || fail=1
+test -d newdir1 || fail=1
+test -d newdir2 || fail=1
+test -d newdir3 || fail=1
+
+# This fails because mkdir-p.c's make_dir_parents fails to return to its
+# initial working directory ($iwd) after creating the first argument, and
+# hence cannot do anything meaningful with the following relative-named dirs.
+iwd=$(pwd)
+mkdir sub || fail=1
+(cd sub &&
+ chmod 0 . &&
+ returns_ 1 ginstall -d "$iwd/xx/yy" rel/sub1 rel/sub2 2> /dev/null
+) || fail=1
+chmod 755 sub
+
+# Ensure that the first argument-dir has been created.
+test -d xx/yy || fail=1
+
+# Make sure that the 'rel' directory was not created...
+test -d sub/rel && fail=1
+# and make sure it was not created in the wrong place.
+test -d xx/rel && fail=1
+
+# Test that we can install from an unreadable directory with an
+# inaccessible parent. coreutils 5.97 fails this test.
+# Perform this test only if "." is on a local file system.
+# Otherwise, it would fail e.g., on an NFS-mounted file system.
+if is_local_dir_ .; then
+ mkdir -p sub1/d || fail=1
+ (cd sub1/d && chmod a-r . && chmod a-rx .. &&
+ ginstall -d "$iwd/xx/zz" rel/a rel/b) || fail=1
+ chmod 755 sub1 sub1/d || fail=1
+ test -d xx/zz || fail=1
+ test -d sub1/d/rel/a || fail=1
+ test -d sub1/d/rel/b || fail=1
+fi
+
+touch file || fail=1
+ginstall -Dv file sub3/a/b/c/file >out 2>&1 || fail=1
+compare - out <<\EOF || fail=1
+ginstall: creating directory 'sub3'
+ginstall: creating directory 'sub3/a'
+ginstall: creating directory 'sub3/a/b'
+ginstall: creating directory 'sub3/a/b/c'
+'file' -> 'sub3/a/b/c/file'
+EOF
+
+# Test -D together with -t (available since coreutils >= 8.23).
+# Let ginstall create a completely new destination hierarchy.
+ginstall -t sub4/a/b/c -Dv file >out 2>&1 || fail=1
+compare - out <<\EOF || fail=1
+ginstall: creating directory 'sub4'
+ginstall: creating directory 'sub4/a'
+ginstall: creating directory 'sub4/a/b'
+ginstall: creating directory 'sub4/a/b/c'
+'file' -> 'sub4/a/b/c/file'
+EOF
+
+# Ensure that -D with an already existing file as -t's option argument fails.
+touch sub4/file_exists || framework_failure_
+ginstall -t sub4/file_exists -Dv file >out 2>&1 && fail=1
+compare - out <<\EOF || fail=1
+ginstall: target 'sub4/file_exists' is not a directory
+EOF
+
+# Ensure that -D with an already existing directory for -t's option argument
+# succeeds.
+mkdir sub4/dir_exists || framework_failure_
+touch sub4/dir_exists || framework_failure_
+ginstall -t sub4/dir_exists -Dv file >out 2>&1 || fail=1
+compare - out <<\EOF || fail=1
+'file' -> 'sub4/dir_exists/file'
+EOF
+
+# Ensure omitted directories are diagnosed
+returns_ 1 ginstall . . 2>err || fail=1
+printf '%s\n' "ginstall: omitting directory '.'" >exp || framework_failure_
+compare exp err || fail=1
+
+Exit $fail
diff --git a/tests/install/create-leading.sh b/tests/install/create-leading.sh
new file mode 100755
index 0000000..5a5e891
--- /dev/null
+++ b/tests/install/create-leading.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# Test -D option.
+
+# Copyright (C) 2000-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# Note that the tests below use 'ginstall', not install, because
+# that's the name of the binary in ../../src.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+
+
+file=file
+echo foo > $file || framework_failure_
+
+# Before 4.0q, this would mistakenly create $file, not 'dest'
+# in no-dir1/no-dir2/.
+ginstall -D $file no-dir1/no-dir2/dest || fail=1
+test -d no-dir1/no-dir2 || fail=1
+test -r no-dir1/no-dir2/dest || fail=1
+
+# Between 6.1 and 8.24, this would not copy $file
+# due to incorrectly modified working directory
+mkdir dir1 || framework_failure_
+touch dir1/file1 || framework_failure_
+ginstall -D "$PWD/dir1/file1" $file -t "$PWD/no-dir2/" || fail=1
+test -r no-dir2/$file && test -r no-dir2/file1 || fail=1
+
+Exit $fail
diff --git a/tests/install/d-slashdot.sh b/tests/install/d-slashdot.sh
new file mode 100755
index 0000000..b92c055
--- /dev/null
+++ b/tests/install/d-slashdot.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+# Ensure that ginstall -d works with arguments specified with a trailing "/.".
+
+# Copyright (C) 2005-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+
+
+ginstall -d d1/. || fail=1
+test -d d1 || fail=1
+
+ginstall -d d2/.. || fail=1
+test -d d2 || fail=1
+
+Exit $fail
diff --git a/tests/install/install-C-root.sh b/tests/install/install-C-root.sh
new file mode 100755
index 0000000..9bff62e
--- /dev/null
+++ b/tests/install/install-C-root.sh
@@ -0,0 +1,77 @@
+#!/bin/sh
+# Ensure "install -C" compares owner and group.
+
+# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+require_root_
+skip_if_setgid_
+skip_if_nondefault_group_
+
+u1=1
+u2=2
+g1=1
+g2=2
+
+
+echo test > a || framework_failure_
+echo "'a' -> 'b'" > out_installed_first
+echo "removed 'b'
+'a' -> 'b'" > out_installed_second
+> out_empty
+
+# destination file does not exist
+ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
+compare out out_installed_first || fail=1
+
+# destination file exists
+ginstall -Cv -o$u1 -g$g1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but -C is not given
+ginstall -v -o$u1 -g$g1 a b > out || fail=1
+compare out out_installed_second || fail=1
+
+# destination file exists but owner differs
+ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -o$u2 -g$g1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but group differs
+ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -o$u2 -g$g2 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but owner differs from getuid ()
+ginstall -Cv -o$u2 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but group differs from getgid ()
+ginstall -Cv -g$g2 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv a b > out || fail=1
+compare out out_empty || fail=1
+
+Exit $fail
diff --git a/tests/install/install-C-selinux.sh b/tests/install/install-C-selinux.sh
new file mode 100755
index 0000000..de9aeef
--- /dev/null
+++ b/tests/install/install-C-selinux.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+# Ensure "install -C" compares SELinux context.
+
+# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+require_selinux_
+skip_if_nondefault_group_
+
+echo test > a || framework_failure_
+chcon -u system_u a || skip_ "chcon doesn't work"
+
+echo "'a' -> 'b'" > out_installed_first
+echo "removed 'b'
+'a' -> 'b'" > out_installed_second
+> out_empty
+
+# destination file does not exist
+ginstall -Cv --preserve-context a b > out || fail=1
+compare out out_installed_first || fail=1
+
+# destination file exists
+ginstall -Cv --preserve-context a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but -C is not given
+ginstall -v --preserve-context a b > out || fail=1
+compare out out_installed_second || fail=1
+
+# destination file exists but SELinux context differs
+chcon -u unconfined_u a || skip_ "chcon doesn't work"
+ginstall -Cv --preserve-context a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv --preserve-context a b > out || fail=1
+compare out out_empty || fail=1
+
+Exit $fail
diff --git a/tests/install/install-C.sh b/tests/install/install-C.sh
new file mode 100755
index 0000000..4486996
--- /dev/null
+++ b/tests/install/install-C.sh
@@ -0,0 +1,115 @@
+#!/bin/sh
+# Ensure "install -C" works. (basic tests)
+
+# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+skip_if_setgid_
+skip_if_nondefault_group_
+
+# Note if a group is not specified, install(1) will assume that a file
+# would be installed with the current user's group ID, and thus if the
+# file is the same except that it does have a different group due to
+# its parent directory being g+s for example, then the copy will be
+# done again redundantly in a futile attempt to reset the group ID to
+# that of the current user.
+#
+# install -d -g wheel -m 2775 test # Create setgid dir
+# touch test/a # Create source
+# install -Cv -m664 test/a test/i1 # install source with mode
+# install -Cv -m664 test/i1 test/i2 # install dest
+# install -Cv -m664 test/i1 test/i2 # again to see redundant install
+#
+# Similarly if an existing file exists that is the same and has the
+# current users group ID, but when an actual install of the file would
+# reset to a different group ID due to the directory being g+s for example,
+# then the install will not be done when it should.
+#
+# install -Cv -m664 -g "$(id -nrg)" test/i1 test/i2 # set i2 to uesr's gid
+# install -Cv -m664 test/i1 test/i2 # this should install but doesn't
+#
+# Therefore we skip the test in the presence of setgid dirs
+# An additional complication on HFS is that it...
+
+mode1=0644
+mode2=0755
+mode3=2755
+
+
+echo test > a || framework_failure_
+echo "'a' -> 'b'" > out_installed_first || framework_failure_
+echo "removed 'b'
+'a' -> 'b'" > out_installed_second || framework_failure_
+> out_empty || framework_failure_
+
+# destination file does not exist
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_installed_first || fail=1
+
+# destination file exists
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists (long option)
+ginstall -v --compare -m$mode1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but -C is not given
+ginstall -v -m$mode1 a b > out || fail=1
+compare out out_installed_second || fail=1
+
+# option -C ignored if any non-permission mode should be set
+ginstall -Cv -m$mode3 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -m$mode3 a b > out || fail=1
+compare out out_installed_second || fail=1
+
+# files are not regular files
+ln -s a c || framework_failure_
+ln -s b d || framework_failure_
+ginstall -Cv -m$mode1 c d > out || fail=1
+echo "removed 'd'
+'c' -> 'd'" > out_installed_second_cd
+compare out out_installed_second_cd || fail=1
+
+# destination file exists but content differs
+echo test1 > a || framework_failure_
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but content differs (same size)
+echo test2 > a || framework_failure_
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -m$mode1 a b > out || fail=1
+compare out out_empty || fail=1
+
+# destination file exists but mode differs
+ginstall -Cv -m$mode2 a b > out || fail=1
+compare out out_installed_second || fail=1
+ginstall -Cv -m$mode2 a b > out || fail=1
+compare out out_empty || fail=1
+
+# options -C and --preserve-timestamps are mutually exclusive
+returns_ 1 ginstall -C --preserve-timestamps a b || fail=1
+
+# options -C and --strip are mutually exclusive
+returns_ 1 ginstall -C --strip --strip-program=echo a b || fail=1
+
+Exit $fail
diff --git a/tests/install/install-Z-selinux.sh b/tests/install/install-Z-selinux.sh
new file mode 100755
index 0000000..d0086f5
--- /dev/null
+++ b/tests/install/install-Z-selinux.sh
@@ -0,0 +1,57 @@
+#!/bin/sh
+# test 'install -Z -D' and 'install -Z -d'
+# based on tests/mkdir/restorecon.sh
+
+# Copyright (C) 2013-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+require_selinux_
+
+mkdir subdir || framework_failure_
+ctx='root:object_r:tmp_t'
+mls_enabled_ && ctx="$ctx:s0"
+chcon "$ctx" subdir || skip "Failed to set context: $ctx"
+cd subdir
+
+# Since in a tmp_t dir, dirs can be created as user_tmp_t ...
+touch standard || framework_failure_
+mkdir restored || framework_failure_
+if restorecon restored 2>/dev/null; then
+ # ... but when restored can be set to user_home_t
+ # So ensure the type for these mkdir -Z cases matches
+ # the directory type as set by restorecon.
+ ginstall -Z standard single || fail=1
+ ginstall -Z -d single_d || fail=1
+ # Run these as separate processes in case global context
+ # set for an arg, impacts on another arg
+ # TODO: Have the defaultcon() vary over these directories
+ for dst in single_d/existing/file multi/ple/file; do
+ ginstall -Z -D standard "$dst" || fail=1
+ done
+ restored_type=$(get_selinux_type 'restored')
+ test "$(get_selinux_type 'single')" = "$restored_type" || fail=1
+ test "$(get_selinux_type 'single_d')" = "$restored_type" || fail=1
+ test "$(get_selinux_type 'single_d/existing')" = "$restored_type" || fail=1
+ test "$(get_selinux_type 'multi')" = "$restored_type" || fail=1
+ test "$(get_selinux_type 'multi/ple')" = "$restored_type" || fail=1
+fi
+if test "$fail" = '1'; then
+ ls -UZd standard restored
+ ls -UZd single single_d single_d/existing multi multi/ple
+fi
+
+Exit $fail
diff --git a/tests/install/strip-program.sh b/tests/install/strip-program.sh
new file mode 100755
index 0000000..f525639
--- /dev/null
+++ b/tests/install/strip-program.sh
@@ -0,0 +1,40 @@
+#!/bin/sh
+# Ensure "install -s --strip-program=PROGRAM" uses the program to strip
+
+# Copyright (C) 2008-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+
+working_umask_or_skip_
+
+cat <<EOF > b || framework_failure_
+#!$SHELL
+sed s/b/B/ \$1 > \$1.t && mv \$1.t \$1
+EOF
+chmod a+x b || framework_failure_
+
+
+echo abc > src || framework_failure_
+echo aBc > exp || framework_failure_
+ginstall src dest -s --strip-program=./b || fail=1
+compare exp dest || fail=1
+
+# Check that install cleans up properly if strip fails.
+returns_ 1 ginstall src dest2 -s --strip-program=./FOO || fail=1
+test -e dest2 && fail=1
+
+Exit $fail
diff --git a/tests/install/trap.sh b/tests/install/trap.sh
new file mode 100755
index 0000000..527d8c4
--- /dev/null
+++ b/tests/install/trap.sh
@@ -0,0 +1,33 @@
+#!/bin/sh
+# Ensure that 'install -s' doesn't infloop when its parent
+# process traps CHLD signal.
+
+# Copyright (C) 2004-2018 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
+print_ver_ ginstall
+require_trap_signame_
+
+
+# Use a subshell and an exec to work around a bug in FreeBSD 5.0 /bin/sh.
+(
+ trap '' CHLD
+
+ # Before 2004-04-21, install would infloop, in the 'while (wait...' loop:
+ exec ginstall -s "$abs_top_builddir/src/ginstall$EXEEXT" .
+)
+
+Exit $fail