]> sourceware.org Git - lvm2.git/commitdiff
tests: add delay_dev
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 30 Aug 2013 12:50:58 +0000 (14:50 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Sat, 31 Aug 2013 19:40:51 +0000 (21:40 +0200)
Function to create slower responsive device.

Useful for testing things which needs to happen something during on
going operation - with  'delayed' device - much smaller sizes of devices
are needed and its much more deterministic (though still not optimal)

test/lib/aux.sh

index 36de6e5fd7bd2d75f9d14572fb55220eb4636dee..c9bb1fb5d8724ea75c8ac6e2bb94070b586d8e4e 100644 (file)
@@ -342,6 +342,35 @@ prepare_devs() {
        echo "ok"
 }
 
+# Replace linear PV device with its 'delayed' version
+# Could be used to more deterministicaly hit some problems.
+# Parameters: {device path} [read delay ms] [write delay ms]
+# Original device is restored when both delay params are 0 (or missing).
+# i.e.  delay_dev "$dev1" 0 200
+delay_dev() {
+       target_at_least dm-delay 1 2 0 || skip
+       local name=$(echo "$1" | sed -e 's,.*/,,')
+       local read_ms=${2:-0}
+       local write_ms=${3:-0}
+       local pos
+       local size
+       local type
+       local pvdev
+       local offset
+
+       read pos size type pvdev offset < "$name.table"
+
+       init_udev_transaction
+       if test $read_ms -ne 0 -o $write_ms -ne 0 ; then
+               echo "0 $size delay $pvdev $offset $read_ms $pvdev $offset $write_ms" | \
+                       dmsetup load "$name"
+       else
+               dmsetup load "$name" "$name.table"
+       fi
+       dmsetup resume "$name"
+       finish_udev_transaction
+}
+
 disable_dev() {
        local dev
 
This page took 0.03466 seconds and 5 git commands to generate.