bug-findutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 3/3] Test find -printf %i.


From: James Youngman
Subject: [PATCH 3/3] Test find -printf %i.
Date: Sun, 19 Jun 2011 23:16:06 +0100

* find/testsuite/test_inode.sh: New test, for find -printf %i.
* find/testsuite/Makefile.am (test_shell_progs): Add test_inode.sh.
---
 ChangeLog                    |    4 +++
 find/testsuite/Makefile.am   |    3 +-
 find/testsuite/test_inode.sh |   51 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 57 insertions(+), 1 deletions(-)
 create mode 100755 find/testsuite/test_inode.sh

diff --git a/ChangeLog b/ChangeLog
index 56a3a30..548711f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2011-06-19  James Youngman  <address@hidden>
 
+       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 4f2593b..b461fb6 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 0000000..ed422c8
--- /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
+
+
+
-- 
1.7.2.5




reply via email to

[Prev in Thread] Current Thread [Next in Thread]