From 387bd4c6fee8ab339fd04e0b841b0c67e6020c8a Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Sun, 8 May 2022 18:05:45 +0100 Subject: [PATCH] tests: luks: Reduce time taken to run these tests Under valgrind they ran very slowly. Turns out valgrinding over GnuTLS hashing code is not pretty. About half the time seems to be taken opening the keyslot, and the rest copying the data. This change reduces the time (under valgrind) from 15 minutes 45 seconds to about 6 mins 30 seconds. (cherry picked from commit 7320ae5dba476171a024ca44b889b3474302dc40) --- tests/test-luks-copy.sh | 18 +++++++++--------- tests/test-luks-info.sh | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/test-luks-copy.sh b/tests/test-luks-copy.sh index 99f300d0..01801811 100755 --- a/tests/test-luks-copy.sh +++ b/tests/test-luks-copy.sh @@ -60,8 +60,8 @@ rm -f $encrypt_disk $plain_disk $pid $sock qemu-img create -f luks \ --object secret,data=123456,id=sec0 \ -o key-secret=sec0 \ - $encrypt_disk 10M -truncate -s 10M $plain_disk + $encrypt_disk 1M +truncate -s 1M $plain_disk qemu-img convert --target-image-opts -n \ --object secret,data=123456,id=sec0 \ $plain_disk \ @@ -74,11 +74,11 @@ start_nbdkit -P $pid -U $sock \ uri="nbd+unix:///?socket=$sock" # Copy the whole disk out. It should be empty. -nbdcopy "$uri" $plain_disk +nbdcopy -C 1 "$uri" $plain_disk if [ "$(hexdump -C $plain_disk)" != '00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * -00a00000' ]; then +00100000' ]; then echo "$0: expected plaintext disk to be empty" exit 1 fi @@ -88,14 +88,14 @@ fi nbdsh -u "$uri" \ -c 'h.pwrite(b"1"*65536, 0)' \ -c 'h.pwrite(b"2"*65536, 128*1024)' \ - -c 'h.pwrite(b"3"*65536, 9*1024*1024)' \ + -c 'h.pwrite(b"3"*65536, 900*1024)' \ -c 'buf = h.pread(65536, 0)' \ -c 'assert buf == b"1"*65536' \ -c 'buf = h.pread(65536, 65536)' \ -c 'assert buf == bytearray(65536)' \ -c 'buf = h.pread(65536, 128*1024)' \ -c 'assert buf == b"2"*65536' \ - -c 'buf = h.pread(65536, 9*1024*1024)' \ + -c 'buf = h.pread(65536, 900*1024)' \ -c 'assert buf == b"3"*65536' \ -c 'h.flush()' @@ -115,11 +115,11 @@ if [ "$(hexdump -C $plain_disk)" != '00000000 31 31 31 31 31 31 31 31 31 31 31 * 00030000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * -00900000 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 |3333333333333333| +000e1000 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 33 |3333333333333333| * -00910000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| +000f1000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| * -00a00000' ]; then +00100000' ]; then echo "$0: unexpected content" exit 1 fi diff --git a/tests/test-luks-info.sh b/tests/test-luks-info.sh index 3eff657b..ef141ecd 100755 --- a/tests/test-luks-info.sh +++ b/tests/test-luks-info.sh @@ -46,11 +46,11 @@ rm -f $disk $info qemu-img create -f luks \ --object secret,data=123456,id=sec0 \ -o key-secret=sec0 \ - $disk 10M + $disk 1M nbdkit -U - file $disk --filter=luks passphrase=123456 \ --run 'nbdinfo $uri' > $info cat $info -# Check the size is 10M (so it doesn't include the LUKS header). -grep "10485760" $info +# Check the size is 1M (so it doesn't include the LUKS header). +grep "1048576" $info -- 2.31.1