From 9b41118b9c8fed755eaabb1b0833f2518ddf1c36 Mon Sep 17 00:00:00 2001 From: Zdenek Kabelac Date: Mon, 20 Jan 2020 13:15:46 +0100 Subject: [PATCH] tests: writeerror_dev Intruduce aux function for easy simulation of disk areas, that are 'normally' readable, but will fail on write. --- test/lib/aux.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/lib/aux.sh b/test/lib/aux.sh index ec0699f88..b90063d1f 100644 --- a/test/lib/aux.sh +++ b/test/lib/aux.sh @@ -564,6 +564,8 @@ teardown() { echo -n "## teardown..." unset LVM_LOG_FILE_EPOCH + test ! -f ERR_DEV || should dmsetup remove $(cat ERR_DEV_NAME) + if test -f TESTNAME ; then if test ! -f SKIP_THIS_TEST ; then @@ -985,6 +987,8 @@ common_dev_() { case "$tgtype" in delay) echo "$from $len delay $pvdev $(( pos + offset )) $read_ms $pvdev $(( pos + offset )) $write_ms" ;; + writeerror) + echo "$from $len delay $pvdev $(( pos + offset )) 0 $(cat ERR_DEV) 0 0" ;; error|zero) echo "$from $len $tgtype" ;; esac @@ -1124,6 +1128,24 @@ error_dev() { common_dev_ error "$@" } +# +# Convert device to device with write errors but normal reads. +# For this 'delay' dev is used and reroutes 'reads' back to original device +# and for writes it will use extra new TEST-errordev (huge error target) +# i.e. writeerror_dev "$dev1" 8:32 +writeerror_dev() { + local name=${PREFIX}-errordev + + if test ! -e ERR_DEV; then + dmsetup create -u "TEST-$name" "$name" --table "0 4611686018427387904 error" + # Take major:minor of our error device + echo "$name" > ERR_DEV_NAME + dmsetup info -c --noheadings -o major,minor "$name" > ERR_DEV + fi + + common_dev_ writeerror "$@" +} + # # Convert existing device to a device with zero segments # Takes the list of pairs of zero segment from:len