diff --git a/src/tests/e2e-failure.test b/src/tests/e2e-failure.test index 038529526..5a2d271fa 100755 --- a/src/tests/e2e-failure.test +++ b/src/tests/e2e-failure.test @@ -20,8 +20,8 @@ baseline() } case $1 in - baseline|variant) - baseline;; - *) - fail "unknown test argument %s\n" "$1";; + baseline|variant) + baseline;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/e2e-success.test b/src/tests/e2e-success.test index 3225e76bf..261e8ae1d 100755 --- a/src/tests/e2e-success.test +++ b/src/tests/e2e-success.test @@ -20,8 +20,8 @@ baseline() } case $1 in - baseline|direct|variant) - baseline;; - *) - fail "unknown test argument %s\n" "$1";; + baseline|direct|variant) + baseline;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/e2e-test b/src/tests/e2e-test index c0e9d27d0..964d53994 100755 --- a/src/tests/e2e-test +++ b/src/tests/e2e-test @@ -23,9 +23,9 @@ dump_logs() shift testname=$(basename "$dir" .d) for logfile in $dir/*.tmux.log; do - printf "travis_fold:start:%s-%s\n" "$testname" "$(basename "$logfile")" - cat "$logfile" - printf "travis_fold:end:%s-%s\n" "$testname" "$(basename "$logfile")" + printf "travis_fold:start:%s-%s\n" "$testname" "$(basename "$logfile")" + cat "$logfile" + printf "travis_fold:end:%s-%s\n" "$testname" "$(basename "$logfile")" done } @@ -56,13 +56,12 @@ test_exitstatus() exit "$status" } - ssh_localhost_check() { ssh localhost : if [ $? -ne 0 ]; then - error "ssh to localhost failed\n" - return 1 + error "ssh to localhost failed\n" + return 1 fi return 0 } @@ -72,7 +71,7 @@ ssh_localhost_check() mosh_client() { if [ -z "$MOSH_CLIENT" ] || [ -z "$MOSH_E2E_TEST" ]; then - test_error "mosh_client: variables missing\n" + test_error "mosh_client: variables missing\n" fi exec 2> "${MOSH_E2E_TEST}.client.stderr" exec "$MOSH_CLIENT" $MOSH_CLIENT_ARGS "$@" @@ -81,7 +80,7 @@ mosh_client() mosh_server() { if [ -z "$MOSH_SERVER" ] || [ -z "$MOSH_E2E_TEST" ]; then - test_error "mosh_server: variables missing\n" + test_error "mosh_server: variables missing\n" fi exec 2> "${MOSH_E2E_TEST}.server.stderr" exec "$MOSH_SERVER" new -vv $MOSH_SERVER_ARGS -@ "$@" @@ -94,23 +93,23 @@ if [ -z "$srcdir" ]; then else srcdir="$(cd "$srcdir" && pwd)" if [ $? -ne 0 ]; then - error "can't cd to srcdir: %s\n" "$srcdir" - exit 99 + error "can't cd to srcdir: %s\n" "$srcdir" + exit 99 fi fi # Wrappers. case "$(basename "$0")" in - mosh-client) - mosh_client "$@" - exit - ;; - mosh-server) - mosh_server "$@" - exit - ;; - *) - ;; + mosh-client) + mosh_client "$@" + exit + ;; + mosh-server) + mosh_server "$@" + exit + ;; + *) + ;; esac if [ $# -lt 2 ]; then @@ -141,13 +140,12 @@ fi rm -rf "${test_dir}" mkdir "${test_dir}" - on_exit() { rv=$? - if test $rv -ne 0; then - dump_logs "$test_dir" $test_args + if test "$rv" -ne 0; then + dump_logs "$test_dir" $test_args fi - exit $rv + exit "$rv" } trap on_exit EXIT @@ -156,30 +154,39 @@ server_tests= compare_tests= for i in $test_args; do case $i in - baseline|direct|variant) - server_tests="$server_tests $i";; - verify|same|different) - compare_tests="$compare_tests $i";; - tmux) - tmux=1;; - client) - client=1;; - server) - server=1;; - post) - post=1;; - mosh-args) - mosh_args=$("${test_script}" mosh-args);; - client-args) - MOSH_CLIENT_ARGS=$("${test_script}" client-args) - export MOSH_CLIENT_ARGS;; - server-args) - MOSH_SERVER_ARGS=$("${test_script}" server-args) - export MOSH_SERVER_ARGS;; - *) - error 'unknown test type argument %s\n' "$i" - exit 99 - ;; + baseline|direct|variant) + server_tests="$server_tests $i" + ;; + verify|same|different) + compare_tests="$compare_tests $i" + ;; + tmux) + tmux=1 + ;; + client) + client=1 + ;; + server) + server=1 + ;; + post) + post=1 + ;; + mosh-args) + mosh_args=$("${test_script}" mosh-args) + ;; + client-args) + MOSH_CLIENT_ARGS=$("${test_script}" client-args) + export MOSH_CLIENT_ARGS + ;; + server-args) + MOSH_SERVER_ARGS=$("${test_script}" server-args) + export MOSH_SERVER_ARGS + ;; + *) + error 'unknown test type argument %s\n' "$i" + exit 99 + ;; esac done @@ -194,7 +201,7 @@ if [ -n "$server" ]; then server_wrapper="\"${srcdir}/${test_script}\" server" fi tmux_stdin="${srcdir}/hold-stdin" -if [ -n "$tmux" ]; then +if [ -n "$tmux" ]; then tmux_stdin="${test_script} tmux" fi @@ -209,7 +216,7 @@ for run in $server_tests; do # XXX need to quote special chars in server pathname here somehow sut="../../scripts/mosh --client=${srcdir}/mosh-client --server=${srcdir}/mosh-server --local --bind-server=127.0.0.1 ${mosh_args} 127.0.0.1" if [ "$run" = "direct" ]; then - sut="" + sut="" fi # Actually execute code under test # XXX tmux 1.8 requires shell command as a single arg; once we move to 2.0, undo these quotes @@ -219,40 +226,39 @@ for run in $server_tests; do ${tmux_stdin} tmux -f /dev/null -S "${tmux_socket}" -C new-session -x 80 -y 24 "${srcdir}/print-exitstatus ${client_wrapper} ${sut} ${server_wrapper} \"${PWD}/${test_dir}/${run}\" \"${PWD}/${test_script} ${run}\"" > "${test_dir}/${run}.tmux.log" rv=$? rm -f "${tmux_socket}" "${test_dir}/tmux-socket" - if [ $rv -ne 0 ]; then - test_error "tmux failure on test %s\n" "$run" + if [ "$rv" -ne 0 ]; then + 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 - test_error "mosh-client had non-zero exitstatus\n" + test_error "mosh-client had non-zero exitstatus\n" fi # Check for server harness failures if [ -z "$server" ]; then - if [ ! -s "${test_dir}/${run}.capture" ] \ - || [ ! -s "${test_dir}/${run}.exitstatus" ]; then - test_error "server harness failure on test %s\n" "$run" - fi - read -r server_rv < "${test_dir}/${run}.exitstatus" - if [ "$server_rv" -ne 0 ]; then - test_error "server harness exited with status %s\n" "$server_rv" - fi + if [ ! -s "${test_dir}/${run}.capture" ] || [ ! -s "${test_dir}/${run}.exitstatus" ]; then + test_error "server harness failure on test %s\n" "$run" + fi + read -r server_rv < "${test_dir}/${run}.exitstatus" + if [ "$server_rv" -ne 0 ]; then + test_error "server harness exited with status %s\n" "$server_rv" + fi fi if [ "${run}" != "direct" ]; then - # Check for "round-trip" failures - if grep -q "round-trip Instruction verification failed" "${test_dir}/${run}.server.stderr"; then - test_error "Round-trip Instruction verification failed on server during %s\n" "$run" - fi - # Check for 0-timeout select() issue - if egrep -q "(polls, rate limiting|consecutive polls)" "${test_dir}/${run}.server.stderr"; then - if [ "osx" != "${TRAVIS_OS_NAME}" ]; then - test_error "select() with zero timeout called too often on server during %s\n" "$run" - fi - fi - # Check for assert() - if egrep -q "assertion.*failed" "${test_dir}/${run}.server.stderr"; then - test_error "assertion during %s\n" "$run" - fi + # Check for "round-trip" failures + if grep -q "round-trip Instruction verification failed" "${test_dir}/${run}.server.stderr"; then + test_error "Round-trip Instruction verification failed on server during %s\n" "$run" + fi + # Check for 0-timeout select() issue + if grep -E -q "(polls, rate limiting|consecutive polls)" "${test_dir}/${run}.server.stderr"; then + if [ "osx" != "${TRAVIS_OS_NAME}" ]; then + test_error "select() with zero timeout called too often on server during %s\n" "$run" + fi + fi + # Check for assert() + if grep -E -q "assertion.*failed" "${test_dir}/${run}.server.stderr"; then + test_error "assertion during %s\n" "$run" + fi fi # XXX We'd also like to check for "target state Instruction # verification failed", a new check, but tmux's lack of BCE @@ -263,27 +269,27 @@ done for compare in $compare_tests; do log "Running server comparison %s.\n" "$compare" # Compare captures - if [ "$compare" = verify ]; then - test1="direct" - test2="baseline" + if [ "$compare" = "verify" ]; then + test1="direct" + test2="baseline" else - test1="baseline" - test2="variant" + test1="baseline" + test2="variant" fi if diff -q "${test_dir}/${test1}.capture" "${test_dir}/${test2}.capture"; then - differ=n + differ=n else - differ=y + differ=y fi - if [ "$compare" = different ]; then - desired=y - badresult=same + if [ "$compare" = "different" ]; then + desired=y + badresult=same else - desired=n - badresult=different + desired=n + badresult=different fi - if [ $differ != $desired ]; then - test_failure "Output is %s between tests %s and %s\n" "$badresult" "$test1" "$test2" + if [ "$differ" != "$desired" ]; then + test_failure "Output is %s between tests %s and %s\n" "$badresult" "$test1" "$test2" fi done @@ -291,7 +297,7 @@ done if [ -n "$post" ]; then "${test_script}" post status=$? - if [ $status -ne 0 ]; then - test_exitstatus $status "Post test failed with exitstatus %d\n" $status + if [ "$status" -ne 0 ]; then + test_exitstatus $status "Post test failed with exitstatus %d\n" $status fi fi diff --git a/src/tests/e2e-test-server b/src/tests/e2e-test-server index fc6d15a00..d1ad73fd9 100755 --- a/src/tests/e2e-test-server +++ b/src/tests/e2e-test-server @@ -12,19 +12,19 @@ wait_for_clients() { if [ -z "$MOSH_E2E_WAIT" ]; then - return + return fi expected=$1 - while true; do - n=$(tmux list-clients -F . | wc -l) - if [ $expected -eq 1 ]; then - if [ $n -eq 1 ]; then - return - fi - elif [ $n -ne 1 ]; then - return - fi - sleep 1 + while true; do + n=$(tmux list-clients -F . | wc -l) + if [ "$expected" -eq 1 ]; then + if [ "$n" -eq 1 ]; then + return + fi + elif [ "$n" -ne 1 ]; then + return + fi + sleep 1 done } @@ -40,8 +40,8 @@ rm -f "$testname.capture" "$testname.exitstatus" trap ":" TERM HUP QUIT # If the session closes on us, let the test we're running drive. on_exit() { rv=$? - echo $rv > "$testname.exitstatus" - exit $rv + echo "$rv" > "$testname.exitstatus" + exit "$rv" } trap on_exit EXIT # check for tmux @@ -65,7 +65,7 @@ wait_for_clients 1 i=0 while [ $i -lt 60 ]; do if grep -q "@@@ server complete @@@" "$testname.tmux.log"; then - break + break fi i=$((i+1)) sleep 1 diff --git a/src/tests/emulation-80th-column.test b/src/tests/emulation-80th-column.test index b33cc442c..906c500e0 100755 --- a/src/tests/emulation-80th-column.test +++ b/src/tests/emulation-80th-column.test @@ -30,10 +30,10 @@ baseline() stty raw printf '\033[H\033[J' for lines in $(seq 1 25); do - for tencols in $(seq 1 8); do - printf "EEEEEEEEEE" - done - printf "\r\n" + for tencols in $(seq 1 8); do + printf "EEEEEEEEEE" + done + printf "\r\n" done } @@ -43,15 +43,15 @@ post() # will have no blank lines in between and we should see 23 # of them. if [ "$(grep -c "EEEEEEEEEE" "$(basename "$0").d/baseline.capture")" -ne 23 ]; then - exit 1 + exit 1 fi } case $1 in - baseline) - baseline;; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + baseline) + baseline;; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/emulation-ascii-iso-8859.test b/src/tests/emulation-ascii-iso-8859.test index b50a00188..d9d859dca 100755 --- a/src/tests/emulation-ascii-iso-8859.test +++ b/src/tests/emulation-ascii-iso-8859.test @@ -36,11 +36,11 @@ d0 Ð d1 Ñ d2 Ò d3 Ó d4 Ô d5 Õ d6 Ö d7 × d8 Ø d9 Ù da Ú db Û dc Ü dd 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 - baseline|direct) - baseline;; - *) - fail "unknown test argument %s\n" "$1";; + baseline|direct) + baseline;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/emulation-attributes.test b/src/tests/emulation-attributes.test index e4ba2f3fe..df20caee3 100755 --- a/src/tests/emulation-attributes.test +++ b/src/tests/emulation-attributes.test @@ -15,13 +15,13 @@ . "$(dirname "$0")/e2e-test-subrs" PATH=$PATH:.:$srcdir # Need 2.3 for true-color support (2.2 may work also) -if [ "$(basename "$0")" = emulation-attributes-truecolor.test ] && +if [ "$(basename "$0")" = "emulation-attributes-truecolor.test" ] && ! tmux_check 2 3; then printf "tmux does not support true color\n" >&2 exit 77 fi # Need 2.4 for BCE support -if [ "$(basename "$0")" = emulation-attributes-bce.test ] && +if [ "$(basename "$0")" = "emulation-attributes-bce.test" ] && ! tmux_check 2 4; then printf "tmux does not support BCE\n" >&2 exit 77 @@ -75,73 +75,72 @@ baseline() printf '\033[H\033[J' - case $testname in - # Traditional ancient VT100 attributes. - vt100) - for attr in 0 1 4 5 7; do - printf '\033[%dmE\033[m ' $attr - done - ;; - # 16-color attributes. - 16color) - for attr in $(seq 30 37) $(seq 39 47) 49; do - printf '\033[%dmE\033[m ' "$attr" - done - ;; - # First 8 256-color attributes. Comparing mosh and tmux fails. - 256color8) - for attr in $(seq 0 7); do - printf '\033[38;5;%dmE\033[m ' "$attr" - printf '\033[48;5;%dmM\033[m ' "$attr" - done - ;; - # Last 248 256-color attributes. - 256color248) - for attr in $(seq 8 255); do - printf '\033[38;5;%dmE\033[m ' "$attr" - printf '\033[48;5;%dmM\033[m ' "$attr" - done - ;; + # Traditional ancient VT100 attributes. + vt100) + for attr in 0 1 4 5 7; do + printf '\033[%dmE\033[m ' $attr + done + ;; + # 16-color attributes. + 16color) + for attr in $(seq 30 37) $(seq 39 47) 49; do + printf '\033[%dmE\033[m ' "$attr" + done + ;; + # First 8 256-color attributes. Comparing mosh and tmux fails. + 256color8) + for attr in $(seq 0 7); do + printf '\033[38;5;%dmE\033[m ' "$attr" + printf '\033[48;5;%dmM\033[m ' "$attr" + done + ;; + # Last 248 256-color attributes. + 256color248) + for attr in $(seq 8 255); do + printf '\033[38;5;%dmE\033[m ' "$attr" + printf '\033[48;5;%dmM\033[m ' "$attr" + done + ;; + # True color. + # See https://gist.github.com/XVilka/8346728 for the test case + truecolor) + echo "Normal:" + test_true_color + echo "Bold:" + test_true_color 1 + echo "Italic:" + test_true_color 3 + echo "Underline:" + test_true_color 4 + echo "Blink:" + test_true_color 5 + echo "Inverse:" + test_true_color 7 + echo "Invisible:" + test_true_color 8 + echo "Bold, italic and underline:" + test_true_color 1 3 4 + ;; + # BCE in combination with various color modes. + bce) # True color. - # See https://gist.github.com/XVilka/8346728 for the test case - truecolor) - echo "Normal:" - test_true_color - echo "Bold:" - test_true_color 1 - echo "Italic:" - test_true_color 3 - echo "Underline:" - test_true_color 4 - echo "Blink:" - test_true_color 5 - echo "Inverse:" - test_true_color 7 - echo "Invisible:" - test_true_color 8 - echo "Bold, italic and underline:" - test_true_color 1 3 4 - ;; - # BCE in combination with various color modes. - bce) - # True color. - printf '\033[48;2;255;0;255m\033[H\033[JTrue color\n' - printf '\033[48;5;32m\033[J256 color\n' - printf '\033[42m\033[J16 color\n' - printf '\033[0mdone\n' - ;; - *) - fail "unknown test name %s\n" "$1" - ;; + printf '\033[48;2;255;0;255m\033[H\033[JTrue color\n' + printf '\033[48;5;32m\033[J256 color\n' + printf '\033[42m\033[J16 color\n' + printf '\033[0mdone\n' + ;; + *) + fail "unknown test name %s\n" "$1" + ;; esac printf '\033[mend\n' -} +} case $1 in - baseline|direct) - baseline "$0";; - *) - fail "unknown test argument %s\n" "$1";; + baseline|direct) + baseline "$0";; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/emulation-back-tab.test b/src/tests/emulation-back-tab.test index 3b24357a4..43f6196a9 100755 --- a/src/tests/emulation-back-tab.test +++ b/src/tests/emulation-back-tab.test @@ -31,26 +31,26 @@ post() { # Basic previously-failing case. if grep -q 'hello, wurldo' "$(basename "$0").d/baseline.capture"; then - exit 1 + exit 1 fi if ! grep -q 'hello, world' "$(basename "$0").d/baseline.capture"; then - exit 99 + exit 99 fi # New test cases for new code. if ! grep -q 'oello, wurld' "$(basename "$0").d/baseline.capture" || - ! grep -q '9ello, wurld' "$(basename "$0").d/baseline.capture" || - ! grep -q 'hello, wurld t' "$(basename "$0").d/baseline.capture" || - ! grep -E -q '^ {79}#$' "$(basename "$0").d/baseline.capture"; then - exit 1 + ! grep -q '9ello, wurld' "$(basename "$0").d/baseline.capture" || + ! grep -q 'hello, wurld t' "$(basename "$0").d/baseline.capture" || + ! grep -E -q '^ {79}#$' "$(basename "$0").d/baseline.capture"; then + exit 1 fi exit 0 } case $1 in - baseline) - baseline;; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + baseline) + baseline;; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/emulation-cursor-motion.test b/src/tests/emulation-cursor-motion.test index 40ea8b9f7..33751b538 100755 --- a/src/tests/emulation-cursor-motion.test +++ b/src/tests/emulation-cursor-motion.test @@ -24,8 +24,8 @@ baseline() printf '\033[H\033[J' while read -r x y text; do - printf '\033[%d;%dH%s' "$y" "$x" "$text" - sleepf + printf '\033[%d;%dH%s' "$y" "$x" "$text" + sleepf done <= 1" | bc) if [ "$onesec" -eq 1 ] || [ "$bigger" -ne 0 ]; then - exit 1 + exit 1 fi exit 0 } case $1 in - baseline) - baseline;; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + baseline) + baseline;; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/prediction-unicode.test b/src/tests/prediction-unicode.test index bbb675c09..6ae003d99 100755 --- a/src/tests/prediction-unicode.test +++ b/src/tests/prediction-unicode.test @@ -37,13 +37,13 @@ fi tmux_commands() { for x in $(seq 1 5); do - for y in $(seq 1 5); do - for i in "gl" ü "ck fa" ĩ "l "; do - printf "send-keys '%s'\n" "$i" - sleepf - done - done - printf "send-keys 0x0d\n" + for y in $(seq 1 5); do + for i in "gl" ü "ck fa" ĩ "l "; do + printf "send-keys '%s'\n" "$i" + sleepf + done + done + printf "send-keys 0x0d\n" done printf "send-keys 0x0d\n" sleep 1 @@ -53,9 +53,9 @@ tmux_commands() printf "send-keys 0x04\n" # This will get killed by SIGPIPE. while printf "show-options\n" && sleep 1; do - : + : done -} +} tmux_stdin() { @@ -73,25 +73,25 @@ post() { # Look for bad output: ')' or \374 ( - unset LC_ALL - unset LC_CTYPE - unset LANGUAGE - ! env LANG=C egrep -q "%output %0 (\)|$(printf \\374))" "$(basename "$0").d/baseline.tmux.log" - # Implicit exitcode return. + unset LC_ALL + unset LC_CTYPE + unset LANGUAGE + ! env LANG=C grep -E -q "%output %0 (\)|$(printf \\374))" "$(basename "$0").d/baseline.tmux.log" + # Implicit exitcode return. ) return $? } case $1 in - tmux) - shift; - tmux_stdin "$@";; - baseline) - baseline;; - mosh-args) - printf "%s\n" "--predict=always";; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + tmux) + shift; + tmux_stdin "$@";; + baseline) + baseline;; + mosh-args) + printf "%s\n" "--predict=always";; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/pty-deadlock.test b/src/tests/pty-deadlock.test index 219eca947..20a662484 100755 --- a/src/tests/pty-deadlock.test +++ b/src/tests/pty-deadlock.test @@ -33,11 +33,11 @@ tmux_commands() # Restart output... printf "send-keys 0x11\n" sleep 10 - # And stop the test script, so it produces its exit messge. + # And stop the test script, so it produces its exit message. printf "send-keys 0x0d\n" # This will get killed by SIGPIPE. while printf "show-options\n" && sleep 1; do - : + : done } @@ -56,7 +56,7 @@ baseline() done) read -r x while printf '%s' "$blat"; do - : + : done & printpid=$! (sleep 120; kill $$ $printpid) & @@ -76,19 +76,19 @@ baseline() post() { if grep -q '=== normal exit ===' "$(basename "$0").d/baseline.capture"; then - exit 0 + exit 0 fi exit 1 } case $1 in - tmux) - shift; - tmux_stdin "$@";; - baseline) - baseline;; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + tmux) + shift; + tmux_stdin "$@";; + baseline) + baseline;; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/repeat.test b/src/tests/repeat.test index 7830c8e81..0a07dbfe4 100755 --- a/src/tests/repeat.test +++ b/src/tests/repeat.test @@ -18,8 +18,8 @@ PATH=$PATH:.:$srcdir if [ $# -eq 0 ]; then do_tmux= case $(basename "$0" .test) in - repeat-with-input) - do_tmux=tmux;; + repeat-with-input) + do_tmux=tmux;; esac e2e-test "$0" baseline client server ${do_tmux} exit @@ -29,14 +29,14 @@ fi client() { for i in $(seq 1 $REPEAT_TEST_LOOPCOUNT); do - (sleep 15; kill $$) & - killpid=$! - if ! "$@"; then - printf "### iteration %d failed\n" "$i" - kill $killpid - exit 1 - fi - kill $killpid + (sleep 15; kill $$) & + killpid=$! + if ! "$@"; then + printf "### iteration %d failed\n" "$i" + kill $killpid + exit 1 + fi + kill $killpid done } @@ -52,7 +52,7 @@ server() tmux_commands() { while printf "send-keys 0x0d\n" && sleepf; do - : + : done } @@ -70,22 +70,22 @@ baseline() post() { if [ "$(grep -c "@@@ done" "$(basename "$0").d/baseline.tmux.log")" -lt $REPEAT_TEST_LOOPCOUNT ]; then - exit 1 + exit 1 fi } case $1 in - tmux) - shift; - tmux_stdin "$@";; - baseline) - baseline;; - client) - shift - client "$@";; - server) - shift - server "$@";; - *) - fail "unknown test argument %s\n" "$1";; + tmux) + shift; + tmux_stdin "$@";; + baseline) + baseline;; + client) + shift + client "$@";; + server) + shift + server "$@";; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/server-network-timeout.test b/src/tests/server-network-timeout.test index 5de601d54..0b995c655 100755 --- a/src/tests/server-network-timeout.test +++ b/src/tests/server-network-timeout.test @@ -28,12 +28,12 @@ fi client() { case "$myname" in - server-network-timeout) - export MOSH_SERVER_NETWORK_TMOUT=$TIMEOUT;; - server-signal-timeout) - export MOSH_SERVER_SIGNAL_TMOUT=$TIMEOUT;; - *) - fail "unexpected test name %s\n" "$myname" + server-network-timeout) + export MOSH_SERVER_NETWORK_TMOUT=$TIMEOUT;; + server-signal-timeout) + export MOSH_SERVER_SIGNAL_TMOUT=$TIMEOUT;; + *) + fail "unexpected test name %s\n" "$myname" esac shift # Print this early, because the server is expected to die before @@ -44,55 +44,56 @@ client() # The client may be murdered. We need to expect that... retval=$? case $retval in - 0|1) - fail "mosh-client had a normal exit\n";; # test condition failed - 9|137|265) - # Aha, signal 9. Wait. - sleep $(( TIMEOUT + 12 )) - exit 0 - ;; - *) - fail "unknown client wrapper failure, retval=%d\n" $retval - ;; + 0|1) + fail "mosh-client had a normal exit\n";; # test condition failed + 9|137|265) + # Aha, signal 9. Wait. + sleep $(( TIMEOUT + 12 )) + exit 0 + ;; + *) + fail "unknown client wrapper failure, retval=%d\n" $retval + ;; esac fail "client wrapper shouldnt get here\n" } + baseline() { # check for our wonderful variable if [ -z "$MOSH_SERVER_NETWORK_TMOUT" ] && [ -z "$MOSH_SERVER_SIGNAL_TMOUT" ]; then - env - fail "Variable unset\n" + env + fail "Variable unset\n" fi # check for our client if [ -z "$MOSH_CLIENT_PID" ]; then - env - fail "Client pid unavailable\n" + env + fail "Client pid unavailable\n" fi if ! kill -0 "$MOSH_CLIENT_PID"; then - fail "mosh client is unexpectedly missing\n" + 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 - + # Kill the client, to stop network traffic. kill -KILL "$MOSH_CLIENT_PID" case "$myname" in - server-network-timeout) - # Just wait. This is the hardest part. - sleep $(( TIMEOUT + 7 )) - ;; - server-signal-timeout) - # Wait for the timeout to expire. - sleep $(( TIMEOUT + 2 )) - # Tell the server to go away. - kill -USR1 "$MOSH_SERVER_PID" - sleep 5 - ;; - *) - fail "unexpected test name %s\n" "$myname" + server-network-timeout) + # Just wait. This is the hardest part. + sleep $(( TIMEOUT + 7 )) + ;; + server-signal-timeout) + # Wait for the timeout to expire. + sleep $(( TIMEOUT + 2 )) + # Tell the server to go away. + kill -USR1 "$MOSH_SERVER_PID" + sleep 5 + ;; + *) + fail "unexpected test name %s\n" "$myname" esac # 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. @@ -105,10 +106,10 @@ baseline() myname="$(basename "$0" .test)" case $1 in - baseline|variant) - baseline;; - client) - client "$@";; - *) - fail "unknown test argument %s\n" "$1";; + baseline|variant) + baseline;; + client) + client "$@";; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/unicode-combine-fallback-assert.test b/src/tests/unicode-combine-fallback-assert.test index 4185e0248..6c6361266 100755 --- a/src/tests/unicode-combine-fallback-assert.test +++ b/src/tests/unicode-combine-fallback-assert.test @@ -28,8 +28,8 @@ baseline() } case $1 in - baseline) - baseline;; - *) - fail "unknown test argument %s\n" "$1";; + baseline) + baseline;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/unicode-later-combining.test b/src/tests/unicode-later-combining.test index a1ca0ad3f..0c67685be 100755 --- a/src/tests/unicode-later-combining.test +++ b/src/tests/unicode-later-combining.test @@ -42,21 +42,21 @@ post() { export LANG=C if [ "$(tmux -V)" = "tmux 2.4" ]; then - skip "tmux 2.4 unicode combining bug breaks this test\n" + skip "tmux 2.4 unicode combining bug breaks this test\n" fi if grep -q "$(printf '^\302\240\314\202$')" "$(basename "$0").d/baseline.capture"; then - exit 0 + exit 0 fi exit 1 } case $1 in - baseline) - baseline;; - variant) - variant;; - post) - post;; - *) - fail "unknown test argument %s\n" "$1";; + baseline) + baseline;; + variant) + variant;; + post) + post;; + *) + fail "unknown test argument %s\n" "$1";; esac diff --git a/src/tests/window-resize.test b/src/tests/window-resize.test index a31025e93..9164955ba 100755 --- a/src/tests/window-resize.test +++ b/src/tests/window-resize.test @@ -24,13 +24,13 @@ tmux_resize_commands() printf "split-window -%s\n" "${hv}" # Shrink the pane we created for i in $(seq 1 10); do - sleepf - printf "resize-pane -%s\n" "${shrink}" + sleepf + printf "resize-pane -%s\n" "${shrink}" done # And grow it for i in $(seq 1 10); do - sleepf - printf "resize-pane -%s\n" "${grow}" + sleepf + printf "resize-pane -%s\n" "${grow}" done sleep 1 # Remove the pane we created. @@ -73,11 +73,11 @@ baseline() } case $1 in - tmux) - shift; - tmux_stdin "$@";; - baseline) - baseline;; - *) - fail "unknown test argument %s\n" "$1";; + tmux) + shift; + tmux_stdin "$@";; + baseline) + baseline;; + *) + fail "unknown test argument %s\n" "$1";; esac