Blame tests/misc/seq-epipe.sh

Packit Service 2723c6
#!/bin/sh
Packit Service 2723c6
# Test for proper detection of EPIPE with ignored SIGPIPE
Packit Service 2723c6
Packit Service 2723c6
# Copyright (C) 2016-2018 Free Software Foundation, Inc.
Packit Service 2723c6
Packit Service 2723c6
# This program is free software: you can redistribute it and/or modify
Packit Service 2723c6
# it under the terms of the GNU General Public License as published by
Packit Service 2723c6
# the Free Software Foundation, either version 3 of the License, or
Packit Service 2723c6
# (at your option) any later version.
Packit Service 2723c6
Packit Service 2723c6
# This program is distributed in the hope that it will be useful,
Packit Service 2723c6
# but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2723c6
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit Service 2723c6
# GNU General Public License for more details.
Packit Service 2723c6
Packit Service 2723c6
# You should have received a copy of the GNU General Public License
Packit Service 2723c6
# along with this program.  If not, see <https://www.gnu.org/licenses/>.
Packit Service 2723c6
Packit Service 2723c6
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
Packit Service 2723c6
print_ver_ seq
Packit Service 2723c6
Packit Service 2723c6
(trap '' PIPE && yes | :) 2>&1 | grep -qF 'Broken pipe' ||
Packit Service 2723c6
    skip_ 'trapping SIGPIPE is not supported'
Packit Service 2723c6
Packit Service 2723c6
# upon EPIPE with signals ignored, 'seq' should exit with an error.
Packit Service 2723c6
timeout 10 sh -c \
Packit Service 2723c6
  'trap "" PIPE && { seq inf 2>err; echo $? >code; } | head -n1' >out
Packit Service 2723c6
Packit Service 2723c6
# Exit-code must be 1, indicating 'write error'
Packit Service 2723c6
echo 1 > exp || framework_failure_
Packit Service 2723c6
compare exp out || fail=1
Packit Service 2723c6
compare exp code || fail=1
Packit Service 2723c6
Packit Service 2723c6
grep '^seq: write error: ' err \
Packit Service 2723c6
  || { warn_ "seq emitted incorrect error on EPIPE"; \
Packit Service 2723c6
       cat err;\
Packit Service 2723c6
       fail=1; }
Packit Service 2723c6
Packit Service 2723c6
Exit $fail