>From 1cc45855e54b98ff5a24434999644964881e0071 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 9 Jan 2019 00:24:34 +0100 Subject: [PATCH 05/12] tests: migrate 'printf_escape_c' to the new testsuite * find/testsuite/test_escape_c.sh: Move to ... * tests/find/printf_escape_c.sh: ... this, and apply the above. Simplify. * find/testsuite/Makefile.am (tests_shell_progs): Remove the reference to this test ... * tests/local.mk (all_tests): .. and add it here. --- find/testsuite/Makefile.am | 1 - .../find/printf_escape_c.sh | 54 ++++++++----------- tests/local.mk | 1 + 3 files changed, 24 insertions(+), 32 deletions(-) rename find/testsuite/test_escape_c.sh => tests/find/printf_escape_c.sh (51%) diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index a5861f53..afb3e8e3 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -252,7 +252,6 @@ find.posix/user-empty.exp \ find.posix/user-missing.exp test_shell_progs = \ -test_escape_c.sh \ test_inode.sh \ test_type-list.sh \ sv-34976-execdir-fd-leak.sh \ diff --git a/find/testsuite/test_escape_c.sh b/tests/find/printf_escape_c.sh similarity index 51% rename from find/testsuite/test_escape_c.sh rename to tests/find/printf_escape_c.sh index f18a31be..26509c7a 100755 --- a/find/testsuite/test_escape_c.sh +++ b/tests/find/printf_escape_c.sh @@ -1,43 +1,35 @@ -#! /bin/sh +#!/bin/sh +# Test -printf with the \c escape character. + # Copyright (C) 2011-2019 Free Software Foundation, Inc. -# + # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. -# + # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# + # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# - -testname="$(basename $0)" - -. "${srcdir}"/binary_locations.sh - -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 + +. "${srcdir=.}/tests/init.sh" +print_ver_ find oldfind + +echo 'hello^.^world' > exp || framework_failure_ + +for executable in oldfind find; do + rm -f out || framework_failure_ + $executable . -maxdepth 0 \ + -printf 'hello^\cthere' \ + -exec printf %s {} \; \ + -printf '^world\n' \ + > out || fail=1 + + compare exp out || fail=1 done + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index d5e88081..5a8315ff 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -107,6 +107,7 @@ all_tests = \ tests/find/many-dir-entries-vs-OOM.sh \ tests/find/name-lbracket-literal.sh \ tests/find/printf_escapechars.sh \ + tests/find/printf_escape_c.sh \ $(all_root_tests) $(TEST_LOGS): $(PROGRAMS) -- 2.20.1