Browse Source

tests: Allow specifying LOGDIR for hwsim scripts

Instead of hardcoding logs/, allow putting LOGDIR into
the environment. This helps run tests in a VM where the
rootfs might be mounted read-only.

Signed-hostap: Johannes Berg <johannes.berg@intel.com>
Johannes Berg 11 years ago
parent
commit
5fecc0f525
3 changed files with 56 additions and 47 deletions
  1. 3 3
      tests/hwsim/README
  2. 35 31
      tests/hwsim/run-all.sh
  3. 18 13
      tests/hwsim/start.sh

+ 3 - 3
tests/hwsim/README

@@ -131,9 +131,9 @@ conditions:
 # run P2P test cases with concurrent station interface under valgrind
 # run P2P test cases with concurrent station interface under valgrind
 ./run-all.sh concurrent-valgrind
 ./run-all.sh concurrent-valgrind
 
 
-run-all.sh directs debug logs into the logs subdirectory. Log file names
+run-all.sh directs debug logs into the logs subdirectory (or $LOGDIR if
-include the current UNIX timestamp and a postfix to identify the
+present in the environment). Log file names include the current UNIX
-specific log:
+timestamp and a postfix to identify the specific log:
 - log0 = wpa_supplicant debug log for the first radio
 - log0 = wpa_supplicant debug log for the first radio
 - log1 = wpa_supplicant debug log for the second radio
 - log1 = wpa_supplicant debug log for the second radio
 - log2 = wpa_supplicant debug log for the third radio
 - log2 = wpa_supplicant debug log for the third radio

+ 35 - 31
tests/hwsim/run-all.sh

@@ -3,6 +3,10 @@
 errors=0
 errors=0
 umask 0002
 umask 0002
 
 
+if [ -z "$LOGDIR" ]; then
+	LOGDIR=logs
+fi
+
 if [ -z "$DBFILE" ]; then
 if [ -z "$DBFILE" ]; then
     DB=""
     DB=""
 else
 else
@@ -14,87 +18,87 @@ fi
 
 
 if [ "x$1" = "xconcurrent-valgrind" ]; then
 if [ "x$1" = "xconcurrent-valgrind" ]; then
     if ! ./start.sh concurrent valgrind; then
     if ! ./start.sh concurrent valgrind; then
-	echo "Could not start test environment" > logs/last-debug
+	echo "Could not start test environment" > $LOGDIR/last-debug
 	exit 1
 	exit 1
     fi
     fi
-    DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    rm logs/last-debug
+    rm $LOGDIR/last-debug
     for i in autogo discovery grpform; do
     for i in autogo discovery grpform; do
-	./run-tests.py -l logs/$DATE-run-$i $DB -e logs/$DATE-failed-$i -r logs/results.txt -f test_p2p_$i.py || errors=1
+	./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i.py || errors=1
-	cat logs/$DATE-run-$i >> logs/last-debug
+	cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug
     done
     done
     ./stop-wifi.sh
     ./stop-wifi.sh
-    failures=`grep "ERROR SUMMARY" logs/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
+    failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
     if [ $failures -gt 0 ]; then
     if [ $failures -gt 0 ]; then
 	echo "Mark as failed due to valgrind errors"
 	echo "Mark as failed due to valgrind errors"
 	errors=1
 	errors=1
     fi
     fi
     if [ $errors -gt 0 ]; then
     if [ $errors -gt 0 ]; then
-	tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent-valgrind.tar.gz logs/$DATE*
+	tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent-valgrind.tar.gz $LOGDIR/$DATE*
 	exit 1
 	exit 1
     fi
     fi
 elif [ "x$1" = "xconcurrent" ]; then
 elif [ "x$1" = "xconcurrent" ]; then
     if ! ./start.sh concurrent; then
     if ! ./start.sh concurrent; then
-	echo "Could not start test environment" > logs/last-debug
+	echo "Could not start test environment" > $LOGDIR/last-debug
 	exit 1
 	exit 1
     fi
     fi
-    DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    rm logs/last-debug
+    rm $LOGDIR/last-debug
     for i in autogo discovery grpform; do
     for i in autogo discovery grpform; do
-	./run-tests.py -l logs/$DATE-run-$i $DB -e logs/$DATE-failed-$i -r logs/results.txt -f test_p2p_$i.py || errors=1
+	./run-tests.py -l $LOGDIR/$DATE-run-$i $DB -e $LOGDIR/$DATE-failed-$i -r $LOGDIR/results.txt -f test_p2p_$i.py || errors=1
-	cat logs/$DATE-run-$i >> logs/last-debug
+	cat $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug
     done
     done
     ./stop-wifi.sh
     ./stop-wifi.sh
     if [ $errors -gt 0 ]; then
     if [ $errors -gt 0 ]; then
-	tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent.tar.gz logs/$DATE*
+	tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent.tar.gz $LOGDIR/$DATE*
 	exit 1
 	exit 1
     fi
     fi
 elif [ "x$1" = "xvalgrind" ]; then
 elif [ "x$1" = "xvalgrind" ]; then
     if ! ./start.sh valgrind; then
     if ! ./start.sh valgrind; then
-	echo "Could not start test environment" > logs/last-debug
+	echo "Could not start test environment" > $LOGDIR/last-debug
 	exit 1
 	exit 1
     fi
     fi
-    DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    ./run-tests.py -l logs/$DATE-run $DB -e logs/$DATE-failed -r logs/results.txt || errors=1
+    ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1
-    cat logs/$DATE-run > logs/last-debug
+    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
     ./stop-wifi.sh
     ./stop-wifi.sh
-    failures=`grep "ERROR SUMMARY" logs/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
+    failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
     if [ $failures -gt 0 ]; then
     if [ $failures -gt 0 ]; then
 	echo "Mark as failed due to valgrind errors"
 	echo "Mark as failed due to valgrind errors"
 	errors=1
 	errors=1
     fi
     fi
     if [ $errors -gt 0 ]; then
     if [ $errors -gt 0 ]; then
-	tar czf /tmp/hwsim-tests-$DATE-FAILED-valgrind.tar.gz logs/$DATE*
+	tar czf /tmp/hwsim-tests-$DATE-FAILED-valgrind.tar.gz $LOGDIR/$DATE*
 	exit 1
 	exit 1
     fi
     fi
 elif [ "x$1" = "xtrace" ]; then
 elif [ "x$1" = "xtrace" ]; then
     if ! ./start.sh trace; then
     if ! ./start.sh trace; then
-	echo "Could not start test environment" > logs/last-debug
+	echo "Could not start test environment" > $LOGDIR/last-debug
 	exit 1
 	exit 1
     fi
     fi
-    DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    DATE=`ls -1tr $LOGDIR | 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 $DB -e logs/$DATE-failed -r logs/results.txt" || errors=1
+    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 logs/$DATE-failed ]; then
+    if [ -e $LOGDIR/$DATE-failed ]; then
 	error=1
 	error=1
     fi
     fi
-    sudo chown $USER logs/$DATE-trace.dat
+    sudo chown $USER $LOGDIR/$DATE-trace.dat
-    cat logs/$DATE-run > logs/last-debug
+    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
     ./stop-wifi.sh
     ./stop-wifi.sh
     if [ $errors -gt 0 ]; then
     if [ $errors -gt 0 ]; then
-	tar czf /tmp/hwsim-tests-$DATE-FAILED-trace.tar.gz logs/$DATE*
+	tar czf /tmp/hwsim-tests-$DATE-FAILED-trace.tar.gz $LOGDIR/$DATE*
 	exit 1
 	exit 1
     fi
     fi
 else
 else
     if ! ./start.sh; then
     if ! ./start.sh; then
-	echo "Could not start test environment" > logs/last-debug
+	echo "Could not start test environment" > $LOGDIR/last-debug
 	exit 1
 	exit 1
     fi
     fi
-    DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
+    DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-    ./run-tests.py -l logs/$DATE-run $DB -e logs/$DATE-failed -r logs/results.txt || errors=1
+    ./run-tests.py -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt || errors=1
-    cat logs/$DATE-run > logs/last-debug
+    cat $LOGDIR/$DATE-run > $LOGDIR/last-debug
     ./stop-wifi.sh
     ./stop-wifi.sh
     if [ $errors -gt 0 ]; then
     if [ $errors -gt 0 ]; then
-	tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz logs/$DATE*
+	tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz $LOGDIR/$DATE*
 	exit 1
 	exit 1
     fi
     fi
 fi
 fi

+ 18 - 13
tests/hwsim/start.sh

@@ -7,6 +7,11 @@ HAPD=$DIR/../../hostapd/hostapd
 WLANTEST=$DIR/../../wlantest/wlantest
 WLANTEST=$DIR/../../wlantest/wlantest
 HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
 HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
 
 
+if [ -z "$LOGDIR" ] ; then
+    LOGDIR=$DIR/logs
+fi
+export LOGDIR
+
 if groups | tr ' ' "\n" | grep -q ^admin$; then
 if groups | tr ' ' "\n" | grep -q ^admin$; then
     GROUP=admin
     GROUP=admin
 else
 else
@@ -42,43 +47,43 @@ if [ "$CONCURRENT" = "y" ]; then
     sudo iw wlan1 interface add sta1 type station
     sudo iw wlan1 interface add sta1 type station
     sudo iw wlan2 interface add sta2 type station
     sudo iw wlan2 interface add sta2 type station
 fi
 fi
-mkdir -p $DIR/logs
+mkdir -p $LOGDIR
 DATE=`date +%s`
 DATE=`date +%s`
 sudo ifconfig hwsim0 up
 sudo ifconfig hwsim0 up
-sudo $WLANTEST -i hwsim0 -c -d > $DIR/logs/$DATE-hwsim0 &
+sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/$DATE-hwsim0 &
-sudo tcpdump -ni hwsim0 -s 2500 -w $DIR/logs/$DATE-hwsim0.dump > $DIR/logs/$DATE-tcpdump 2>&1 &
+sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/$DATE-hwsim0.dump > $LOGDIR/$DATE-tcpdump 2>&1 &
 if [ "$VALGRIND" = "y" ]; then
 if [ "$VALGRIND" = "y" ]; then
     for i in 0 1 2; do
     for i in 0 1 2; do
 	chmod a+rx $WPAS
 	chmod a+rx $WPAS
 	if [ "$CONCURRENT" = "y" ]; then
 	if [ "$CONCURRENT" = "y" ]; then
-	    sudo valgrind --log-file=$DIR/logs/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $DIR/logs/$DATE-log$i &
+	    sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i &
 	else
 	else
-	    sudo valgrind --log-file=$DIR/logs/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $DIR/logs/$DATE-log$i &
+	    sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan$i $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i &
 	fi
 	fi
     done
     done
     chmod a+rx $HAPD
     chmod a+rx $HAPD
-    sudo valgrind --log-file=$DIR/logs/$DATE-valgrind-hostapd $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $DIR/logs/$DATE-hostapd &
+    sudo valgrind --log-file=$LOGDIR/$DATE-valgrind-hostapd $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd &
 else
 else
     for i in 0 1 2; do
     for i in 0 1 2; do
 	if [ "$CONCURRENT" = "y" ]; then
 	if [ "$CONCURRENT" = "y" ]; then
-	    sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $DIR/logs/$DATE-log$i &
+	    sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -N -Dnl80211 -ista$i -c $DIR/sta-dummy.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i &
 	else
 	else
-	    sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $DIR/logs/$DATE-log$i &
+	    sudo $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf -ddKt$TRACE > $LOGDIR/$DATE-log$i &
 	fi
 	fi
     done
     done
-    sudo $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $DIR/logs/$DATE-hostapd &
+    sudo $HAPD -ddKt -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd &
 fi
 fi
 sleep 1
 sleep 1
-sudo chown $USER $DIR/logs/$DATE-hwsim0.dump
+sudo chown $USER $LOGDIR/$DATE-hwsim0.dump
 if [ "x$VALGRIND" = "xy" ]; then
 if [ "x$VALGRIND" = "xy" ]; then
-    sudo chown $USER $DIR/logs/$DATE-*valgrind*
+    sudo chown $USER $LOGDIR/$DATE-*valgrind*
 fi
 fi
 
 
 if [ -x $HLR_AUC_GW ]; then
 if [ -x $HLR_AUC_GW ]; then
-    $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $DIR/logs/$DATE-hlr_auc_gw &
+    $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/$DATE-hlr_auc_gw &
 fi
 fi
 
 
-$HAPD -ddKt $DIR/auth_serv/as.conf > $DIR/logs/$DATE-auth_serv &
+$HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/$DATE-auth_serv &
 
 
 # wait for programs to be fully initialized
 # wait for programs to be fully initialized
 for i in 0 1 2; do
 for i in 0 1 2; do