1Step-by-step guide for setting up hostapd/wpa_supplicant test framework (VM)
2----------------------------------------------------------------------------
3
4This document can be used as a quick guide for getting started with
5hostapd/wpa_supplicant test framework with mac80211_hwsim. While the
6example here uses Ubuntu 22.04 desktop to have a list of exact steps,
7there are no requirements for using that specific distribution in the
8testing setup.
9
10The steps here describe how to run a guest VM for testing on a Linux
11host system.
12
13
14Install Ubuntu 22.04 as the host system for VMs
15
16- download installation image
17- install the host system with default settings
18- boot to the installed system
19- update the installed packages:
20  sudo apt update
21  sudo apt upgrade
22
23
24Install the prerequisite packages that may not have been installed by default
25
26# build tools
27sudo apt install build-essential git libpcap-dev libssl-dev libxml2-dev \
28	libcurl4-openssl-dev libnl-3-dev libnl-genl-3-dev libnl-route-3-dev \
29	libsqlite3-dev binutils-dev libiberty-dev zlib1g-dev libpcsclite-dev \
30	flex bison libconfig-dev
31
32# tools used be the test scripts
33sudo apt install net-tools bridge-utils ebtables iw tshark \
34	python3-openssl python3-pyrad python3-cryptography python3-pycryptodome
35
36# If using kvm and VM instead of UML (though, UML is the recommended option)
37# kvm for running the VM guests
38sudo apt install qemu-kvm
39#Enable kvm use for the user
40sudo adduser $USER kvm
41
42
43
44Download a snapshot of the hostap.git repository and build the programs
45
46cd
47git clone git://w1.fi/hostap.git
48cd hostap/tests/hwsim
49./build.sh
50cd vm
51cat > vm-config <<EOF
52KERNELDIR=~/wireless-next
53MEMORY=512
54KVMARGS="-cpu host"
55EOF
56
57
58Build a Linux kernel for testing
59
60cd
61git clone git://git.kernel.org/pub/scm/linux/kernel/git/wireless/wireless-next.git
62cd wireless-next
63cp ~/hostap/tests/hwsim/vm/kernel-config.uml .config
64make ARCH=um oldconfig
65make -j8 ARCH=um
66
67
68Build wmediumd for testing
69
70cd
71git clone https://github.com/bcopeland/wmediumd.git
72cd wmediumd
73make
74sudo cp wmediumd/wmediumd /usr/local/bin
75
76
77Build sigma_dut for testing
78
79cd
80git clone https://github.com/qca/sigma-dut.git
81cd sigma_dut
82make
83cd ~/hostap/tests/hwsim
84ln -s ~/sigma_dut/sigma_dut
85ln -s ~/sigma_dut/dpp-ca.py
86
87
88Setup is now ready for testing. You can run a quick test to confirm that
89things work as expected:
90
91cd ~/hostap/tests/hwsim/vm
92./vm-run ap_open
93
94This should print out following style results:
95
96Starting test run in a virtual machine
97./run-all.sh: passing the following args to run-tests.py: ap_open
98START ap_open 1/1
99PASS ap_open 0.924019 2017-01-28 20:20:12.137717
100passed all 1 test case(s)
101ALL-PASSED
102
103Test run completed
104Logfiles are at /tmp/hwsim-test-logs/1485634801
105
106(If that "PASS ap_open" line does not show up, something unexpected has
107happened and the setup is not in working condition.)
108
109
110To run all available test cases in 7 parallel VMs, you can run
111following:
112
113cd ~/hostap/tests/hwsim/vm
114./parallel-vm.py 7
115