>From c809ce8fa2743e4b8e5ef979a30d8781d148bac5 Mon Sep 17 00:00:00 2001 From: Bernhard Voelker Date: Wed, 9 Jan 2019 00:24:34 +0100 Subject: [PATCH 06/12] tests: migrate 'printf_inode' to the new testsuite * find/testsuite/test_inode.sh: Move to ... * tests/find/printf_inode.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/test_inode.sh | 62 ------------------------------------ tests/find/printf_inode.sh | 39 +++++++++++++++++++++++ tests/local.mk | 1 + 4 files changed, 40 insertions(+), 63 deletions(-) delete mode 100755 find/testsuite/test_inode.sh create mode 100755 tests/find/printf_inode.sh diff --git a/find/testsuite/Makefile.am b/find/testsuite/Makefile.am index afb3e8e3..1a78eeac 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_inode.sh \ test_type-list.sh \ sv-34976-execdir-fd-leak.sh \ sv-48030-exec-plus-bug.sh \ diff --git a/find/testsuite/test_inode.sh b/find/testsuite/test_inode.sh deleted file mode 100755 index 595e3593..00000000 --- a/find/testsuite/test_inode.sh +++ /dev/null @@ -1,62 +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 . -# -# Essentially this test verifies that ls -i and find -printf %i produce -# the same output. - -testname="$(basename $0)" - -. "${srcdir}"/binary_locations.sh - -make_canonical() { - sed -e 's/ /_/g' -} - -test_percent_i() { - if "${executable}" "${tmpfile}" -printf '%i_%p\n' | - make_canonical >| "${outfile}"; then - cmp "${outfile}" "${goldfile}" || { - exec >&2 - cat <| "${goldfile}" - - if outfile=$(mktemp); then - for executable in "${oldfind}" "${ftsfind}" - do - test_percent_i - done - rm -f "${outfile}" - fi - rm -f "${goldfile}" - fi - rm -f "${tmpfile}" -fi diff --git a/tests/find/printf_inode.sh b/tests/find/printf_inode.sh new file mode 100755 index 00000000..6844268c --- /dev/null +++ b/tests/find/printf_inode.sh @@ -0,0 +1,39 @@ +#!/bin/sh +# Verify that ls -i and find -printf %i produce the same output. + +# 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 + +make_canonical() { + sed -e 's/ /_/g' +} + +# Create a file. +> file || framework_failure_ + +# Let ls(1) create the expected output. +ls -i file | make_canonical > exp || framework_failure_ + +for executable in oldfind find; do + rm -f out out2 + $executable file -printf '%i_%p\n' > out || fail=1 + make_canonical < out > out2 || framework_failure_ + compare exp out2 || fail=1 +done + +Exit $fail diff --git a/tests/local.mk b/tests/local.mk index 5a8315ff..0dcabab4 100644 --- a/tests/local.mk +++ b/tests/local.mk @@ -108,6 +108,7 @@ all_tests = \ tests/find/name-lbracket-literal.sh \ tests/find/printf_escapechars.sh \ tests/find/printf_escape_c.sh \ + tests/find/printf_inode.sh \ $(all_root_tests) $(TEST_LOGS): $(PROGRAMS) -- 2.20.1