mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
tests: update aux
When we use /dev/loopX device - shift first PV1 sector by 1M so /dev/loop0 and dm device do not appear as same device. Also notify lvmetad once 'devs' are created - so in case this command is called in the middle of test - lvmetad properly drops its metadata for these devices. Drop used test.img file between reuse so the 'prepare_vg' always starts with zeroed disks. When LVM_TEST_AUX_TRACE is set, allow shell tracing of aux commands.
This commit is contained in:
parent
b7ebab7657
commit
f08154cc7b
@ -284,7 +284,8 @@ prepare_loop() {
|
|||||||
echo -n .
|
echo -n .
|
||||||
|
|
||||||
local LOOPFILE="$PWD/test.img"
|
local LOOPFILE="$PWD/test.img"
|
||||||
dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size)) 2> /dev/null
|
rm -f "$LOOPFILE"
|
||||||
|
dd if=/dev/zero of="$LOOPFILE" bs=$((1024*1024)) count=0 seek=$(($size + 1)) 2> /dev/null
|
||||||
if LOOP=$(losetup -s -f "$LOOPFILE" 2>/dev/null); then
|
if LOOP=$(losetup -s -f "$LOOPFILE" 2>/dev/null); then
|
||||||
:
|
:
|
||||||
elif LOOP=$(losetup -f) && losetup "$LOOP" "$LOOPFILE"; then
|
elif LOOP=$(losetup -f) && losetup "$LOOP" "$LOOPFILE"; then
|
||||||
@ -367,8 +368,11 @@ prepare_devs() {
|
|||||||
local n=${1:-3}
|
local n=${1:-3}
|
||||||
local devsize=${2:-34}
|
local devsize=${2:-34}
|
||||||
local pvname=${3:-pv}
|
local pvname=${3:-pv}
|
||||||
|
local shift=0
|
||||||
|
|
||||||
prepare_backing_dev $(($n*$devsize))
|
prepare_backing_dev $(($n*$devsize))
|
||||||
|
# shift start of PV devices on /dev/loopXX by 1M
|
||||||
|
not diff LOOP BACKING_DEV >/dev/null 2>&1 || shift=2048
|
||||||
echo -n "## preparing $n devices..."
|
echo -n "## preparing $n devices..."
|
||||||
|
|
||||||
local size=$(($devsize*2048)) # sectors
|
local size=$(($devsize*2048)) # sectors
|
||||||
@ -379,7 +383,7 @@ prepare_devs() {
|
|||||||
local dev="$DM_DEV_DIR/mapper/$name"
|
local dev="$DM_DEV_DIR/mapper/$name"
|
||||||
DEVICES[$count]=$dev
|
DEVICES[$count]=$dev
|
||||||
count=$(( $count + 1 ))
|
count=$(( $count + 1 ))
|
||||||
echo 0 $size linear "$BACKING_DEV" $((($i-1)*$size)) > "$name.table"
|
echo 0 $size linear "$BACKING_DEV" $((($i-1)*$size + $shift)) > "$name.table"
|
||||||
if not dmsetup create -u "TEST-$name" "$name" "$name.table" &&
|
if not dmsetup create -u "TEST-$name" "$name" "$name.table" &&
|
||||||
test -n "$LVM_TEST_BACKING_DEVICE";
|
test -n "$LVM_TEST_BACKING_DEVICE";
|
||||||
then # maybe the backing device is too small for this test
|
then # maybe the backing device is too small for this test
|
||||||
@ -408,6 +412,10 @@ prepare_devs() {
|
|||||||
printf "%s\n" "${DEVICES[@]}" > DEVICES
|
printf "%s\n" "${DEVICES[@]}" > DEVICES
|
||||||
# ( IFS=$'\n'; echo "${DEVICES[*]}" ) >DEVICES
|
# ( IFS=$'\n'; echo "${DEVICES[*]}" ) >DEVICES
|
||||||
echo "ok"
|
echo "ok"
|
||||||
|
|
||||||
|
for dev in "${DEVICES[@]}"; do
|
||||||
|
notify_lvmetad "$dev"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
# Replace linear PV device with its 'delayed' version
|
# Replace linear PV device with its 'delayed' version
|
||||||
@ -894,6 +902,8 @@ dmsetup_wrapped() {
|
|||||||
dmsetup "$@"
|
dmsetup "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test -z "$LVM_TEST_AUX_TRACE" || set -x
|
||||||
|
|
||||||
test -f DEVICES && devs=$(< DEVICES)
|
test -f DEVICES && devs=$(< DEVICES)
|
||||||
|
|
||||||
if test "$1" = dmsetup; then
|
if test "$1" = dmsetup; then
|
||||||
|
Loading…
x
Reference in New Issue
Block a user