hostap/tests/hwsim/start.sh
Johannes Berg 5fecc0f525 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>
2013-10-30 15:55:58 +02:00

114 lines
3 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
fi
export LOGDIR
if groups | tr ' ' "\n" | grep -q ^admin$; then
GROUP=admin
else
GROUP=adm
fi
if [ "$1" = "concurrent" ]; then
CONCURRENT=y
shift
else
unset CONCURRENT
fi
if [ "$1" = "valgrind" ]; then
VALGRIND=y
shift
else
unset VALGRIND
fi
if [ "$1" = "trace" ]; then
TRACE="T"
shift
else
TRACE=""
fi
$DIR/stop-wifi.sh
git show -s --format=%H > commit
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
DATE=`date +%s`
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 &
if [ "$VALGRIND" = "y" ]; then
for i in 0 1 2; do
chmod a+rx $WPAS
if [ "$CONCURRENT" = "y" ]; then
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=$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=$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 > $LOGDIR/$DATE-log$i &
else
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 > $LOGDIR/$DATE-hostapd &
fi
sleep 1
sudo chown $USER $LOGDIR/$DATE-hwsim0.dump
if [ "x$VALGRIND" = "xy" ]; then
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 > $LOGDIR/$DATE-hlr_auc_gw &
fi
$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
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