mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
tests: allow tests to use real devices
user creates a file listing real devices they want lvm tests to use, and sets LVM_TEST_DEVICE_LIST. lvm tests can use these with prepare_real_devs and get_real_devs. Other aux functions do not work with these devs.
This commit is contained in:
parent
dc5e6a2cc1
commit
36dda7f219
@ -109,6 +109,7 @@ help:
|
|||||||
@echo " LVM_TEST_CACHE_REPAIR_CMD Command for cache_repair [$(LVM_TEST_CACHE_REPAIR_CMD)]."
|
@echo " LVM_TEST_CACHE_REPAIR_CMD Command for cache_repair [$(LVM_TEST_CACHE_REPAIR_CMD)]."
|
||||||
@echo " LVM_TEST_CACHE_RESTORE_CMD Command for cache_restore [$(LVM_TEST_CACHE_RESTORE_CMD)]."
|
@echo " LVM_TEST_CACHE_RESTORE_CMD Command for cache_restore [$(LVM_TEST_CACHE_RESTORE_CMD)]."
|
||||||
@echo " LVM_TEST_UNLIMITED Set to get unlimited test log (>32MB)"
|
@echo " LVM_TEST_UNLIMITED Set to get unlimited test log (>32MB)"
|
||||||
|
@echo " LVM_TEST_DEVICE_LIST File path listing real devs that tests can use."
|
||||||
@echo " LVM_VALGRIND Enable valgrind testing, execs $$"VALGRIND.
|
@echo " LVM_VALGRIND Enable valgrind testing, execs $$"VALGRIND.
|
||||||
@echo " LVM_VALGRIND_DMEVENTD Enable valgrind testing of dmeventd (1)."
|
@echo " LVM_VALGRIND_DMEVENTD Enable valgrind testing of dmeventd (1)."
|
||||||
@echo " LVM_VALGRIND_LVMPOLLD Enable valgrind testing of lvmpolld (1)."
|
@echo " LVM_VALGRIND_LVMPOLLD Enable valgrind testing of lvmpolld (1)."
|
||||||
|
@ -657,6 +657,24 @@ prepare_ramdisk() {
|
|||||||
touch RAMDISK
|
touch RAMDISK
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prepare_real_devs() {
|
||||||
|
aux lvmconf 'devices/scan = "/dev"'
|
||||||
|
|
||||||
|
touch REAL_DEVICES
|
||||||
|
|
||||||
|
if test -n "$LVM_TEST_DEVICE_LIST"; then
|
||||||
|
local count=0
|
||||||
|
while read path; do
|
||||||
|
REAL_DEVICES[$count]=$path
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
aux extend_filter "a|$path|"
|
||||||
|
dd if=/dev/zero of="$path" bs=32k count=1
|
||||||
|
wipefs -a "$path" 2>/dev/null || true
|
||||||
|
done < $LVM_TEST_DEVICE_LIST
|
||||||
|
fi
|
||||||
|
printf "%s\\n" "${REAL_DEVICES[@]}" > REAL_DEVICES
|
||||||
|
}
|
||||||
|
|
||||||
# A drop-in replacement for prepare_loop() that uses scsi_debug to create
|
# A drop-in replacement for prepare_loop() that uses scsi_debug to create
|
||||||
# a ramdisk-based SCSI device upon which all LVM devices will be created
|
# a ramdisk-based SCSI device upon which all LVM devices will be created
|
||||||
# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer
|
# - scripts must take care not to use a DEV_SIZE that will enduce OOM-killer
|
||||||
@ -909,7 +927,6 @@ prepare_devs() {
|
|||||||
echo "ok"
|
echo "ok"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
common_dev_() {
|
common_dev_() {
|
||||||
local tgtype=$1
|
local tgtype=$1
|
||||||
local dev=$2
|
local dev=$2
|
||||||
|
@ -252,6 +252,11 @@ skip() {
|
|||||||
exit 200
|
exit 200
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get_real_devs() {
|
||||||
|
REAL_DEVICES=( $(<REAL_DEVICES) )
|
||||||
|
export REAL_DEVICES
|
||||||
|
}
|
||||||
|
|
||||||
get_devs() {
|
get_devs() {
|
||||||
local IFS=$IFS_NL
|
local IFS=$IFS_NL
|
||||||
DEVICES=( $(<DEVICES) )
|
DEVICES=( $(<DEVICES) )
|
||||||
@ -265,10 +270,21 @@ prepare_test_vars() {
|
|||||||
lv=LV
|
lv=LV
|
||||||
|
|
||||||
for i in {1..16}; do
|
for i in {1..16}; do
|
||||||
eval "dev$i=\"$DM_DEV_DIR/mapper/${PREFIX}pv$i\""
|
|
||||||
eval "lv$i=\"LV$i\""
|
eval "lv$i=\"LV$i\""
|
||||||
eval "vg$i=\"${PREFIX}vg$i\""
|
eval "vg$i=\"${PREFIX}vg$i\""
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if test -n "$LVM_TEST_DEVICE_LIST"; then
|
||||||
|
local count=0
|
||||||
|
while read path; do
|
||||||
|
count=$(( count + 1 ))
|
||||||
|
eval "dev$count=\"$path\""
|
||||||
|
done < $LVM_TEST_DEVICE_LIST
|
||||||
|
else
|
||||||
|
for i in {1..16}; do
|
||||||
|
eval "dev$i=\"$DM_DEV_DIR/mapper/${PREFIX}pv$i\""
|
||||||
|
done
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if test -z "${abs_top_builddir+varset}" && test -z "${installed_testsuite+varset}"; then
|
if test -z "${abs_top_builddir+varset}" && test -z "${installed_testsuite+varset}"; then
|
||||||
|
39
test/shell/real_devs.sh
Normal file
39
test/shell/real_devs.sh
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# Copyright (C) 2020 Red Hat, Inc. All rights reserved.
|
||||||
|
#
|
||||||
|
# This copyrighted material is made available to anyone wishing to use,
|
||||||
|
# modify, copy, or redistribute it subject to the terms and conditions
|
||||||
|
# of the GNU General Public License v.2.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program; if not, write to the Free Software Foundation,
|
||||||
|
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
test_description='hello world for user-defined device list'
|
||||||
|
|
||||||
|
. lib/inittest
|
||||||
|
|
||||||
|
aux prepare_real_devs
|
||||||
|
|
||||||
|
echo "$dev1"
|
||||||
|
|
||||||
|
pvcreate "$dev1"
|
||||||
|
|
||||||
|
pvs "$dev1"
|
||||||
|
|
||||||
|
pvremove "$dev1"
|
||||||
|
|
||||||
|
vgcreate $vg "$dev1"
|
||||||
|
|
||||||
|
lvcreate -l1 $vg
|
||||||
|
|
||||||
|
vgchange -an $vg
|
||||||
|
|
||||||
|
vgremove -ff $vg
|
||||||
|
|
||||||
|
get_real_devs
|
||||||
|
for d in "${REAL_DEVICES[@]}"; do
|
||||||
|
echo $d
|
||||||
|
done
|
||||||
|
|
Loading…
Reference in New Issue
Block a user