Blame tests/brief-vs-stat-zero-kernel-lies

Packit Service fdd496
#!/bin/sh
Packit Service fdd496
# Before diff-3.4, diff --brief could mistakenly declare a difference.
Packit Service fdd496
# For example, when comparing a file like /proc/cmdline (for which the linux
Packit Service fdd496
# kernel reports a st_size of 0 even though it is not an empty file) to a
Packit Service fdd496
# copy of that file's contents residing on a "normal" file system.
Packit Service fdd496
Packit Service fdd496
. "${srcdir=.}/init.sh"; path_prepend_ ../src
Packit Service fdd496
Packit Service fdd496
fail=0
Packit Service fdd496
Packit Service fdd496
# Skip the test unless we have an appropriate file.
Packit Service fdd496
boot=/proc/cmdline
Packit Service fdd496
test -r $boot || skip_ no $boot file
Packit Service fdd496
sz=$(stat --format %s $boot) || skip_ stat --format %s does not work
Packit Service fdd496
test $sz = 0 || skip_ $boot has nonzero size
Packit Service fdd496
Packit Service fdd496
# /proc/self is not useful on the Hurd, where it always points to "1",
Packit Service fdd496
# so skip this test when /proc/self does not point to a file whose name is
Packit Service fdd496
# the current process ID.
Packit Service fdd496
readlink /proc/self > pid & pid=$!
Packit Service fdd496
wait $pid
Packit Service fdd496
echo $pid > exp
Packit Service fdd496
compare exp pid || skip_ /proc/self is not useful on this system
Packit Service fdd496
Packit Service fdd496
# There are two code paths to test: one for non-binary and one for binary files.
Packit Service fdd496
# $boot is non-binary.
Packit Service fdd496
cat $boot > ref || framework_failure_
Packit Service fdd496
diff --brief $boot ref > out 2>&1 || fail=1
Packit Service fdd496
compare /dev/null out || fail=1
Packit Service fdd496
Packit Service fdd496
# /proc/self/cmdline is a NUL-terminated list of argv values,
Packit Service fdd496
# so construct the expected output here:
Packit Service fdd496
printf 'diff\0--brief\0/proc/self/cmdline\0bin\0' > bin || framework_failure_
Packit Service fdd496
# And run the command that is embedded in that output:
Packit Service fdd496
diff --brief /proc/self/cmdline bin > out 2>&1 || fail=1
Packit Service fdd496
compare /dev/null out || fail=1
Packit Service fdd496
Packit Service fdd496
Exit $fail