* find/testsuite/Makefile.am (test_shell_progs): New variable, where we keep the list of shell script tests. This avoids needing to remember to update both TESTS and EXTRA_DIST. Add test_escape_c.sh (which is new) and test_escapechars.sh (which we previously forgot). * find/testsuite/test_escape_c.sh: New test for "find -printf \c". --- ChangeLog | 9 +++++++++ find/testsuite/Makefile.am | 7 +++++-- find/testsuite/test_escape_c.sh | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 2 deletions(-) create mode 100755 find/testsuite/test_escape_c.sh
diff --git a/ChangeLog b/ChangeLog index f25ea28..6ca10fc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2011-06-18 James Youngman <[email protected]> + Add a test for "find -printf \c". + * find/testsuite/Makefile.am (test_shell_progs): New variable, + where we keep the list of shell script tests. This avoids needing + to remember to update both TESTS and EXTRA_DIST. Add + test_escape_c.sh (which is new) and test_escapechars.sh (which we + previously forgot). + * find/testsuite/test_escape_c.sh: New test for "find -printf + \c". + Remove an unnecessary argument from insert_fprintf. * find/print.c (insert_fprintf): Eliminate the 'func' argument, since it is always pref_fprintf. diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index 6ca56d5..e944456 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -242,14 +242,17 @@ 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 +test_shell_progs = sv-bug-32043.sh test_escapechars.sh test_escape_c.sh + +EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) \ + $(test_shell_progs) CLEANFILES = *.log *.sum site.exp site.bak #DIST_SUBDIRS = config -TESTS = sv-bug-32043.sh test_escapechars.sh +TESTS = $(test_shell_progs) checklists: cd $(srcdir) && \ diff --git a/find/testsuite/test_escape_c.sh b/find/testsuite/test_escape_c.sh new file mode 100755 index 0000000..50351ea --- /dev/null +++ b/find/testsuite/test_escape_c.sh @@ -0,0 +1,37 @@ +#! /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" +expected='hello^.^world' + +for executable in "$oldfind" "$ftsfind" +do + if result="$($executable . -maxdepth 0 \ + -printf 'hello^\cthere' \ + -exec printf %s {} \; \ + -printf '^world\n' )"; then + if [[ "${result}" != "${expected}" ]]; then + exec >&2 + echo "$executable produced incorrect output:" + echo "${result}" + echo "Expected output was:" + echo "${expected}" + exit 1 + fi + else + echo "$executable returned $?" >&2 + exit 1 + fi +done -- 1.7.2.5
