nixpkgs/nixos/tests/nixos-test-driver/console-timeout.nix
Arthur Gautier 4e5b779a75 nixos/test-driver: rework timeout for wait_for_console_text
Before this commit, `wait_for_console_text` would read one line every
900ms before trying again to read the next line.

This commit fixes that behavior by greedily reading all buffer that is
available for match trying to find a match rather than reading one per
retry iteration.

In effect this moves the loop inside the `console_matches` helper and
makes the behavior of `wait_for_console_text` with timeout behave the
same way as with timeout.

This also provides a test that showcases the problem.
2026-06-01 19:12:06 -07:00

26 lines
510 B
Nix

{ pkgs, lib, ... }:
{
name = "console-timeout";
nodes.machine = {
systemd.services.generate-output.script = ''
echo "match that"
sleep 1
for i in $(seq 15); do
echo "line $i"
done
echo "match this"
'';
};
testScript = ''
machine.start()
machine.wait_for_unit("multi-user.target")
machine.systemctl("start generate-output")
machine.wait_for_console_text("match that")
machine.wait_for_console_text("match this", timeout=10)
'';
}