diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 08:06:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 08:06:26 +0000 |
commit | fd888e850cf413955483bfb993aeeea5ea611289 (patch) | |
tree | 6148fed3d1f30272c48403f4cdefa59c2b7e1513 /debian/tests/cryptroot-lvm.d/mock | |
parent | Adding upstream version 2:2.6.1. (diff) | |
download | cryptsetup-debian.tar.xz cryptsetup-debian.zip |
Adding debian version 2:2.6.1-4~deb12u2.debian/2%2.6.1-4_deb12u2debian
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rwxr-xr-x | debian/tests/cryptroot-lvm.d/mock | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/debian/tests/cryptroot-lvm.d/mock b/debian/tests/cryptroot-lvm.d/mock new file mode 100755 index 0000000..f57e42f --- /dev/null +++ b/debian/tests/cryptroot-lvm.d/mock @@ -0,0 +1,49 @@ +#!/usr/bin/perl -T + +BEGIN { + require "./debian/tests/utils/mock.pm"; + CryptrootTest::Mock::->import(); +} + +my $POWERCYCLE_COUNT = $ARGV[0]; + +unlock_disk("topsecret"); + +if ($POWERCYCLE_COUNT == 0) { + login("root"); + + # make sure the root FS and swap are help by dm-crypt devices + shell(q{cryptsetup luksOpen --test-passphrase /dev/vda3 <<<topsecret}, 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#^\s{2}[`|]-cryptvg-root\s+lvm\s+/\s*$#m; + die unless $out =~ m#^\s{2}[`|]-cryptvg-swap\s+lvm\s+\[SWAP\]\s*$#m; + + # create a stamp in memory, hibernate (suspend on disk) and thaw + shell(q{echo hello >/dev/shm/foo.stamp}); + hibernate(); +} +else { + expect($SERIAL => qr/(?:^|\s)?PM: (?:hibernation: )?hibernation exit\r\n/m); + # no need to relogin, we get the shell as we left it + shell(q{grep -Fx hello </dev/shm/foo.stamp}, rv => 0); + + # briefly suspend + suspend(); + + # make sure wakeup yields a cryptsetup prompt + wakeup(); + expect($SERIAL => qr/(?:^|\s)?PM: suspend exit\r\n/m); + unlock_disk("topsecret"); + + # consume PS1 to make sure we're at a shell prompt + expect($CONSOLE => qr/\A $PS1 \z/aamsx); + my $out = shell(q{dmsetup info -c --noheadings -omangled_name,suspended --separator ' '}); + die if grep !/[:[:blank:]]Active$/i, split(/\r?\n/, $out); + + # test I/O on the root file system + shell(q{cp -vT /dev/shm/foo.stamp /cryptroot.stamp}); + shell(q{grep -Fx hello </cryptroot.stamp}, rv => 0); + + QMP::quit(); +} |