]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
tests: install: check the behavior when standard input is the source master
authorCollin Funk <collin.funk1@gmail.com>
Fri, 22 May 2026 06:15:43 +0000 (23:15 -0700)
committerCollin Funk <collin.funk1@gmail.com>
Fri, 22 May 2026 06:15:43 +0000 (23:15 -0700)
* tests/install/stdin.sh: New file.
* tests/local.mk: Add the new test.

tests/install/stdin.sh [new file with mode: 0755]
tests/local.mk

diff --git a/tests/install/stdin.sh b/tests/install/stdin.sh
new file mode 100755 (executable)
index 0000000..4ee8a85
--- /dev/null
@@ -0,0 +1,58 @@
+#!/bin/sh
+# Test 'install' when the source is standard input.
+
+# Copyright (C) 2026 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
+
+# work around a dash bug when redirecting
+# from symlinked ttys in the background
+tty=$(readlink -f /dev/stdin)
+
+test -r "$tty" 2>&1 \
+  || skip_ '/dev/stdin is not readable'
+
+echo a >a || framework_failure_
+echo b >b || framework_failure_
+
+# Test the behavior when the source is a pipe and the destination does
+# not exist.
+cat a | ginstall /dev/stdin file1 >out 2>err || fail=1
+compare a file1 || fail=1
+compare /dev/null out || fail=1
+compare /dev/null err || fail=1
+
+# Test the behavior when the source is a file and the destination does
+# not exist.
+ginstall /dev/stdin file2 <b >out 2>err || fail=1
+compare b file2 || fail=1
+compare /dev/null out || fail=1
+compare /dev/null err || fail=1
+
+# Test the behavior when the source is a file and the destination exists.
+ginstall /dev/stdin file1 <file2 >out 2>err || fail=1
+compare b file1 || fail=1
+compare /dev/null out || fail=1
+compare /dev/null err || fail=1
+
+# Test the behavior when the source is a pipe and the destination exists.
+cat b | ginstall /dev/stdin file1 >out 2>err || fail=1
+compare b file1 || fail=1
+compare /dev/null out || fail=1
+compare /dev/null err || fail=1
+
+Exit $fail
index 7712837bc15236a4aac8700afe6c1e791e09522d..cc7e20a46635ad205b66f43d59568da80801c2cd 100644 (file)
@@ -679,6 +679,7 @@ all_tests =                                 \
   tests/install/install-C.sh                   \
   tests/install/install-C-selinux.sh           \
   tests/install/install-Z-selinux.sh           \
+  tests/install/stdin.sh                       \
   tests/install/strip-program.sh               \
   tests/install/trap.sh                                \
   tests/ln/backup-1.sh                         \