]> git.ipfire.org Git - thirdparty/hostap.git/blob - tests/hwsim/start.sh
tests: FT-EAP and PMKSA caching for initial mobility domain association
[thirdparty/hostap.git] / tests / hwsim / start.sh
1 #!/bin/sh
2
3 DIR="$( cd "$( dirname "$0" )" && pwd )"
4 WPAS=$DIR/../../wpa_supplicant/wpa_supplicant
5 WPACLI=$DIR/../../wpa_supplicant/wpa_cli
6 HAPD=$DIR/../../hostapd/hostapd
7 HAPD_AS=$DIR/../../hostapd/hostapd
8 HAPDCLI=$DIR/../../hostapd/hostapd_cli
9 WLANTEST=$DIR/../../wlantest/wlantest
10 HLR_AUC_GW=$DIR/../../hostapd/hlr_auc_gw
11
12 if [ -z "$LOGDIR" ] ; then
13 DATE="$(date +%s)"
14 LOGDIR="$DIR/logs/$DATE"
15 mkdir -p $LOGDIR
16 else
17 if [ -e $LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant ]; then
18 WPAS=$LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_supplicant
19 WPACLI=$LOGDIR/alt-wpa_supplicant/wpa_supplicant/wpa_cli
20 # extra code coverage
21 $WPAS > /dev/null 2>&1
22 $WPAS -efoo -Ifoo -mfoo -ofoo -Ofoo -pfoo -Pfoo -h > /dev/null 2>&1
23 $WPAS -bfoo -B -Cfoo -q -W -N -L > /dev/null 2>&1
24 $WPAS -T -v > /dev/null 2>&1
25 $WPAS -u -z > /dev/null 2>&1
26 fi
27 if [ -e $LOGDIR/alt-hostapd/hostapd/hostapd ]; then
28 HAPD=$LOGDIR/alt-hostapd/hostapd/hostapd
29 HAPDCLI=$LOGDIR/alt-hostapd/hostapd/hostapd_cli
30 # extra code coverage
31 $HAPD > /dev/null 2>&1
32 $HAPD -v > /dev/null 2>&1
33 $HAPD -B -efoo -Pfoo -T -bfoo -h > /dev/null 2>&1
34 $HAPD -ufoo > /dev/null 2>&1
35 $HAPD -u00:11:22:33:44:55 > /dev/null 2>&1
36 $HAPD -gfoo > /dev/null 2>&1
37 $HAPD -Gfoo-not-exists > /dev/null 2>&1
38 $HAPD -z > /dev/null 2>&1
39 $HAPD -i foo1,foo2,foo3 > /dev/null 2>&1
40 fi
41 if [ -e $LOGDIR/alt-hostapd-as/hostapd/hostapd ]; then
42 HAPD_AS=$LOGDIR/alt-hostapd-as/hostapd/hostapd
43 fi
44 if [ -e $LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw ]; then
45 HLR_AUC_GW=$LOGDIR/alt-hlr_auc_gw/hostapd/hlr_auc_gw
46 # extra code coverage
47 $HLR_AUC_GW > /dev/null 2>&1
48 $HLR_AUC_GW -Dfoo -i7 -sfoo -h > /dev/null 2>&1
49 $HLR_AUC_GW -i100 > /dev/null 2>&1
50 $HLR_AUC_GW -z > /dev/null 2>&1
51 fi
52 fi
53
54 LOGBASEDIR="$( cd "$(dirname "$LOGDIR")" && pwd )"
55 if test "$LOGBASEDIR" = "$DIR/logs" -a -w "$LOGBASEDIR" ; then
56 rm -rf "$LOGBASEDIR/current"
57 ln -sf "$(basename "$LOGDIR")" "$LOGBASEDIR/current"
58 fi
59
60 if groups | tr ' ' "\n" | grep -q ^admin$; then
61 GROUP=admin
62 elif groups | tr ' ' "\n" | grep -q ^wheel$; then
63 GROUP=wheel
64 else
65 GROUP=adm
66 fi
67
68 for i in 0 1 2; do
69 sed "s/ GROUP=.*$/ GROUP=$GROUP/" "$DIR/p2p$i.conf" > "$LOGDIR/p2p$i.conf"
70 done
71
72 sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as.conf" > "$LOGDIR/as.conf"
73 sed "s/group=admin/group=$GROUP/;s%LOGDIR%$LOGDIR%g" "$DIR/auth_serv/as2.conf" > "$LOGDIR/as2.conf"
74
75 unset VM
76 if [ "$1" = "VM" ]; then
77 VM="y"
78 shift
79 fi
80
81 if [ "$1" = "valgrind" ]; then
82 VALGRIND=y
83 VALGRIND_WPAS="valgrind --log-file=$LOGDIR/valgrind-wlan%d"
84 VALGRIND_HAPD="valgrind --log-file=$LOGDIR/valgrind-hostapd"
85 chmod -f a+rx $WPAS
86 chmod -f a+rx $HAPD
87 chmod -f a+rx $HAPD_AS
88 HAPD_AS="valgrind --log-file=$LOGDIR/valgrind-auth-serv $HAPD_AS"
89 shift
90 else
91 unset VALGRIND
92 VALGRIND_WPAS=
93 VALGRIND_HAPD=
94 fi
95
96 if [ "$1" = "trace" ]; then
97 TRACE="T"
98 shift
99 else
100 TRACE=""
101 fi
102
103 $DIR/stop.sh
104
105 TMP=$1
106 if [ x${TMP%=[0-9]*} = "xchannels" ]; then
107 NUM_CH=${TMP#channels=}
108 shift
109 else
110 NUM_CH=1
111 fi
112
113 test -f /proc/modules && sudo modprobe mac80211_hwsim radios=7 channels=$NUM_CH support_p2p_device=0 dyndbg=+p
114
115 sudo ifconfig hwsim0 up
116 sudo $WLANTEST -i hwsim0 -n $LOGDIR/hwsim0.pcapng -c -dtN -L $LOGDIR/hwsim0 &
117 for i in 0 1 2; do
118 DBUSARG=""
119 if [ $i = "0" ] && ([ -r /var/run/dbus/pid ] || [ -r /var/run/dbus/system_bus_socket ]); then
120 if $WPAS | grep -q -- -u; then
121 DBUSARG="-u"
122 fi
123 fi
124 sudo $(printf -- "$VALGRIND_WPAS" $i) $WPAS -g /tmp/wpas-wlan$i -G$GROUP -Dnl80211 -iwlan$i -c $LOGDIR/p2p$i.conf \
125 -ddKt$TRACE -f $LOGDIR/log$i $DBUSARG &
126 done
127 sudo $(printf -- "$VALGRIND_WPAS" 5) $WPAS -g /tmp/wpas-wlan5 -G$GROUP \
128 -ddKt$TRACE -f $LOGDIR/log5 &
129 sudo $VALGRIND_HAPD $HAPD -ddKt$TRACE -g /var/run/hostapd-global -G $GROUP -f $LOGDIR/hostapd &
130 HPID=$!
131
132 if [ -z "$VM" ]; then
133 # Sleep a bit, otherwise pgrep may run before the child is forked
134 sleep 0.1
135 pgrep -P $HPID > $LOGDIR/hostapd-test.pid
136 else
137 echo $HPID > $LOGDIR/hostapd-test.pid
138 fi
139
140 if [ -x $HLR_AUC_GW ]; then
141 cp $DIR/auth_serv/hlr_auc_gw.milenage_db $LOGDIR/hlr_auc_gw.milenage_db
142 sudo $HLR_AUC_GW -u -m $LOGDIR/hlr_auc_gw.milenage_db -g $DIR/auth_serv/hlr_auc_gw.gsm > $LOGDIR/hlr_auc_gw &
143 fi
144
145 openssl ocsp -index $DIR/auth_serv/index.txt \
146 -rsigner $DIR/auth_serv/ocsp-responder.pem \
147 -rkey $DIR/auth_serv/ocsp-responder.key \
148 -CA $DIR/auth_serv/ca.pem \
149 -issuer $DIR/auth_serv/ca.pem \
150 -verify_other $DIR/auth_serv/ca.pem -trust_other \
151 -ndays 7 \
152 -reqin $DIR/auth_serv/ocsp-req.der \
153 -respout $LOGDIR/ocsp-server-cache.der > $LOGDIR/ocsp.log 2>&1
154 if [ ! -r $LOGDIR/ocsp-server-cache.der ]; then
155 cp $DIR/auth_serv/ocsp-server-cache.der $LOGDIR/ocsp-server-cache.der
156 fi
157
158 cp $DIR/auth_serv/ocsp-multi-server-cache.der $LOGDIR/ocsp-multi-server-cache.der
159
160 openssl ocsp -index $DIR/auth_serv/index.txt \
161 -rsigner $DIR/auth_serv/ocsp-responder.pem \
162 -rkey $DIR/auth_serv/ocsp-responder.key \
163 -resp_key_id \
164 -CA $DIR/auth_serv/ca.pem \
165 -issuer $DIR/auth_serv/ca.pem \
166 -verify_other $DIR/auth_serv/ca.pem -trust_other \
167 -ndays 7 \
168 -reqin $DIR/auth_serv/ocsp-req.der \
169 -respout $LOGDIR/ocsp-server-cache-key-id.der > $LOGDIR/ocsp.log 2>&1
170
171 for i in unknown revoked; do
172 openssl ocsp -index $DIR/auth_serv/index-$i.txt \
173 -rsigner $DIR/auth_serv/ocsp-responder.pem \
174 -rkey $DIR/auth_serv/ocsp-responder.key \
175 -CA $DIR/auth_serv/ca.pem \
176 -issuer $DIR/auth_serv/ca.pem \
177 -verify_other $DIR/auth_serv/ca.pem -trust_other \
178 -ndays 7 \
179 -reqin $DIR/auth_serv/ocsp-req.der \
180 -respout $LOGDIR/ocsp-server-cache-$i.der >> $LOGDIR/ocsp.log 2>&1
181 done
182
183 openssl ocsp -reqout $LOGDIR/ocsp-req.der -issuer $DIR/auth_serv/ca.pem \
184 -sha256 -serial 0xD8D3E3A6CBE3CD17 -no_nonce >> $LOGDIR/ocsp.log 2>&1
185 for i in "" "-unknown" "-revoked"; do
186 openssl ocsp -index $DIR/auth_serv/index$i.txt \
187 -rsigner $DIR/auth_serv/ca.pem \
188 -rkey $DIR/auth_serv/ca-key.pem \
189 -CA $DIR/auth_serv/ca.pem \
190 -ndays 7 \
191 -reqin $LOGDIR/ocsp-req.der \
192 -resp_no_certs \
193 -respout $LOGDIR/ocsp-resp-ca-signed$i.der >> $LOGDIR/ocsp.log 2>&1
194 done
195 openssl ocsp -index $DIR/auth_serv/index.txt \
196 -rsigner $DIR/auth_serv/server.pem \
197 -rkey $DIR/auth_serv/server.key \
198 -CA $DIR/auth_serv/ca.pem \
199 -ndays 7 \
200 -reqin $LOGDIR/ocsp-req.der \
201 -respout $LOGDIR/ocsp-resp-server-signed.der >> $LOGDIR/ocsp.log 2>&1
202
203 touch $LOGDIR/hostapd.db
204 sudo $HAPD_AS -ddKt $LOGDIR/as.conf $LOGDIR/as2.conf > $LOGDIR/auth_serv &
205
206 # wait for programs to be fully initialized
207 for i in 0 1 2 3 4 5 6 7 8 9; do
208 if [ -e /tmp/wpas-wlan0 ]; then
209 break
210 fi
211 sleep 0.05
212 done
213 for i in 0 1 2; do
214 for j in `seq 1 10`; do
215 if $WPACLI -g /tmp/wpas-wlan$i ping | grep -q PONG; then
216 break
217 fi
218 if [ $j = "10" ]; then
219 echo "Could not connect to /tmp/wpas-wlan$i"
220 exit 1
221 fi
222 sleep 1
223 done
224 done
225
226 for j in `seq 1 10`; do
227 if $WPACLI -g /var/run/hostapd-global ping | grep -q PONG; then
228 break
229 fi
230 if [ $j = "10" ]; then
231 echo "Could not connect to /var/run/hostapd-global"
232 exit 1
233 fi
234 sleep 1
235 done
236
237 for j in `seq 1 10`; do
238 if $HAPDCLI -i as ping | grep -q PONG; then
239 break
240 fi
241 if [ $j = "10" ]; then
242 echo "Could not connect to hostapd-as-RADIUS-server"
243 exit 1
244 fi
245 sleep 1
246 done
247
248 if [ $USER = "0" -o $USER = "root" ]; then
249 exit 0
250 fi
251
252 sleep 0.75
253 sudo chown -f $USER $LOGDIR/hwsim0.pcapng $LOGDIR/hwsim0 $LOGDIR/log* $LOGDIR/hostapd
254 if [ "x$VALGRIND" = "xy" ]; then
255 sudo chown -f $USER $LOGDIR/*valgrind*
256 fi
257
258 exit 0