Imported Upstream version 4.5.14
[platform/upstream/findutils.git] / find / testsuite / test_inode.sh
1 #! /bin/sh
2 #
3 # Essentially this test verifies that ls -i and find -printf %i produce
4 # the same output.
5
6 testname="$(basename $0)"
7
8 . "${srcdir}"/binary_locations.sh
9
10 make_canonical() {
11     sed -e 's/ /_/g'
12 }
13
14 test_percent_i() {
15     if "${executable}" "${tmpfile}" -printf '%i_%p\n' |
16         make_canonical >| "${outfile}"; then
17         cmp "${outfile}" "${goldfile}" || {
18             exec >&2
19             cat <<EOF
20 ${executable} ${printf_format} produced incorrect output.
21 Actual output:
22 $(cat ${outfile})
23 Expected output:
24 $(cat ${goldfile})
25 EOF
26             rm -f "${outfile}" "${goldfile}" "${tmpfile}"
27             exit 1
28         }
29     fi
30 }
31
32
33
34 if tmpfile=$(mktemp); then
35     if goldfile=$(mktemp); then
36         ls -i "${tmpfile}" | make_canonical >| "${goldfile}"
37
38         if outfile=$(mktemp); then
39             for executable in "${oldfind}" "${ftsfind}"
40             do
41                 test_percent_i
42             done
43             rm -f "${outfile}"
44         fi
45         rm -f "${goldfile}"
46     fi
47     rm -f "${tmpfile}"
48 fi
49
50
51