[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[7863] info tests do not use read -t to time out
From: |
gavinsmith0123 |
Subject: |
[7863] info tests do not use read -t to time out |
Date: |
Mon, 26 Jun 2017 16:24:29 -0400 (EDT) |
Revision: 7863
http://svn.sv.gnu.org/viewvc/?view=rev&root=texinfo&revision=7863
Author: gavin
Date: 2017-06-26 16:24:28 -0400 (Mon, 26 Jun 2017)
Log Message:
-----------
info tests do not use read -t to time out
Modified Paths:
--------------
trunk/ChangeLog
trunk/info/t/Init-inter.inc
trunk/info/t/Init-test.inc
trunk/info/t/Timeout-test.inc
Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog 2017-06-26 19:59:50 UTC (rev 7862)
+++ trunk/ChangeLog 2017-06-26 20:24:28 UTC (rev 7863)
@@ -1,5 +1,19 @@
2017-06-26 Gavin Smith <address@hidden>
+ * info/t/Init-inter.inc (run_ginfo): Time out test by running a
+ subshell in the background that kills the current shell inside
+ an "sh -c" command, and execing the ginfo program. Do not use a
+ FIFO to communicate that the process has finished.
+
+ * info/t/Timeout-test.inc: Do not use "read -t" to read from a
+ FIFO with a timeout. Use the "wait" shell builtin to wait for
+ the process to finish.
+
+ * info/t/Init-test.inc (cleanup): Eliminate use of SUBSHELL,
+ TIMED_OUT and FINISHEDFIFO variables.
+
+2017-06-26 Gavin Smith <address@hidden>
+
* info/t/Init-inter.inc (run_ginfo): Remove use of pgrep to get
PID of process. Get PID of ginfo process by running a subshell
with "sh -c", printing the value of $$ (the shell PID), and then
Modified: trunk/info/t/Init-inter.inc
===================================================================
--- trunk/info/t/Init-inter.inc 2017-06-26 19:59:50 UTC (rev 7862)
+++ trunk/info/t/Init-inter.inc 2017-06-26 20:24:28 UTC (rev 7863)
@@ -51,8 +51,6 @@
# Avoid ginfo complaining that terminal is too dumb
TERM=vt100; export TERM
-FINISHEDFIFO=t/`basename $0.finished`
-
# See cleanup in Init-test.inc.
findprog stty && { STTY=stty ; reset_required=yes ; }
test $reset_required=yes && { $STTY | grep [-]echo ; } && reset_required=no
@@ -94,24 +92,14 @@
run_ginfo ()
{
- rm -f $FINISHEDFIFO
- mkfifo $FINISHEDFIFO
- { # Close fd opened to control FIFO in subshell so pseudotty can exit
+ sh -c "
+ # Close fd opened to control FIFO in subshell so pseudotty can exit
# for an EOF. This prevents lingering processes if a test is
# interrupted.
exec 7>&- ;
- exec 8>$FINISHEDFIFO ;
- sh -c "echo \$\$ >&8 ; exec $GINFO $GINFO_OPTIONS $*" ;
- test $? -eq 0 || echo failure >$FINISHEDFIFO ;
- echo finished >$FINISHEDFIFO ; } 0<>$PTS_DEVICE 1<&0 &
- SUBSHELL=$!
- exec 8<$FINISHEDFIFO
- read GINFO_PID <&8
+ (sleep 3 ; kill \$\$) &
+ exec $GINFO $GINFO_OPTIONS $* 0<>$PTS_DEVICE 1<&0 ;" &
- # Although we don't write to the FIFO in this process, we still need
- # to open it for writing, because if the above subshell exits before
- # we read from it, we won't be able to open it - even though
- # "finished" is buffered.
- exec 9>$FINISHEDFIFO
+ GINFO_PID=$!
}
Modified: trunk/info/t/Init-test.inc
===================================================================
--- trunk/info/t/Init-test.inc 2017-06-26 19:59:50 UTC (rev 7862)
+++ trunk/info/t/Init-test.inc 2017-06-26 20:24:28 UTC (rev 7863)
@@ -1,4 +1,4 @@
-# Copyright (C) 2014, 2015 Free Software Foundation, Inc.
+# Copyright (C) 2014, 2015, 2016, 2017 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
@@ -50,7 +50,6 @@
# Not an interactive test
PTY_PID=0
-SUBSHELL=0
# Get error messages in English
LC_ALL=C; export LC_ALL
@@ -71,11 +70,9 @@
{
# Delete created files and kill spawned processes if any.
test $PTY_PID -ne 0 && kill $PTY_PID
- test $SUBSHELL -ne 0 && kill $SUBSHELL
rm -f $GINFO_OUTPUT
rm -f $PIPEIN $PTY_TYPE
- rm -f $FINISHEDFIFO
# We do this because some versions of ksh93 (including that in
# Solaris 11) have a bug where a timed-out "read -t" can mess up
@@ -83,10 +80,6 @@
# This is only done if we don't start with "-echo" at the beginning.
test $reset_required = yes && { $STTY | grep '[-]echo' ; } && $STTY sane
- if test -n "$TIMED_OUT"; then
- exit 1
- fi
-
#killall `basename $0` # see below
exit $RETVAL
}
Modified: trunk/info/t/Timeout-test.inc
===================================================================
--- trunk/info/t/Timeout-test.inc 2017-06-26 19:59:50 UTC (rev 7862)
+++ trunk/info/t/Timeout-test.inc 2017-06-26 20:24:28 UTC (rev 7863)
@@ -15,61 +15,14 @@
# Shell script snippet. Wait for program to finish.
-# Not timed out yet
-TIMED_OUT=
+wait $GINFO_PID
+status=$?
-# Attempt to test if "read -t" works. Under Solaris 10, read -t below
-# should exit the subshell with an error exit status. Under some other
-# shells the subshell will not exit but the "read -t" will have an exit
-# status of 2, representing a syntax error.
-status=0
-(read -t 0 ; test $? != 2 ; exit $?)
-if test $? != 0; then
- # skip test below
- status=2
-fi
-
-# If that succeeded, now check that "read -t 0" has no output, which could
-# be an error message.
-if test $status != 2; then
- (read -t 0 2>&1 ) | grep .
- test $? = 0 && status=2
-fi
-# This last test was needed under OpenBSD 5.5, where
-# "read -t 0" has an exit status of 1, not 2
-
-if test $status != 2; then
- read -t 3 FINISHED <$FINISHEDFIFO
- status=$?
-fi
-
RETVAL=0
-if test $status = 1; then
- echo 'read -t failed - probably end-of-file' >&2
+if test $status != 0; then
RETVAL=1
-
-elif test $status != 0 -a $status -le 128 ; then
- # Exit status of 'read' should be 0 on a successful read, or
- # greater than 128 if it timed out.
- rm -f $FINISHEDFIFO
- echo 'read -t not supported - test skipped' >&2
- RETVAL=77
- cleanup
-elif test "$FINISHED" = failure; then
- echo 'Program exited unsuccessfully' >&2
- RETVAL=1
-
-elif test "$FINISHED" != finished; then
- # Kill ginfo if we have its PID. Failing this, it will probably exit
- # with an I/O error when pseudotty is killed in Cleanup.inc.
- test "$GINFO_PID" != unknown && kill $GINFO_PID
-
- echo 'Program timed out after 3 seconds' >&2
- TIMED_OUT=1
fi
-# Subshell is gone, so avoid trying to kill it in cleanup
-SUBSHELL=0
+# Program is gone, so avoid trying to kill it in cleanup
+GINFO_PID=0
-rm -f $FINISHEDFIFO
-
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [7863] info tests do not use read -t to time out,
gavinsmith0123 <=