3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-20 12:39:25 +01:00
Commit Graph

350 Commits

Author SHA1 Message Date
James Prestwood
f9c2fa7bb2 test-runner: remove stale file after test
test-runner will print out if files were left behind after a
test which lets the developer know something was not cleaned
up. But in this case test-runner should also remove these files
so they are not left, and printed, for each subsequent test.
2021-05-10 10:12:48 -05:00
James Prestwood
751db56045 test-runner: increase RAM for valgrind
Certain tests like testAP spawn two IWD process in separate
namespaces. When --valrind is used this eats up quite a bit
of RAM and causes the VM to run out of memory and start
killing off processes.
2021-05-04 10:30:55 -05:00
James Prestwood
4085aceb4a test-runner: fix verbose output with --valgrind
Since using --valgrind actually runs IWD using the valgrind
process the --verbose flag would only work if 'valgrind' was
also specified. This was taken into account with is_verbose
but the actual logic enabling stdout did not use that helper.
This was due, in part, to logging since is_verbose will always
return true if --log is used. To fix this a new flag was added
to is_verbose which omits the --log check to handle this
specific case.
2021-04-29 12:56:51 -05:00
James Prestwood
8aac527e29 test-runner: fix process output truncation
There was a bug with process output where the last bit of data would
never make it into stdout or log files. This was due to the IO watch
being cleaned up when the process was killed and never allowing it
to finish writing any pending data.

Now the IO watch implementation has been moved out into its own
function (io_process) which is now used to write the final bits of
data out on process exit.
2021-04-22 13:25:23 -05:00
James Prestwood
d11974c717 test-runner: add timeout for waiting for process to finish
If a process hangs on exit test-runner would sit indefinitely
waiting.
2021-04-22 13:25:23 -05:00
James Prestwood
709c86086f test-runner: fix process cleanup loop
The processes in the list ultimately get removed for each
kill() call. This causes strange behavior since the list is
being iterated and each iteration is removing items. Instead
iterate over a new temporary list so the actual process list
can be cleaned up.
2021-04-22 13:25:23 -05:00
Denis Kenzior
38a7c4a8dc test-runner: Don't bother enabling IWD_GENL_DEBUG
IWD_GENL_DEBUG is not generally useful anymore as it just prints a
hexdump of the raw data on the socket.  The messages are quite verbose
and spam test-runner logs for little utility.
2021-04-20 10:48:50 -05:00
James Prestwood
0756c301f3 hwsim: add Prefix match rule support
Hwsim rules now have a 'Prefix' property which will allow
matching frames based on their payload data.
2021-04-05 17:47:42 -05:00
James Prestwood
66b4723216 test-runner: fix duplicate process output
Process output was being duplicated when -v was used. This was
due to both stderr and stdout being appended to the write_fd list
as well as stderr being set to stdout in the Popen call.

To fix this only stdout should be appended to the write_fd list,
but then there comes a problem with closing the streams. stdout
cannot be closed, so instead it is special cased. A new
verbose boolean was added to Process which, if True, will
cause any output to be written to stdout explicitly.
2021-03-02 10:37:22 -06:00
James Prestwood
c660feadf1 test-runner: stop/warn on processes running after test
This gives the dev some inidication their test did not clean up
correctly and running processes remain.
2021-02-26 10:09:56 -06:00
James Prestwood
670f063a30 test-runner: warn on files left after test completes 2021-02-26 10:09:56 -06:00
James Prestwood
2e55e00662 test-runner: start haveged in foreground
haveged was forking itself which then prevented test-runner from
cleaning it up.
2021-02-26 10:09:56 -06:00
James Prestwood
73b89555fa test-runner: fix Namespace class ref problems
The Namespace class was never being removed when tests finished.
This is fixed by unreffing the hwsim internal _radio object which
both cleans up the radio and allows the Namespace to be removed.
2021-02-26 10:09:56 -06:00
James Prestwood
d8abc88e4c test-runner: move process cleanup into kill()
This moves all the de-init code into kill(), which fixes a few
reference issues causing processes to hang around longer than
desired. If the process terminates on its own and/or the last
reference is lost __del__ will kill the process and clean up.
2021-02-26 10:09:56 -06:00
James Prestwood
48d27c982d test-runner: reset namespaces on test completion 2021-02-26 10:09:56 -06:00
James Prestwood
8f33926a75 test-runner: use cleanup() for start_dbus
Use a cleanup routine to remove the dbus_address/dbus_cfg files
2021-02-26 10:09:56 -06:00
James Prestwood
11f0abebe6 test-runner: add better Hostapd cleanup
There were a few issues with the cleanup of Hostapd. First the
process was only being killed, which did not actually remove
the process from the list.

In addition, with EAP-SIM/AKA tests, hostapd created sim_db
unix socket files which it does not clean up.
2021-02-26 10:09:36 -06:00
James Prestwood
bf9d2b6c52 test-runner: allow radio remove failure
This is somewhat of an open issue/TODO but for now this avoids
the exception caused by trying to remove a radio that has been
moved to a namespace. Once a radio is moved hwsim loses that phy
and can no longer interact with it. This causes the Destroy()
method call to fail.
2021-02-26 10:09:36 -06:00
James Prestwood
5e79cda7c6 test-runner: cleanup output files/others in Process
A cleanup parameter was added to __init__ which can be used
by processes which create any additional files or require more
a custom cleanup routine. Some additional house keeping was
done to make Process cleanup more robust.
2021-02-26 10:09:36 -06:00
James Prestwood
697b4ce82f test-runner: remove concept of 'multi_test'
Though multi-test processes seemed like a good idea in terms of
efficiency, the additional code/special cases was not worth it
for the only two multi-test processes (dbus/haveged). Intead this
concept was removed completely and TestContext/Namespaces will
now start all processes for each individual test. This also is
fair to all tests as a previous failed test could end up bleeding
into future tests.
2021-02-26 10:09:36 -06:00
James Prestwood
90b695cfdf test-runner: fix start_dbus and clean up config
start_dbus was not returning the Process class which was
expected by the caller. This resulted in the config not
being cleaned up.
2021-02-19 10:16:37 -06:00
James Prestwood
4682c22ece test-runner: add __str__ method to Process
Printing out processes was done manually but instead we can
make Process printing extendable by adding its own __str__
method. This now will print if the process is a multi-test
process as well.
2021-02-19 10:16:37 -06:00
James Prestwood
c10bd14cde test-runner: use unique name for namespace output files
Output files in namespaces were not handled differently and would
end up overwriting/duplicating files from the root namespace. These
are now named /tmp/<process>-<namespace>-out.
2021-02-19 10:16:37 -06:00
James Prestwood
1791ef1dc7 test-runner: refactor Process class
The process class was quite hard to understand, and somewhat
fragile when multiple output options were needed like verbose
and logging, and in some cases even an additional output file.

To make things simpler we can have all processes output to a
temporary file (/tmp/<name>-out) and set a GLib IO watch on
that file. When the IO watch callback fires any additional
files (stdout, log files, output files) can be written to.

For wait=True processes we do not use an IO watch, but do
the same thing once the process exits, write to any additional
output files using the process output we already have.
2021-02-19 10:16:37 -06:00
James Prestwood
272a60a478 test-runner: require root user to run with --monitor
Since the monitor file requires touching the host file
system, root access is required.
2021-02-19 10:16:37 -06:00
James Prestwood
c2d71fdaa5 test-runner: clear log dir before new log test run
The log dir was never being cleaned out prior to a new logging
test run. This could leave old stale files around. Note that this
will remove any past log files so if you need them, you want to
make a copy before running test-runner with --log again.
2021-02-19 10:16:37 -06:00
James Prestwood
a0865c9010 test-runner: start dmesg process with start_process
This avoids the need to pass in the context explicitly.
2021-02-19 10:16:37 -06:00
Denis Kenzior
897ef661fe hwsim: Don't use l_genl_msg_new_sized with a conditional
l_genl API will now automatically grow message buffers as needed, so
there's no need to make the logic over-complicated
2021-02-08 15:37:21 -06:00
James Prestwood
af8438878f test-runner: clean up dbus path file properly
Dbus should be started as a multi-test process from the
TestContext, which leaves the dbus address file around for
the full test run. For Namespaces dbus-daemon should be
closed when the Namespace closes.
2021-02-08 11:56:42 -06:00
James Prestwood
a8768e354d test-runner: print error if kernel/qemu path is not found 2021-02-05 18:01:49 -06:00
James Prestwood
f21e79c81c test-runner: add monitor to path 2021-02-05 18:01:49 -06:00
James Prestwood
ed80dc68aa test-runner: clean up temporary files 2021-02-05 18:01:43 -06:00
James Prestwood
b60f564bed test-runner: print Radio class path 2021-02-05 14:43:17 -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
cc345582ad test-runner: don't always print "verbose on for ..."
This shouldn't have been a dbg print, but rather a normal print
which will only be printed when '-d' is used.
2021-01-26 13:41:01 -06:00
James Prestwood
296f1d0d1c test-runner: fix verbose arguments as single string
The verbose arguments come in from the QEMU command line as a
single string. This should have been split into an array immediately
but was not. This led to issues like hostapd debug being enabled
when "-v hostapd_cli" was passed in.
2021-01-26 13:40:49 -06:00
Andrew Zaborowski
a55f8864d2 testrunner: Fix /tmp files cleanup on error
Since the list of files copied to /tmp was part of the return value from
pre_test(), if an exception occurred inside pre_test(), "copied" would
be undefined and the post_test(ctx, copied) call in the finally clause
cause another exception:

raceback (most recent call last):
  File "/home/balrog/repos/iwd/tools/test-runner", line 1508, in <module>
    run_tests()
  File "/home/balrog/repos/iwd/tools/test-runner", line 1242, in run_tests
    run_auto_tests(config.ctx, args)
  File "/home/balrog/repos/iwd/tools/test-runner", line 1166, in run_auto_tests
    post_test(ctx, copied)
UnboundLocalError: local variable 'copied' referenced before assignment

(apart from not being able to clean up the files).  Pass "copied" as a
paremeter to pre_test instead.
2021-01-25 14:01:58 -06:00
James Prestwood
01c108938e test-runner: Use DBus for hwsim radios
Use the hwsim DBus API rather than command line. This both is
faster and more dynamic than doing so with the command line.
This also avoids tracking the radio ID since we can just hang
on to the radio Dbus object directly.
2020-12-17 20:13:56 -06:00
James Prestwood
5567caf64a hwsim: add iftype/cipher disabling through DBus
Update the Dbus API to allow disabling iftypes and ciphers
just as you can with the command line.
2020-12-17 20:11:25 -06:00
James Prestwood
fe0879f7d1 test-runner: start hwsim always (optionally --no-register)
Always start hwsim but if tests do not need radio rules start
with the --no-register option.
2020-12-17 20:11:13 -06:00
James Prestwood
e8031bab2a test-runner: add wait_for_dbus_service
Common API to wait for a DBus service to appear on the bus
2020-12-17 20:10:57 -06:00
James Prestwood
6a1853b01a hwsim: change radio Create() to take a dictionary
The Create() API was limited to only taking a Name and boolean
(for p2p enabling). The actual hwsim nl80211 API can take more
attributes than this (which are actually utilized when creating
from the command line). To get the DBus API up to the same
functionality the two arguments in Create were replaced with
a single dictionary. This allows for extending later if more
arguments are needed.
2020-12-17 20:10:33 -06:00
James Prestwood
799ab03f59 hwsim: check pending_create_msg before replying
In the NEW_RADIO callback hwsim was assuming that DBus had no
yet replied to the Create() method. In some cases the NEW_RADIO
event fires before the actual callback which will respond to
DBus. This causes a crash in the create callback.
2020-12-17 20:08:54 -06:00
James Prestwood
554a78fbf0 hwsim: add --no-register option
Starts hwsim but does not register to mac80211_hwsim. This is to
allow autotests to disable hwsim, while still having the ability
to create/destroy radios over DBus.
2020-12-17 20:08:49 -06:00
James Prestwood
4e4ba6769d test-runner: add iwd-acd to verbose options
This will turn on IWD_ACD_DEBUG
2020-12-08 15:16:28 -06:00
James Prestwood
ada46fb2db test-runner: set processor count for VM
For better reliability the processor count is now set to qemu.
In cases of low CPU count (< 2) hosts the processor count is
limited to 1. Otherwise half of the host cores will be used for
the VM.
2020-12-08 15:15:51 -06:00
James Prestwood
41b8a32dfc test-runner: have start_iwd take a storage dir
Allow the storage directory (default /tmp/iwd) to be configured
just like the state directory. This is in order to support multiple
IWD instances which require separate storage directories for network
provisioning files.
2020-12-08 15:15:33 -06:00
James Prestwood
e1e1c4edd1 test-runner: introduce network namespaces
Our simulated environment was really only meant to test air-to-air
communication by using mac80211_hwsim. Protocols like DHCP use IP
communication which starts to fall apart when using hwsim radios.
Mainly unicast sockets do not work since there is no underlying
network infrastructure.

In order to simulate a more realistic environment network namespaces
are introduced in this patch. This allows wireless phy's to be added
to a network namespace and unique IWD instances manage those phys.
This is done automatically when 'NameSpaces' entries are configured
in hw.conf:

[SETUP]
num_radios=2

[NameSpaces]
ns0=rad1,...

This will create a namespace named ns0, and add rad1 to that
namespace. rad1 will not appear as a phy in what's being called the
'root' namespace (the default namespace).

As far as a test is concerned you can create a new IWD() class and
pass the namespace in. This will start a new IWD instance in that
namespace:

ns0 = ctx.get_namespace('ns0')
wd_ns0 = IWD(start_iwd=True, namespace=ns0)

'wd_ns0' can now be used to interact with IWD in that namespace, just
like any other IWD class object.
2020-11-18 11:01:11 -06:00
James Prestwood
a6808aa55a auto-t: introduce new autotest syntax
Sometimes improperly written tests can end up causing future tests
to fail. For faster debugging you can now add a '+' after a given
autotest which will start that test and run all tests which come
alphabetically after it (as if you are running a full autotest suite).

Example:

./test-runner -A testWPA+

This will run testWPA, testWPA2, testWPA2-no-CCMP, testWPA2-SHA256,
and testWPA2withMFP.
2020-11-16 17:05:45 -06:00
James Prestwood
423f9a4e60 auto-t: do away with -1 test results
This can result in strange test results since there was no less
than zero checks before subtracting the total tests from failed
tests. In case of an internal exception we can just set all values
to zero. This will be handled specially as we do for timeout
errors.
2020-11-16 17:05:45 -06:00