about summary refs log tree commit diff
path: root/nixos/doc/manual/development/writing-nixos-tests.xml
diff options
context:
space:
mode:
authorJan Tojnar <jtojnar@gmail.com>2019-09-18 22:13:35 +0200
committerJan Tojnar <jtojnar@gmail.com>2019-09-18 22:13:35 +0200
commitea6e8775bd69e4676c623a85c39f1da540d29ad1 (patch)
tree87c478306e7bc911b267e356c608faacb38ff573 /nixos/doc/manual/development/writing-nixos-tests.xml
parent83c2ad80ca8c6087b034155e2a767c4f72a6df3f (diff)
downloadnixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar.gz
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar.bz2
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar.lz
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar.xz
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.tar.zst
nixlib-ea6e8775bd69e4676c623a85c39f1da540d29ad1.zip
nixos/doc: re-format
Diffstat (limited to 'nixos/doc/manual/development/writing-nixos-tests.xml')
-rw-r--r--nixos/doc/manual/development/writing-nixos-tests.xml113
1 files changed, 29 insertions, 84 deletions
diff --git a/nixos/doc/manual/development/writing-nixos-tests.xml b/nixos/doc/manual/development/writing-nixos-tests.xml
index 6be2d0a4d231..5df60e2ec822 100644
--- a/nixos/doc/manual/development/writing-nixos-tests.xml
+++ b/nixos/doc/manual/development/writing-nixos-tests.xml
@@ -31,22 +31,9 @@ import ./make-test.nix {
     '';
 }
 </programlisting>
-  The attribute <literal>testScript</literal> is a bit of Perl code that
-  executes the test (described below). During the test, it will start one or
-  more virtual machines, the configuration of which is described by the
-  attribute <literal>machine</literal> (if you need only one machine in your
-  test) or by the attribute <literal>nodes</literal> (if you need multiple
-  machines). For instance,
-  <filename
-xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix">login.nix</filename>
-  only needs a single machine to test whether users can log in on the virtual
-  console, whether device ownership is correctly maintained when switching
-  between consoles, and so on. On the other hand,
-  <filename
-xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nfs.nix">nfs.nix</filename>,
-  which tests NFS client and server functionality in the Linux kernel
-  (including whether locks are maintained across server crashes), requires
-  three machines: a server and two clients.
+  The attribute <literal>testScript</literal> is a bit of Perl code that executes the test (described below). During the test, it will start one or more virtual machines, the configuration of which is described by the attribute <literal>machine</literal> (if you need only one machine in your test) or by the attribute <literal>nodes</literal> (if you need multiple machines). For instance, <filename
+xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/login.nix">login.nix</filename> only needs a single machine to test whether users can log in on the virtual console, whether device ownership is correctly maintained when switching between consoles, and so on. On the other hand, <filename
+xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nfs.nix">nfs.nix</filename>, which tests NFS client and server functionality in the Linux kernel (including whether locks are maintained across server crashes), requires three machines: a server and two clients.
  </para>
 
  <para>
@@ -69,10 +56,8 @@ xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nfs.nix">nf
     </term>
     <listitem>
      <para>
-      The virtual networks to which the VM is connected. See
-      <filename
-    xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nat.nix">nat.nix</filename>
-      for an example.
+      The virtual networks to which the VM is connected. See <filename
+    xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nat.nix">nat.nix</filename> for an example.
      </para>
     </listitem>
    </varlistentry>
@@ -82,38 +67,23 @@ xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/nfs.nix">nf
     </term>
     <listitem>
      <para>
-      By default, the Nix store in the VM is not writable. If you enable this
-      option, a writable union file system is mounted on top of the Nix store
-      to make it appear writable. This is necessary for tests that run Nix
-      operations that modify the store.
+      By default, the Nix store in the VM is not writable. If you enable this option, a writable union file system is mounted on top of the Nix store to make it appear writable. This is necessary for tests that run Nix operations that modify the store.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
-  For more options, see the module
-  <filename
+  For more options, see the module <filename
 xlink:href="https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/virtualisation/qemu-vm.nix">qemu-vm.nix</filename>.
  </para>
 
  <para>
-  The test script is a sequence of Perl statements that perform various
-  actions, such as starting VMs, executing commands in the VMs, and so on. Each
-  virtual machine is represented as an object stored in the variable
-  <literal>$<replaceable>name</replaceable></literal>, where
-  <replaceable>name</replaceable> is the identifier of the machine (which is
-  just <literal>machine</literal> if you didn’t specify multiple machines
-  using the <literal>nodes</literal> attribute). For instance, the following
-  starts the machine, waits until it has finished booting, then executes a
-  command and checks that the output is more-or-less correct:
+  The test script is a sequence of Perl statements that perform various actions, such as starting VMs, executing commands in the VMs, and so on. Each virtual machine is represented as an object stored in the variable <literal>$<replaceable>name</replaceable></literal>, where <replaceable>name</replaceable> is the identifier of the machine (which is just <literal>machine</literal> if you didn’t specify multiple machines using the <literal>nodes</literal> attribute). For instance, the following starts the machine, waits until it has finished booting, then executes a command and checks that the output is more-or-less correct:
 <programlisting>
 $machine->start;
 $machine->waitForUnit("default.target");
 $machine->succeed("uname") =~ /Linux/ or die;
 </programlisting>
-  The first line is actually unnecessary; machines are implicitly started when
-  you first execute an action on them (such as <literal>waitForUnit</literal>
-  or <literal>succeed</literal>). If you have multiple machines, you can speed
-  up the test by starting them in parallel:
+  The first line is actually unnecessary; machines are implicitly started when you first execute an action on them (such as <literal>waitForUnit</literal> or <literal>succeed</literal>). If you have multiple machines, you can speed up the test by starting them in parallel:
 <programlisting>
 startAll;
 </programlisting>
@@ -128,8 +98,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Start the virtual machine. This method is asynchronous — it does not
-      wait for the machine to finish booting.
+      Start the virtual machine. This method is asynchronous — it does not wait for the machine to finish booting.
      </para>
     </listitem>
    </varlistentry>
@@ -159,8 +128,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Simulate unplugging the Ethernet cable that connects the machine to the
-      other machines.
+      Simulate unplugging the Ethernet cable that connects the machine to the other machines.
      </para>
     </listitem>
    </varlistentry>
@@ -180,8 +148,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Take a picture of the display of the virtual machine, in PNG format. The
-      screenshot is linked from the HTML log.
+      Take a picture of the display of the virtual machine, in PNG format. The screenshot is linked from the HTML log.
      </para>
     </listitem>
    </varlistentry>
@@ -191,13 +158,11 @@ startAll;
     </term>
     <listitem>
      <para>
-      Return a textual representation of what is currently visible on the
-      machine's screen using optical character recognition.
+      Return a textual representation of what is currently visible on the machine's screen using optical character recognition.
      </para>
      <note>
       <para>
-       This requires passing <option>enableOCR</option> to the test attribute
-       set.
+       This requires passing <option>enableOCR</option> to the test attribute set.
       </para>
      </note>
     </listitem>
@@ -208,8 +173,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Send a command to the QEMU monitor. This is rarely used, but allows doing
-      stuff such as attaching virtual USB disks to a running machine.
+      Send a command to the QEMU monitor. This is rarely used, but allows doing stuff such as attaching virtual USB disks to a running machine.
      </para>
     </listitem>
    </varlistentry>
@@ -219,8 +183,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Simulate pressing keys on the virtual keyboard, e.g.,
-      <literal>sendKeys("ctrl-alt-delete")</literal>.
+      Simulate pressing keys on the virtual keyboard, e.g., <literal>sendKeys("ctrl-alt-delete")</literal>.
      </para>
     </listitem>
    </varlistentry>
@@ -230,9 +193,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Simulate typing a sequence of characters on the virtual keyboard, e.g.,
-      <literal>sendKeys("foobar\n")</literal> will type the string
-      <literal>foobar</literal> followed by the Enter key.
+      Simulate typing a sequence of characters on the virtual keyboard, e.g., <literal>sendKeys("foobar\n")</literal> will type the string <literal>foobar</literal> followed by the Enter key.
      </para>
     </listitem>
    </varlistentry>
@@ -242,9 +203,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Execute a shell command, returning a list
-      <literal>(<replaceable>status</replaceable>,
-      <replaceable>stdout</replaceable>)</literal>.
+      Execute a shell command, returning a list <literal>(<replaceable>status</replaceable>, <replaceable>stdout</replaceable>)</literal>.
      </para>
     </listitem>
    </varlistentry>
@@ -254,8 +213,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Execute a shell command, raising an exception if the exit status is not
-      zero, otherwise returning the standard output.
+      Execute a shell command, raising an exception if the exit status is not zero, otherwise returning the standard output.
      </para>
     </listitem>
    </varlistentry>
@@ -265,8 +223,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Like <methodname>succeed</methodname>, but raising an exception if the
-      command returns a zero status.
+      Like <methodname>succeed</methodname>, but raising an exception if the command returns a zero status.
      </para>
     </listitem>
    </varlistentry>
@@ -316,8 +273,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Wait until a process is listening on the given TCP port (on
-      <literal>localhost</literal>, at least).
+      Wait until a process is listening on the given TCP port (on <literal>localhost</literal>, at least).
      </para>
     </listitem>
    </varlistentry>
@@ -347,14 +303,11 @@ startAll;
     </term>
     <listitem>
      <para>
-      Wait until the supplied regular expressions matches the textual contents
-      of the screen by using optical character recognition (see
-      <methodname>getScreenText</methodname>).
+      Wait until the supplied regular expressions matches the textual contents of the screen by using optical character recognition (see <methodname>getScreenText</methodname>).
      </para>
      <note>
       <para>
-       This requires passing <option>enableOCR</option> to the test attribute
-       set.
+       This requires passing <option>enableOCR</option> to the test attribute set.
       </para>
      </note>
     </listitem>
@@ -365,8 +318,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Wait until an X11 window has appeared whose name matches the given
-      regular expression, e.g., <literal>waitForWindow(qr/Terminal/)</literal>.
+      Wait until an X11 window has appeared whose name matches the given regular expression, e.g., <literal>waitForWindow(qr/Terminal/)</literal>.
      </para>
     </listitem>
    </varlistentry>
@@ -376,13 +328,10 @@ startAll;
     </term>
     <listitem>
      <para>
-      Copies a file from host to machine, e.g.,
-      <literal>copyFileFromHost("myfile", "/etc/my/important/file")</literal>.
+      Copies a file from host to machine, e.g., <literal>copyFileFromHost("myfile", "/etc/my/important/file")</literal>.
      </para>
      <para>
-      The first argument is the file on the host. The file needs to be
-      accessible while building the nix derivation. The second argument is the
-      location of the file on the machine.
+      The first argument is the file on the host. The file needs to be accessible while building the nix derivation. The second argument is the location of the file on the machine.
      </para>
     </listitem>
    </varlistentry>
@@ -392,8 +341,7 @@ startAll;
     </term>
     <listitem>
      <para>
-      Runs <literal>systemctl</literal> commands with optional support for
-      <literal>systemctl --user</literal>
+      Runs <literal>systemctl</literal> commands with optional support for <literal>systemctl --user</literal>
      </para>
      <para>
 <programlisting>
@@ -407,15 +355,12 @@ $machine->systemctl("list-jobs --no-pager", "any-user"); // spawns a shell for `
  </para>
 
  <para>
-  To test user units declared by <literal>systemd.user.services</literal> the
-  optional <literal>$user</literal> argument can be used:
+  To test user units declared by <literal>systemd.user.services</literal> the optional <literal>$user</literal> argument can be used:
 <programlisting>
 $machine->start;
 $machine->waitForX;
 $machine->waitForUnit("xautolock.service", "x-session-user");
 </programlisting>
-  This applies to <literal>systemctl</literal>, <literal>getUnitInfo</literal>,
-  <literal>waitForUnit</literal>, <literal>startJob</literal> and
-  <literal>stopJob</literal>.
+  This applies to <literal>systemctl</literal>, <literal>getUnitInfo</literal>, <literal>waitForUnit</literal>, <literal>startJob</literal> and <literal>stopJob</literal>.
  </para>
 </section>