diff options
author | Florian Klink <flokli@flokli.de> | 2019-05-11 23:33:58 +0200 |
---|---|---|
committer | Andreas Rammhold <andreas@rammhold.de> | 2019-06-03 15:05:18 +0200 |
commit | bc71b6eaf6ff9451cbbaa3e62aa200845d12f4e3 (patch) | |
tree | 9746a574ac7839cfe6b136732494b6c84624e3aa /nixos/tests/containers-imperative.nix | |
parent | 1b7b1dbe2f88a3c8f0c5416d4e43de10977915cc (diff) |
nixosTests.containers-imperative: add tmpfiles test
(cherry picked from commit 92600a90e248aa27f2aedcce4ad309f987a390df)
Diffstat (limited to 'nixos/tests/containers-imperative.nix')
-rw-r--r-- | nixos/tests/containers-imperative.nix | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/nixos/tests/containers-imperative.nix b/nixos/tests/containers-imperative.nix index 0c101037aa7f..2e7e4b2f1d69 100644 --- a/nixos/tests/containers-imperative.nix +++ b/nixos/tests/containers-imperative.nix @@ -35,7 +35,17 @@ import ./make-test.nix ({ pkgs, ...} : { ]; }; - testScript = + testScript = let + tmpfilesContainerConfig = pkgs.writeText "container-config-tmpfiles" '' + { + systemd.tmpfiles.rules = [ "d /foo - - - - -" ]; + systemd.services.foo = { + serviceConfig.Type = "oneshot"; + script = "ls -al /foo"; + wantedBy = [ "multi-user.target" ]; + }; + } + ''; in '' # Make sure we have a NixOS tree (required by ‘nixos-container create’). $machine->succeed("PAGER=cat nix-env -qa -A nixos.hello >&2"); @@ -93,6 +103,15 @@ import ./make-test.nix ({ pkgs, ...} : { $machine->succeed("nixos-container stop $id1"); $machine->succeed("nixos-container start $id1"); + # Ensure tmpfiles are present + $machine->log("creating container tmpfiles"); + $machine->succeed("nixos-container create tmpfiles --config-file ${tmpfilesContainerConfig}"); + $machine->log("created, starting…"); + $machine->succeed("nixos-container start tmpfiles"); + $machine->log("done starting, investigating…"); + $machine->succeed("echo \$(nixos-container run tmpfiles -- systemctl is-active foo.service) | grep -q active;"); + $machine->succeed("nixos-container destroy tmpfiles"); + # Execute commands via the root shell. $machine->succeed("nixos-container run $id1 -- uname") =~ /Linux/ or die; |