61 lines
1.9 KiB
Diff
61 lines
1.9 KiB
Diff
From 874ee402645f9c3c40eaf5882a9cb92bc88b1a8f Mon Sep 17 00:00:00 2001
|
|
From: Sergio Correia <scorreia@redhat.com>
|
|
Date: Sun, 22 Dec 2019 16:46:19 -0500
|
|
Subject: [PATCH] Improve tests speed Also run tests only as root, if they
|
|
involve cryptsetup
|
|
|
|
---
|
|
src/luks/tests/tests-common-functions | 16 +++++++++++++---
|
|
1 file changed, 13 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/src/luks/tests/tests-common-functions b/src/luks/tests/tests-common-functions
|
|
index b65a84a..7758876 100644
|
|
--- a/src/luks/tests/tests-common-functions
|
|
+++ b/src/luks/tests/tests-common-functions
|
|
@@ -25,6 +25,11 @@ luks2_supported() {
|
|
return 0
|
|
}
|
|
|
|
+skip_test() {
|
|
+ echo "${1}" >&2
|
|
+ exit 77
|
|
+}
|
|
+
|
|
# Creates a tang adv to be used in the test.
|
|
create_tang_adv() {
|
|
local adv="${1}"
|
|
@@ -39,14 +44,18 @@ create_tang_adv() {
|
|
| jose jws sig -I- -s "${TEMPLATE}" -k "${SIG}" -o "${adv}"
|
|
}
|
|
|
|
-
|
|
# Creates a new LUKS1 or LUKS2 device to be used.
|
|
new_device() {
|
|
local LUKS="${1}"
|
|
local DEV="${2}"
|
|
-
|
|
local DEV_CACHED="${TMP}/${LUKS}.cached"
|
|
|
|
+ # Some builders fail if the cryptsetup steps are not ran as root, so let's
|
|
+ # skip the test now if not running as root.
|
|
+ if [ $(id -u) != 0 ]; then
|
|
+ skip_test "WARNING: You must be root to run this test; test skipped."
|
|
+ fi
|
|
+
|
|
# Let's reuse an existing device, if there is one.
|
|
if [ -f "${DEV_CACHED}" ]; then
|
|
echo "Reusing cached ${LUKS} device..."
|
|
@@ -55,7 +64,8 @@ new_device() {
|
|
fi
|
|
|
|
fallocate -l16M "${DEV}"
|
|
- cryptsetup luksFormat --type "${LUKS}" --batch-mode --force-password "${DEV}" <<< "${DEFAULT_PASS}"
|
|
+ local extra_options='--pbkdf pbkdf2 --pbkdf-force-iterations 1000'
|
|
+ cryptsetup luksFormat --type "${LUKS}" ${extra_options} --batch-mode --force-password "${DEV}" <<< "${DEFAULT_PASS}"
|
|
# Caching the just-formatted device for possible reuse.
|
|
cp -f "${DEV}" "${DEV_CACHED}"
|
|
}
|
|
--
|
|
2.18.1
|
|
|