]> sourceware.org Git - lvm2.git/commitdiff
tests: add device holding function
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 22 Dec 2016 21:21:09 +0000 (22:21 +0100)
committerZdenek Kabelac <zkabelac@redhat.com>
Thu, 22 Dec 2016 22:37:07 +0000 (23:37 +0100)
Hold device open with sleep and wait till sleep really opens
given devices.

test/lib/aux.sh

index a1958835fcd346913629200e340181cd77edd7a3..174e05e45dd01f61a48ed7eee4dffd7ae5d6fdc4 100644 (file)
@@ -1491,6 +1491,27 @@ wait_pvmove_lv_ready() {
        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
 total_mem() {
        while IFS=":" read -r a b ; do
This page took 0.040598 seconds and 5 git commands to generate.