2015-04-21 07:27:40 +01:00
|
|
|
<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">
|
2018-05-02 00:57:09 +01:00
|
|
|
<title>Running Tests interactively</title>
|
2015-04-21 07:27:40 +01:00
|
|
|
|
2018-05-02 00:57:09 +01:00
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
The test itself can be run interactively. This is particularly useful when
|
|
|
|
developing or debugging a test:
|
2015-04-21 07:27:40 +01:00
|
|
|
<screen>
|
2019-06-17 12:25:50 +01:00
|
|
|
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver
|
|
|
|
<prompt>$ </prompt>./result/bin/nixos-test-driver
|
2015-04-21 07:27:40 +01:00
|
|
|
starting VDE switch for network 1
|
2019-06-17 12:25:50 +01:00
|
|
|
<prompt>></prompt>
|
2015-04-21 07:27:40 +01:00
|
|
|
</screen>
|
2019-11-04 22:50:50 +00:00
|
|
|
You can then take any Python statement, e.g.
|
2015-04-21 07:27:40 +01:00
|
|
|
<screen>
|
2019-11-04 22:50:50 +00:00
|
|
|
<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
|
2015-04-21 07:27:40 +01:00
|
|
|
</screen>
|
2019-11-04 22:50:50 +00:00
|
|
|
The function <command>test_script</command> executes the entire test script
|
2019-09-19 18:17:30 +01:00
|
|
|
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).
|
2018-05-02 00:57:09 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
To just start and experiment with the VMs, run:
|
2015-04-21 07:27:40 +01:00
|
|
|
<screen>
|
2019-06-17 12:25:50 +01:00
|
|
|
<prompt>$ </prompt>nix-build nixos/tests/login.nix -A driver
|
|
|
|
<prompt>$ </prompt>./result/bin/nixos-run-vms
|
2015-04-21 07:27:40 +01:00
|
|
|
</screen>
|
2019-09-19 18:17:30 +01:00
|
|
|
The script <command>nixos-run-vms</command> starts the virtual machines
|
|
|
|
defined by test.
|
2018-09-17 11:58:14 +01:00
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
2019-09-19 18:17:30 +01:00
|
|
|
The machine state is kept across VM restarts in
|
|
|
|
<filename>/tmp/vm-state-</filename><varname>machinename</varname>.
|
2018-05-02 00:57:09 +01:00
|
|
|
</para>
|
2015-04-21 07:27:40 +01:00
|
|
|
</section>
|