diff options
author | Bernhard Voelker <mail@bernhard-voelker.de> | 2019-01-09 00:24:34 +0100 |
---|---|---|
committer | Bernhard Voelker <mail@bernhard-voelker.de> | 2019-01-09 00:24:34 +0100 |
commit | 3f6b28c4fb48f7e9cbfe5b71837679aee7a6f732 (patch) | |
tree | eeb57a203081b6ce1b6f01d1cf1bc764485044ab /tests/find | |
parent | 77df15aa8b91a3ef4d961ba1b1714cdb03a9fe86 (diff) | |
download | findutils-3f6b28c4fb48f7e9cbfe5b71837679aee7a6f732.tar.gz |
tests: migrate test 'printf_escapechars' 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/test_escapechars.golden: Remove, as the axpected output
is created on the fly by the new test.
* find/testsuite/test_escapechars.sh: Move to ...
* tests/find/printf_escapechars.sh: ... this, and apply the above.
Create the expected output on the fly, and also check for the expected
error diagnostic on stderr.
* find/testsuite/Makefile.am (EXTRA_DIST_GOLDEN): Remove.
(EXTRA_DIST): Remove $(EXTRA_DIST_GOLDEN).
(tests_shell_progs): Remove the reference to this test ...
* tests/local.mk (all_tests): .. and add it here.
Diffstat (limited to 'tests/find')
-rwxr-xr-x | tests/find/printf_escapechars.sh | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/find/printf_escapechars.sh b/tests/find/printf_escapechars.sh new file mode 100755 index 00000000..861dd0b0 --- /dev/null +++ b/tests/find/printf_escapechars.sh @@ -0,0 +1,86 @@ +#!/bin/sh +# Test -printf with octal and letter escapes. + +# 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 <https://www.gnu.org/licenses/>. + +. "${srcdir=.}/tests/init.sh" +print_ver_ find oldfind + +# Check for working od(1). +echo test | od -c >/dev/null \ + || skip_ "no working 'od -c' found" + +# Create file with expected output interpreted as octal; use: +# $ printf '%s' \ +# $'OCTAL1: \1\n' \ +# $'OCTAL2: \02\n' \ +# $'OCTAL3: \003\n' \ +# $'OCTAL4: \0044\n' \ +# $'OCTAL8: \0028\n' \ +# $'BEL: \a\n' \ +# $'CR: \r\n' \ +# $'FF: \f\n' \ +# $'TAB: \t\n' \ +# $'VTAB: \v\n' \ +# $'BS: \b\n' \ +# $'BACKSLASH: \\\n' \ +# $'UNKNOWN: \z\n' \ +# | od -t o1 +cat <<_EOD_ > expout || framework_failure_ +0000000 117 103 124 101 114 061 072 040 001 012 117 103 124 101 114 062 +0000020 072 040 002 012 117 103 124 101 114 063 072 040 003 012 117 103 +0000040 124 101 114 064 072 040 004 064 012 117 103 124 101 114 070 072 +0000060 040 002 070 012 102 105 114 072 040 007 012 103 122 072 040 015 +0000100 012 106 106 072 040 014 012 124 101 102 072 040 011 012 126 124 +0000120 101 102 072 040 013 012 102 123 072 040 010 012 102 101 103 113 +0000140 123 114 101 123 110 072 040 134 012 125 116 113 116 117 127 116 +0000160 072 040 134 172 012 +0000165 +_EOD_ + +# Prepare expected stderr. +echo "warning: unrecognized escape" > experr || framework_failure_ + +for executable in oldfind find; do + rm -f out* err* || framework_failure_ + + $executable . -maxdepth 0 \ + -printf 'OCTAL1: \1\n' \ + -printf 'OCTAL2: \02\n' \ + -printf 'OCTAL3: \003\n' \ + -printf 'OCTAL4: \0044\n' \ + -printf 'OCTAL8: \0028\n' \ + -printf 'BEL: \a\n' \ + -printf 'CR: \r\n' \ + -printf 'FF: \f\n' \ + -printf 'TAB: \t\n' \ + -printf 'VTAB: \v\n' \ + -printf 'BS: \b\n' \ + -printf 'BACKSLASH: \\\n' \ + -printf 'UNKNOWN: \z\n' \ + > out 2> err || fail=1 + + # Some 'od' implementations (e.g. on the *BSDs) produce different indentation + # and trailing spaces, therefore squeeze the former and remove the latter. + od -t o1 < out | sed 's/ */ /g; s/ *$//;' > out2 || framework_failure_ + compare expout out2 || fail=1 + + sed 's/^.*\(warning: unrecognized escape\) .*$/\1/' err > err2 \ + || framework_failure_ + compare experr err2 || fail=1 +done + +Exit $fail |