From 79568ec5757eea24ab7e0c432931f09c2f070912 Mon Sep 17 00:00:00 2001 From: James Youngman Date: Sat, 18 Jun 2011 00:50:11 +0100 Subject: [PATCH] Add new test for octal and letter escapes in -printf format. * find/testsuite/test_escapechars.golden: Expected output file. * find/testsuite/Makefile.am (EXTRA_DIST_GOLDEN): New variable; distribute test_escapechars.golden. * find/testsuite/test_escapechars.sh: New test. * find/testsuite/Makefile.am (test_shell_progs): New variable, where we keep the list of shell script tests. Move existing examples from TESTS and add test_escapechars.sh. * find/testsuite/Makefile.am (TESTS): Refer to test_shell_progs. * cfg.mk: allow trailing blanks and space-tab sequences in find/testsuite/test_escapechars.golden. --- ChangeLog | 14 +++++++ cfg.mk | 4 +- find/testsuite/Makefile.am | 10 ++++- find/testsuite/test_escapechars.golden | 13 +++++++ find/testsuite/test_escapechars.sh | 54 ++++++++++++++++++++++++++ 5 files changed, 91 insertions(+), 4 deletions(-) create mode 100644 find/testsuite/test_escapechars.golden create mode 100755 find/testsuite/test_escapechars.sh diff --git a/ChangeLog b/ChangeLog index 15ebc96d..184dcc57 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +2011-06-18 James Youngman + + Add new test for octal and letter escapes in -printf format. + * find/testsuite/test_escapechars.golden: Expected output file. + * find/testsuite/Makefile.am (EXTRA_DIST_GOLDEN): New variable; + distribute test_escapechars.golden. + * find/testsuite/test_escapechars.sh: New test. + * find/testsuite/Makefile.am (test_shell_progs): New variable, + where we keep the list of shell script tests. Move existing + examples from TESTS and add test_escapechars.sh. + * find/testsuite/Makefile.am (TESTS): Refer to test_shell_progs. + * cfg.mk: allow trailing blanks and space-tab sequences in + find/testsuite/test_escapechars.golden. + 2011-06-17 James Youngman Split find's printf-related code into a new file. diff --git a/cfg.mk b/cfg.mk index 121c3372..84f395e5 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 441b7393..dd5a8410 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -242,14 +242,20 @@ find.posix/exec-one.exp \ find.posix/user-empty.exp \ find.posix/user-missing.exp -EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) sv-bug-32043.sh +EXTRA_DIST_GOLDEN = \ + test_escapechars.golden + +test_shell_progs = sv-bug-32043.sh test_escapechars.sh + +EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) $(EXTRA_DIST_GOLDEN) \ + $(test_shell_progs) CLEANFILES = *.log *.sum site.exp site.bak #DIST_SUBDIRS = config -TESTS = sv-bug-32043.sh +TESTS = $(test_shell_progs) checklists: cd $(srcdir) && \ diff --git a/find/testsuite/test_escapechars.golden b/find/testsuite/test_escapechars.golden new file mode 100644 index 00000000..c5cd8ede --- /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 00000000..87fe6798 --- /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