]> git.ipfire.org Git - thirdparty/hostap.git/blobdiff - tests/hwsim/run-all.sh
tests: Refactor run-all.sh
[thirdparty/hostap.git] / tests / hwsim / run-all.sh
index 9471dd8fdc0df26a16ccdd3f4142b63a1b7abd6e..4822534fe004117c0ee8ee870c0cf85c92554c8e 100755 (executable)
@@ -17,90 +17,65 @@ else
 fi
 
 if [ "x$1" = "xconcurrent-valgrind" ]; then
-    if ! ./start.sh concurrent valgrind; then
-       echo "Could not start test environment" > $LOGDIR/last-debug
-       exit 1
-    fi
-    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    rm $LOGDIR/last-debug
-    for i in autogo discovery grpform; do
-       ./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i || errors=1
-       cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug
-    done
-    ./stop-wifi.sh
-    failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
-    if [ $failures -gt 0 ]; then
-       echo "Mark as failed due to valgrind errors"
-       errors=1
-    fi
-    if [ $errors -gt 0 ]; then
-       tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent-valgrind.tar.gz $LOGDIR/$DATE*
-       exit 1
-    fi
+       VALGRIND=valgrind
+       CONCURRENT=concurrent
+       CONCURRENT_TESTS="-f test_p2p_autogo test_p2p_discovery test_p2p_grpform"
+       SUFFIX=-concurrent-valgrind
+       shift
 elif [ "x$1" = "xconcurrent" ]; then
-    if ! ./start.sh concurrent; then
-       echo "Could not start test environment" > $LOGDIR/last-debug
-       exit 1
-    fi
-    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    rm $LOGDIR/last-debug
-    for i in autogo discovery grpform; do
-       ./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i || errors=1
-       cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug
-    done
-    ./stop-wifi.sh
-    if [ $errors -gt 0 ]; then
-       tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent.tar.gz $LOGDIR/$DATE*
-       exit 1
-    fi
+       CONCURRENT=concurrent
+       CONCURRENT_TESTS="-f test_p2p_autogo test_p2p_discovery test_p2p_grpform"
+       unset VALGRIND
+       SUFFIX=-concurrent
+       shift
 elif [ "x$1" = "xvalgrind" ]; then
-    if ! ./start.sh valgrind; then
+       VALGRIND=valgrind
+       unset CONCURRENT
+       unset CONCURRENT_TESTS
+       SUFFIX=-valgrind
+       shift
+else
+       unset VALGRIND
+       unset CONCURRENT
+       unset CONCURRENT_TESTS
+       SUFFIX=
+fi
+
+if [ "x$1" = "xtrace" ] ; then
+       TRACE=trace
+       SUFFIX=$SUFFIX-trace
+else
+       unset TRACE
+fi
+
+if ! ./start.sh $CONCURRENT $VALGRIND $TRACE; then
        echo "Could not start test environment" > $LOGDIR/last-debug
        exit 1
-    fi
-    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1
-    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
-    ./stop-wifi.sh
+fi
+DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
+rm $LOGDIR/last-debug 2>/dev/null
+RUNTESTS="./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt $CONCURRENT_TESTS"
+
+if [ "$TRACE" != "" ] ; then
+       sudo trace-cmd record -o $LOGDIR/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c $RUNTESTS || errors=1
+else
+       $RUNTESTS || errors=1
+fi
+
+
+cat $LOGDIR/$DATE-run >> $LOGDIR/last-debug
+./stop-wifi.sh
+
+if [ ! -z "$VALGRIND" ] ; then
     failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
     if [ $failures -gt 0 ]; then
        echo "Mark as failed due to valgrind errors"
        errors=1
     fi
-    if [ $errors -gt 0 ]; then
-       tar czf /tmp/hwsim-tests-$DATE-FAILED-valgrind.tar.gz $LOGDIR/$DATE*
-       exit 1
-    fi
-elif [ "x$1" = "xtrace" ]; then
-    if ! ./start.sh trace; then
-       echo "Could not start test environment" > $LOGDIR/last-debug
-       exit 1
-    fi
-    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    sudo trace-cmd record -o $LOGDIR/$DATE-trace.dat -e mac80211 -e cfg80211 su $USER -c "./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt" || errors=1
-    if [ -e $LOGDIR/$DATE-failed ]; then
-       error=1
-    fi
-    sudo chown $USER $LOGDIR/$DATE-trace.dat
-    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
-    ./stop-wifi.sh
-    if [ $errors -gt 0 ]; then
-       tar czf /tmp/hwsim-tests-$DATE-FAILED-trace.tar.gz $LOGDIR/$DATE*
-       exit 1
-    fi
-else
-    if ! ./start.sh; then
-       echo "Could not start test environment" > $LOGDIR/last-debug
-       exit 1
-    fi
-    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1
-    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
-    ./stop-wifi.sh
-    if [ $errors -gt 0 ]; then
-       tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz $LOGDIR/$DATE*
-       exit 1
-    fi
+fi
+if [ $errors -gt 0 ]; then
+    tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/$DATE*
+    exit 1
 fi
 
 echo "ALL-PASSED"