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