mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-18 19:26:02 +00:00
20893b3a70
For a lot of the work the non-interactive drivers are enough and it is probably a good idea to keep it accessible for debugging without touching the Nix expression.
50 lines
1.7 KiB
XML
50 lines
1.7 KiB
XML
<section xmlns="http://docbook.org/ns/docbook"
|
|
xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
version="5.0"
|
|
xml:id="sec-running-nixos-tests-interactively">
|
|
<title>Running Tests interactively</title>
|
|
|
|
<para>
|
|
The test itself can be run interactively. This is particularly useful when
|
|
developing or debugging a test:
|
|
<screen>
|
|
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
|
|
<prompt>$ </prompt>./result/bin/nixos-test-driver
|
|
starting VDE switch for network 1
|
|
<prompt>></prompt>
|
|
</screen>
|
|
You can then take any Python statement, e.g.
|
|
<screen>
|
|
<prompt>></prompt> start_all()
|
|
<prompt>></prompt> test_script()
|
|
<prompt>></prompt> machine.succeed("touch /tmp/foo")
|
|
<prompt>></prompt> print(machine.succeed("pwd")) # Show stdout of command
|
|
</screen>
|
|
The function <command>test_script</command> executes the entire test script
|
|
and drops you back into the test driver command line upon its completion.
|
|
This allows you to inspect the state of the VMs after the test (e.g. to debug
|
|
the test script).
|
|
</para>
|
|
|
|
<para>
|
|
To just start and experiment with the VMs, run:
|
|
<screen>
|
|
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driverInteractive
|
|
<prompt>$ </prompt>./result/bin/nixos-run-vms
|
|
</screen>
|
|
The script <command>nixos-run-vms</command> starts the virtual machines
|
|
defined by test.
|
|
</para>
|
|
|
|
<para>
|
|
You can re-use the VM states coming from a previous run
|
|
by setting the <command>--keep-vm-state</command> flag.
|
|
<screen>
|
|
<prompt>$ </prompt>./result/bin/nixos-run-vms --keep-vm-state
|
|
</screen>
|
|
The machine state is stored in the
|
|
<filename>$TMPDIR/vm-state-</filename><varname>machinename</varname> directory.
|
|
</para>
|
|
</section>
|