1<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-running-nixos-tests-interactively">
2 <title>Running Tests interactively</title>
3 <para>
4 The test itself can be run interactively. This is particularly
5 useful when developing or debugging a test:
6 </para>
7 <programlisting>
8$ nix-build nixos/tests/login.nix -A driverInteractive
9$ ./result/bin/nixos-test-driver --interactive
10starting VDE switch for network 1
11>
12</programlisting>
13 <para>
14 You can then take any Python statement, e.g.
15 </para>
16 <programlisting language="python">
17> start_all()
18> test_script()
19> machine.succeed("touch /tmp/foo")
20> print(machine.succeed("pwd")) # Show stdout of command
21</programlisting>
22 <para>
23 The function <literal>test_script</literal> executes the entire test
24 script and drops you back into the test driver command line upon its
25 completion. This allows you to inspect the state of the VMs after
26 the test (e.g. to debug the test script).
27 </para>
28 <para>
29 You can re-use the VM states coming from a previous run by setting
30 the <literal>--keep-vm-state</literal> flag.
31 </para>
32 <programlisting>
33$ ./result/bin/nixos-test-driver --interactive --keep-vm-state
34</programlisting>
35 <para>
36 The machine state is stored in the
37 <literal>$TMPDIR/vm-state-machinename</literal> directory.
38 </para>
39</section>