Skip to content

Commit

Permalink
Add test readme.
Browse files Browse the repository at this point in the history
  • Loading branch information
abeltrano committed Nov 22, 2023
1 parent 2c058e9 commit 0b3d418
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions tests/unit/linux/wpa-controller/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

# WPA Controller Tests

## Wi-Fi Drivers and WPA Daemons

Some of the tests that exercise wpa daemon (hostapd, wpa_supplicant) functionality require a wlan device driver and a running instance of the daemon. To satisfy these requirements, the mac80211_hwsim driver is used to create a virtualized wlan device that the wpa daemon can then control. Helpers are provided for managing the virtualized wlan device(s) with [WifiVirtualDeviceManager](./detail/WifiVirtualDeviceManager.hxx) and for managing the wpa daemons with [WpaDaemonManager](./detail/WpaDaemonManager.hxx) and [WpaDaemonInstance](./detail/WpaDaemonInstance.hxx).

Presently, the tests use [event listeners](https://github.com/catchorg/Catch2/blob/devel/docs/event-listeners.md) from the [Catch2](https://github.com/catchorg/Catch2) unit test framework instead of traditional, class-based setup/teardown fixtures. The event listeners have access to test case information such as the test case name and their tags. The [WpaDaemonCatch2EventListener](./detail/WpaDaemonCatch2EventListener.hxx) was developed to detect when a test case requires either of the daemons, and automatically creates a wlan driver and starts the required daemon . Similarly, it handles removing the driver instances and stopping the daemons on test case completion.

To trigger this behavior, the test case must include a tag that corresponds to the name of a [WpaType](../../../../linux/wpa-controller/include/Wpa/WpaCore.hxx) enumeration value (a case insensitive comparison is done). For example, if the hostapd daemon is needed for the test, then a tag corresponding to WpaType::Hosapd is needed in the test case definition, for example '**hostapd**' as shown below:

```C++
TEST_CASE("Send command: GetStatus()", "[wpa][hostapd][client][remote]")
```
Only the first `WpaType` will be used. Failure to add the appropriate tag will cause the test to fail since no daemon will be running and thus, no connection to it will be possible.
### Future Work
This method will be improved in the future, with some possible improvements including:
1. Allow multiple wpa daemon types.
2. Allow a more generic daemon specification (eg. `[wpaDaemon=hostapd]`)
3. Replacement of event-based fixtures to class-based fixtures.

0 comments on commit 0b3d418

Please sign in to comment.