Skip to content

Commit 789a2a7

Browse files
committed
patch tests
1 parent 415f596 commit 789a2a7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

tests/fixtures/cleanup-test-env.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,15 @@ close_luks() {
8383
detach_loop_devices() {
8484
log_info "Detaching loop devices..."
8585

86+
# Remove UUID symlinks for loop devices
87+
if [[ -f /tmp/test_env.conf ]]; then
88+
source /tmp/test_env.conf 2>/dev/null || true
89+
if [[ -n "${TEST_LOOP_UUID:-}" && -L "/dev/disk/by-uuid/$TEST_LOOP_UUID" ]]; then
90+
log_info "Removing UUID symlink /dev/disk/by-uuid/$TEST_LOOP_UUID..."
91+
rm -f "/dev/disk/by-uuid/$TEST_LOOP_UUID"
92+
fi
93+
fi
94+
8695
# Find and detach all loop devices using our test file
8796
for loop_dev in $(losetup -j /tmp/test_loop.img 2>/dev/null | cut -d: -f1); do
8897
log_info "Detaching $loop_dev..."

tests/fixtures/setup-test-env.sh

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ create_luks_container() {
9393
# Format as LUKS
9494
echo -n "$TEST_PASSWORD" | cryptsetup luksFormat --type luks2 "$loop_dev" -
9595

96+
# Trigger udev to create symlinks
97+
udevadm settle
98+
9699
# Open the LUKS container
97100
echo -n "$TEST_PASSWORD" | cryptsetup open "$loop_dev" "$TEST_LUKS_NAME" -
98101

@@ -114,9 +117,15 @@ create_lvm_on_luks() {
114117
# Create logical volume (use most of the space)
115118
lvcreate -L 90M -n "$TEST_LV_NAME" "$TEST_VG_NAME"
116119

120+
# Trigger udev to create symlinks
121+
udevadm settle
122+
117123
# Format with ext4
118124
mkfs.ext4 -q "/dev/$TEST_VG_NAME/$TEST_LV_NAME"
119125

126+
# Trigger udev again after formatting
127+
udevadm settle
128+
120129
log_info "LVM created: /dev/$TEST_VG_NAME/$TEST_LV_NAME"
121130
}
122131

@@ -134,10 +143,23 @@ export_test_config() {
134143
# Get UUID of the loop device (for unlock_device function)
135144
local loop_uuid
136145
loop_uuid=$(blkid -s UUID -o value "$loop_dev")
146+
if [ -z "$loop_uuid" ]; then
147+
log_error "Failed to get UUID for loop device $loop_dev"
148+
return "$FAILURE"
149+
fi
150+
151+
# Create /dev/disk/by-uuid symlink manually for loop device (udev doesn't do this)
152+
mkdir -p /dev/disk/by-uuid
153+
ln -sf "$loop_dev" "/dev/disk/by-uuid/$loop_uuid"
154+
log_info "Created UUID symlink: /dev/disk/by-uuid/$loop_uuid -> $loop_dev"
137155

138156
# Get UUID of the LVM logical volume (for mount tests)
139157
local lv_uuid
140158
lv_uuid=$(blkid -s UUID -o value "/dev/$TEST_VG_NAME/$TEST_LV_NAME")
159+
if [ -z "$lv_uuid" ]; then
160+
log_error "Failed to get UUID for LV /dev/$TEST_VG_NAME/$TEST_LV_NAME"
161+
return "$FAILURE"
162+
fi
141163

142164
cat > "$config_file" <<EOF
143165
# Test environment configuration

0 commit comments

Comments
 (0)