>From 8b1bb605439d981b0985c2856512bddb32df0756 Mon Sep 17 00:00:00 2001
From: Bernhard Voelker
Date: Wed, 9 Jan 2019 00:24:34 +0100
Subject: [PATCH 10/12] tests: migrate 'debug-missing-arg' to the new testsuite
* find/testsuite/sv-52220.sh: Move to ...
* tests/find/debug-missing-arg.sh: ... this, and apply the above.
Simplify, and make more robust.
* 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-52220.sh | 62 ---------------------------------
tests/find/debug-missing-arg.sh | 32 +++++++++++++++++
tests/local.mk | 1 +
4 files changed, 33 insertions(+), 63 deletions(-)
delete mode 100755 find/testsuite/sv-52220.sh
create mode 100755 tests/find/debug-missing-arg.sh
diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am
index dad736ff..2169803e 100644
--- a/find/testsuite/Makefile.am
+++ b/find/testsuite/Makefile.am
@@ -253,7 +253,6 @@ find.posix/user-missing.exp
test_shell_progs = \
test_type-list.sh \
-sv-52220.sh
EXTRA_DIST = $(EXTRA_DIST_EXP) $(EXTRA_DIST_XO) \
$(test_shell_progs) binary_locations.sh checklists.py
diff --git a/find/testsuite/sv-52220.sh b/find/testsuite/sv-52220.sh
deleted file mode 100755
index d995c60a..00000000
--- a/find/testsuite/sv-52220.sh
+++ /dev/null
@@ -1,62 +0,0 @@
-#! /bin/sh
-# Copyright (C) 2017-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 .
-#
-#
-# Verify that 'find -D' without further argument outputs an error diagnostic.
-# Between FINDUTILS_4_3_1-1 and 4.6, find crashed on some platforms.
-
-testname="$(basename $0)"
-
-. "${srcdir}"/binary_locations.sh
-
-die() {
- echo "$@" >&2
- exit 1
-}
-
-# This is used to simplify checking of the return value
-# which is useful when ensuring a command fails as desired.
-# I.e., just doing `command ... &&fail=1` will not catch
-# a segfault in command for example. With this helper you
-# instead check an explicit exit code like
-# returns_ 1 command ... || fail
-returns_ () {
- # Disable tracing so it doesn't interfere with stderr of the wrapped command
- { set +x; } 2>/dev/null
-
- local exp_exit="$1"
- shift
- "$@"
- test $? -eq $exp_exit && ret_=0 || ret_=1
-
- set -x
- { return $ret_; } 2>/dev/null
-}
-
-set -x
-
-fail=0
-# Exercise both find executables.
-for exe in "${ftsfind}" "${oldfind}"; do
- e="$(basename "$exe")"
- err="${e}${opt}.err"
- returns_ 1 "$exe" -D >/dev/null 2> "$err" || fail=1
- grep -F "find: Missing argument after the -D option." "$err" \
- || { cat "$err"; fail=1; }
- rm -f "$err" || die "cleanup failed"
-done
-
-exit $fail
diff --git a/tests/find/debug-missing-arg.sh b/tests/find/debug-missing-arg.sh
new file mode 100755
index 00000000..64ed82cd
--- /dev/null
+++ b/tests/find/debug-missing-arg.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# Verify that 'find -D' without further argument outputs an error diagnostic.
+# Between FINDUTILS_4_3_1-1 and 4.6, find crashed on some platforms.
+# See Savannah bug #52220.
+
+# Copyright (C) 2017-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
+
+# Exercise both find executables.
+for exe in find oldfind; do
+ rm -f out err || framework_failure_
+ returns_ 1 "$exe" -D >/dev/null 2> err || fail=1
+ grep -F "find: Missing argument after the -D option." err \
+ || { cat err; fail=1; }
+done
+
+Exit $fail
diff --git a/tests/local.mk b/tests/local.mk
index 01176031..7b82eefd 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -112,6 +112,7 @@ all_tests = \
tests/find/execdir-fd-leak.sh \
tests/find/exec-plus-last-file.sh \
tests/find/refuse-noop.sh \
+ tests/find/debug-missing-arg.sh \
$(all_root_tests)
$(TEST_LOGS): $(PROGRAMS)
--
2.20.1