Commit Graph

169 Commits

Author SHA1 Message Date
James Prestwood 42fe6c5a15 auto-t: hostapd.py: remove _hostapd_restarted concept
The destructor was trying to do more than the scope of a destructor
by trying to handle this single case of hostapd being restarted.

Instead we can simply pass a keyword argument 'reinit' to the
constructor to tell it to reinitialize everything. And as for killing
hostapd this can be done in ungraceful_restart itself rather than
trying to handle it in the destructor.
2021-08-16 11:33:26 -05:00
James Prestwood a2c777ba84 auto-t: iwd.py: clean up StationDebug
Initialize this once and reference that for each method/property
2021-08-13 20:39:13 -05:00
James Prestwood 973ee269d3 auto-t: return existing instance from HostapdCLI
This addresses the TODO where HostapdCLI was creating separate
objects each time HostapdCLI was called. This was worked around
by manually setting the important members but instead the class
can be re-worked to act as somewhat of a singleton, per-config
at least.

If there is no HostapdCLI instance for a given config one is
created and initialized. Subsequent HostapdCLI calls (for the
same config) will be returned the same object rather than a
new one.
2021-08-13 20:39:13 -05:00
James Prestwood 365f955318 auto-t: ead.py: remove wait_for_object_condition
Instead the class method IWD._wait_for_object_condition can
be used.
2021-08-13 15:18:40 -05:00
James Prestwood 3adb91fc9e auto-t: iwd.py: allow renaming in copy_to_storage
By providing a 'name' keyword argument the file copied will be
renamed to that.
2021-08-13 14:54:53 -05:00
James Prestwood 36777d1e68 auto-t: iwd.py: add StationDebug.Event support
Adds a new wait_for_event API which waits for a StationDebug.Event.
2021-08-13 14:45:12 -05:00
James Prestwood b705a579ad auto-t: ead.py: use non_block_wait 2021-08-13 11:16:19 -05:00
James Prestwood 5ebbe07fa6 auto-t: hostapd.py: use non_block_wait 2021-08-13 11:16:19 -05:00
James Prestwood 732871b601 auto-t: iwd.py: use non_block_wait 2021-08-13 11:16:19 -05:00
James Prestwood 80ee406e3e auto-t: ofono.py: use non_block_wait 2021-08-13 11:16:19 -05:00
James Prestwood 541dca499a auto-t: hostapd.py: remove get_freq()/get_config_value() 2021-08-13 10:46:21 -05:00
James Prestwood 7a74a825a4 auto-t: iwd.py: scan only on needed frequencies
get_ordered_network() now scans automatically and has been updated
to use the StationDebug.Scan() API rather than doing a full
dbus scan (unless full_scan = True). The frequencies to be scanned
are picked automatically based on the current hostapd status
(hidden behind ctx.hostapd.get_frequency()).
2021-08-13 10:46:16 -05:00
James Prestwood 57933425ca test-runner: start HostapdCLI from test-runner
This gives the benefit of test-runner itself having access to
the CLI, e.g. for getting status information.
2021-08-13 10:46:13 -05:00
James Prestwood c7466cd56a auto-t: add python API for StationDebug.Scan 2021-08-13 10:46:10 -05:00
James Prestwood 5519faecba auto-t: iwd.py: make scan_if_needed True by default
There is a common block of code in nearly every test which is incorrect,
most likely a copy-paste from long ago. It goes something like:

wd.wait_for_object_condition(device, 'not obj.scanning')
device.scan()
wd.wait_for_object_condition(device, 'not obj.scanning')

network = device.get_ordered_network("ssid")

The problem here is that sometimes the scanning property does not get
updated fast enough before device.scan() returns, meaning get_ordered_network
comes up with nothing. Some tests pass scan_if_needed=True which 'fixes'
this but ends up re-scanning after the original scan finishes.

To put this to rest scan_if_needed is now defaulted to True, and no
explicit scan should be needed.
2021-08-12 16:58:39 -05:00
James Prestwood 4f5010f69d auto-t: iwd.py: add autoconnect property/StationDebug 2021-08-12 16:58:30 -05:00
James Prestwood 77d5b57e9e auto-t: iwd.py: add roam() method
This will use the Roam() developer method to force a roam to
a certain BSS. This is particularly useful for any test requiring
roams that are not testing IWD's BSS selection logic. Rather than
creating hwsim rules, setting low RSSI values, and waiting for the
roam logic/scan to happen Roam() can be used to force the roam
logic immediately.
2021-08-12 15:14:07 -05:00
James Prestwood 3402f5994b auto-t: iwd.py: add connect_bssid() method
Python API for ConnectBssid() developer method
2021-08-12 15:14:07 -05:00
James Prestwood 518808c709 auto-t: testutil.py: add expect_fail flag
Several tests tests for connectivity with the expectation that it
will fail. This ends up taking 30+ seconds because testutil retries
3 times, each with a 10 second timeout. By passing expect_fail=True
this lowers the timeout to zero, and skips any retries.
2021-08-12 15:14:07 -05:00
James Prestwood 80123efabd auto-t: hostapd.py: add 'bssid' property
This gets the APs BSSID, bypassing the need to use hwsim
for obtaining this address.
2021-08-12 15:14:07 -05:00
James Prestwood 36bc4e15c3 auto-t: hostapd: catch local socket remove exception
This happens if hostapd is killed ungracefully which is done in
some tests.
2021-07-29 17:51:25 -05:00
Denis Kenzior 6d76b3e21d auto-t: SAE: Rework SAE tests
Break up the SAE tests into two parts: testSAE and testSAE-AntiClogging

testSAE is simplified to only use two radios and a single phy managed
by hostapd.  hostapd configurations are changed via the new 'set_value'
method added to hostapd utils.  This allows forcing hostapd to use a
particular sae group set, or force hostapd to use SAE H2E/Hunting and
Pecking Loop for key derivation.  A separate test for IKE Group 20 is no
longer required and is folded into connection_test.py

testSAE-AntiClogging is added with an environment for 5 radios instead
of 7, again with hostapd running on a single phy.  'sae_pwe' is used to
force hostapd to use SAE H2E or Hunting and Pecking for key derivation.
Both Anti-Clogging protocol variants are thus tested.

main.conf is added to both directories to force scan randomization off.
This seems to be required for hostapd to work properly on hwsim.
2021-07-14 19:02:06 -05:00
Andrew Zaborowski 2a37dba4bf autotest: Improve cleanup in testP2P
Make sure some of the processes and files created are also cleaned up on
failure so that the next chance has a chance to succeed anyway.
2021-06-14 09:02:34 -05:00
Andrew Zaborowski e583bc470f autotests: Add P2P GO role test scenarios
autotests/testP2P/client_test.py is renamed to connection_test.py to
reflect that it now tests both roles.
2021-06-04 11:56:48 -05:00
Andrew Zaborowski 0be475af3c autotests: Add missing space in wpas P2P_CONNECT commands 2021-06-04 11:56:40 -05:00
Andrew Zaborowski c54ba7158c autotests: Initialise P2PPeer objects with correct namespace 2021-06-04 11:56:32 -05:00
James Prestwood cb6faed69a auto-t: properly print wait_for_object_change exception 2021-04-22 13:25:23 -05:00
James Prestwood 3c3c1a3304 auto-t: add python wrapper for hwsim rule prefix 2021-04-05 17:47:42 -05:00
James Prestwood 80ff2fe140 auto-t: iwd.py: release namespace on IWD close 2021-02-26 10:09:36 -06:00
James Prestwood e8389190a9 auto-t: testutil.py: pass wait into ping
This will wait for the process and cleanup ping-out file
2021-02-26 10:07:32 -06:00
James Prestwood 0e13c8d32b auto-t: hlrauc.py: remove unix socket on cleanup 2021-02-26 10:07:17 -06:00
James Prestwood c5538f6450 auto-t: add API wait_for_object_change
This is similar to wait_for_object_condition, but will not allow
any intermediate state changes between the initial and expected
conditions. This is useful for roaming tests when the expected
state change is 'connected' --> 'roaming' with no changes in
between.
2021-02-05 14:44:00 -06:00
James Prestwood e7d941dc3c auto-t: make spoof_frame more robust
Sometimes scan results can come in with a MAC address which
should be in the first index of addrs[] (42:xx:xx:xx:xx:xx).
This causes a failure to lookup the radio path.

There was also a failure path added if the radio cannot be
found rather than rely on DBus to fail with a None path.

The arguments to SendFrame were also changed to use the
ByteArray DBus type rather than python's internal bytearray.
This shouldn't have any effect, but its more consistent with
how DBus arguments should be used.
2021-02-05 14:43:17 -06:00
James Prestwood 4b07280319 auto-t: fix wait_for_object_condition to work with any object
After recent changes fixing wait_for_object_condition it was accidentally
made to only work with classes, not other types of objects. Instead
create a minimal class to hold _wait_timed_out so it doesnt rely on
'obj' holding the boolean.
2021-02-04 20:56:34 -06:00
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 5e631b4e38 auto-t: fix wait_for_object_condition
After the re-write this was broken and not noticed until
recently. The issue appeared to be that the GLib timeout
callback retained no context of local variables. Previously
_wait_timed_out was set as a class variable, but this was
removed so multiple IWD instances could work. Without
_wait_timed_out being a class variable the GLib timeout
setting it had no effect on the wait loop.

To fix this we can set _wait_timed_out on the object being
passed in. This is preserved in the GLib timeout callback
and setting it gets honored in the wait loop.
2021-01-25 13:10:52 -06:00
James Prestwood 55e7caa8e0 auto-t: add iftype/cipher disable to hwsim.py 2020-12-17 20:13:41 -06:00
James Prestwood 5525f32cdd auto-t: update hwsim radio create to use dictionary 2020-12-17 20:10:45 -06:00
James Prestwood eaf176220c auto-t: fix hwsim.py to use Destroy rather than Remove
There is no Remove() method, but since this code never was used it
remained incorrect for quite some time.
2020-12-17 20:10:30 -06:00
James Prestwood d40cac403f auto-t: support IP match with no IP set
This allows an interface with no IP set to be checked for
by passing None in as the address. This will generate an
exception by ioctl which we catch.
2020-12-08 15:15:42 -06:00
James Prestwood d2cc033d09 auto-t: pass namespace on to other IWD classes
Certain classes were still using the default namespace. This
didn't matter yet since testAP was the only test using namespaces,
and the AP interface was the only one being used.

For an IWD station on a separate namespace all objects need to
be accessable, so the namespace is passed along to those as needed.
2020-12-08 15:15:39 -06:00
James Prestwood b18f843532 auto-t: add storage dir to IWD() constructor
Add support for setting a custom storage directory.
2020-12-08 15:15:36 -06:00
James Prestwood 4168e20243 auto-t: add test_ip_connected to testutil
Used to check IP connectivity between namespaces. The input
should be two tuples containing the IP and namespace to ping
from/to.
2020-11-18 11:01:11 -06:00
James Prestwood 5a7eb91378 auto-t: update utilities to use namespaces 2020-11-18 11:01:11 -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 eb92c0a6e5 auto-t: refactor get_instance from iwd.py
When network namespaces are introduced there may be multiple
IWD class instances. This makes IWD.get_instance ambiguous
when namespaces are involved. iwd.py has been refactored to
not use IWD.get_instance, but testutil still needs it since
its purely based off interface names. Rather than remove it
and modify every test to pass the IWD object we can just
maintain the existing behavior for only the root namespace.
2020-11-16 17:05:45 -06:00
James Prestwood 2d45461dfd auto-t: simplify copy_to_hotspot
Since copy_to_storage can take an arbitrary destination path now
we can reuse that instead of duplicating code.
2020-11-04 13:36:03 -06:00
James Prestwood efe53e28c8 auto-t: add copy_to_ap utility 2020-11-04 13:35:44 -06:00
James Prestwood 2a6690e50d auto-t: fix agent path timing issue
The agent path was generated based on the current time which
sometimes yielded duplicate paths if agents were created quickly
after one another. Instead a simple iterator removes any chance
of a duplicate path.
2020-11-03 13:58:23 -06:00