Commit Graph

22 Commits

Author SHA1 Message Date
Alvin Šipraga fda4734a1b auto-t: throw exception if hostapd can't send BSS transition req
The testAPRoam autotest was silently failing on my machine until I
realized that my distribution hostapd (Arch Linux) is not built with
CONFIG_WNM_AP=y. Indeed, it is also disabled by default in upstream
hostapd. This resulted in the send_bss_transition() function of
hostapd.py silently failing. With this change, throw an exception in
case the BSS_TM_REQ command does not succeed to hopefully save others
the time of debugging this problem.
2021-01-28 13:30:57 -06:00
James Prestwood b0e970ae38 test-runner: fix logging, verbose, and process output
There were some major problems related to logging and process
output. Tests which required output from start_process would
break if used with '--log/--verbose'. This is because we relied
on 'communicate' to retrieve the process output, but Popen does
not store process output when stdout/stderr are anything other
than PIPE.

Intead, in the case of logging or outfiles, we can simply read
from the file we just wrote to.

For an explicit --verbose application we must handle things
slightly different. A keyword argument was added to Process,
'need_out' which will ensure the process output is kept
regardless of --log or --verbose.

Now a user should be able to use --log/--verbose without any
tests failing.
2021-01-26 13:41:23 -06:00
James Prestwood 3c708b0e14 auto-t: update hostapd.list_sta to use Process.out
Instead of list_sta() waiting for the PID itself it can
just use wait=True and grab the output out of the Process
class itself.
2020-11-16 17:05:45 -06:00
James Prestwood ebd712af4e auto-t: no hostapd instance graceful failure
If a test does not need any hostapd instances but still loads
hostapd.py for some reason we want to gracefully throw an
exception rather than fail in some other manor.
2020-10-20 13:30:43 -05:00
James Prestwood 5df28473cb auto-t: fix set_neighbor SSID escaping
Before the re-write there was interesting escapes being used for
set_neighbor. Curiously now hostapd fails to set the neighbor due
to these escapes so they have been removed.
2020-09-11 13:42:13 -05:00
James Prestwood edac41b1b3 auto-t: hostapd.py: update to work with test-runner rewrite
Before hostapd was initialized using the wiphy_map which has now
gone away. Instead we have a global config module which contains
a single 'ctx'. This is the centeral store for all test information.

This patch converts hostapd.py to lookup instances by already
initialized Hostapd object. The interface parameter was removed
since all tests have been converted to use config= instead.

In addition HostapdCLI was changed to allow no parameters if there
is only a single hostapd instance.
2020-09-10 17:59:49 -05:00
James Prestwood 933be89812 auto-t: fix hostapd.ungraceful_restart
Restarting hostapd from python was actually leaking memory and
causing the hostapd object to stay referenced in python. The
GLib timeout in wait_for_event was the ultimate cause, but this
had no come to light because no tests restarted hostapd then
used wait_for_event.

In addition, any use of wait_for_event after a restart would
cause an exception because the event socket was never re-attached
after hostapd restarted.

Now we properly clean up the timeout in wait_for_event and
re-initialize the hostapd object on restart.
2020-07-15 14:43:29 -05:00
James Prestwood 87bd9f4c6e auto-t: support hostapd event processing
Hostapd has a feature where you can connect to its control socket and
receive events it generates. Currently we only send commands via this
socket.

First we open the socket (/var/run/hostapd/<iface>) and send the
ATTACH command. This tells hostapd we are ready and after this any
events will be sent over this socket.

A new API, wait_for_event, was added which takes an event string and
waits for some timeout. The glib event loop has been integrated into
this, though its not technically async since we are selecting over a
socket which blocks. To mitigate this a small timeout was chosen for
each select call and then wrapped in a while loop which waits for the
full timeout.
2019-11-04 14:42:17 -06:00
James Prestwood cdc9eb13aa auto-t: hostapd: raise exception upon invalid config
If the config file passed in is not found we would continue and
eventually something else would fail. Instead immediately raise an
exception to be more clear on what is actually failing.
2019-10-22 21:58:30 -05:00
James Prestwood 35f06ef87a auto-t: hostapd: allow CLI to lookup by config file
There is a common interface lookup in many tests in order to initialize
the HostapdCLI object e.g.:

for intf in hostapd_map.values():
    if intf.config == 'ssidOWE.conf':
        hapd = HostapdCLI(intf)
        break

Instead of having to do this in every test, HostapdCLI will now
optionally take a config file (config=<file>). The interface object
will still be prefered (i.e. supplying an interface will not even
check the config file) as to not break existing tests. But if only
a config file is supplied the lookup is done internally.

There are some tests that do still need the interface, as they do
an interface lookup to initialize both hostapd and hwsim at the
same time.
2019-06-05 16:18:26 -05:00
Andrew Zaborowski 0a196025f2 autotests: Remove unneded loops
The hostapd_map dictionary is indexed by the interface name so there's
no point iterating over it to find that entry whose name matches, we can
look up by the name directly.  Simplify code.
2019-04-22 16:34:36 -05:00
Andrew Zaborowski e13c749d1e autotests: Update the wiphy_map and hostapd_map structs
In the test utilties updated the wiphy_map struct built from the
TEST_WIPHY_LIST variable to parse the new format and to use a new
structure where each wiphy is a namedtuple and each interface under it
also contains a reference to that wiphy.  The 'use' field is now
assigned to the wiphy instead of to the interface.
2019-04-22 16:34:17 -05:00
James Prestwood 699b83cb1f auto-t: removed ';' from many autotests
At some point a stray ';' got added into an autotest in a section
of code that is heavily copy pasted. So in turn nearly all the autotests
have this stray ';' after list_devices (and a few in other places).
2018-12-14 13:46:23 -06:00
Denis Kenzior 332d4f8e61 auto-t: Add additional utilities for WPS PIN support 2018-09-24 12:19:27 -05:00
Tim Kourt 7f437c30e3 auto-t: add eapol reauth cmd into hostapd mngr 2018-05-30 18:59:02 -05:00
James Prestwood fe616fbfa5 auto-t: hostapd util get_config_value and get_freq
The hwsim SendFrame method requires the radio frequency which
is obtained from the hostapd config file. This adds a generic
API to get any config value from the hostapd config, as well
as a get_freq API that converts the channel number to a
frequency.
2018-01-30 23:03:51 -06:00
James Prestwood 0db0ce43b8 auto-t: add ungraceful restart to hostapd util
For testing SA Query, the autotest needs the ablility to force
kill (and restart) hostapd without giving it time to deauth its
stations gracefully. A method was added to the HostapdCLI class
which does a killall -9 hostapd, resets the wlnX interface,
and restarts hostapd with the same arguments as it had before.
2018-01-29 14:05:57 -06:00
James Prestwood 27a35da0ba autotests: add AP roam support to hostapd.py 2018-01-18 15:35:38 -06:00
Andrew Zaborowski 1df2e18f61 autotests: Add FT roaming test and utility functions
This tests the FT-PSK initial Mobility Domain authentication, neighbor
reports, scanning on a subset of frequencies and FT transition.
2017-03-28 15:38:38 -05:00
Andrew Zaborowski c72cd38e76 autotests: Support multiple hostapd instances in HostapdCLI
Make the HostapdCLI class non-static so that each objects corresponds
to a hostapd instance on one network interface (this is independent of
whether the AP instances use one or separate hostapd processes)
2017-03-28 15:33:03 -05:00
Tim Kourt 91059e68cd auto-t: Add functions to hostapd_cli 2016-10-12 10:14:28 -05:00
Tim Kourt 95079dabab auto-t: Create hostapd_cli py lib 2016-10-05 18:08:43 -05:00