bug-findutils
[Top][All Lists]
Advanced

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

[PATCH 2/8] Add new test for octal and letter escapes in -printf format.


From: James Youngman
Subject: [PATCH 2/8] Add new test for octal and letter escapes in -printf format.
Date: Sat, 18 Jun 2011 15:50:55 +0100

* find/testsuite/test_escapechars.golden: Expected output file.
* find/testsuite/test_escapechars.sh: New test.
* find/testsuite/Makefile.am (TESTS): Add new test
test_escapechars.sh.
---
 ChangeLog                              |   10 ++++++
 cfg.mk                                 |    4 +-
 find/testsuite/Makefile.am             |    2 +-
 find/testsuite/test_escapechars.golden |   13 ++++++++
 find/testsuite/test_escapechars.sh     |   54 ++++++++++++++++++++++++++++++++
 5 files changed, 80 insertions(+), 3 deletions(-)
 create mode 100644 find/testsuite/test_escapechars.golden
 create mode 100755 find/testsuite/test_escapechars.sh

diff --git a/ChangeLog b/ChangeLog
index 51dc96c..2fbe2e9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-06-18  James Youngman  <address@hidden>
+
+       Add new test for octal and letter escapes in -printf format.
+       * find/testsuite/test_escapechars.golden: Expected output file.
+       * find/testsuite/test_escapechars.sh: New test.
+       * find/testsuite/Makefile.am (TESTS): Add new test
+       test_escapechars.sh.
+       * cfg.mk: allow trailing blanks and space-tab sequences in
+       find/testsuite/test_escapechars.golden.
+
 2011-06-17  James Youngman  <address@hidden>
 
        Split find's printf-related code into a new file.
diff --git a/cfg.mk b/cfg.mk
index 121c337..84f395e 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -22,7 +22,7 @@ local-checks-to-skip += sc_error_message_period 
sc_error_message_uppercase \
 
 exclude_file_name_regexp--sc_obsolete_symbols = build-aux/src-sniff\.py
 exclude_file_name_regexp--sc_space_tab = \
-       xargs/testsuite/(inputs/.*\.xi|xargs.(gnu|posix|sysv)/.*\.xo)$$
+       
xargs/testsuite/(inputs/.*\.xi|xargs.(gnu|posix|sysv)/.*\.xo)|find/testsuite/test_escapechars\.golden$$
 
 # Skip sc_two_space_separator_in_usage because it reflects the requirements
 # of help2man.   It gets run on files that are not help2man inputs, and in
@@ -31,7 +31,7 @@ local-checks-to-skip += sc_two_space_separator_in_usage
 
 # Some test inputs/outputs have trailing blanks.
 exclude_file_name_regexp--sc_trailing_blank = \
- 
^COPYING|(po/.*\.po)|(find/testsuite/find.gnu/printf\.xo)|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
+ 
^COPYING|(po/.*\.po)|(find/testsuite/(test_escapechars\.golden|find.gnu/printf\.xo))|(xargs/testsuite/(inputs/.*\.xi|xargs\.(gnu|posix|sysv)/.*\.(x[oe])))$$
 
 exclude_file_name_regexp--sc_prohibit_empty_lines_at_EOF = \
        
^(.*/testsuite/.*\.(xo|xi|xe))|COPYING|doc/regexprops\.texi|m4/order-(bad|good)\.bin$$
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index 441b739..6ca56d5 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -249,7 +249,7 @@ CLEANFILES = *.log *.sum site.exp site.bak
 #DIST_SUBDIRS = config
 
 
-TESTS = sv-bug-32043.sh
+TESTS = sv-bug-32043.sh test_escapechars.sh
 
 checklists:
        cd $(srcdir) && \
diff --git a/find/testsuite/test_escapechars.golden 
b/find/testsuite/test_escapechars.golden
new file mode 100644
index 0000000..c5cd8ed
--- /dev/null
+++ b/find/testsuite/test_escapechars.golden
@@ -0,0 +1,13 @@
+OCTAL1: 
+OCTAL2: 
+OCTAL3: 
+OCTAL4: 4
+OCTAL8: 8
+BEL: 
+CR: 
+FF: 
+TAB:   
+VTAB: 
+BS: 
+BACKSLASH: \
+UNKNOWN: \z
diff --git a/find/testsuite/test_escapechars.sh 
b/find/testsuite/test_escapechars.sh
new file mode 100755
index 0000000..87fe679
--- /dev/null
+++ b/find/testsuite/test_escapechars.sh
@@ -0,0 +1,54 @@
+#! /bin/sh
+testname="$(basename $0)"
+
+parent="$(cd .. && pwd)"
+if [[ -f "${parent}/ftsfind" ]]; then
+    ftsfind="${parent}/ftsfind"
+    oldfind="${parent}/find"
+elif [[ -f "${parent}/oldfind" ]]; then
+    ftsfind="${parent}/find"
+    oldfind="${parent}/oldfind"
+else
+    echo "Cannot find the executables to test." >&2
+    exit 1
+fi
+
+goldenfile="${srcdir}/test_escapechars.golden"
+
+if outfile=$(mktemp); then
+    for executable in "$oldfind" "$ftsfind"
+    do
+        if "$executable" . -maxdepth 0 \
+            -printf 'OCTAL1: \1\n' \
+            -printf 'OCTAL2: \02\n' \
+            -printf 'OCTAL3: \003\n' \
+            -printf 'OCTAL4: \0044\n' \
+            -printf 'OCTAL8: \0028\n' \
+            -printf 'BEL: \a\n' \
+            -printf 'CR: \r\n' \
+            -printf 'FF: \f\n' \
+            -printf 'TAB: \t\n' \
+            -printf 'VTAB: \v\n' \
+            -printf 'BS: \b\n' \
+            -printf 'BACKSLASH: \\\n' \
+            -printf 'UNKNOWN: \z\n' \
+            >| "${outfile}" 2>/dev/null; then
+            if cmp "${outfile}" "${goldenfile}"; then
+                rm "${outfile}"
+            else
+                exec >&2
+                echo "FAIL: $executable produced incorrect output:"
+                od -c "${outfile}"
+                echo "Expected output was:"
+                od -c "${goldenfile}"
+                exit 1
+            fi
+        else
+            echo "FAIL: $executable returned $?" >&2
+            exit 1
+        fi
+    done
+else
+    echo "FAIL: could not create a test output file." >&2
+    exit 1
+fi
-- 
1.7.2.5




reply via email to

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