diff options
author | James Youngman <jay@gnu.org> | 2011-06-19 23:03:10 +0100 |
---|---|---|
committer | James Youngman <jay@gnu.org> | 2011-06-21 10:59:07 +0100 |
commit | 41ebd53039726f59dcfdc82145429e150f6c2a88 (patch) | |
tree | 04f76f0f5fac272c6023754d3fdd7dd2da826573 | |
parent | 3864f6adaf3447d09e86f29cde17f0a5012aa3b3 (diff) | |
download | findutils-41ebd53039726f59dcfdc82145429e150f6c2a88.tar.gz |
Test find -printf %i.
* find/testsuite/test_inode.sh: New test, for find -printf %i.
* find/testsuite/Makefile.am (test_shell_progs): Add test_inode.sh.
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | find/testsuite/Makefile.am | 3 | ||||
-rwxr-xr-x | find/testsuite/test_inode.sh | 51 |
3 files changed, 57 insertions, 1 deletions
@@ -1,5 +1,9 @@ 2011-06-19 James Youngman <jay@gnu.org> + Test find -printf %i. + * find/testsuite/test_inode.sh: New test, for find -printf %i. + * find/testsuite/Makefile.am (test_shell_progs): Add test_inode.sh. + Extract common test code into a sourced file. * find/testsuite/binary_locations.sh: New file, extracting common code from the test scripts. diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index 4f2593b7..b461fb6f 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -246,7 +246,8 @@ find.posix/user-missing.exp EXTRA_DIST_GOLDEN = \ test_escapechars.golden -test_shell_progs = sv-bug-32043.sh test_escapechars.sh test_escape_c.sh +test_shell_progs = sv-bug-32043.sh test_escapechars.sh test_escape_c.sh \ + test_inode.sh EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) $(EXTRA_DIST_GOLDEN) \ $(test_shell_progs) binary_locations.sh diff --git a/find/testsuite/test_inode.sh b/find/testsuite/test_inode.sh new file mode 100755 index 00000000..ed422c8a --- /dev/null +++ b/find/testsuite/test_inode.sh @@ -0,0 +1,51 @@ +#! /bin/sh +# +# Essentially this test verifies that ls -i and find -printf %i produce +# the same output. + +testname="$(basename $0)" + +. "${srcdir}"/binary_locations.sh + +make_canonical() { + sed -e 's/ /_/g' +} + +test_percent_i() { + if "${executable}" "${tmpfile}" -printf '%i_%p\n' | + make_canonical >| "${outfile}"; then + cmp "${outfile}" "${goldfile}" || { + exec >&2 + cat <<EOF +${executable} ${printf_format} produced incorrect output. +Actual output: +$(cat ${outfile}) +Expected output: +$(cat ${goldfile}) +EOF + rm -f "${outfile}" "${goldfile}" "${tmpfile}" + exit 1 + } + fi +} + + + +if tmpfile=$(mktemp); then + if goldfile=$(mktemp); then + ls -i "${tmpfile}" | make_canonical >| "${goldfile}" + + if outfile=$(mktemp); then + for executable in "${oldfind}" "${ftsfind}" + do + test_percent_i + done + rm -f "${outfile}" + fi + rm -f "${goldfile}" + fi + rm -f "${tmpfile}" +fi + + + |