From 8d0825d65575d393415de5f594cea55960c0846b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 28 Sep 2013 18:19:38 +0300 Subject: [PATCH] tests: Exit early if startup fails There is no point trying to go through the tests if hostapd and wpa_supplicant processes cannot be started properly. Signed-hostap: Jouni Malinen --- tests/hwsim/run-all.sh | 27 ++++++++++++++++++++++----- tests/hwsim/start-p2p-concurrent.sh | 4 ++++ tests/hwsim/start.sh | 4 ++++ 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh index 68fc5359e..dbd74034a 100755 --- a/tests/hwsim/run-all.sh +++ b/tests/hwsim/run-all.sh @@ -4,7 +4,10 @@ errors=0 umask 0002 if [ "x$1" = "xconcurrent-valgrind" ]; then - ./start-p2p-concurrent.sh valgrind + if ! ./start-p2p-concurrent.sh valgrind; then + echo "Could not start test environment" > logs/last-debug + exit 1 + fi DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` rm logs/last-debug for i in autogo discovery grpform; do @@ -22,7 +25,10 @@ if [ "x$1" = "xconcurrent-valgrind" ]; then exit 1 fi elif [ "x$1" = "xconcurrent" ]; then - ./start-p2p-concurrent.sh + if ! ./start-p2p-concurrent.sh; then + echo "Could not start test environment" > logs/last-debug + exit 1 + fi DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` rm logs/last-debug for i in autogo discovery grpform; do @@ -35,7 +41,10 @@ elif [ "x$1" = "xconcurrent" ]; then exit 1 fi elif [ "x$1" = "xvalgrind" ]; then - ./start.sh valgrind + if ! ./start.sh valgrind; then + echo "Could not start test environment" > logs/last-debug + exit 1 + fi DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` ./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1 cat logs/$DATE-run > logs/last-debug @@ -50,7 +59,10 @@ elif [ "x$1" = "xvalgrind" ]; then exit 1 fi elif [ "x$1" = "xtrace" ]; then - ./start.sh trace + if ! ./start.sh trace; then + echo "Could not start test environment" > logs/last-debug + exit 1 + fi DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` sudo trace-cmd record -o logs/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c "./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed" || errors=1 if [ -e logs/$DATE-failed ]; then @@ -64,7 +76,10 @@ elif [ "x$1" = "xtrace" ]; then exit 1 fi else - ./start.sh + if ! ./start.sh; then + echo "Could not start test environment" > logs/last-debug + exit 1 + fi DATE=`ls -1tr logs | tail -1 | cut -f1 -d-` ./run-tests.py -l logs/$DATE-run -e logs/$DATE-failed || errors=1 cat logs/$DATE-run > logs/last-debug @@ -74,3 +89,5 @@ else exit 1 fi fi + +echo "ALL-PASSED" diff --git a/tests/hwsim/start-p2p-concurrent.sh b/tests/hwsim/start-p2p-concurrent.sh index c038f339f..1d1200eab 100755 --- a/tests/hwsim/start-p2p-concurrent.sh +++ b/tests/hwsim/start-p2p-concurrent.sh @@ -47,6 +47,7 @@ for i in 0 1 2; do fi if [ $j = "10" ]; then echo "Could not connect to /tmp/wpas-wlan$i" + exit 1 fi sleep 1 done @@ -58,6 +59,9 @@ for j in `seq 1 10`; do fi if [ $j = "10" ]; then echo "Could not connect to /var/run/hostapd-global" + exit 1 fi sleep 1 done + +exit 0 diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh index 98328ef7a..503a59a6b 100755 --- a/tests/hwsim/start.sh +++ b/tests/hwsim/start.sh @@ -52,6 +52,7 @@ for i in 0 1 2; do fi if [ $j = "10" ]; then echo "Could not connect to /tmp/wpas-wlan$i" + exit 1 fi sleep 1 done @@ -63,6 +64,9 @@ for j in `seq 1 10`; do fi if [ $j = "10" ]; then echo "Could not connect to /var/run/hostapd-global" + exit 1 fi sleep 1 done + +exit 0