eiwd

no dbus iwd with iwctl functionality
git clone https://git.daat.foo/repos/eiwd.git
Log | Files | Refs | Submodules | README | LICENSE

test-runner.txt (16261B)


      1 Notes for test-runner usage
      2 ***************************
      3 
      4 Tool Description
      5 ================
      6 
      7 test-runner is an automated test execution tool for IWD. It is capable of
      8 creating the emulated environments representing a variety of network topologies
      9 and run the automated tests of IWD functionality.
     10 
     11 Software Prerequisites
     12 ======================
     13 
     14 The test-runner tool requires the following binaries to be present on the host
     15 OS:
     16 
     17 	Name:			Tested ver.:
     18 	 1. qemu		2.4.1
     19 	 2. Linux kernel	4.20+
     20 	 3. dbus-daemon		1.11.18
     21 	 4. iproute2
     22 	 5. iw			3.17
     23 	 6. python		3.9
     24 	 7. haveged		no ver. avail.
     25 	 8. hostapd		recent
     26 	 9. <iwd>/tools/hwsim	0.0
     27 	10. <iwd>/src/iwd	0.0
     28 	11. ofono (optional)
     29 	12. phonesim (optional)
     30 	13. wpa_supplicant	2.9
     31 	14. radvd		2.18
     32 	15. dhcpd
     33 
     34 Note: The version for hostapd is listed as 'recent'. Older hostapd versions
     35 will work but we are continually adopting new features from hostapd and using
     36 those to test. Its recommended to use a recent release of hostapd.
     37 
     38 Note: The test-runner mounts host's file system in readonly mode and executes
     39 the above binaries inside of an emulated environment directly from it.
     40 
     41 Note: Running EAP-SIM/AKA/AKA' tests using oFono will require oFono and
     42 phonesim to be installed on the host. This is explained further in the
     43 "Running with oFono and phonesim" section.
     44 
     45 In addition, the following Python packages are required:
     46 
     47 	Name:			Tested ver.:
     48 	 1. python-prettytable	0.7.2
     49 	 2. python-termcolor	1.1.0
     50 	 3. python-pyroute2	0.5.14
     51 	 4. python-gobject	3.38.0
     52 	 5. python-dbus		1.2.16
     53 	 6. scapy		2.4.5
     54 
     55 Building Kernel
     56 ===============
     57 
     58 test-runner can work both in a fully virtualized environment (QEMU) or inside
     59 a UML (User Mode Linux) instance. Its recommended using UML as its both faster
     60 and more reliable than QEMU for timing specific scenarios. When building the
     61 kernel for UML its important to always specify ARCH=um for any build command.
     62 The default architectures seem to muck with the kernel config that UML needs
     63 and will likely result in a UML binary that won't run under test-runner.
     64 
     65 The test-runner tool requires a kernel that is at least build with these
     66 minimal options for a successful boot and execution:
     67 
     68 	<arch>_defconfig 			Default kernel configuration
     69 
     70 	kvm_guest.config			Default configuration for
     71 						kvm guests (QEMU only)
     72 
     73 	<iwd>/tools/test_runner_kernel_config	The test-runner specific
     74 						configuration
     75 
     76 These configurations should be installed as .config in the kernel source
     77 directory. To build a x86_64 UML kernel the sequence of commands may look
     78 as follows:
     79 
     80 	$ cd linux-X.X.X
     81 
     82 	$ make ARCH=um x86_64_defconfig
     83 
     84 	$ ARCH=um sh <iwd>/tools/test_runner_kernel_config
     85 
     86 	$ make ARCH=um olddefconfig
     87 
     88 After that a default kernel with the required options can be built:
     89 
     90 	$ make ARCH=um -j$(nproc)
     91 
     92 If you do need to build a QEMU kernel you can remove ARCH=um and make the
     93 kvm_guest.config target as well.
     94 
     95 After building (for UML) there should be a 'linux' executable at the root of the
     96 repository, this is the UML binary that should be supplied to test-runner with
     97 the --kernel,-k option.
     98 
     99 For QEMU it is instead a kernel image located at arch/boot/<arch>/bzImage.
    100 
    101 Note: If your host distribution does not contain a regulatory.db you may get an
    102 error similar to this when building the kernel:
    103 
    104 No rule to make target '/lib/firmware/regulatory.db'...
    105 
    106 To fix this you must download the regulatory.db manually and place it in
    107 /lib/firmware. This can be found here:
    108 
    109 https://git.kernel.org/pub/scm/linux/kernel/git/sforshee/wireless-regdb.git
    110 
    111 Note: To catch locking related issues the following set of kernel config
    112 options may be useful:
    113 
    114 	CONFIG_LOCKDEP_SUPPORT=y
    115 	CONFIG_DEBUG_SPINLOCK=y
    116 	CONFIG_DEBUG_LOCK_ALLOC=y
    117 	CONFIG_PROVE_LOCKING=y
    118 	CONFIG_LOCKDEP=y
    119 	CONFIG_DEBUG_MUTEXES=y
    120 
    121 By default the test-runner will search for the kernel image in these locations:
    122 
    123 	<iwd>/tools/bzImage
    124 
    125 		or
    126 
    127 	<iwd>/tools/arch/x86/boot/bzImage
    128 
    129 An arbitrary kernel image location can be specified by using '--kernel <path>'
    130 parameter into test-runner.
    131 
    132 Running Automated Tests
    133 =======================
    134 Before running any tests, its expected that the folder /var/lib/iwd exists on
    135 the host machine. If not, you will see a mounting error when starting
    136 test-runner.
    137 
    138 	mkdir /var/lib/iwd
    139 
    140 By default, the automated test configuration directories reside in
    141 '<iwd>/autotests' and have a mandatory prefix of 'test'.
    142 
    143 	<iwd>/autotests/test1
    144 			/test2
    145 			...
    146 
    147 The test configurations along with test cases in <iwd>/autotests/test*
    148 directories will be discovered and executed by test-runner in sequential
    149 fashion. The following set of commands is sufficient to run the automated
    150 tests shipped with IWD:
    151 
    152 	$ cd <iwd>/tools
    153 
    154 	$ sudo ./test-runner -k <kernel binary>
    155 
    156 One can specify a particular set of test configurations to be executed by using
    157 '-A <dir1,dir2>' parameter. An absolute path is necessary for the test
    158 configuration directories outside of <iwd>/autotests.
    159 
    160 The command line may look as follows:
    161 
    162 	$ sudo ./test-runner -A test1,test3,/home/test4
    163 
    164 Glob matching is also supported when specifying a test list:
    165 
    166 	$ sudo ./test-runner -A testWPA*
    167 
    168 
    169 Creating Test Configurations
    170 ============================
    171 
    172 A typical test configuration directory may consist of these types of files:
    173 
    174 	hw.conf			Defines the network configuration and
    175 				properties of the radios.
    176 
    177 	*Test or *Test.py	The set of test cases for IWD functionality
    178 				implemented using Python scripting language.
    179 				These files must have one of the two predefined
    180 				suffixes: 'test' or 'test.py'. The file name
    181 				must also be more descriptive than simply 'test'.
    182 				e.g. 'connection_test' or 'failure_test'. Files
    183 				named 'test' will not be dynamically loaded due
    184 				to python module naming overlap.
    185 
    186 	*.conf			A configuration file for an instance of hostapd
    187 	(Defined in hw.conf)	service.
    188 
    189 Each configuration directory has exactly one hw.conf, where the number of
    190 Python script files is virtually unlimited. The number of hostapd configuration
    191 files is bounded by the limitation in mac80211_hwsim driver and is set
    192 to 99. (The mac80211_hwsim driver allows to create 100 of simultaneous radios
    193 and one of them is reserved by the test-runner for IWD)
    194 
    195 A typical contents of a test configuration directory may look as follows:
    196 
    197 	 /test1/hw.conf
    198 		ap1.conf
    199 		ap2.conf
    200 		networkScanTest
    201 		networkConnectTest.py
    202 
    203 Note: Any additional files in your test directory will be copied to /tmp inside
    204 the VM. These additional file should be referenced using /tmp/<file> inside
    205 any configuration file for hostapd.
    206 
    207 Defining Network
    208 ----------------
    209 Network topology along with configuration for the automated test cases is
    210 predetermined in hardware configuration file 'hw.conf'. In addition, it allows
    211 to establish the relationships between the emulated hardware radios and
    212 services that represent various entities of a wireless network.
    213 
    214 The following sample hardware configuration file allows to emulate a network
    215 of three nodes. Two of which are access points and the third one represents a
    216 supplicant running IWD:
    217 
    218 #~~~~~~~~~~~~~~~~~~~~~~~~~ hw.conf ~~~~~~~~~~~~~~~~~~~~~~~~~
    219 # Lines starting with # are ignored
    220 
    221 # 'SETUP' is a mandatory configuration group.
    222 [SETUP]
    223 #
    224 # Total number of radios requested per network setup. This includes
    225 # the radios used by APs as well as one for IWD. This field is mandatory and
    226 # has a range of [1, 100].
    227 num_radios=3
    228 
    229 # Maximum execution interval per Python script file in seconds. This field is
    230 # optional.
    231 # Default: 20 seconds.
    232 #max_test_exec_interval_sec=5
    233 
    234 #
    235 # The following two configuration groups are examples of the radio
    236 # configurations.
    237 #
    238 # This group of settings allows to specify a set of properties for a radio. The
    239 # name of the group represents a radio identifier. These configuration groups
    240 # are optional.
    241 [rad0]
    242 
    243 # For each radX group you can specify radio properties:
    244 # Disables the provided interface type(s):
    245 disable_iftype=ap,p2p
    246 
    247 # Disables the provided cipher types:
    248 disable_cipher=ccmp,bip
    249 
    250 # 'HOSTAPD' configuration group identifies a set of access points (AP) for the
    251 # current network topology. Each key/value pair represents a single AP that is
    252 # emulated by the instance of hostapd service. The key indicates an arbitrary
    253 # radio identifier and value specifies a configuration file for the instance.
    254 # If a radio identifier can not be mapped to a predefined radio configuration
    255 # (identifier is not part of the 'radio_confs' list), then a radio with the
    256 # default configuration is used. This configuration group is optional.
    257 [HOSTAPD]
    258 rad0=ap1.conf
    259 rad1=ap2.conf
    260 
    261 # 'radius_server' is a special option used to specify a hostapd instance which
    262 # acts as a radius server only (not an access point). This option does not
    263 # require an additional 'num_radios' to be used.
    264 radius_server=radius.conf
    265 #~~~~~~~~~~~~~~~~~~ end of hw.conf ~~~~~~~~~~~~~~~~~~~~~~~~~
    266 
    267 Configuring Access Points
    268 -------------------------
    269 The test-runner tool makes use of the hostapd service to emulate the access
    270 points (AP). Despite the fact that hostapd service comes preinstalled on most
    271 Linux distributions, test-runner uses some of the recently introduced features,
    272 which may only be available from the master tree of the hostapd repository:
    273 
    274 	git://w1.fi/srv/git/hostap.git
    275 
    276 		OR (its HTTP version)
    277 
    278 	http://w1.fi/hostap.git
    279 
    280 commit id: 31d3692fe5d56c05753ed4a70c7943979e1d29e7 or above is required.
    281 
    282 The sequence of commands to clone, build and install hostapd may look as
    283 follows:
    284 
    285 	$ git clone git://w1.fi/srv/git/hostap.git
    286 
    287 	$ cd hostap/hostapd
    288 
    289 	$ cp <iwd>/doc/hostapd.config .config
    290 
    291 	Note: You may need to pre-install: 'gnutls-devel' and 'libgcrypt-devel'
    292 	libraries.
    293 
    294 	$ make install
    295 
    296 Note: All hostapd build options (CONFIG_*) are stored in doc/hostapd.config.
    297 Any new options which are required for a test should be added there.
    298 
    299 Note: If 'make install' fails with the netlink warnings you may need to
    300 install libnl-1.0pre8 (or later).
    301 
    302 Note: It is recommended to override the pre-installed version of hostapd with
    303 the newly built one to avoid any confusion. The simplest way to make sure
    304 that the correct version of hostapd is used is to execute the following
    305 command:
    306 
    307 	$ hostapd -h
    308 
    309 Make sure that '-i' option is available in the list of option.
    310 For more information on hostapd refer to this page:
    311 
    312 	https://wireless.wiki.kernel.org/en/users/documentation/hostapd
    313 
    314 A full set of the hostapd configurations along with explanation can be
    315 found at:
    316 
    317 	https://w1.fi/cgit/hostap/plain/hostapd/hostapd.conf
    318 
    319 Note: for EAP-SIM/AKA/AKA' hostapd needs an authenticator running separately.
    320 IWD has a python version of hostapd's "hlrauc.c". This may work out of the box
    321 on your system, but the pycrypto library is required. This can be installed
    322 with python pip3:
    323 
    324 	sudo pip3 install pycrypto
    325 
    326 Running with oFono and phonesim
    327 -------------------------------
    328 EAP-SIM/AKA/AKA' require SIM card access to perform the authentication
    329 algorithms. This is achieved in test runner using oFono and phonesim. If
    330 either oFono or phonesim are not found when test runner starts, any test
    331 involving oFono will be skipped. Using the option "sim_keys=ofono" in the
    332 hardware config file will tell test runner that the test should use oFono.
    333 There is some setup that needs to be done before test runner will work with
    334 ofono/phonesim
    335 
    336 setup ofono:
    337 
    338 	$ git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
    339 	$ cd ofono
    340 	$ ./bootstrap-configure
    341 	$ make install
    342 
    343 setup phonesim:
    344 
    345 	$ git clone git://git.kernel.org/pub/scm/network/ofono/phonesim.git
    346 	$ cd phonesim
    347 	$ ./bootstrap-configure
    348 	$ make install
    349 
    350 Now test runner should pick up both installed binaries.
    351 
    352 Note: EAP-SIM/AKA/AKA' can also be tested using the hardcoded SIM plugin. This
    353 just reads hardcoded SIM values from a local file. Tests using this plugin
    354 should not need any additional setup. This plugin is enabled by setting
    355 "sim_keys=<file>" in the hardware config file.
    356 
    357 Writing Python Test Scripts
    358 ---------------------------
    359 The test-runner tool relies on test cases written in Python script language
    360 to exercise the functionality of IWD. The outcomes of the tests are determined
    361 by the exit status of a process running test and reported on per Python file
    362 bases. The test creators are highly encouraged to use the Python unit test
    363 framework.
    364 
    365 For more information on Python unit test framework refer to the following page:
    366 
    367 	http://pyunit.sourceforge.net/pyunit.html
    368 
    369 Using hardware passthrough
    370 ---------------------------
    371 
    372 The --hw, -w flag lets you pass in a config file containing USB/PCI adapter
    373 addresses, which can then be used as radios inside the test/VM just as the
    374 virtual mac80211_hwsim radios are used. Note: physical radios cannot be used at
    375 the same time as mac80211_hwsim radios.
    376 
    377 Using this option, in some cases, does require some pre-configuration that won't
    378 be described in this document. Specifically, PCI adapters are very involved to
    379 get setup, and require special kernel boot options (on the host), BIOS changes,
    380 and most likely a lot of time to get the system working reliably. Because of
    381 this only USB adapters will be discussed in this document.
    382 
    383 If PCI passthrough is something you need, it would be best to follow this guide:
    384 
    385 https://wiki.archlinux.org/index.php/PCI_passthrough_via_OVMF
    386 
    387 First, whatever kernel you are using must contain the adapters driver and, if
    388 required, firmware built in. The driver can be built in using 'make menuconfig'
    389 and finding the correct driver for your adapter:
    390 
    391 Device Driver -> Network Device Support -> Wireless LAN
    392 
    393 Enable [*] the driver(s) you need, save, and exit.
    394 
    395 The firmware also needs to be built in, and this will require you finding the
    396 right firmware file (/lib/firmware/) required for your adapter and adding it to
    397 CONFIG_EXTRA_FIRMWARE in your .config file. It is sometimes not very obvious
    398 what firmware you need. I have found that during the kernel boot some adapters
    399 will print out if the firmware was not found, and the name of the firmware file
    400 they expect. If you are having trouble finding the firmware file try continuing
    401 on and see what happens when test-runner starts. Google is also your friend.
    402 
    403 Once you have the kernel built you can write your hardware config file for
    404 test-runner. Find the USB bus and device for the adapter:
    405 
    406 $ lsusb
    407 
    408 You should see your device listed with a 'Bus' and 'Device' number:
    409 
    410 $ Bus 001 Device 002: ........
    411 
    412 Put these into your passthrough config file under a 'USBAdapters' group:
    413 
    414 [USBAdapters]
    415 rad0=1,2
    416 
    417 Note: The 'rad#' does not matter at this time. These named keys will not
    418 correspond to rad0, rad1, etc in your test config file. This may change in the
    419 future.
    420 
    421 You can then run test-runner using this config file:
    422 
    423 ./test-runner -k <kernel> --hw passthrough.conf ...
    424 
    425 If running specific tests you need to ensure you have enough adapters defined
    426 in the config file, and that the adapters support the features you expect. For
    427 example, some adapters cannot go into AP mode, or use certain channels. If your
    428 test expects these features and the adapters do not support them, the test will
    429 fail in sometimes unexpected ways.
    430 
    431 Using the 'shell' feature
    432 ---------------------------
    433 
    434 The --shell,-s flag allows you to boot into a shell inside the test-runner VM.
    435 If this flag is used the python test will not actually run, only the environment
    436 will be setup. Tis is useful for diagnosing issues with a particular test
    437 quickly without having to modify the python test and restart the VM. The shell
    438 flag is meant to be used in conjunction with --autotest,-A. If no specific test
    439 is specified test-runner will default to the 'shell' test, which is just an
    440 empty test with one adapter.
    441 
    442 Using the shell with real hardware (--hw flag) is even more powerful. If your
    443 system is setup for USB/PCI passthrough you can expose physical network cards
    444 in the VM and use them in the shell sandbox. This allows you to try out
    445 different kernels in the VM very quickly (no reboots/swapping out kernels on
    446 the host system).
    447 
    448 Here are some examples of --shell usage:
    449 
    450 Setup environment for 'testWPA' and boot into shell:
    451 ./test-runner -k <kernel> -A testWPA --shell
    452 
    453 Boot directly into 'shell' test (sandbox):
    454 ./test-runner -k <kernel> --shell
    455 
    456 Use hardware passthrough:
    457 ./test-runner -k <kernel> --hw <hw.conf> --shell