Monday, August 20, 2018

hostapd/wpa_supplicant hwsim test scripts

Files to take a look

hostap/tests/hwsim/README
hostap/tests/hwsim/example-setup.txt

1st. install required packages

sudo apt-get install build-essential git libpcap-dev libsqlite3-dev binutils-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev libssl-dev libiberty-dev libdbus-1-dev iw bridge-utils python-pyrad python-crypto tshark python-netifaces binutils-dev libsqlite3-dev libpcap-dev libxml2-dev libcurl4-openssl-dev

2nd. build binaries

#!/bin/bash

pushd ./wpa_supplicant
cp ../tests/hwsim/example-wpa_supplicant.config .config
make clean
make
popd

pushd ./hostapd
cp ../tests/hwsim/example-hostapd.config .config
make clean
make hostapd hostapd_cli hlr_auc_gw
popd

pushd ./wlantest
make clean
make
popd


pushd ./tests/hwsim
./build.sh
popd

3rd. Install a recent wireless kernel components (mac80211_hwsim, mac80211, cfg80211)
wget https://mirrors.edge.kernel.org/pub/linux/kernel/projects/backports/stable/v4.4.2/backports-4.4.2-1.tar.xz
tar xJf backports-4.4.2-1.tar.xz
cd backports-4.4.2-1

make defconfig-hwsim
make
sudo make install

4th. Update based iw on custom iw.git build
wget https://www.kernel.org/pub/software/network/iw/iw-3.17.tar.gz
tar xf iw-3.17.tar.gz
cd iw-3.17
make
sudo mv /sbin/iw{,-distro}
sudo cp iw /sbin/iw

5th. Update wireless-regdb
wget http://kernel.org/pub/software/network/wireless-regdb/wireless-regdb-2018.05.31.tar.xz
tar xJf wireless-regdb-2018.05.31.tar.xz
sudo mv /lib/crda/regulatory.bin{,-distro}
sudo cp wireless-regdb-2018.05.31/regulatory.bin /lib/crda/regulatory.bin

# following command can be used to verify that the new version is trusted
regdbdump /lib/crda/regulatory.bin

6th start running test cases
cd tests/hwsim
# load mac80211_hwsim and start test software
./start.sh

# run a single test case ap_open
sudo ./run-tests.py ap_open

This should print out following style results:

DEV: wlan0: 02:00:00:00:00:00
DEV: wlan1: 02:00:00:00:01:00
DEV: wlan2: 02:00:00:00:02:00
APDEV: wlan3
APDEV: wlan4
START ap_open 1/1
Test: AP with open mode (no security) configuration
Starting AP wlan3
Connect STA wlan0 to AP
PASS ap_open 0.175895 2015-01-17 20:12:07.486006
passed all 1 test case(s)

(If that "PASS ap_open" line does not show up, something unexpected has
happened and the setup is not in working condition.)

# to stop test software and unload mac80211_hwsim
./stop.sh


To run all available test cases (about thousand or so), you can run following:

./run-all.sh

For mesh group test
sudo ./run-tests.py -f wpas_mesh

For SAE group test
sudo ./run-tests.py -f sae

For single test
sudo ./run-tests.py  wpas_mesh_open_ht40

# run normal test cases under valgrind
./run-all.sh valgrind

# run normal test cases with Linux tracing
./run-all.sh trace


Trouble shooting

sudo rfkill unblock wifi; sudo rfkill unblock all
systemctl mask systemd-rfkill.service

sudo rmmod iwldvm
sudo rmmod iwlwifi

Test logs
hostap/tests/hwsim$ ./start.sh
[sudo] password for peter:
Control interface file /tmp/wpa_ctrl_29092-1 exists - remove it
Failed to connect to hostapd - wpa_ctrl_open: No such file or directory

hostap/tests/hwsim$ sudo rfkill unblock wifi; sudo rfkill unblock all
peter@peter-linux-dell:~/works/src/__upstream/hostap_dfs/hostap/tests/hwsim$ ./start.sh 
Failed to connect to hostapd - wpa_ctrl_open: No such file or directory

peter@peter-linux-dell:~/works/src/__upstream/hostap_dfs/hostap/tests/hwsim$ sudo ./run-tests.py ap_open
DEV: wlan0: 02:00:00:00:00:00
DEV: wlan1: 02:00:00:00:01:00
DEV: wlan2: 02:00:00:00:02:00
APDEV: wlan3
APDEV: wlan4
START ap_open 1/1
Test: AP with open mode (no security) configuration
Starting AP wlan3
Connect STA wlan0 to AP
PASS ap_open 0.219952 2018-08-20 16:16:40.280540
passed all 1 test case(s)

Test outputs
checkout  tests/hwsim/logs/ folder

No comments:

Post a Comment