From b262225972114023ac3199b5ca8ebcb508bfa828 Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 1 Jul 2013 00:47:56 +0200 Subject: [PATCH] tests/partition: Check if nixpart loses mounts. As the whole partitioning run is quite an invasive procedure, we want to especially make sure that it doesn't unmount any filesystems that were mounted before the partitioner was run. Signed-off-by: aszlig --- tests/partition.nix | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/partition.nix b/tests/partition.nix index 4cee14e4e5cd..0051b290c922 100644 --- a/tests/partition.nix +++ b/tests/partition.nix @@ -65,12 +65,23 @@ in { testScript = '' my $diskStart; + my @mtab; + + sub getMtab { + my $mounts = $machine->succeed("cat /proc/mounts"); + chomp $mounts; + return map [split], split /\n/, $mounts; + } sub parttest { my ($desc, $code) = @_; $machine->start; $machine->waitForUnit("default.target"); + + # Gather mounts and superblock + @mtab = getMtab; $diskStart = $machine->succeed("dd if=/dev/vda bs=512 count=1"); + subtest($desc, $code); $machine->shutdown; } @@ -83,6 +94,21 @@ in { "something into the first 512 bytes of /dev/vda!"); die; } + + # Check whether nixpart has unmounted anything + my @currentMtab = getMtab; + for my $mount (@mtab) { + my $path = $mount->[1]; + unless (grep { $_->[1] eq $path } @currentMtab) { + $machine->log("The partitioner seems to have unmounted $path."); + die; + } + } + } + + sub checkMount { + my $mounts = $machine->succeed("cat /proc/mounts"); + } sub kickstart {