Commit Graph

5853 Commits

Author SHA1 Message Date
James Prestwood 7b98a6ed9c test-runner: only remove GLib timeout if it exists
There was a race condition here where the GLib timeout could have
fired but the test function returned successfully prior to the
end of the while loop. This would end up causing source_remove to
print a warning that the source did not exist.

Instead check if the timeout fired prior to removing it.
2021-08-13 20:39:13 -05:00
James Prestwood cb4f1d2a99 auto-t: turn off scan address randomization in testHotspot
This (hopefully) will make this test pass better on slower machines.
In addition the mechanism of copying over separate main.conf files
was changed (rather than echo'ing the option into /tmp/main.conf)
2021-08-13 20:39:13 -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 f721f1de1e auto-t: skip testEAP-PEAP-SIM if ofonod is not running 2021-08-13 16:44:14 -05:00
James Prestwood dbd8842d51 test-runner: fix test skipping
Tests that called skipTest would result in an exception which would
hault execution as it was uncaught. In addition this wouldn't result
in an skipped test.

Now the actual test run is surrounded in a try/except block, skipped
exceptions are handled specifically, and a stack trace is printed if
some other exception occurs.
2021-08-13 16:44:14 -05:00
Denis Kenzior 6fee25af9b test-runner: Make run 2021-08-13 15:19:28 -05:00
James Prestwood 790bb44785 test-runner: don't always print failure to remove ctrl interface
This can happen, particularly with SAQuery when hostapd is forcefully
killed. Better to only print when running in debug mode.
2021-08-13 15:18:40 -05:00
James Prestwood c03afda96f test-runner: start dmesg early with --follow
dmesg was being called at the very end of testing and dumped into
a log file. If many tests were run this could take quite a long
time and was timing out the default process wait. Instead --follow
can be used (basically like 'tail') which prints messages as they
come and avoids the time consuming full dump at the end.
2021-08-13 15:18:40 -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 382b73c11a auto-t: cleanup dhcpd.leases[~] in testNetconfig 2021-08-13 15:18:40 -05:00
James Prestwood 5c14742a87 auto-t: use prefix on hotspot anqp test
The hotspot ANQP delay test was setting a global delay on all
packets which had some unintended consequences. At the time this
was the only way of simulating the test scenario but now hwsim
supports prefix matching so only the ANQP request/response will
be delayed.
2021-08-13 15:18:40 -05:00
James Prestwood c2caa325ba auto-t: fix testAgent use of Process
This test was accessing the subprocess object and calling terminate
which ends up causing issues with test-runners own process cleanup.
Instead kill() should be used.
2021-08-13 15:18:40 -05:00
James Prestwood 82d7c81bd3 auto-t: remove unneeded BSSs in testEAP-MSCHAPv2
Hostapd sometimes has trouble with specifying additional BSSs in
a single config file, at least in the test-runner environment.
Since all the BSS's specified were identical instead the test was
reworked to only have a single BSS and each subtest can connect
in its own unique way.
2021-08-13 14:54:53 -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 78f5a5dde4 auto-t: speed up testRoamRetry
This test took quite a while to execute (~2 minutes on my machine)
because there was simply no other way to test this scenario but
waiting. Now the no-roam-candidates condition can be waited for
rather than just sleeping for 20 seconds. Additionally the default
RoamRetryInterval was being used which is 60 seconds. Instead
main.conf can set this to 5 seconds and really cut down on the time
to wait.

Part of a comment was also removed due to being incorrect. Even
with neighbor reports IWD still must scan, its just that the
scan is more limited and, in theory, faster.
2021-08-13 14:45:14 -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 cd2dd4e2dc station: Add generic Event signal
This is meant to be used as a generic notification to autotests. For
now 'no-roam-candidates' is the only event being sent. The idea
is to extend these events to signal conditions that are otherwise
undiscoverable in autotesting.
2021-08-13 14:44:24 -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 4e3cedc901 test-runner: wait for individual hostapd control sockets 2021-08-13 11:16:19 -05:00
James Prestwood 23cf6cb2e4 test-runner: implement non_block_wait
There was a common bit of code all over test-runner and utilities
which would wait for 'something' in a loop. At best these loops
would do the right thing and use the GLib.iteration call as to not
block the main loop, and at worst would not use it and just busy
wait.

Namespace.non_block_wait unifies all these into a single API to
a) do the wait correctly and b) prevent duplicate code.
2021-08-13 11:16:19 -05:00
Andrew Zaborowski 2af0166970 ap: Make station removal safer
Replace instances of the ap_del_station() +
ap_sta_free()/ap_remove_sta() with calls to ap_station_disconnect to
make sure we consistently remove the station from the ap->sta_states
queue before using ap_del_station().  ap_del_station() may generate an
event to the ap.h API user (e.g. P2P) and this may end up tearing down
the AP completely.

For that scenario we also don't want ap_sta_free() to access sta->ap so
we make sure ap_del_station() performs these cleanup steps so that
ap_sta_free() has nothing to do that accesses sta->ap.
2021-08-13 10:49:28 -05:00
Andrew Zaborowski 97a34e6b4a ap: Fix an invalid access in ap_write_wsc_ie
client_frame is not valid for a beacon frame as beacons are not sent in
response to another frame.  Move the access to client_frame->address_2
to the conditional blocks for Probe Response and Association Response
frames.
2021-08-13 10:49:28 -05:00
Andrew Zaborowski 5c9de0cf23 eapol: Store IP address in network byte order
Switch handshake_state's .client_ip_addr, .subnet_mask and .go_ip_addr
from host byte order to network by order.
2021-08-13 10:47:05 -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 876ac5f569 auto-t: use .frequency property in SAQuery-spoofing test 2021-08-13 10:46:18 -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 dffff73e89 station: implement Scan on debug interface
This is to support the autotesting framework by allowing a smaller
scan subset. This will cut down on the amount of time spent scanning
via normal DBus scans (where the entire spectrum is scanned).
2021-08-13 10:44:26 -05:00
James Prestwood ba6c8174d2 test-runner: run individual test functions manually
While losing the convenience of unittest this patch breaks out
each individual test function in order to run it manually and
get results. This vastly improves the user experience by seeing
which test file and function is being executed rather than simply
seeing "PASSED" for the entire test set.

In addition exceptions/failures are printed out as they happen
rather than at the end.
2021-08-13 10:43:47 -05:00
James Prestwood 89bddf551a test-runner: pass **kwargs in dbg() 2021-08-13 10:43:47 -05:00
James Prestwood c23c37c07c test-runner: print uncaught test exceptions always 2021-08-13 10:43:47 -05:00
James Prestwood ea3ce7a119 station: set autoconnect via setter
This updates the autoconnect property for the debug interface
2021-08-13 10:41:25 -05:00
James Prestwood 836f0d9a08 auto-t: set autoconnect=True for tests that need it
After the default behavior was changed to disable autoconnect there
were several tests which still needed it to be turned on.
2021-08-12 16:59:05 -05:00
James Prestwood a15b781feb auto-t: update all tests to remove bad scanning logic
This changes all tests to use the default get_ordered_network behavior
rather than some custom or incorrect logic. Any use of
scan_if_needed=True has been removed since this is now the default.
Also any explicit scanning has been removed for tests which do not
require it (where the default behavior is good enough).
2021-08-12 16:59:03 -05:00
James Prestwood 89c1ec3d79 auto-t: make hwsim registration off by default
With the addition of connect_bssid/roam very few tests actually
require hwsim. Since hwsim can lead to problems with scan results
its best to have it off by default and have each test that needs
it explicitly turn it on.

Tests which previously turned it off have had that option removed.

Tests that do require hwsim still are vulnerable to scan result
problems, so for these tests beacon_int was added to the hostapd
config which seems to help with reliability somewhat.
2021-08-12 16:59:01 -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 f6f08f9b96 station: disable autoconnect when in developer mode
Most autotests do not want autoconnect behavior so it is being
turned off by default. There are a few tests where it is needed
and in these few cases the test can enable autoconnect through
the new station debug property.
2021-08-12 16:53:58 -05:00
James Prestwood 249a1ef1c0 station: make autoconnect settable via debug interface
This adds the property "AutoConnect" to the station debug interface
which can be read/written to disable or enable autoconnect globally.
As one would expect this property is only going to be used for testing
hence why it was put on the debug interface. Mosts tests disable
autoconnect (or they should) because it leads to unexpected connections.
2021-08-12 15:57:00 -05:00
James Prestwood 7af6aac440 auto-t: use connect_bssid in APRoam
In addition the send_bss_transition call was updated to only send a
single BSS. By sending two BSS's IWD is left to pick whichever one
it wants which makes the test behavior undefined.
2021-08-12 15:14:07 -05:00
James Prestwood 6e331efbda auto-t: update testPreauth-roam to use connect_bssid/roam() 2021-08-12 15:14:07 -05:00
James Prestwood 1addaf3355 auto-t: remove FT-over-DS test, and rename testFT-PSK-roam 2021-08-12 15:14:07 -05:00
James Prestwood 20f7907436 auto-t: use connect_bssid/roam APIs in testFT-PSK-roam
This also adds FT-over-DS into this test, as well as a reassociation
test for good measure.
2021-08-12 15:14:07 -05:00
James Prestwood 49eb17973e auto-t: remove testFT-FILS-SHA384 2021-08-12 15:14:07 -05:00
James Prestwood 85759a6f3c auto-t: rename testFT-FILS-SHA256 to testFT-FILS 2021-08-12 15:14:07 -05:00