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

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