mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
nixos/tests/qemu-vm-store: init
This commit is contained in:
parent
ded6d983d6
commit
0e5f929851
@ -799,6 +799,7 @@ in {
|
||||
qemu-vm-restrictnetwork = handleTest ./qemu-vm-restrictnetwork.nix {};
|
||||
qemu-vm-volatile-root = runTest ./qemu-vm-volatile-root.nix;
|
||||
qemu-vm-external-disk-image = runTest ./qemu-vm-external-disk-image.nix;
|
||||
qemu-vm-store = runTest ./qemu-vm-store.nix;
|
||||
qgis = handleTest ./qgis.nix { qgisPackage = pkgs.qgis; };
|
||||
qgis-ltr = handleTest ./qgis.nix { qgisPackage = pkgs.qgis-ltr; };
|
||||
qownnotes = handleTest ./qownnotes.nix {};
|
||||
|
71
nixos/tests/qemu-vm-store.nix
Normal file
71
nixos/tests/qemu-vm-store.nix
Normal file
@ -0,0 +1,71 @@
|
||||
{ lib, ... }: {
|
||||
|
||||
name = "qemu-vm-store";
|
||||
|
||||
meta.maintainers = with lib.maintainers; [ nikstur ];
|
||||
|
||||
nodes = {
|
||||
sharedWritable = {
|
||||
virtualisation.writableStore = true;
|
||||
};
|
||||
|
||||
sharedReadOnly = {
|
||||
virtualisation.writableStore = false;
|
||||
};
|
||||
|
||||
imageWritable = {
|
||||
virtualisation.useNixStoreImage = true;
|
||||
virtualisation.writableStore = true;
|
||||
};
|
||||
|
||||
imageReadOnly = {
|
||||
virtualisation.useNixStoreImage = true;
|
||||
virtualisation.writableStore = false;
|
||||
};
|
||||
|
||||
fullDisk = {
|
||||
virtualisation.useBootLoader = true;
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
build_derivation = """
|
||||
nix-build --option substitute false -E 'derivation {
|
||||
name = "t";
|
||||
builder = "/bin/sh";
|
||||
args = ["-c" "echo something > $out"];
|
||||
system = builtins.currentSystem;
|
||||
preferLocalBuild = true;
|
||||
}'
|
||||
"""
|
||||
|
||||
start_all()
|
||||
|
||||
with subtest("Nix Store is writable"):
|
||||
sharedWritable.succeed(build_derivation)
|
||||
imageWritable.succeed(build_derivation)
|
||||
fullDisk.succeed(build_derivation)
|
||||
|
||||
with subtest("Nix Store is read only"):
|
||||
sharedReadOnly.fail(build_derivation)
|
||||
imageReadOnly.fail(build_derivation)
|
||||
|
||||
# Checking whether the fs type is 9P is just a proxy to test whether the
|
||||
# Nix Store is shared. If we switch to a different technology (e.g.
|
||||
# virtiofs) for sharing, we need to adjust these tests.
|
||||
|
||||
with subtest("Nix store is shared from the host via 9P"):
|
||||
sharedWritable.succeed("findmnt --kernel --type 9P /nix/.ro-store")
|
||||
sharedReadOnly.succeed("findmnt --kernel --type 9P /nix/.ro-store")
|
||||
|
||||
with subtest("Nix store is not shared via 9P"):
|
||||
imageWritable.fail("findmnt --kernel --type 9P /nix/.ro-store")
|
||||
imageReadOnly.fail("findmnt --kernel --type 9P /nix/.ro-store")
|
||||
|
||||
with subtest("Nix store is not mounted separately"):
|
||||
rootDevice = fullDisk.succeed("stat -c %d /")
|
||||
nixStoreDevice = fullDisk.succeed("stat -c %d /nix/store")
|
||||
assert rootDevice == nixStoreDevice, "Nix store is mounted separately from the root fs"
|
||||
'';
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user