summaryrefslogtreecommitdiffstats
path: root/debian/tests/cryptroot-nested.d/mock
blob: cccb35f4d039f82cac158d14658bb553aaa4b2ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/usr/bin/perl -T

BEGIN {
    require "./debian/tests/utils/mock.pm";
    CryptrootTest::Mock::->import();
}

my %passphrases;
$passphrases{$_} = $_ foreach qw/testvg-lv0_crypt testvg-lv1_crypt md0_crypt vdd_crypt/;
unlock_disk(\%passphrases) for 1 .. scalar(%passphrases);

# check that the above was done at initramfs stage
expect($SERIAL => qr#\bRunning /scripts/init-bottom\s*\.\.\. #);

login("root");

# make sure the root FS and swap are help by dm-crypt devices
shell(q{cryptsetup luksOpen --test-passphrase /dev/md0 <<<md0_crypt}, rv => 0);
shell(q{cryptsetup luksOpen --test-passphrase /dev/vdd <<<vdd_crypt}, rv => 0);
shell(q{cryptsetup luksOpen --test-passphrase /dev/testvg/lv1 <<<testvg-lv1_crypt}, rv => 0);

my $out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vda3});
die unless $out =~ m#^[`|]-testvg-lv0\s+lvm\s*$#m;
die unless $out =~ m#^[| ] `-testvg-lv0_crypt\s+crypt\s+\[SWAP\]\s*$#m;
die unless $out =~ m#^[`|]-testvg-lv1\s+lvm\s*$#m;
die unless $out =~ m#^[| ] `-testvg-lv1_crypt\s+crypt\s*$#m;
die unless $out =~ m#^[| ]   `-md0\s+raid1\s*$#m;
die unless $out =~ m#^[| ]     `-md0_crypt\s+crypt(?:\s+/(?:home|usr|var)?)?\s*$#m;

$out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vdb});
die unless $out =~ m#^`-testvg-lv1\s+lvm\s*$#m;
die unless $out =~ m#^  `-testvg-lv1_crypt\s+crypt\s*$#m;
die unless $out =~ m#^    `-md0\s+raid1\s*$#m;
die unless $out =~ m#^      `-md0_crypt\s+crypt(?:\s+/(?:home|usr|var)?)?\s*$#m;

$out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vdc});
die unless $out =~ m#^`-md0\s+raid1\s*$#m;
die unless $out =~ m#^  `-md0_crypt\s+crypt(?:\s+/(?:home|usr|var)?)?\s*$#m;

$out = shell(q{btrfs filesystem show /});
die unless $out =~ m#^\s*devid\s+1\s.*\s/dev/mapper/vdd_crypt\s*$#m;
die unless $out =~ m#^\s*devid\s+2\s.*\s/dev/mapper/md0_crypt\s*$#m;

QMP::quit();