From 36dda7f219d8269aae5083eb55132a52961ba004 Mon Sep 17 00:00:00 2001 From: David Teigland Date: Mon, 16 Nov 2020 16:05:39 -0600 Subject: [PATCH] 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. --- test/Makefile.in | 1 + test/lib/aux.sh | 19 ++++++++++++++++++- test/lib/utils.sh | 18 +++++++++++++++++- test/shell/real_devs.sh | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 75 insertions(+), 2 deletions(-) create mode 100644 test/shell/real_devs.sh diff --git a/test/Makefile.in b/test/Makefile.in index bbdde7196..882620362 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -109,6 +109,7 @@ help: @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_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_DMEVENTD Enable valgrind testing of dmeventd (1)." @echo " LVM_VALGRIND_LVMPOLLD Enable valgrind testing of lvmpolld (1)." diff --git a/test/lib/aux.sh b/test/lib/aux.sh index 5dbb580be..00c0fc6a6 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -657,6 +657,24 @@ prepare_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 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 @@ -909,7 +927,6 @@ prepare_devs() { echo "ok" } - common_dev_() { local tgtype=$1 local dev=$2 diff --git a/test/lib/utils.sh b/test/lib/utils.sh index 88de1a0e2..175d1564a 100644 --- a/test/lib/utils.sh +++ b/test/lib/utils.sh @@ -252,6 +252,11 @@ skip() { exit 200 } +get_real_devs() { + REAL_DEVICES=( $(