1<section xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="sec-running-nixos-tests">
2 <title>Running Tests</title>
3 <para>
4 You can run tests using <literal>nix-build</literal>. For example,
5 to run the test
6 <link xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix"><literal>login.nix</literal></link>,
7 you just do:
8 </para>
9 <programlisting>
10$ nix-build '<nixpkgs/nixos/tests/login.nix>'
11</programlisting>
12 <para>
13 or, if you don’t want to rely on <literal>NIX_PATH</literal>:
14 </para>
15 <programlisting>
16$ cd /my/nixpkgs/nixos/tests
17$ nix-build login.nix
18…
19running the VM test script
20machine: QEMU running (pid 8841)
21…
226 out of 6 tests succeeded
23</programlisting>
24 <para>
25 After building/downloading all required dependencies, this will
26 perform a build that starts a QEMU/KVM virtual machine containing a
27 NixOS system. The virtual machine mounts the Nix store of the host;
28 this makes VM creation very fast, as no disk image needs to be
29 created. Afterwards, you can view a pretty-printed log of the test:
30 </para>
31 <programlisting>
32$ firefox result/log.html
33</programlisting>
34</section>