From 618ec053fe2d1353eb1c15ebf98c1f4ef9b08ed1 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Fri, 12 Apr 2013 16:36:33 +0200 Subject: tests: consolidate scsi_debug usage Signed-off-by: Karel Zak --- tests/functions.sh | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'tests/functions.sh') diff --git a/tests/functions.sh b/tests/functions.sh index 8293539d2..2ca98f8ca 100644 --- a/tests/functions.sh +++ b/tests/functions.sh @@ -461,10 +461,35 @@ s/# //; } function ts_fdisk_clean { + local DEVNAME=$(basename "$1") + # remove non comparable parts of fdisk output - [ x"${DEVNAME}" != x"" ] && sed -i -e "s/\/dev\/${DEVNAME}/\/dev\/.../g" $TS_OUTPUT + if [ x"${DEVNAME}" != x"" ]; then + sed -i -e "s/\/dev\/${DEVNAME}/\/dev\/.../g" $TS_OUTPUT + fi + sed -i -e 's/Disk identifier:.*//g' \ -e 's/Building a new.*//g' \ -e 's/Welcome to fdisk.*//g' \ $TS_OUTPUT } + +function ts_scsi_debug_init { + + modprobe --dry-run --quiet scsi_debug + [ "$?" == 0 ] || ts_skip "missing scsi_debug module" + + rmmod scsi_debug &> /dev/null + modprobe scsi_debug $* + [ "$?" == 0 ] || ts_die "Cannot init device" + + DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}') + [ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device" + + DEVICE="/dev/${DEVNAME}" + + sleep 1 + udevadm settle + + echo $DEVICE +} -- cgit v1.2.3-55-g7522