diff --git a/src/tests/e2e-test b/src/tests/e2e-test index 3a9d8c3..387919d 100755 --- a/src/tests/e2e-test +++ b/src/tests/e2e-test @@ -216,7 +216,7 @@ for run in $server_tests; do test_error "tmux failure on test %s\n" "$run" fi # 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" fi diff --git a/src/tests/e2e-test-server b/src/tests/e2e-test-server index caeaafc..4a92915 100755 --- a/src/tests/e2e-test-server +++ b/src/tests/e2e-test-server @@ -24,8 +24,21 @@ fi # run harnessed command eval "$@" testret=$? -# Wait a bit for tmux screen to become up to date. +# Wait for tmux client screen to become up to date. 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 if ! tmux capture-pane -et $TMUX_PANE; then printf "tmux capture-pane failed, erroring test\n" >&2 diff --git a/src/tests/e2e-test-subrs b/src/tests/e2e-test-subrs index 98add40..3a7b4a9 100644 --- a/src/tests/e2e-test-subrs +++ b/src/tests/e2e-test-subrs @@ -54,25 +54,3 @@ chr() { 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 -} - diff --git a/src/tests/emulation-80th-column.test b/src/tests/emulation-80th-column.test index 30fc4c9..041863d 100755 --- a/src/tests/emulation-80th-column.test +++ b/src/tests/emulation-80th-column.test @@ -24,6 +24,8 @@ fi baseline() { # We need to control CR and LF individually for this test. + TERMIO=$(stty -g) + trap "stty $TERMIO" EXIT stty raw printf '\033[H\033[J' for lines in $(seq 1 25); do diff --git a/src/tests/emulation-ascii-iso-8859.test b/src/tests/emulation-ascii-iso-8859.test index 3c44b60..3cb2055 100755 --- a/src/tests/emulation-ascii-iso-8859.test +++ b/src/tests/emulation-ascii-iso-8859.test @@ -21,16 +21,20 @@ baseline() { printf '\033[H\033[J' - # ASCII, then ISO-8859-1. - for char in $(seq 32 126) $(seq 160 255) ; do - if [ $(( char % 16 )) -eq 0 ]; then - printf '\n' - fi - printf '%02x ' $char - utf8cp $char - printf ' ' - done - printf '\n' + cat <<'EOF' +20 21 ! 22 " 23 # 24 $ 25 % 26 & 27 ' 28 ( 29 ) 2a * 2b + 2c , 2d - 2e . 2f / +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 ? +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 +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 _ +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 +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 ~ +a0   a1 ¡ a2 ¢ a3 £ a4 ¤ a5 ¥ a6 ¦ a7 § a8 ¨ a9 © aa ª ab « ac ¬ ad ­ ae ® af ¯ +b0 ° b1 ± b2 ² b3 ³ b4 ´ b5 µ b6 ¶ b7 · b8 ¸ b9 ¹ ba º bb » bc ¼ bd ½ be ¾ bf ¿ +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 diff --git a/src/tests/emulation-multiline-scroll.test b/src/tests/emulation-multiline-scroll.test index ce8186c..f2bcfc3 100755 --- a/src/tests/emulation-multiline-scroll.test +++ b/src/tests/emulation-multiline-scroll.test @@ -32,7 +32,7 @@ baseline() # delays so that each iteration percolates to the client # by itself. On the other hand, that makes the test take # a long time. Compromise on .1 second. - (sleep .1 || sleep 1) > /dev/null 2>&1 + sleepf done done } diff --git a/src/tests/emulation-wrap-across-frames.test b/src/tests/emulation-wrap-across-frames.test index 5c4f758..1a50cc3 100755 --- a/src/tests/emulation-wrap-across-frames.test +++ b/src/tests/emulation-wrap-across-frames.test @@ -28,9 +28,9 @@ baseline() for x in $(seq 1 10); do printf "abcdXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX1234" - sleep .1 + sleepf printf "ABCDxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx5678" - sleep .1 + sleepf done printf '\n' } diff --git a/src/tests/prediction-unicode.test b/src/tests/prediction-unicode.test index 0cdcdca..416aa24 100755 --- a/src/tests/prediction-unicode.test +++ b/src/tests/prediction-unicode.test @@ -37,7 +37,7 @@ tmux_commands() { for x 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" sleepf done @@ -47,7 +47,13 @@ tmux_commands() printf "send-keys 0x0d\n" sleep 1 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() diff --git a/src/tests/print-exitstatus b/src/tests/print-exitstatus index efa5dcd..4f0db2b 100755 --- a/src/tests/print-exitstatus +++ b/src/tests/print-exitstatus @@ -17,6 +17,17 @@ if ($? == 0) { } else { $rc = ($? & 127) | 128; } -print STDERR "%%% exitstatus: ${rc} %%%\n"; -sleep 1; +print STDERR "@@@ exitstatus: ${rc} @@@\n"; +# 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; diff --git a/src/tests/pty-deadlock.test b/src/tests/pty-deadlock.test index bb0086c..4e67aeb 100755 --- a/src/tests/pty-deadlock.test +++ b/src/tests/pty-deadlock.test @@ -25,18 +25,19 @@ tmux_commands() # Start test... sleep 2 printf "send-keys 0x0d\n" - sleep 1 + sleep 5 # Stop output... printf "send-keys 0x13\n" - sleep 2 + sleep 10 # Restart output... printf "send-keys 0x11\n" - sleep 2 + sleep 10 # And stop the test script, so it produces its exit messge. printf "send-keys 0x0d\n" - # need to sleep extra long here, to let child commands complete - # and buffers drain, and not have tmux exit prematurely - sleep 10 + # This will get killed by SIGPIPE. + while sleep 1; do + printf "show-options\n" + done } tmux_stdin() @@ -49,12 +50,15 @@ baseline() { # 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. + 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 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 & printpid=$! - (sleep 30; kill $$ $printpid) & + (sleep 120; kill $$ $printpid) & killpid=$! read x kill $printpid diff --git a/src/tests/server-network-timeout.test b/src/tests/server-network-timeout.test index d1bf267..9024c34 100755 --- a/src/tests/server-network-timeout.test +++ b/src/tests/server-network-timeout.test @@ -35,6 +35,10 @@ client() fail "unexpected test name %s\n" "$myname" esac 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 "$@" # The client may be murdered. We need to expect that... retval=$? @@ -67,6 +71,7 @@ baseline() if ! kill -0 $MOSH_CLIENT_PID; then fail "mosh client is unexpectedly missing\n" fi + # Set up for good return and cleanup on being killed trap "echo got killed >&2; sleep 1; exit 0" HUP TERM sleep 1 @@ -91,6 +96,7 @@ baseline() # 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. # Exit with error only if server is still around. + sleep 1 ! kill -0 $MOSH_SERVER_PID exit }