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