summaryrefslogtreecommitdiffstats
path: root/debian/tests/cryptroot-md.d/mock
blob: 51f8c9c668ff979c8bb03c08c233f05af5ecad26 (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
#!/usr/bin/perl -T

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

my %passphrases;
$passphrases{$_} = $_ foreach qw/vda3_crypt vda4_crypt vdb3_crypt vdb4_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/vda3 <<<vda3_crypt}, rv => 0);
shell(q{cryptsetup luksOpen --test-passphrase /dev/vda4 <<<vda4_crypt}, rv => 0);
shell(q{cryptsetup luksOpen --test-passphrase /dev/vdb3 <<<vdb3_crypt}, rv => 0);
shell(q{cryptsetup luksOpen --test-passphrase /dev/vdb4 <<<vdb4_crypt}, rv => 0);

my $out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vda3});
die unless $out =~ m#^`-vda3_crypt\s+crypt\s*$#m;
die unless $out =~ m#^  `-md1\s+raid0\s+\[SWAP\]\s*$#m;

$out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vdb3});
die unless $out =~ m#^`-vdb3_crypt\s+crypt\s*$#m;
die unless $out =~ m#^  `-md1\s+raid0\s+\[SWAP\]\s*$#m;

$out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vda4});
die unless $out =~ m#^`-vda4_crypt\s+crypt\s*$#m;
die unless $out =~ m#^    [`|]-cryptvg-swap\s+lvm\s+\[SWAP\]\s*$#m;
die unless $out =~ m#^    [`|]-cryptvg-root\s+lvm\s+/\s*$#m;

$out = shell(q{lsblk -in -oNAME,TYPE,MOUNTPOINT /dev/vdb4});
die unless $out =~ m#^`-vdb4_crypt\s+crypt\s*$#m;
die unless $out =~ m#^    [`|]-cryptvg-swap\s+lvm\s+\[SWAP\]\s*$#m;
die unless $out =~ m#^    [`|]-cryptvg-root\s+lvm\s+/\s*$#m;

QMP::quit();