mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
tests: add device holding function
Hold device open with sleep and wait till sleep really opens given devices.
This commit is contained in:
parent
1053d46aff
commit
e1943fc07f
@ -1491,6 +1491,27 @@ wait_pvmove_lv_ready() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Holds device open with sleep which automatically expires after given timeout
|
||||||
|
# Prints PID of running holding sleep process in background
|
||||||
|
hold_device_open() {
|
||||||
|
local vgname=$1
|
||||||
|
local lvname=$2
|
||||||
|
local sec=${3:-20} # default 20sec
|
||||||
|
|
||||||
|
sleep $sec < "$DM_DEV_DIR/$vgname/$lvname" >/dev/null 2>&1 &
|
||||||
|
SLEEP_PID=$!
|
||||||
|
# wait till device is openned
|
||||||
|
for i in $(seq 1 50) ; do
|
||||||
|
if test "$(dmsetup info --noheadings -c -o open $vgname-$lvname)" -ne 0 ; then
|
||||||
|
echo "$SLEEP_PID"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
sleep .1
|
||||||
|
done
|
||||||
|
|
||||||
|
die "$vgname-$lvname expected to be openned, but it's not!"
|
||||||
|
}
|
||||||
|
|
||||||
# return total memory size in kB units
|
# return total memory size in kB units
|
||||||
total_mem() {
|
total_mem() {
|
||||||
while IFS=":" read -r a b ; do
|
while IFS=":" read -r a b ; do
|
||||||
|
Loading…
Reference in New Issue
Block a user