>From 77df15aa8b91a3ef4d961ba1b1714cdb03a9fe86 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 9 Jan 2019 00:24:34 +0100 Subject: [PATCH 03/12] tests: migrate 'name-lbracket-literal' to the new testsuite For migrating, merge with the basic structure from 'tests/sample-test', i.e., source in 'tests/init.sh', call 'print_ver_', "Exit $fail", etc. Also remove now-common functions like die() and framework_failure_(). * find/testsuite/sv-bug-32043.sh: Move to ... * tests/find/name-lbracket-literal.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/testsuite/sv-bug-32043.sh | 48 ----------------------------- tests/find/name-lbracket-literal.sh | 33 ++++++++++++++++++++ tests/local.mk | 1 + 4 files changed, 34 insertions(+), 49 deletions(-) delete mode 100755 find/testsuite/sv-bug-32043.sh create mode 100755 tests/find/name-lbracket-literal.sh diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index c0f397ab..1e88c6c3 100644 --- a/find/testsuite/Makefile.am +++ b/find/testsuite/Makefile.am @@ -255,7 +255,6 @@ EXTRA_DIST_GOLDEN = \ test_escapechars.golden test_shell_progs = \ -sv-bug-32043.sh \ test_escapechars.sh \ test_escape_c.sh \ test_inode.sh \ diff --git a/find/testsuite/sv-bug-32043.sh b/find/testsuite/sv-bug-32043.sh deleted file mode 100755 index 8181c3e6..00000000 --- a/find/testsuite/sv-bug-32043.sh +++ /dev/null @@ -1,48 +0,0 @@ -#! /bin/sh -# 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)" - -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 -if tstdir=$(mktemp -d); then - touch "$tstdir/[" - expected="$tstdir/[" - for executable in "$oldfind" "$ftsfind"; do - if result=$("$executable" "$tstdir" -name '[' -print); then - if ! [ "$result" = "$expected" ]; then - echo "FAIL: $testname with $executable returned '$result' but '$expected' was expected" >&2 - exit 1 - fi - else - echo "FAIL: $executable returned $?" >&2 - exit 1 - fi - done - rm -rf "$tstdir" -else - echo "FAIL: could not create a test directory." >&2 - exit 1 -fi diff --git a/tests/find/name-lbracket-literal.sh b/tests/find/name-lbracket-literal.sh new file mode 100755 index 00000000..ac2b0326 --- /dev/null +++ b/tests/find/name-lbracket-literal.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# Test that find -name treats the unquoted '[' argument literally. +# See Savannah bug #32043. + +# 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 . + +. "${srcdir=.}/tests/init.sh" +print_ver_ find oldfind + +# Prepare a file named '['. +touch '[' || framework_failure_ +echo './[' > exp || framework_failure_ + +find -name '[' -print > out || fail=1 +compare exp out || fail=1 + +oldfind -name '[' -print > out2 || fail=1 +compare exp out2 || fail=1 + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 7808a9b3..292ff54f 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -105,6 +105,7 @@ check-root: all_tests = \ tests/misc/help-version.sh \ tests/find/many-dir-entries-vs-OOM.sh \ + tests/find/name-lbracket-literal.sh \ $(all_root_tests) $(TEST_LOGS): $(PROGRAMS) -- 2.20.1