Alyssa Ross
507ff39251
nixos/test-driver: fix formatting
...
This caused the test driver to fail to build.
Fixes: 406de94b41
("nixos/test-driver: add `timeout` option for `wait_for_console_text`")
2023-05-28 12:29:26 +00:00
Jacek Galowicz
b4b45ee6d2
Revert "nixos/lib/test-driver: enable EFI variable reads at runtime"
2023-05-28 13:05:59 +02:00
Jacek Galowicz
d9626034f1
Merge pull request #234513 from NixOS/test-driver/wait_for_console_timeout
...
nixos/test-driver: add `timeout` option for `wait_for_console_text`
2023-05-28 09:57:00 +02:00
Jacek Galowicz
be62469b22
Merge pull request #229027 from NixOS/qemu-vm/read-efi-var
...
nixos/lib/test-driver: enable EFI variable reads at runtime
2023-05-28 09:51:29 +02:00
Raito Bezarius
d1104e2109
nixos/test-driver: add timeout
option for wait_for_console_text
(variant 2)
2023-05-28 00:07:43 +02:00
Raito Bezarius
406de94b41
nixos/test-driver: add timeout
option for wait_for_console_text
...
Previously, `wait_for_console_text` would block indefinitely until there were lines
shown in the buffer.
This is highly annoying when testing for things that can just hang for some reasons.
This introduces a classical timeout mechanism via non-blocking get on the Queue.
2023-05-27 23:55:52 +02:00
Raito Bezarius
f1aee66f92
nixos/lib/test-driver: enable EFI variable reads at runtime
...
This is useful whenever you want to diagnose the current state of UEFI
variables, to assert that bootloaders or boot programs (systemd-stub)
did their job correctly and set their variables accordingly.
In the future, it can enable inspecting SecureBoot keys also.
2023-05-27 22:44:58 +02:00
Alyssa Ross
e33c2a5e4c
nixos/test-driver: add missing spaces to warning
2023-05-27 15:00:00 +00:00
figsoda
202699c918
nixos/tests: fix typos
2023-05-19 22:31:04 -04:00
r-vdp
4147b878bc
nixos-test-driver: include a timeout for the recv call, do not assume sh == bash
2023-04-26 01:05:53 +02:00
Alyssa Ross
27f97953e0
nixos/test-driver: accept non-\w* filenames
...
What the code was trying to do was helpfully add a directory and
extension if none were specified, but it did this by checking whether
the filename was composed of a very limited character set that didn't
even include dashes.
With this change, the intention of the code is clearer, and I can put
dashes in my screenshot names.
2023-03-22 15:54:06 +00:00
Astro
64a4ae6f37
nixos/test-driver: remove allow_reboot state from Machine, make it a start() kwarg
2023-03-16 01:50:15 +01:00
Astro
9fc85a85d5
nixos/test-driver: implement Machine.reboot()
2023-03-16 01:41:32 +01:00
Astro
95d121e798
nixos/test-driver: fix allow_reboot
2023-03-15 12:48:01 +01:00
rnhmjoj
067d688b16
nixos/test-driver: handle decoding errors in Machine.execute
...
The output of a command is not guaranteed to be valid UTF-8, so the
decoding can fail raising UnicodeDecodeError. If this happens during a
`succeeds` the check will be erroneously marked failed.
This changes the error handling to the "replace" mode, where invalid
codepoints are replaced with � (REPLACEMENT CHARACTER U+FFFD) and the
decoding can go on.
2023-02-07 08:47:14 +01:00
rnhmjoj
f2929eb949
nixos/test-driver: drop logging from Machine.send_monitor_command
...
Several machine operations, like `send_chars` and `send_key`, are
implemented by calling `send_monitor_command`, possibly multiple times.
This generates a huge amount of unnecessary noise in the log, because
`send_monitor_command` is a low-level operation and an implementation
detail.
Here's an excerpt from a highlighted log before and afte the change.
Before:
[1m[32msubtest: Can generate a PGP key[0m[0m
machine: [1m[32msending keys 'gpg --gen-key\n'[0m[0m
machine: [1m[32msending monitor command: sendkey g[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey g, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey p[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey p, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey g[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey g, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey spc[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey spc, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey 0x0C[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey 0x0C, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey 0x0C[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey 0x0C, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey g[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey g, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey e[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey e, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey n[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey n, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey 0x0C[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey 0x0C, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey k[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey k, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey e[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey e, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey y[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey y, in 0.00 seconds)
machine: [1m[32msending monitor command: sendkey ret[0m[0m
machine: [1m[32mwaiting for monitor prompt[0m[0m
(finished: waiting for monitor prompt, in 0.00 seconds)
(finished: sending monitor command: sendkey ret, in 0.00 seconds)
(finished: sending keys 'gpg --gen-key\n', in 0.15 seconds)
After:
[1m[32msubtest: Can generate a PGP key[0m[0m
machine: [1m[32msending keys 'gpg --gen-key\n'[0m[0m
(finished: sending keys 'gpg --gen-key\n', in 0.15 seconds)
2023-02-07 08:40:54 +01:00
Jörg Thalheim
29db54c373
nixos/tests: extend shell_interact to accept alternative socat addresses
...
`shell_interact()` is currently not nice to use. If you try to cancel
the socat process, it will also break the nixos test. Furthermore
ptpython creates it's own terminal that subprocesses are running in,
which breaks some of the terminal features of socat.
Hence this commit extends `shell_interact` to allow also to connect to
arbitrary servers i.e. tcp servers started by socat.
2023-01-27 13:09:25 +01:00
Jacek Galowicz
869545857f
Merge pull request #208354 from bjornfor/nixos-test-driver-quote-shell-args
...
nixos/test-driver: quote some shell command lines
2022-12-30 22:41:04 +01:00
Bjørn Forsman
c876f0c146
nixos/test-driver: quote some shell command lines
...
This makes them robust against paths with whitespace.
2022-12-30 13:19:59 +01:00
Bjørn Forsman
4c45c3f8f2
nixos/test-driver: use ASCII single quotes everywhere
...
A few places used Unicode U+2018/U+2019 left/right single quotes (but
not always correctly balanced). Let's just use plain ASCII single quotes
everywhere.
2022-12-30 13:00:19 +01:00
Bjørn Forsman
ce5644f658
nixos/test-driver: use f-strings instead of .format()
...
For readability.
Suggested-by: @tfc
2022-12-29 23:51:35 +01:00
Bjørn Forsman
dba49a43a0
nixos/test-driver: add optional address arg to wait_for_{open,closed}_port
...
This is useful for testing servers configured to listen on specific
addresses.
2022-12-29 13:50:17 +01:00
Zhaofeng Li
8b2d34fa5e
test-driver: Allow configuring delay for send_{key,chars}
2022-11-19 06:55:25 +01:00
Jacek Galowicz
8ae3e986a7
Merge pull request #189999 from sbruder/test-driver-formatting-closed-port
...
nixos/test-driver: fix formatting of closed port
2022-09-06 14:48:13 +02:00
Simon Bruder
9caf5f6ba9
nixos/test-driver: fix formatting of closed port
...
Co-authored-by: a-kenji <aks.kenji@protonmail.com>
2022-09-06 14:32:56 +02:00
Alyssa Ross
488412a1db
nixos/test-driver: add wait_for_unit() timeout arg
...
For example, the wait_for_unit() call in the Moodle test times out for
myself and others[1], so it would be good to be able to increase it to
something less likely to be hit by a test that would otherwise pass.
[1]: https://github.com/NixOS/nixpkgs/pull/177052#issue-1266336706
2022-09-02 18:06:03 +00:00
Bobby Rong
9d2a8e3190
nixos/test-driver: fix type hint for send_chars
2022-06-04 12:05:47 +08:00
Anna Gillert
dbc95f15b8
nixos/test-driver: Avoid shell injection in machine.execute()
2022-04-21 10:54:00 +02:00
Anna Gillert
f7e89a59da
nixos/test-driver: fix missing shellopts in execute
...
Without this fix, setting the shellopts in `machine.execute` is
inconsitent. When no timeout is used, shellopts `set -euo pipefail` are
applied to the command as expected. When a timeout is specified, the
shellopts are not applied to the command itself (which is called inside
a `sh -c` that doesn't inherit the shellopts) but rather to the
`timeout` command, leading to the following full command:
```bash
(set -euo pipefail; timeout 900 sh -c 'cmd') | (base64 --wrap 0; echo)\n
```
With this fix, this is the command we get:
```bash
timeout 900 sh -c 'set -euo pipefail; false | true') | (base64 --wrap 0; echo)\n
```
2022-04-21 10:54:00 +02:00
Janne Heß
7d0e21c77e
nixos/test-runner: Allow writing to qemu stdin
2022-03-25 12:08:21 +01:00
Daniel Fullmer
24fb872079
nixos/test-driver: fix regression when using legacy start command
...
The aarch64-linux versions of the boot.uefiUsb and boot.uefiCdrom tests
were broken by b0fc9da879
.
That commit was a refactor which omitted the qemuBinary option, which was
previously available in the legacy start command. This restores that
option and fixes the tests previously mentioned.
2022-02-17 18:12:24 -08:00
Lassulus
b80607af67
Merge pull request #154804 from Mic92/tests-prompt
...
nixos/tests: add prompt to shell_interact()
2022-02-02 18:50:46 +01:00
Marijan Petričević
f9b5f9dba7
nixos/test-driver: use an argument instead of the out env-var
2022-01-25 01:17:29 +01:00
Jörg Thalheim
f472e52aa6
nixos/tests: add prompt to shell_interact()
...
Example session:
>>> start_all()
>>> machines[0].shell_interact()
client: waiting for the VM to finish booting
client: connected to guest root shell
client: (connecting took 0.00 seconds)
(finished: waiting for the VM to finish booting, in 0.05 seconds)
client: Terminal is ready (there is no initial prompt):
$ ls -la
total 39
drwxrwxrwt 11 root root 4096 Jan 15 06:06 .
drwxr-xr-x 17 root root 4096 Jan 15 06:06 ..
drwxrwxrwt 2 root root 4096 Jan 15 06:06 .font-unix
drwxrwxrwt 2 root root 4096 Jan 15 06:06 .ICE-unix
drwx------ 2 root root 2 Jan 12 20:19 shared
drwx------ 3 root root 4096 Jan 15 06:06 systemd-private-b8f21699ea684491926859758de41975-nscd.service-txgYVZ
drwx------ 3 root root 4096 Jan 15 06:06 systemd-private-b8f21699ea684491926859758de41975-systemd-logind.service-U3GmlL
drwxrwxrwt 2 root root 4096 Jan 15 06:06 .Test-unix
drwxrwxrwt 2 root root 4096 Jan 15 06:06 .X11-unix
drwxr-xr-x 2 root root 2 Jan 15 06:06 xchg
drwxrwxrwt 2 root root 4096 Jan 15 06:06 .XIM-unix
2022-01-15 07:07:06 +01:00
Patrick Hilhorst
793a2f50f1
nixos/test-driver: remove unused imports, add pylint unused-import check
2022-01-02 23:12:21 +01:00
Patrick Hilhorst
a2f5092867
nixos/test-driver: simplify logic, reduce interaction surface
2022-01-02 22:52:17 +01:00
Patrick Hilhorst
4e1556ed4d
nixos/test-driver: add polling_condition
2022-01-01 23:17:32 +01:00
Marijan Petričević
ab693de868
nixos/test-driver: make the test-driver a python package
2021-12-10 12:27:45 +00:00