Blame SOURCES/0009-tests-luks-Reduce-time-taken-to-run-these-tests.patch

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