From 39442393627569a4fd644b3d23658178a8245218 Mon Sep 17 00:00:00 2001 From: "William A. Kennington III" Date: Fri, 29 Aug 2014 16:37:28 -0700 Subject: [PATCH] nixos/tests-installer: Add a test for btrfs default volumes and bind mounts --- nixos/release-combined.nix | 1 + nixos/release.nix | 1 + nixos/tests/installer.nix | 24 ++++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix index 23348e1d089..0c72bae35bb 100644 --- a/nixos/release-combined.nix +++ b/nixos/release-combined.nix @@ -56,6 +56,7 @@ in rec { (all nixos.tests.installer.simpleProvided) (all nixos.tests.installer.btrfsSimple) (all nixos.tests.installer.btrfsSubvols) + (all nixos.tests.installer.btrfsSubvolDefault) (all nixos.tests.ipv6) (all nixos.tests.kde4) (all nixos.tests.login) diff --git a/nixos/release.nix b/nixos/release.nix index f78ecb4383d..d4e1a3737e3 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -232,6 +232,7 @@ in rec { tests.installer.simpleProvided = forAllSystems (system: (import tests/installer.nix { inherit system; }).simpleProvided.test); tests.installer.btrfsSimple = forAllSystems (system: (import tests/installer.nix { inherit system; }).btrfsSimple.test); tests.installer.btrfsSubvols = forAllSystems (system: (import tests/installer.nix { inherit system; }).btrfsSubvols.test); + tests.installer.btrfsSubvolDefault = forAllSystems (system: (import tests/installer.nix { inherit system; }).btrfsSubvolDefault.test); tests.influxdb = callTest tests/influxdb.nix {}; tests.ipv6 = callTest tests/ipv6.nix {}; tests.jenkins = callTest tests/jenkins.nix {}; diff --git a/nixos/tests/installer.nix b/nixos/tests/installer.nix index 154f3323d29..7765b7945c7 100644 --- a/nixos/tests/installer.nix +++ b/nixos/tests/installer.nix @@ -469,4 +469,28 @@ in { ); ''; }; + + # Test to see if we can detect default and aux subvolumes correctly + btrfsSubvolDefault = makeInstallerTest "btrfsSubvolDefault" { + createPartitions = '' + $machine->succeed( + "sgdisk -Z /dev/vda", + "sgdisk -n 1:0:+1M -n 2:0:+1G -N 3 -t 1:ef02 -t 2:8200 -t 3:8300 -c 3:root /dev/vda", + "mkswap /dev/vda2 -L swap", + "swapon -L swap", + "mkfs.btrfs -L root /dev/vda3", + "btrfs device scan", + "mount LABEL=root /mnt", + "btrfs subvol create /mnt/badpath", + "btrfs subvol create /mnt/badpath/boot", + "btrfs subvol create /mnt/nixos", + "btrfs subvol set-default \$(btrfs subvol list /mnt | grep 'nixos' | awk '{print \$2}') /mnt", + "umount /mnt", + "mount -o defaults LABEL=root /mnt", + "mkdir -p /mnt/badpath/boot", # Help ensure the detection mechanism is actually looking up subvolumes + "mkdir /mnt/boot", + "mount -o defaults,subvol=badpath/boot LABEL=root /mnt/boot", + ); + ''; + }; }