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>
This commit is contained in:
Johannes Berg 2013-10-30 15:55:58 +02:00 committed by Jouni Malinen
parent 392e68e81f
commit 5fecc0f525
3 changed files with 56 additions and 47 deletions

View file

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

View file

@ -3,6 +3,10 @@
errors=0
umask 0002
if [ -z "$LOGDIR" ]; then
LOGDIR=logs
fi
if [ -z "$DBFILE" ]; then
DB=""
else
@ -14,87 +18,87 @@ fi
if [ "x$1" = "xconcurrent-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
fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
rm logs/last-debug
DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
rm $LOGDIR/last-debug
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
cat logs/$DATE-run-$i >> logs/last-debug
./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 $LOGDIR/$DATE-run-$i >> $LOGDIR/last-debug
done
./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
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 logs/$DATE*
tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent-valgrind.tar.gz $LOGDIR/$DATE*
exit 1
fi
elif [ "x$1" = "xconcurrent" ]; 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
fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
rm logs/last-debug
DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
rm $LOGDIR/last-debug
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
cat logs/$DATE-run-$i >> logs/last-debug
./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 $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 logs/$DATE*
tar czf /tmp/hwsim-tests-$DATE-FAILED-concurrent.tar.gz $LOGDIR/$DATE*
exit 1
fi
elif [ "x$1" = "xvalgrind" ]; 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
fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
./run-tests.py -l logs/$DATE-run $DB -e logs/$DATE-failed -r logs/results.txt || errors=1
cat logs/$DATE-run > logs/last-debug
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
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
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 logs/$DATE*
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" > logs/last-debug
echo "Could not start test environment" > $LOGDIR/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 $DB -e logs/$DATE-failed -r logs/results.txt" || errors=1
if [ -e logs/$DATE-failed ]; then
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 logs/$DATE-trace.dat
cat logs/$DATE-run > logs/last-debug
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 logs/$DATE*
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" > logs/last-debug
echo "Could not start test environment" > $LOGDIR/last-debug
exit 1
fi
DATE=`ls -1tr logs | tail -1 | cut -f1 -d-`
./run-tests.py -l logs/$DATE-run $DB -e logs/$DATE-failed -r logs/results.txt || errors=1
cat logs/$DATE-run > logs/last-debug
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 logs/$DATE*
tar czf /tmp/hwsim-tests-$DATE-FAILED.tar.gz $LOGDIR/$DATE*
exit 1
fi
fi

View file

@ -7,6 +7,11 @@ HAPD=$DIR/../../hostapd/hostapd
WLANTEST=$DIR/../../wlantest/wlantest
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
GROUP=admin
else
@ -42,43 +47,43 @@ if [ "$CONCURRENT" = "y" ]; then
sudo iw wlan1 interface add sta1 type station
sudo iw wlan2 interface add sta2 type station
fi
mkdir -p $DIR/logs
mkdir -p $LOGDIR
DATE=`date +%s`
sudo ifconfig hwsim0 up
sudo $WLANTEST -i hwsim0 -c -d > $DIR/logs/$DATE-hwsim0 &
sudo tcpdump -ni hwsim0 -s 2500 -w $DIR/logs/$DATE-hwsim0.dump > $DIR/logs/$DATE-tcpdump 2>&1 &
sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/$DATE-hwsim0 &
sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/$DATE-hwsim0.dump > $LOGDIR/$DATE-tcpdump 2>&1 &
if [ "$VALGRIND" = "y" ]; then
for i in 0 1 2; do
chmod a+rx $WPAS
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
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
done
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
for i in 0 1 2; do
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
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
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
sleep 1
sudo chown $USER $DIR/logs/$DATE-hwsim0.dump
sudo chown $USER $LOGDIR/$DATE-hwsim0.dump
if [ "x$VALGRIND" = "xy" ]; then
sudo chown $USER $DIR/logs/$DATE-*valgrind*
sudo chown $USER $LOGDIR/$DATE-*valgrind*
fi
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
$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
for i in 0 1 2; do