@@ -23,9 +23,9 @@ dump_logs()
2323 shift
2424 testname=$( basename " $dir " .d)
2525 for logfile in $dir /* .tmux.log; do
26- printf " travis_fold:start:%s-%s\n" " $testname " " $( basename " $logfile " ) "
27- cat " $logfile "
28- printf " travis_fold:end:%s-%s\n" " $testname " " $( basename " $logfile " ) "
26+ printf " travis_fold:start:%s-%s\n" " $testname " " $( basename " $logfile " ) "
27+ cat " $logfile "
28+ printf " travis_fold:end:%s-%s\n" " $testname " " $( basename " $logfile " ) "
2929 done
3030}
3131
@@ -56,13 +56,12 @@ test_exitstatus()
5656 exit " $status "
5757}
5858
59-
6059ssh_localhost_check ()
6160{
6261 ssh localhost :
6362 if [ $? -ne 0 ]; then
64- error " ssh to localhost failed\n"
65- return 1
63+ error " ssh to localhost failed\n"
64+ return 1
6665 fi
6766 return 0
6867}
@@ -72,7 +71,7 @@ ssh_localhost_check()
7271mosh_client ()
7372{
7473 if [ -z " $MOSH_CLIENT " ] || [ -z " $MOSH_E2E_TEST " ]; then
75- test_error " mosh_client: variables missing\n"
74+ test_error " mosh_client: variables missing\n"
7675 fi
7776 exec 2> " ${MOSH_E2E_TEST} .client.stderr"
7877 exec " $MOSH_CLIENT " $MOSH_CLIENT_ARGS " $@ "
@@ -81,7 +80,7 @@ mosh_client()
8180mosh_server ()
8281{
8382 if [ -z " $MOSH_SERVER " ] || [ -z " $MOSH_E2E_TEST " ]; then
84- test_error " mosh_server: variables missing\n"
83+ test_error " mosh_server: variables missing\n"
8584 fi
8685 exec 2> " ${MOSH_E2E_TEST} .server.stderr"
8786 exec " $MOSH_SERVER " new -vv $MOSH_SERVER_ARGS -@ " $@ "
@@ -94,23 +93,23 @@ if [ -z "$srcdir" ]; then
9493else
9594 srcdir=" $( cd " $srcdir " && pwd) "
9695 if [ $? -ne 0 ]; then
97- error " can't cd to srcdir: %s\n" " $srcdir "
98- exit 99
96+ error " can't cd to srcdir: %s\n" " $srcdir "
97+ exit 99
9998 fi
10099fi
101100
102101# Wrappers.
103102case " $( basename " $0 " ) " in
104- mosh-client)
105- mosh_client " $@ "
106- exit
107- ;;
108- mosh-server)
109- mosh_server " $@ "
110- exit
111- ;;
112- * )
113- ;;
103+ mosh-client)
104+ mosh_client " $@ "
105+ exit
106+ ;;
107+ mosh-server)
108+ mosh_server " $@ "
109+ exit
110+ ;;
111+ * )
112+ ;;
114113esac
115114
116115if [ $# -lt 2 ]; then
141140rm -rf " ${test_dir} "
142141mkdir " ${test_dir} "
143142
144-
145143on_exit () {
146144 rv=$?
147- if test $rv -ne 0; then
148- dump_logs " $test_dir " $test_args
145+ if test " $rv " -ne 0; then
146+ dump_logs " $test_dir " $test_args
149147 fi
150- exit $rv
148+ exit " $rv "
151149}
152150trap on_exit EXIT
153151
@@ -156,30 +154,39 @@ server_tests=
156154compare_tests=
157155for i in $test_args ; do
158156 case $i in
159- baseline|direct|variant)
160- server_tests=" $server_tests $i " ;;
161- verify|same|different)
162- compare_tests=" $compare_tests $i " ;;
163- tmux)
164- tmux=1;;
165- client)
166- client=1;;
167- server)
168- server=1;;
169- post)
170- post=1;;
171- mosh-args)
172- mosh_args=$( " ${test_script} " mosh-args) ;;
173- client-args)
174- MOSH_CLIENT_ARGS=$( " ${test_script} " client-args)
175- export MOSH_CLIENT_ARGS;;
176- server-args)
177- MOSH_SERVER_ARGS=$( " ${test_script} " server-args)
178- export MOSH_SERVER_ARGS;;
179- * )
180- error ' unknown test type argument %s\n' " $i "
181- exit 99
182- ;;
157+ baseline|direct|variant)
158+ server_tests=" $server_tests $i "
159+ ;;
160+ verify|same|different)
161+ compare_tests=" $compare_tests $i "
162+ ;;
163+ tmux)
164+ tmux=1
165+ ;;
166+ client)
167+ client=1
168+ ;;
169+ server)
170+ server=1
171+ ;;
172+ post)
173+ post=1
174+ ;;
175+ mosh-args)
176+ mosh_args=$( " ${test_script} " mosh-args)
177+ ;;
178+ client-args)
179+ MOSH_CLIENT_ARGS=$( " ${test_script} " client-args)
180+ export MOSH_CLIENT_ARGS
181+ ;;
182+ server-args)
183+ MOSH_SERVER_ARGS=$( " ${test_script} " server-args)
184+ export MOSH_SERVER_ARGS
185+ ;;
186+ * )
187+ error ' unknown test type argument %s\n' " $i "
188+ exit 99
189+ ;;
183190 esac
184191done
185192
@@ -194,7 +201,7 @@ if [ -n "$server" ]; then
194201 server_wrapper=" \" ${srcdir} /${test_script} \" server"
195202fi
196203tmux_stdin=" ${srcdir} /hold-stdin"
197- if [ -n " $tmux " ]; then
204+ if [ -n " $tmux " ]; then
198205 tmux_stdin=" ${test_script} tmux"
199206fi
200207
@@ -209,7 +216,7 @@ for run in $server_tests; do
209216 # XXX need to quote special chars in server pathname here somehow
210217 sut=" ../../scripts/mosh --client=${srcdir} /mosh-client --server=${srcdir} /mosh-server --local --bind-server=127.0.0.1 ${mosh_args} 127.0.0.1"
211218 if [ " $run " = " direct" ]; then
212- sut=" "
219+ sut=" "
213220 fi
214221 # Actually execute code under test
215222 # 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
219226 ${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"
220227 rv=$?
221228 rm -f " ${tmux_socket} " " ${test_dir} /tmux-socket"
222- if [ $rv -ne 0 ]; then
223- test_error " tmux failure on test %s\n" " $run "
229+ if [ " $rv " -ne 0 ]; then
230+ test_error " tmux failure on test %s\n" " $run "
224231 fi
225232 # Check for mosh failures
226233 if ! grep -q " @@@ exitstatus: 0 @@@" " ${test_dir} /${run} .tmux.log" ; then
227- test_error " mosh-client had non-zero exitstatus\n"
234+ test_error " mosh-client had non-zero exitstatus\n"
228235 fi
229236
230237 # Check for server harness failures
231238 if [ -z " $server " ]; then
232- if [ ! -s " ${test_dir} /${run} .capture" ] \
233- || [ ! -s " ${test_dir} /${run} .exitstatus" ]; then
234- test_error " server harness failure on test %s\n" " $run "
235- fi
236- read -r server_rv < " ${test_dir} /${run} .exitstatus"
237- if [ " $server_rv " -ne 0 ]; then
238- test_error " server harness exited with status %s\n" " $server_rv "
239- fi
239+ if [ ! -s " ${test_dir} /${run} .capture" ] || [ ! -s " ${test_dir} /${run} .exitstatus" ]; then
240+ test_error " server harness failure on test %s\n" " $run "
241+ fi
242+ read -r server_rv < " ${test_dir} /${run} .exitstatus"
243+ if [ " $server_rv " -ne 0 ]; then
244+ test_error " server harness exited with status %s\n" " $server_rv "
245+ fi
240246 fi
241247 if [ " ${run} " != " direct" ]; then
242- # Check for "round-trip" failures
243- if grep -q " round-trip Instruction verification failed" " ${test_dir} /${run} .server.stderr" ; then
244- test_error " Round-trip Instruction verification failed on server during %s\n" " $run "
245- fi
246- # Check for 0-timeout select() issue
247- if egrep -q " (polls, rate limiting|consecutive polls)" " ${test_dir} /${run} .server.stderr" ; then
248- if [ " osx" != " ${TRAVIS_OS_NAME} " ]; then
249- test_error " select() with zero timeout called too often on server during %s\n" " $run "
250- fi
251- fi
252- # Check for assert()
253- if egrep -q " assertion.*failed" " ${test_dir} /${run} .server.stderr" ; then
254- test_error " assertion during %s\n" " $run "
255- fi
248+ # Check for "round-trip" failures
249+ if grep -q " round-trip Instruction verification failed" " ${test_dir} /${run} .server.stderr" ; then
250+ test_error " Round-trip Instruction verification failed on server during %s\n" " $run "
251+ fi
252+ # Check for 0-timeout select() issue
253+ if grep -E -q " (polls, rate limiting|consecutive polls)" " ${test_dir} /${run} .server.stderr" ; then
254+ if [ " osx" != " ${TRAVIS_OS_NAME} " ]; then
255+ test_error " select() with zero timeout called too often on server during %s\n" " $run "
256+ fi
257+ fi
258+ # Check for assert()
259+ if grep -E -q " assertion.*failed" " ${test_dir} /${run} .server.stderr" ; then
260+ test_error " assertion during %s\n" " $run "
261+ fi
256262 fi
257263 # XXX We'd also like to check for "target state Instruction
258264 # verification failed", a new check, but tmux's lack of BCE
@@ -263,35 +269,35 @@ done
263269for compare in $compare_tests ; do
264270 log " Running server comparison %s.\n" " $compare "
265271 # Compare captures
266- if [ " $compare " = verify ]; then
267- test1=" direct"
268- test2=" baseline"
272+ if [ " $compare " = " verify" ]; then
273+ test1=" direct"
274+ test2=" baseline"
269275 else
270- test1=" baseline"
271- test2=" variant"
276+ test1=" baseline"
277+ test2=" variant"
272278 fi
273279 if diff -q " ${test_dir} /${test1} .capture" " ${test_dir} /${test2} .capture" ; then
274- differ=n
280+ differ=n
275281 else
276- differ=y
282+ differ=y
277283 fi
278- if [ " $compare " = different ]; then
279- desired=y
280- badresult=same
284+ if [ " $compare " = " different" ]; then
285+ desired=y
286+ badresult=same
281287 else
282- desired=n
283- badresult=different
288+ desired=n
289+ badresult=different
284290 fi
285- if [ $differ != $desired ]; then
286- test_failure " Output is %s between tests %s and %s\n" " $badresult " " $test1 " " $test2 "
291+ if [ " $differ " != " $desired " ]; then
292+ test_failure " Output is %s between tests %s and %s\n" " $badresult " " $test1 " " $test2 "
287293 fi
288294done
289295
290296# Run a post script (usually a custom validation of results)
291297if [ -n " $post " ]; then
292298 " ${test_script} " post
293299 status=$?
294- if [ $status -ne 0 ]; then
295- test_exitstatus $status " Post test failed with exitstatus %d\n" $status
300+ if [ " $status " -ne 0 ]; then
301+ test_exitstatus $status " Post test failed with exitstatus %d\n" $status
296302 fi
297303fi
0 commit comments