3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-14 07:59:24 +01:00
Commit Graph

496 Commits

Author SHA1 Message Date
James Prestwood
c76f7eac05 auto-t: add ability to reserve radios not for IWD/hostapd/etc
If the test needs to do something very specific it may be useful to
prevent IWD from managing all the radios. This can now be done
by setting a "reserve" option in the radio settings. The value of
this should be something other than iwd, hostapd, or wpa_supplicant.

For example:

[rad1]
reserve=false
2024-03-01 08:42:02 -06:00
James Prestwood
5067654a6d auto-t: end process_io on HUP signal, detect process crash
When HUP is received the IO read callback was never completing which
caused it to block indefinitely until waited for. This didn't matter
for most transient processes but for IWD, hostapd, wpa_supplicant
it would cause test-runner to hang if the process crashed.

Detecting a crash is somewhat hacky because we have no process
management like systemd and the return code isn't reliable as some
processes return non-zero under normal circumstances. So to detect
a crash the process output is being checked for the string:
"++++++++ backtrace ++++++++". This isn't 100% reliable obviously
since its dependent on how the binary is compiled, but even if the
crash itself isn't detected any test should still fail if written
correctly.

Doing this allows auto-tests to handle IWD crashes gracefully by
failing the test, printing the exception (event without debugging)
and continue with other tests.
2024-02-29 14:31:55 -06:00
James Prestwood
c54ef5a8da auto-t: timestamp log files in test-runner
The log files become much more useful when there are timestamps
associated with each log.
2024-02-22 09:28:55 -06:00
James Prestwood
390fd58cad auto-t: increase RAM when running with valgrind (UML)
This was done for QEMU but not for UML. Running more than a few
tests with --valgrind will generally thrown an OOM error pretty
quick.
2023-12-19 19:48:51 -06:00
James Prestwood
63e35dbd88 auto-t: throw exception if executable is missing
Certain tests may require external processes to work
(e.g. testNetconfig) and if missing the test will just hang until
the maximum test timeout. Check in start_process if the exe
actually exists and if not throw an exception.
2023-12-15 10:21:01 -06:00
James Prestwood
2be49a93ba auto-t: make test timeout configurable
With the addition of DPP PKEX autotests some of the timeouts are
quite long and hit test-runners maximum timeouts. For UML we should
allow this since time-travel lets us skip idle waits. Move the test
timeout out of a global define and into the argument list so QEMU
and UML can define it differently.
2023-11-13 09:46:34 -06:00
James Prestwood
7418c5fd3c hwsim: handle ADD/DEL_MAC_ADDR events
Handling these events notifies hwsim of address changes for interface
creation/removal outside the initial namespace as well as address
changes due to scanning address randomization.

Interfaces that hwsim already knows about are still handled via
nl80211. But any interfaces not known when ADD/DEL_MAC_ADDR events
come will be treated specially.

For ADD, a dummy interface object will be created and added to the
queue. This lets the frame processing match the destination address
correctly. This can happen both for scan randomization and interface
creation outside of the initial namespace.

For the DEL event we handle similarly and don't touch any interfaces
found via nl80211 (i.e. have a 'name') but need to also be careful
with the dummy interfaces that were created outside the initial
namespace. We want to keep these around but scanning MAC changes can
also delete them. This is why a reference count was added so scanning
doesn't cause a removal.

For example, the following sequence:

ADD_MAC_ADDR (interface creation)
ADD_MAC_ADDR (scanning started)
DEL_MAC_ADDR (scanning done)
2023-07-05 22:03:32 -05:00
James Prestwood
5f4f15a600 hwsim: move frame processing into a separate function
The ADD/DEL_MAC_ADDR events come through the unicast handler so
move the frame processing to a separate function so these other
events can be handled.
2023-07-05 21:52:19 -05:00
James Prestwood
cda7644557 hwsim: add ADD/DEL_MAC_ADDR events
These events are important to support both moving radios to other
namespaces, and to allow scan address randomization to work.
2023-07-05 21:52:09 -05:00
James Prestwood
44a37d7eae hwsim: properly cleanup rules queue
After adding prefix matching the rule structure contained allocated
memory which was not being cleaned up on exit if rules still
remained in the list (removing the rule via DBus was done correctly)
2023-04-16 11:26:54 -05:00
James Prestwood
802e9e5916 hwsim: add remaining ciphers to supported list
This list was not updated when adding the new ciphers which prevented
these ciphers from being disabled.
2022-11-01 15:50:41 -05:00
James Prestwood
81e48eaba5 hwsim: add additional ciphers to disable list
Allows these ciphers to be disabled when creating radios.
2022-10-27 09:40:32 -05:00
Denis Kenzior
201b85e8da crypto: Rename BIP to BIP_CMAC
To match the spec more closely.  Several additional BIP algorithms are
being introduced, including BIP_GMAC_128|256 and BIP_CMAC_256.
2022-10-24 11:05:24 -05:00
James Prestwood
e31d6296d8 hwsim: fix early bail out processing rules
If a rule was disabled it would cause hwsim to not continue processing
frames using rules further in the queue. _Most_ tests only use one
rule so this shouldn't have changed their behavior but others which
use multiple rules may be effected and the tests have not been
running properly.
2022-10-06 09:01:08 -05:00
James Prestwood
47e11dea58 test-runner: write out individual test results
The --results option only wrote PASS/FAIL for the entire run.
Instead write out each individual test result.
2022-10-03 10:39:40 -05:00
James Prestwood
dd80bbf397 test-runner: add custom verbose option iwd-sae
Enables IWD_SAE_DEBUG to be set in the test-runner environment
2022-09-26 14:15:08 -05:00
James Prestwood
950624761c auto-t: remove bringing up lo interface
Several tests were setting lo up which is already done by
test-runner.
2022-08-22 12:53:16 -05:00
James Prestwood
90dc2e5547 test-runner: double RAM for --valgrind
It seems 256MB was right on the edge if valgrind was being used and
sometimes the test would fail with OOM exceptions.
2022-08-22 12:53:16 -05:00
James Prestwood
71ac0a8909 test-runner: make developer mode optional
IWD can now be started without -E if needed
2022-07-26 13:11:33 -05:00
James Prestwood
07a3b1d655 test-runner: automatically find PCI passthrough config
When PCI adapters are properly configured they should exist in the
vfio-pci system tree. It is assumed any devices configured as such
are used for test-runner.

This removes the need for a hw.conf file to be supplied, but still
is required for USB adapters. Because of this the --hw option was
updated to allow no value, or a file path.
2022-07-19 14:32:49 -05:00
James Prestwood
99773ea7e8 test-runner: start dbus with --start
Starts dbus-daemon as well as sets the right environment variables
so IWD can start (and any other dbus services).
2022-07-19 14:32:49 -05:00
James Prestwood
5692dcf9a0 test-runner: allow infinite process wait
subprocess.Popen's wait() method was overwritten to be non-blocking but
in certain circumstances you do want to wait forever. Fix this to allow
timeout=None, which calls the parent wait() method directly.
2022-07-19 14:32:49 -05:00
Denis Kenzior
c57a15d21c tools: Add CONFIG_CRYPTO_ECDSA 2022-07-18 10:58:06 -05:00
Denis Kenzior
0593846ffc tools: Add CONFIG_CRYPTO_GCM
Certain TLS suites are based on AES/GCM, make sure it is added to the
reference test-runner kernel config.
2022-07-14 11:50:37 -05:00
Denis Kenzior
ee68e44b80 tools: Remove ARC4 from t-runner reference config
ARC4 is now supported natively inside ell and has been made unavailable
via the skcipher userspace API.
2022-07-14 11:49:30 -05:00
Andrew Zaborowski
043a6959e0 test-runner: Mark source directory as safe for git
Since we use git ls-files to produce the list of all tests for -A, if
the source directory is owned by somebody other than root one might
get:

fatal: unsafe repository ('/home/balrog/repos/iwd' is owned by someone else)
To add an exception for this directory, call:

	git config --global --add safe.directory /home/balrog/repos/iwd

Starting
/home/balrog/repos/iwd/tools/..//autotests/ threw an uncaught exception
Traceback (most recent call last):
  File "/home/balrog/repos/iwd/tools/run-tests", line 966, in run_auto_tests
    subtests = pre_test(ctx, test, copied)
  File "/home/balrog/repos/iwd/tools/run-tests", line 814, in pre_test
    raise Exception("No hw.conf found for %s" % test)
Exception: No hw.conf found for /home/balrog/repos/iwd/tools/..//autotests/

Mark args.testhome as a safe directory on every run.
2022-07-12 12:47:50 -05:00
Andrew Zaborowski
39fa246d9e test-runner: Support running hostapd in namespaces
The kernel will not let us test some scenarios of communication between
two hwsim radios (e.g. STA and AP) if they're in the same net namespace.
For example, when connected, you can't add normal IPv4 subnet routes for
the same subnet on two different interfaces in one namespace (you'd
either get an EEXIST or you'd replace the other route), you can set
different metrics on the routes but that won't fix IP routing.  For
testNetconfig the result is that communication works for DHCP before we
get the inital lease but renewals won't work because they're unicast.
Allow hostapd to run on a radio that has been moved to a different
namespace in hw.conf so we don't have to work around these issues.
2022-07-12 12:47:09 -05:00
James Prestwood
6022ebaa36 test-runner: run prepare_environment with --start
The --start option was directly passed to the kernel init parameter,
preventing any environment setup from happening.

Intead always use 'run-tests' as the init process but detect --start
and execute that binary/script once inside the environment.
2022-07-11 11:11:35 -05:00
James Prestwood
1ecadc3952 test-runner: fix UML blocking on wait_for_socket/service
In UML if any process dies while test-runner is waiting for the DBus
service or some socket to be available it will block forever. This
is due to the way the non_block_wait works.

Its not optimal but it essentially polls over some input function
until the conditions are met. And, depending on the input function,
this can cause UML to hang since it never has a chance to go idle
and advance the time clock.

This can be fixed, at least for services/sockets, by sleeping in
the input function allowing time to pass. This will then allow
test-runner to bail out with an exception.

This patch adds a new wait_for_service function which handles this
automatically, and wait_for_socket was refactored to behave
similarly.
2022-06-24 18:11:10 -05:00
James Prestwood
3e5ce99e82 test-runner: make is_process_running more accurate
This function was checking if the process object exists, which can
persist long after a process is killed, or dies unexpectedly. Check
that the actual PID exists by sending signal 0.
2022-06-24 18:11:02 -05:00
James Prestwood
c10ade711d test-runner: remove reference to missing class member
The print statement was referencing self.name, which doesn't exist. Use
self.args[0] instead.
2022-06-24 18:10:54 -05:00
James Prestwood
d43ec1b014 test-runner: fix result/monitor options
An earlier commit fixed several options but ended up breaking others. The
result_parent/monitor_parent options are hidden from the user and only meant
to be passed to the kernel but they relied on the fact that the underscore
was present, not a dash. This updates the argument to use a dash:

--result-parent
--monitor-parent

Fixes: 00e41eb0ff ("test-runner: Fix parsing for some arguments")
2022-06-22 18:41:21 -05:00
James Prestwood
8f42507641 test-runner: fix matching with --verbose
The new regex match update was actually matching way more than it should
have due to how python's 'match' API works. 'match' will return successfully
if zero or more characters match from the beginning of the string. In this
case we actually need the entire regex to match otherwise we start matching
all prefixes, for example:

"--verbose iwd" will match iwd, iwd-dhcp, iwd-acd, iwd-genl and iwd-tls.

Instead use re.fullmatch which requires the entire string to match the
regex.
2022-06-22 18:39:41 -05:00
James Prestwood
679cea02af test-runner: exclude 'iwd-rtnl' from being enabled with --log
Enabling this ends up dumping so much logging and, at least with namespaces,
seems to break the logger module and cause really weird behavior, worst of
which is that all processes start dumping to stdout.

This can still be enabled explicitly with --verbose iwd-rtnl, but is turned
off by default when --log is used.
2022-06-22 18:37:15 -05:00
Andrew Zaborowski
00e41eb0ff test-runner: Fix parsing for some arguments
Currently the parameter values reach run-tests by first being parsed by
runner.py's RunnerArgParser, then the resulting object members being
encoded as a commandline string, then as environment variables, then the
environment being converted to a python string list and passed to
RunnerCoreArgParser again.  Where argument names (like --sub-tests) had
dashes, the object members had underscores (.sub_tests), this wasn't
taken into account when building the python string list from environment
variables so convert all underscores to dashes and hope that all the
names match now.

Additionally some arguments used nargs='1' or nargs='*' which resulted
in their python values becoming lists.  They were converted back to command
line arguments such as: --sub_tests ['static_test.py'], and when parsed
by RunnerCoreArgParser again, the values ended up being lists of lists.
In all three cases it seems the actual user of the parsed value actually
expects a single string with comma-separated substrings in it so just drop
the nargs= uses.
2022-06-22 15:56:01 -05:00
Andrew Zaborowski
1aa418d098 test-runner: Support iwd-rtnl as a --verbose value 2022-06-17 14:13:30 -05:00
James Prestwood
b2ed779ce9 test-runner: fix testhome mounting for QEMU
This was lazily copied from UML but really made no sense in the context
of QEMU. First QEMU needs the virtfs option to define the mount tag and
in addition a 9p mount should be used rather than 'hostfs'.
2022-06-03 18:20:55 -05:00
James Prestwood
db3d6a3652 test-runner: allow regex for verbose option
The glob match was completely broken for --verbose because globs
are actually path matches, not generally for strings. Instead
match based on regular expressions.

First the verbose option was fixed to store it as an array as well
as write any list arguments into the kernel command line properly
(str() would include []). This has worked up until now because the
'in' keyword in python will work on strings just as well
as lists, for example:

>>> 'test' in 'this,is,a,test'
True

Then, the glob match was replaced with a regex match. Any exceptions
are caught and somewhat ignored (printed, but only seen with --debug).
This only guards against fatal exceptions from a user passing an
invalid expression.
2022-06-03 18:20:48 -05:00
James Prestwood
c36f94a15a test-runner: only remove /tmp files if they exist
This bit of code was throwing exceptions if a test cleaned up files that
test-runner was expecting to clean up. Specifically testHotspot swaps out
main.conf and PSK files many times. This led to the exception being thrown,
caught, and ignored but further on test-runner would print:

"File _X_ not cleaned up!"

Now the files will be checked if they exist before trying to remove it.
2022-06-03 11:59:13 -05:00
James Prestwood
df46776046 auto-t: allow skipping tests is wpa_supplicant is not found
Similarly to ofono/phonesim allow tests to be skipped if wpa_supplicant
is not found on the system.

This required some changes to DPP/P2P where Wpas() should be called first
since this can now throw a SkipTest exception.

The Wpas class was also made to allow __del__ to be called without
throwing additional exceptions in case wpa_supplicant was not found.
2022-06-02 16:47:02 -05:00
James Prestwood
87bb9a42b5 test-runner: skip mounting duplicate folders
If the user specifies the same parent directory for several outfiles
skip mounting since it already exists. For example:

--monitor /outfiles/monitor.txt --result /outfiles/result.txt
2022-05-25 15:00:05 -05:00
James Prestwood
1e6773d2a7 test-runner: disallow result/monitor/log directly under /tmp
Inside the virtual environments /tmp is mounted as its own FS and not
taken from the host. This poses issues if any output files are directly
under /tmp since test-runner tries to mount the parent directory (/tmp).
The can be fixed by ensuring these output files are either not under
/tmp or at least one folder down the tree (e.g. /tmp/outputs/outfile.txt).

Now this requirement is enforced and test-runner will not start if any
output files parent directory is /tmp.
2022-05-25 15:00:05 -05:00
James Prestwood
78c918c2c1 test-runner: mount testhome rather than assume location
Usually the test home directory is a git repo somewhere e.g. under
/home. But if the home directory is located under /tmp this poses
a problem since UML remounts /tmp. To handle both cases mount
the home directory explicity.
2022-05-25 15:00:05 -05:00
James Prestwood
641f558b3d test-runner: remove root user requirement from log/monitor/result
Certain aspects of QEMU like mounting host directories may still require
root access but for UML this is not the case. To handle both cases first
check if SUDO_UID/GID are set and use those to obtain the actual users
ID's. Otherwise if running as non-root use the UID/GID of the user
directly.
2022-05-25 15:00:05 -05:00
James Prestwood
9353c7748b test-runner: resolve --kernel absolute path
This only posed a problem oddly if the kernel binary was in the same
directory as test-runner. Resolving the absolute path with the
argument parser resolves the issue.
2022-04-06 17:22:06 -05:00
James Prestwood
5453f71a7c test-runner: fix check for phonesim
This got changed to use which, but not updated to remove the
list argument.
2022-04-06 17:22:06 -05:00
James Prestwood
cec5fab9b3 test-runner: allow decode failure when writing IO
If this fails, e.g. an invalid utf-8 character it should not cause
the test to fail.
2022-04-06 14:47:58 -05:00
James Prestwood
9edb196395 test-runner: fix ctrl-c for UML
The TIOCSTTY ioctl was not shared between UML and QEMU which prevented
any console input from making it into UML. This fixes that, and now
ctrl-c can be used to stop UML test execution.
2022-04-06 14:47:52 -05:00
James Prestwood
5710cc097b test-runner: Unify QEMU/UML logging code
The MountInfo tuple was changed to explicitly take a source string. This
is redundant for UML and system mounts since the fstype/source are the same,
but it allows QEMU to specify the '9p' fstype and use MountInfo rather than
calling mount() explicitly.

This also moves logging cleanup into _prepare_mounts so both UML and QEMU
can use it.
2022-04-06 14:47:45 -05:00
James Prestwood
e70d7e0857 test-runner: write separators for transient processes
Many processes are not long running (e.g. hostapd_cli, ip, iw, etc)
and the separators written to log files don't show up for these which
makes debugging difficult. This is even true for IWD/Hostapd for tests
with start_iwd=0.

After writing separators for long running processes write them out for
any additional log files too.
2022-04-06 14:47:24 -05:00