tests: improve robustness
Replace some blind timeouts with actual synchronization. Improve performance on some slow tests. Tweak some of the remaining timeouts. This still isn't good enough to get 'make -j9 check' working reliably on Cygwin for me; I think some Cygwin/ Windows scheduling issues remain.
This commit is contained in:
+1
-1
@@ -216,7 +216,7 @@ for run in $server_tests; do
|
|||||||
test_error "tmux failure on test %s\n" "$run"
|
test_error "tmux failure on test %s\n" "$run"
|
||||||
fi
|
fi
|
||||||
# Check for mosh failures
|
# Check for mosh failures
|
||||||
if ! grep -q "%%% exitstatus: 0 %%%" "${test_dir}/${run}.tmux.log"; then
|
if ! grep -q "@@@ exitstatus: 0 @@@" "${test_dir}/${run}.tmux.log"; then
|
||||||
test_error "mosh-client had non-zero exitstatus\n"
|
test_error "mosh-client had non-zero exitstatus\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,21 @@ fi
|
|||||||
# run harnessed command
|
# run harnessed command
|
||||||
eval "$@"
|
eval "$@"
|
||||||
testret=$?
|
testret=$?
|
||||||
# Wait a bit for tmux screen to become up to date.
|
# Wait for tmux client screen to become up to date.
|
||||||
sleep 1
|
sleep 1
|
||||||
|
printf "@@@ server complete @@@" >&2
|
||||||
|
i=0
|
||||||
|
while [ $i -lt 60 ]; do
|
||||||
|
if grep -q "@@@ server complete @@@" $testname.tmux.log; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
i=$((i+1))
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
if [ $i -ge 60 ]; then
|
||||||
|
printf "wait for tmux client update failed, erroring test\n" >&2
|
||||||
|
exit 99
|
||||||
|
fi
|
||||||
# capture screen
|
# capture screen
|
||||||
if ! tmux capture-pane -et $TMUX_PANE; then
|
if ! tmux capture-pane -et $TMUX_PANE; then
|
||||||
printf "tmux capture-pane failed, erroring test\n" >&2
|
printf "tmux capture-pane failed, erroring test\n" >&2
|
||||||
|
|||||||
@@ -54,25 +54,3 @@ chr()
|
|||||||
{
|
{
|
||||||
printf "\\$(printf %03o $1)"
|
printf "\\$(printf %03o $1)"
|
||||||
}
|
}
|
||||||
|
|
||||||
utf8cp()
|
|
||||||
{
|
|
||||||
if [ $1 -gt $((0x10ffff)) ]; then
|
|
||||||
fail "illegal Unicode code point %x\n" $1
|
|
||||||
elif [ $1 -lt $((0x80)) ]; then
|
|
||||||
chr $1
|
|
||||||
elif [ $1 -lt $((0x800)) ]; then
|
|
||||||
chr $(( (($1 >> 6) & 0x1f) | 0xc0 ))
|
|
||||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
|
||||||
elif [ $1 -lt $((0x10000)) ]; then
|
|
||||||
chr $(( (($1 >> 12) & 0x0f) | 0xe0 ))
|
|
||||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
|
||||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
|
||||||
elif [ $1 -lt $((0x200000)) ]; then
|
|
||||||
chr $(( (($1 >> 18) & 0x03) | 0xf0 ))
|
|
||||||
chr $(( (($1 >> 12) & 0x3f) | 0x80 ))
|
|
||||||
chr $(( (($1 >> 6) & 0x3f) | 0x80 ))
|
|
||||||
chr $(( ($1 & 0x3f) | 0x80 ))
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,8 @@ fi
|
|||||||
baseline()
|
baseline()
|
||||||
{
|
{
|
||||||
# We need to control CR and LF individually for this test.
|
# We need to control CR and LF individually for this test.
|
||||||
|
TERMIO=$(stty -g)
|
||||||
|
trap "stty $TERMIO" EXIT
|
||||||
stty raw
|
stty raw
|
||||||
printf '\033[H\033[J'
|
printf '\033[H\033[J'
|
||||||
for lines in $(seq 1 25); do
|
for lines in $(seq 1 25); do
|
||||||
|
|||||||
@@ -21,16 +21,20 @@ baseline()
|
|||||||
{
|
{
|
||||||
printf '\033[H\033[J'
|
printf '\033[H\033[J'
|
||||||
|
|
||||||
# ASCII, then ISO-8859-1.
|
cat <<'EOF'
|
||||||
for char in $(seq 32 126) $(seq 160 255) ; do
|
20 21 ! 22 " 23 # 24 $ 25 % 26 & 27 ' 28 ( 29 ) 2a * 2b + 2c , 2d - 2e . 2f /
|
||||||
if [ $(( char % 16 )) -eq 0 ]; then
|
30 0 31 1 32 2 33 3 34 4 35 5 36 6 37 7 38 8 39 9 3a : 3b ; 3c < 3d = 3e > 3f ?
|
||||||
printf '\n'
|
40 @ 41 A 42 B 43 C 44 D 45 E 46 F 47 G 48 H 49 I 4a J 4b K 4c L 4d M 4e N 4f O
|
||||||
fi
|
50 P 51 Q 52 R 53 S 54 T 55 U 56 V 57 W 58 X 59 Y 5a Z 5b [ 5c \ 5d ] 5e ^ 5f _
|
||||||
printf '%02x ' $char
|
60 ` 61 a 62 b 63 c 64 d 65 e 66 f 67 g 68 h 69 i 6a j 6b k 6c l 6d m 6e n 6f o
|
||||||
utf8cp $char
|
70 p 71 q 72 r 73 s 74 t 75 u 76 v 77 w 78 x 79 y 7a z 7b { 7c | 7d } 7e ~
|
||||||
printf ' '
|
a0 a1 ¡ a2 ¢ a3 £ a4 ¤ a5 ¥ a6 ¦ a7 § a8 ¨ a9 © aa ª ab « ac ¬ ad ae ® af ¯
|
||||||
done
|
b0 ° b1 ± b2 ² b3 ³ b4 ´ b5 µ b6 ¶ b7 · b8 ¸ b9 ¹ ba º bb » bc ¼ bd ½ be ¾ bf ¿
|
||||||
printf '\n'
|
c0 À c1 Á c2 Â c3 Ã c4 Ä c5 Å c6 Æ c7 Ç c8 È c9 É ca Ê cb Ë cc Ì cd Í ce Î cf Ï
|
||||||
|
d0 Ð d1 Ñ d2 Ò d3 Ó d4 Ô d5 Õ d6 Ö d7 × d8 Ø d9 Ù da Ú db Û dc Ü dd Ý de Þ df ß
|
||||||
|
e0 à e1 á e2 â e3 ã e4 ä e5 å e6 æ e7 ç e8 è e9 é ea ê eb ë ec ì ed í ee î ef ï
|
||||||
|
f0 ð f1 ñ f2 ò f3 ó f4 ô f5 õ f6 ö f7 ÷ f8 ø f9 ù fa ú fb û fc ü fd ý fe þ ff ÿ
|
||||||
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
case $1 in
|
case $1 in
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ baseline()
|
|||||||
# delays so that each iteration percolates to the client
|
# delays so that each iteration percolates to the client
|
||||||
# by itself. On the other hand, that makes the test take
|
# by itself. On the other hand, that makes the test take
|
||||||
# a long time. Compromise on .1 second.
|
# a long time. Compromise on .1 second.
|
||||||
(sleep .1 || sleep 1) > /dev/null 2>&1
|
sleepf
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,9 +28,9 @@ baseline()
|
|||||||
|
|
||||||
for x in $(seq 1 10); do
|
for x in $(seq 1 10); do
|
||||||
printf "abcdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1234"
|
printf "abcdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1234"
|
||||||
sleep .1
|
sleepf
|
||||||
printf "ABCDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5678"
|
printf "ABCDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5678"
|
||||||
sleep .1
|
sleepf
|
||||||
done
|
done
|
||||||
printf '\n'
|
printf '\n'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ tmux_commands()
|
|||||||
{
|
{
|
||||||
for x in $(seq 1 5); do
|
for x in $(seq 1 5); do
|
||||||
for y in $(seq 1 5); do
|
for y in $(seq 1 5); do
|
||||||
for i in g l ü c k " " f a ĩ l " "; do
|
for i in "gl" ü "ck fa" ĩ "l "; do
|
||||||
printf "send-keys '%s'\n" "$i"
|
printf "send-keys '%s'\n" "$i"
|
||||||
sleepf
|
sleepf
|
||||||
done
|
done
|
||||||
@@ -47,7 +47,13 @@ tmux_commands()
|
|||||||
printf "send-keys 0x0d\n"
|
printf "send-keys 0x0d\n"
|
||||||
sleep 1
|
sleep 1
|
||||||
printf "send-keys 0x04\n"
|
printf "send-keys 0x04\n"
|
||||||
sleep 10
|
# Unreliable on Cygwin under load, it seems.
|
||||||
|
sleep 1
|
||||||
|
printf "send-keys 0x04\n"
|
||||||
|
# This will get killed by SIGPIPE.
|
||||||
|
while sleep 1; do
|
||||||
|
printf "show-options\n"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tmux_stdin()
|
tmux_stdin()
|
||||||
|
|||||||
@@ -17,6 +17,17 @@ if ($? == 0) {
|
|||||||
} else {
|
} else {
|
||||||
$rc = ($? & 127) | 128;
|
$rc = ($? & 127) | 128;
|
||||||
}
|
}
|
||||||
print STDERR "%%% exitstatus: ${rc} %%%\n";
|
print STDERR "@@@ exitstatus: ${rc} @@@\n";
|
||||||
sleep 1;
|
# Now look for it in log file.
|
||||||
|
my $grepfilename = $ENV{'MOSH_E2E_TEST'} . ".tmux.log";
|
||||||
|
for my $i (1..600) {
|
||||||
|
open(my $grepfile, "<", $grepfilename) or die;
|
||||||
|
while (<$grepfile>) {
|
||||||
|
chomp;
|
||||||
|
/@@@ exitstatus: .* @@@/ && goto gotit;
|
||||||
|
}
|
||||||
|
close($grepfile);
|
||||||
|
sleep .1;
|
||||||
|
}
|
||||||
|
gotit:
|
||||||
exit $rc;
|
exit $rc;
|
||||||
|
|||||||
@@ -25,18 +25,19 @@ tmux_commands()
|
|||||||
# Start test...
|
# Start test...
|
||||||
sleep 2
|
sleep 2
|
||||||
printf "send-keys 0x0d\n"
|
printf "send-keys 0x0d\n"
|
||||||
sleep 1
|
sleep 5
|
||||||
# Stop output...
|
# Stop output...
|
||||||
printf "send-keys 0x13\n"
|
printf "send-keys 0x13\n"
|
||||||
sleep 2
|
sleep 10
|
||||||
# Restart output...
|
# Restart output...
|
||||||
printf "send-keys 0x11\n"
|
printf "send-keys 0x11\n"
|
||||||
sleep 2
|
sleep 10
|
||||||
# And stop the test script, so it produces its exit messge.
|
# And stop the test script, so it produces its exit messge.
|
||||||
printf "send-keys 0x0d\n"
|
printf "send-keys 0x0d\n"
|
||||||
# need to sleep extra long here, to let child commands complete
|
# This will get killed by SIGPIPE.
|
||||||
# and buffers drain, and not have tmux exit prematurely
|
while sleep 1; do
|
||||||
sleep 10
|
printf "show-options\n"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
tmux_stdin()
|
tmux_stdin()
|
||||||
@@ -49,12 +50,15 @@ baseline()
|
|||||||
{
|
{
|
||||||
# Make a lot of noise on stdout to keep mosh busy, and exit
|
# Make a lot of noise on stdout to keep mosh busy, and exit
|
||||||
# with a distinctive message when we get a CR. Exit after 10s in any case.
|
# with a distinctive message when we get a CR. Exit after 10s in any case.
|
||||||
|
blat=$(for i in $(seq 1 100); do
|
||||||
|
printf 'a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n'
|
||||||
|
done)
|
||||||
read x
|
read x
|
||||||
while true; do
|
while true; do
|
||||||
printf 'a\nb\nc\nd\ne\nf\ng\nh\ni\nj\nk\nl\nm\nn\no\np\nq\nr\ns\nt\nu\nv\nw\nx\ny\nz\n'
|
printf "$blat"
|
||||||
done &
|
done &
|
||||||
printpid=$!
|
printpid=$!
|
||||||
(sleep 30; kill $$ $printpid) &
|
(sleep 120; kill $$ $printpid) &
|
||||||
killpid=$!
|
killpid=$!
|
||||||
read x
|
read x
|
||||||
kill $printpid
|
kill $printpid
|
||||||
|
|||||||
@@ -35,6 +35,10 @@ client()
|
|||||||
fail "unexpected test name %s\n" "$myname"
|
fail "unexpected test name %s\n" "$myname"
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
|
# Print this early, because the server is expected to die before
|
||||||
|
# the normal time this is sent by e2e-test-server.
|
||||||
|
printf "@@@ server complete @@@\n" >&2
|
||||||
|
# Run mosh SUT.
|
||||||
eval "$@"
|
eval "$@"
|
||||||
# The client may be murdered. We need to expect that...
|
# The client may be murdered. We need to expect that...
|
||||||
retval=$?
|
retval=$?
|
||||||
@@ -67,6 +71,7 @@ baseline()
|
|||||||
if ! kill -0 $MOSH_CLIENT_PID; then
|
if ! kill -0 $MOSH_CLIENT_PID; then
|
||||||
fail "mosh client is unexpectedly missing\n"
|
fail "mosh client is unexpectedly missing\n"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Set up for good return and cleanup on being killed
|
# Set up for good return and cleanup on being killed
|
||||||
trap "echo got killed >&2; sleep 1; exit 0" HUP TERM
|
trap "echo got killed >&2; sleep 1; exit 0" HUP TERM
|
||||||
sleep 1
|
sleep 1
|
||||||
@@ -91,6 +96,7 @@ baseline()
|
|||||||
# If we're still alive and the server is too, the test failed.
|
# If we're still alive and the server is too, the test failed.
|
||||||
# XXX the server is getting killed and we're getting here anyway.
|
# XXX the server is getting killed and we're getting here anyway.
|
||||||
# Exit with error only if server is still around.
|
# Exit with error only if server is still around.
|
||||||
|
sleep 1
|
||||||
! kill -0 $MOSH_SERVER_PID
|
! kill -0 $MOSH_SERVER_PID
|
||||||
exit
|
exit
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user