Files
sed/testsuite/panic-tests.sh
T
Assaf Gordon 3b29bece3e build: switch to non-recursive makefile
* .gitignore: Ignore '.dirstamp' files
* bootstrap.conf: Add 'non-recursive-gnulib-prefix-hack' gnulib module.
  Add missing 'stdalign' module.
  (bootstrap_post_import_hook): Use module to adjust gnulib.mk file.
* configure.ac: Add 'subdir-objects' automake option, don't generate
  makefiles in subdirectories. Adjust path of XFAIL tests.
* Makefile.am: Include 'local.mk' files, adjust for non-recursive make.
* doc/Makefile.am: Rename to ...
* doc/local.mk: Adjust paths. Rename SED to
  SEDBIN variable, to avoid overriding the default system-wide SED value
  which is automatically set by autotools.
* lib/Makefile.am: Rename to ...
* lib/local.mk: Adjust paths.
* lib/.gitignore: Ignore 'stdalign.h' from gnulib module.
* sed/Makefile.am: Rename to ...
* sed/local.mk: Adjust paths.
* testsuite/Makefile.am: Rename to ...
* testsuite/local.mk: Adjust paths.
* testsuite/init.cfg: Move to ...
* init.cfg: ... here. Moved to avoid changing the path in init.sh, and to
  keep the same directory structure as coreutils.
  (require_en_utf8_locale_): Adjust path for get-mb-cur-max executable.
  (require_ja_shiftjis_locale_,require_valid_ja_shiftjis_locale_): Adjust
  path for test-mbrtowc executable.
* m4/.gitignore: Add gnulib's non-recusive-make module.
* testsuite/runtest: Adjust paths of Makefile.tests and dir variables,
  Skip utility program 'get-mb-cur-max' which is not a standalone test.
* testsuite/Makefile.tests: Adjust path of sed exeutable.
* testsuite/eval.sed, testsuite/eval.good: Adjust path of sed executable.
* testsuite/cmd-R.sh,
  testsuite/cmd-l.sh,
  testsuite/colon-with-no-label.sh,
  testsuite/comment-n.sh,
  testsuite/compile-errors.sh,
  testsuite/compile-tests.sh,
  testsuite/convert-number.sh,
  testsuite/execute-tests.sh,
  testsuite/follow-symlinks-stdin.sh,
  testsuite/follow-symlinks.sh,
  testsuite/help-version.sh,
  testsuite/in-place-hyphen.sh,
  testsuite/in-place-suffix-backup.sh,
  testsuite/invalid-mb-seq-UMR.sh,
  testsuite/mb-bad-delim.sh,
  testsuite/mb-charclass-non-utf8.sh,
  testsuite/mb-match-slash.sh,
  testsuite/mb-y-translate.sh,
  testsuite/normalize-text.sh,
  testsuite/nulldata.sh,
  testsuite/panic-tests.sh,
  testsuite/posix-char-class.sh,
  testsuite/posix-mode-N.sh,
  testsuite/posix-mode-addr.sh,
  testsuite/posix-mode-bad-ref.sh,
  testsuite/posix-mode-s.sh,
  testsuite/range-overlap.sh,
  testsuite/recursive-escape-c.sh,
  testsuite/regex-errors.sh,
  testsuite/stdin-prog.sh,
  testsuite/subst-mb-incomplete.sh,
  testsuite/subst-options.sh,
  testsuite/subst-replacement.sh,
  testsuite/temp-file-cleanup.sh,
  testsuite/unbuffered.sh: Adjust paths of init.sh, sed executable.
2016-07-24 22:22:53 -04:00

102 lines
2.7 KiB
Bash

#!/bin/sh
# Exercise some panic stops
# Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
. "${srcdir=.}/testsuite/init.sh"; path_prepend_ ./sed
print_ver_ sed
#
# failure to create temp file
#
# inplace with an unwritable directory
mkdir a || framework_failure_
touch a/a || framework_failure_
chmod a-w a || framework_failure_
# Expected error message, with actual filename/errno trimmed
cat <<\EOF >exp-err-temp || framework_failure_
sed: couldn't open temporary file
EOF
# TODO: why exit-code 4 (currently hard-coded)
returns_ 4 sed -i = a/a 2>err-temp || fail=1
# trim the filename/errno message (using sed itself...)
sed -i 's/file.*$/file/' err-temp || framework_failure_
compare_ exp-err-temp err-temp || fail=1
# restore writability, to ensure it can be deleted
chmod a+w a || framework_failure_
#
# no input files (with inplace)
#
# Expected error message
cat <<\EOF> exp-err-no-files || framework_failure_
sed: no input files
EOF
# /dev/null to ensure it doesn't hang if panic is not invoked
returns_ 4 sed -i = </dev/null 2>err-no-files || fail=1
compare_ exp-err-no-files err-no-files || fail=1
#
# Not a regular file (with inplace)
#
cat <<\EOF >exp-err-not-reg-file || framework_failure_
sed: couldn't edit f: not a regular file
EOF
mkfifo f || framework_failure_
# NOTE: the file-mode check is not performed until the first line is read.
# an empty/blocking fifo will hang forever.
printf a > f &
# TODO: add a timeout in case of bug leading to a blocking fifo?
returns_ 4 sed -i = f 2>err-not-reg-file || fail=1
compare_ exp-err-not-reg-file err-not-reg-file || fail=1
#
# inplace on a terminal device
# (if available)
#
#NOTE: device name is replaced later
cat <<\EOF >exp-err-tty || framework_failure_
sed: couldn't edit X: is a terminal
EOF
ttydev=no-such-file
type tty >/dev/null 2>&1 && ttydev=$(tty 2>/dev/null)
if test -w "$ttydev" ; then
returns_ 4 sed -i = "$ttydev" 2>err-tty || fail=1
# remove the actual terminal device name (using sed itself...)
sed -i 's/edit.*:/edit X:/' err-tty || framework_failure_
compare_ exp-err-tty err-tty || fail=1
fi
Exit $fail