From 501d532188bcabe5c1684880779ee62c31520f15 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 29 Apr 2014 15:29:52 +0200 Subject: [PATCH] Add a test for automounting --- nixos/tests/misc.nix | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/nixos/tests/misc.nix b/nixos/tests/misc.nix index 705ea0d0b864..e33581b4d2d4 100644 --- a/nixos/tests/misc.nix +++ b/nixos/tests/misc.nix @@ -3,12 +3,23 @@ import ./make-test.nix { machine = - { config, pkgs, ... }: - { swapDevices = pkgs.lib.mkOverride 0 + { config, lib, pkgs, ... }: + with lib; + { swapDevices = mkOverride 0 [ { device = "/root/swapfile"; size = 128; } ]; - environment.variables.EDITOR = pkgs.lib.mkOverride 0 "emacs"; - services.nixosManual.enable = pkgs.lib.mkOverride 0 true; + environment.variables.EDITOR = mkOverride 0 "emacs"; + services.nixosManual.enable = mkOverride 0 true; systemd.tmpfiles.rules = [ "d /tmp 1777 root root 10d" ]; + fileSystems = mkVMOverride { "/tmp2" = + { device = "none"; + fsType = "tmpfs"; + options = "mode=1777,noauto"; + }; + }; + systemd.automounts = singleton + { wantedBy = [ "multi-user.target" ]; + where = "/tmp2"; + }; }; testScript = @@ -80,6 +91,13 @@ import ./make-test.nix { $machine->succeed('systemctl start systemd-tmpfiles-clean'); $machine->fail('[ -e /tmp/foo ]'); }; + + # Test whether automounting works. + subtest "automount", sub { + $machine->fail("grep '/tmp2 tmpfs' /proc/mounts"); + $machine->succeed("touch /tmp2/x"); + $machine->succeed("grep '/tmp2 tmpfs' /proc/mounts"); + }; ''; }