summary refs log tree commit diff
path: root/nixos/doc/manual/development/running-nixos-tests-interactively.xml
blob: e390d62fde2f80b3f0851aaf398661450662b38c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<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">
 <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 driver
<prompt>$ </prompt>./result/bin/nixos-test-driver
starting VDE switch for network 1
<prompt>&gt;</prompt>
</screen>
  You can then take any Perl statement, e.g.
<screen>
<prompt>&gt;</prompt> startAll
<prompt>&gt;</prompt> testScript
<prompt>&gt;</prompt> $machine->succeed("touch /tmp/foo")
<prompt>&gt;</prompt> print($machine->succeed("pwd")) # Show stdout of command
</screen>
  The function <command>testScript</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 driver
<prompt>$ </prompt>./result/bin/nixos-run-vms
</screen>
  The script <command>nixos-run-vms</command> starts the virtual machines
  defined by test.
 </para>

 <para>
  The machine state is kept across VM restarts in
  <filename>/tmp/vm-state-</filename><varname>machinename</varname>.
 </para>
</section>