hostapd/tests/hwsim/start.sh
Johannes Berg 958bf1ba39 hwsim tests: Move logging into timestamped subdirectory
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-hostap: Johannes Berg <johannes.berg@intel.com>
2013-10-31 11:07:26 +02:00

104 lines
2.4 KiB
Bash
Executable file

#!/bin/sh
DIR="$( cd "$( dirname "$0" )" && pwd )"
WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
WPACLI=$DIR/../../wpa_supplicant/wpa_cli
HAPD=$DIR/../../hostapd/hostapd
WLANTEST=$DIR/../../wlantest/wlantest
HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
if [ -z "$LOGDIR" ] ; then
LOGDIR="$DIR/logs/$(date +%s)"
mkdir -p $LOGDIR
fi
if groups | tr ' ' "\n" | grep -q ^admin$; then
GROUP=admin
else
GROUP=adm
fi
if [ "$1" = "concurrent" ]; then
CONCURRENT=y
CONCURRENT_ARGS="-N -Dnl80211 -ista%d -c $DIR/sta-dummy.conf"
shift
else
unset CONCURRENT
CONCURRENT_ARGS=
fi
if [ "$1" = "valgrind" ]; then
VALGRIND=y
VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
chmod -f a+rx $WPAS
chmod -f a+rx $HAPD
shift
else
unset VALGRIND
VALGRIND_WPAS=
VALGRIND_HAPD=
fi
if [ "$1" = "trace" ]; then
TRACE="T"
shift
else
TRACE=""
fi
$DIR/stop-wifi.sh
sudo modprobe mac80211_hwsim radios=5
if [ "$CONCURRENT" = "y" ]; then
sudo iw wlan0 interface add sta0 type station
sudo iw wlan1 interface add sta1 type station
sudo iw wlan2 interface add sta2 type station
fi
mkdir -p $LOGDIR
sudo ifconfig hwsim0 up
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/log$i &
done
sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -ddKt > $LOGDIR/hostapd &
sleep 1
sudo chown $USER $LOGDIR/hwsim0.dump
if [ "x$VALGRIND" = "xy" ]; then
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/hlr_auc_gw &
fi
$HAPD -ddKt $DIR/auth_serv/as.conf > $LOGDIR/auth_serv &
# wait for programs to be fully initialized
for i in 0 1 2; do
for j in `seq 1 10`; do
if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
break
fi
if [ $j = "10" ]; then
echo "Could not connect to /tmp/wpas-wlan$i"
exit 1
fi
sleep 1
done
done
for j in `seq 1 10`; do
if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
break
fi
if [ $j = "10" ]; then
echo "Could not connect to /var/run/hostapd-global"
exit 1
fi
sleep 1
done
exit 0