On 01/11/2026 06:07, Collin Funk wrote:
It would be nice to add more mknod test cases, but I haven't decided the best way yet. For 'mkfifo', I am not too concerned about using 'mkfifo' to see if the system supports FIFOs. If 'mkfifo' is actually broken, many other test cases will fail.With character and block devices, that is unlikely. I'm leaning towards using a tiny Perl or Python script to see if a character device or block device can be created. Note that the tests/misc/mknod.sh test is sort of misnamed, since it is testing whether various programs with the --mode option interact correctly with the current umask. -- 8< -- * tests/mkfifo/basic.sh: New file. * tests/local.mk (all_tests): Add the new test. --- tests/local.mk | 1 + tests/mkfifo/basic.sh | 72 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100755 tests/mkfifo/basic.sh diff --git a/tests/local.mk b/tests/local.mk index a8662acb5..fbaaa653f 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -791,6 +791,7 @@ all_tests = \ tests/mkdir/special-1.sh \ tests/mkdir/t-slash.sh \ tests/mkdir/smack-no-root.sh \ + tests/mkfifo/basic.sh \ tests/mv/acl.sh \ tests/mv/atomic.sh \ tests/mv/atomic2.sh \ diff --git a/tests/mkfifo/basic.sh b/tests/mkfifo/basic.sh new file mode 100755 index 000000000..9ac8ac492 --- /dev/null +++ b/tests/mkfifo/basic.sh @@ -0,0 +1,72 @@ +#!/bin/sh +# Basic tests for 'mkfifo'. + +# 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_ mkfifo +getlimits_ + +# Ensure fifos are supported. +mkfifo_or_skip_ fifo + +for mode in '' 600; do + mode_arg="--mode $mode" + test -z "$mode" && mode_arg= + + mkdir -p d1 d2 || framework_failure_ + + # Single non-existent operand. + for name in d1/f1 d2/f1; do + mkfifo $mode_arg $name >out 2>err || fail=1 + compare /dev/null out || fail=1 + compare /dev/null err || fail=1 + if test -n "$mode"; then + test "$(stat --format=%a $name)" = $mode || fail=1 + fi + done + + # Two non-existent operands. + mkfifo $mode_arg d1/f2 d2/f2 >out 2>err || fail=1 + compare /dev/null out || fail=1 + compare /dev/null err || fail=1 + if test -n "$mode"; then + test "$(stat --format=%a d1/f2)" = $mode || fail=1 + test "$(stat --format=%a d2/f2)" = $mode || fail=1 + fi + + # Mix of non-existent operands, existent-operands, + # and one missing its parent. + cat <<EOF >exp-err || framework_failure_ +mkfifo: cannot create fifo 'd1/f1': $EEXIST +mkfifo: cannot create fifo 'd1/f2': $EEXIST +mkfifo: cannot create fifo 'd2/f1': $EEXIST +mkfifo: cannot create fifo 'd2/f2': $EEXIST +mkfifo: cannot create fifo 'missing/f1': $ENOENT +EOF + returns_ 1 mkfifo $mode_arg d1/f1 d2/f3 d1/f2 d2/f1 d2/f2 missing/f1 d1/f3 \ + >out 2>err || fail=1 + compare /dev/null out || fail=1 + compare exp-err err || fail=1 + if test -n "$mode"; then + test "$(stat --format=%a d1/f3)" = $mode || fail=1 + test "$(stat --format=%a d2/f3)" = $mode || fail=1 + fi + + rm -rf d1 d2 || framework_failure_ +done + +Exit $fail
Both these patches look good to me. thanks! Padraig
