From d5c4f1997a5672999618d410f8d76c1929dac05b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 27 Nov 2024 00:06:39 +0900 Subject: [PATCH] TEST-67-INTEGRITY: modernize test code - make udevd generate debugging logs for loopback and DM devices, - insert 'udevadm wait' at several places to make the device processed by udevd, - cleanup generated integritysetup service before moving to next algorithm, - drop unnecessary exit on command failure, - also test data splitting mode for all algorithms. --- test/units/TEST-67-INTEGRITY.sh | 169 ++++++++++++++++---------------- 1 file changed, 85 insertions(+), 84 deletions(-) diff --git a/test/units/TEST-67-INTEGRITY.sh b/test/units/TEST-67-INTEGRITY.sh index eb3082d132..d13f9071ac 100755 --- a/test/units/TEST-67-INTEGRITY.sh +++ b/test/units/TEST-67-INTEGRITY.sh @@ -2,120 +2,121 @@ # SPDX-License-Identifier: LGPL-2.1-or-later set -euxo pipefail -export DM_NAME="integrity_test" -export FULL_DM_DEV_NAME="/dev/mapper/${DM_NAME}" -export FS_UUID="01234567-ffff-eeee-eeee-0123456789ab" -export GEN="/var/run/systemd/generator" +DM_NAME="integrity_test" +DM_NODE="/dev/mapper/${DM_NAME}" +DM_SERVICE="systemd-integritysetup@${DM_NAME}.service" +FS_UUID="01234567-ffff-eeee-eeee-0123456789ab" -image_dir="" +TMP_DIR= +LOOP= -cleanup() -{ - if [ -z "${image_dir}" ]; then - return +cleanup() ( + set +e + + if [[ -n "${LOOP}" ]]; then + losetup -d "${LOOP}" fi - if [ -f "${image_dir}/image" ]; then - if [ -e "${FULL_DM_DEV_NAME}" ]; then - integritysetup close "${DM_NAME}" - fi - losetup -d "${loop}" + if [[ -n "${TMP_DIR}" ]]; then + rm -rf "${TMP_DIR}" fi - rm -rf "${image_dir}" -} + rm -rf /run/udev/rules.d/ + udevadm control --reload +) trap cleanup EXIT -build_integrity_tab() -{ -cat <"/etc/integritytab" -${DM_NAME} ${loop} - integrity-algorithm=$1 +udevadm settle + +# Enable debugging logs for loop and dm block devices. +mkdir -p /run/udev/rules.d/ +cat >/run/udev/rules.d/00-integrity-test.rules <"/etc/integritytab" <