[PATCH] hwsim tests: move logging into timestamped subdirectory
Johannes Berg
johannes
Wed Oct 30 14:14:24 PDT 2013
From: Johannes Berg <johannes.berg at intel.com>
Instead of logging many files called "<timestamp>-*", log into
a new "<timestamp>/*" in the logs/ subdirectory and only put
the last-debug file into logs/. If a LOGDIR is specified in the
environment, instead just put everything into that directory
(so the caller should make sure to give it a timestamp or so)
and skip the creation of last-debug entirely.
Also clean up a bit and pass the LOGDIR from run-all.sh to
start.sh rather than having start.sh create the timestamp and
run-all.sh detect the latest one when having run start.sh.
Signed-off-by: Johannes Berg <johannes.berg at intel.com>
---
tests/hwsim/run-all.sh | 28 ++++++++++++++++++++--------
tests/hwsim/start.sh | 26 ++++++++++++--------------
2 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/tests/hwsim/run-all.sh b/tests/hwsim/run-all.sh
index bef49f9..22b4f43 100755
--- a/tests/hwsim/run-all.sh
+++ b/tests/hwsim/run-all.sh
@@ -3,9 +3,14 @@
errors=0
umask 0002
+DATE="$(date +%s)"
+unset LOGBASEDIR
if [ -z "$LOGDIR" ]; then
- LOGDIR=logs
+ LOGBASEDIR=logs
+ LOGDIR=$LOGBASEDIR/$DATE
+ mkdir -p $LOGDIR
fi
+export LOGDIR
if [ -z "$DBFILE" ]; then
DB=""
@@ -52,25 +57,32 @@ else
fi
if ! ./start.sh $CONCURRENT $VALGRIND $TRACE; then
- echo "Could not start test environment" > $LOGDIR/last-debug
+ if ! [ -z "$LOGBASEDIR" ] ; then
+ echo "Could not start test environment" > $LOGDIR/run
+ fi
exit 1
fi
-DATE=`ls -1tr $LOGDIR | tail -1 | cut -f1 -d-`
-rm $LOGDIR/last-debug 2>/dev/null
-./run-tests.py $TRACE_ARGS -l $LOGDIR/$DATE-run $DB -e $LOGDIR/$DATE-failed -r $LOGDIR/results.txt $CONCURRENT_TESTS $@ || errors=1
-cat $LOGDIR/$DATE-run >> $LOGDIR/last-debug
+if ! [ -z "$LOGBASEDIR" ] ; then
+ rm $LOGBASEDIR/last-debug 2>/dev/null
+fi
+./run-tests.py $TRACE_ARGS -l $LOGDIR/run $DB -e $LOGDIR/failed -r $LOGDIR/results.txt $CONCURRENT_TESTS $@ || errors=1
+
+if ! [ -z "$LOGBASEDIR" ] ; then
+ cat $LOGDIR/run >> $LOGBASEDIR/last-debug
+fi
+
./stop-wifi.sh
if [ ! -z "$VALGRIND" ] ; then
- failures=`grep "ERROR SUMMARY" $LOGDIR/$DATE-valgrind-* | grep -v " 0 errors" | wc -l`
+ failures=`grep "ERROR SUMMARY" $LOGDIR/valgrind-* | grep -v " 0 errors" | wc -l`
if [ $failures -gt 0 ]; then
echo "Mark as failed due to valgrind errors"
errors=1
fi
fi
if [ $errors -gt 0 ]; then
- tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/$DATE*
+ tar czf /tmp/hwsim-tests-$DATE-FAILED$SUFFIX.tar.gz $LOGDIR/
exit 1
fi
diff --git a/tests/hwsim/start.sh b/tests/hwsim/start.sh
index c82bf8a..64b089d 100755
--- a/tests/hwsim/start.sh
+++ b/tests/hwsim/start.sh
@@ -7,12 +7,10 @@ HAPD=$DIR/../../hostapd/hostapd
WLANTEST=$DIR/../../wlantest/wlantest
HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
-DATE=`date +%s`
-
if [ -z "$LOGDIR" ] ; then
- LOGDIR=$DIR/logs
+ LOGDIR="$DIR/logs/$(date +%s)"
+ mkdir -p $LOGDIR
fi
-export LOGDIR
if groups | tr ' ' "\n" | grep -q ^admin$; then
GROUP=admin
@@ -31,8 +29,8 @@ fi
if [ "$1" = "valgrind" ]; then
VALGRIND=y
- VALGRIND_WPAS="valgrind --log-file=$LOGDIR/$DATE-valgrind-wlan%d"
- VALGRIND_HAPD="valgrind --log-file=$LOGDIR/$DATE-valgrind-hostapd"
+ VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
+ VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
# why chmod?
chmod a+rx $WPAS
chmod a+rx $HAPD
@@ -59,25 +57,25 @@ if [ "$CONCURRENT" = "y" ]; then
fi
mkdir -p $LOGDIR
sudo ifconfig hwsim0 up
-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 &
+sudo $WLANTEST -i hwsim0 -c -d > $LOGDIR/hwsim0 &
+sudo tcpdump -ni hwsim0 -s 2500 -w $LOGDIR/hwsim0.dump > $LOGDIR/tcpdump 2>&1 &
for i in 0 1 2; do
sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $DIR/p2p$i.conf \
- $(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE > $LOGDIR/$DATE-log$i &
+ $(printf -- "$CONCURRENT_ARGS" $i) -ddKt$TRACE > $LOGDIR/log$i &
done
-sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/$DATE-hostapd &
+sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/hostapd &
sleep 1
-sudo chown $USER $LOGDIR/$DATE-hwsim0.dump
+sudo chown $USER $LOGDIR/hwsim0.dump
if [ "x$VALGRIND" = "xy" ]; then
- sudo chown $USER $LOGDIR/$DATE-*valgrind*
+ sudo chown $USER $LOGDIR/*valgrind*
fi
if [ -x $HLR_AUC_GW ]; then
- $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/$DATE-hlr_auc_gw &
+ $HLR_AUC_GW -m $DIR/auth_serv/hlr_auc_gw.milenage_db > $LOGDIR/hlr_auc_gw &
fi
-$HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/$DATE-auth_serv &
+$HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/auth_serv &
# wait for programs to be fully initialized
for i in 0 1 2; do
--
1.8.4.rc3
More information about the Hostap
mailing list