tests: consolidate scsi_debug usage
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
2d87a7dc84
commit
618ec053fe
|
@ -461,10 +461,35 @@ s/# <!-- util-linux.*-->//;
|
|||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
|
|
@ -79,6 +79,7 @@ ts_device_deinit $DEVICE1
|
|||
ts_device_deinit $DEVICE2
|
||||
|
||||
ts_fdisk_clean
|
||||
|
||||
# remove generated UUIDs
|
||||
sed -i -e 's/ID_FS_UUID.*//g' $TS_OUTPUT
|
||||
|
||||
|
|
|
@ -23,20 +23,7 @@ TS_DESC="MD raid1 (last partition)"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
[ -x /sbin/mdadm ] || ts_skip "missing mdadm"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=51 sector_size=512
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=51 sector_size=512)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
|
||||
|
@ -79,7 +66,7 @@ $TS_CMD_BLKID -p -o udev ${DEVICE}2 2>&1 | sort >> $TS_OUTPUT
|
|||
udevadm settle
|
||||
rmmod scsi_debug
|
||||
|
||||
ts_fdisk_clean
|
||||
ts_fdisk_clean $DEVICE
|
||||
# substitue UUIDs and major/minor number before comparison
|
||||
sed -i \
|
||||
-e 's/^\(ID_FS_UUID\)=.*/\1=__ts_uuid__/' \
|
||||
|
|
|
@ -12,22 +12,8 @@ ts_skip_nonroot
|
|||
# not removable device.
|
||||
#
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
|
||||
function init_device {
|
||||
modprobe scsi_debug dev_size_mb=100
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
echo "/dev/${DEVNAME}"
|
||||
|
||||
ts_scsi_debug_init dev_size_mb=100
|
||||
}
|
||||
|
||||
function init_partitions {
|
||||
|
|
|
@ -27,19 +27,8 @@ TS_DESC="align 512/4K"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50 sector_size=512 physblk_exp=3
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
|
||||
|
@ -82,6 +71,6 @@ cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $TS_OUTP
|
|||
|
||||
rmmod scsi_debug
|
||||
|
||||
ts_fdisk_clean
|
||||
ts_fdisk_clean $DEVICE
|
||||
|
||||
ts_finalize
|
||||
|
|
|
@ -27,19 +27,8 @@ TS_DESC="align 512/4K +alignment_offset"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50 sector_size=512 physblk_exp=3 lowest_aligned=7
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3 lowest_aligned=7)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
|
||||
|
@ -82,6 +71,6 @@ cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $TS_OUTP
|
|||
|
||||
rmmod scsi_debug
|
||||
|
||||
ts_fdisk_clean
|
||||
ts_fdisk_clean $DEVICE
|
||||
|
||||
ts_finalize
|
||||
|
|
|
@ -27,20 +27,8 @@ TS_DESC="align 512/4K +MD"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
[ -x /sbin/mdadm ] || ts_skip "missing mdadm"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50 sector_size=512 physblk_exp=3
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50 sector_size=512 physblk_exp=3)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
|
||||
|
@ -97,6 +85,6 @@ cat /sys/block/${MD_DEVNAME}/${MD_DEVNAME}p{1,2}/alignment_offset >> $TS_OUTPUT
|
|||
udevadm settle
|
||||
rmmod scsi_debug
|
||||
|
||||
ts_fdisk_clean
|
||||
ts_fdisk_clean $DEVICE
|
||||
|
||||
ts_finalize
|
||||
|
|
|
@ -27,19 +27,9 @@ TS_DESC="align 512/512 +topology"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50 sector_size=512
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50 sector_size=512)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> $TS_OUTPUT 2>&1 <<EOF
|
||||
|
@ -82,6 +72,6 @@ cat /sys/block/${DEVNAME}/${DEVNAME}{1,2,3,4,5,6,7}/alignment_offset >> $TS_OUTP
|
|||
|
||||
rmmod scsi_debug
|
||||
|
||||
ts_fdisk_clean
|
||||
ts_fdisk_clean $DEVICE
|
||||
|
||||
ts_finalize
|
||||
|
|
|
@ -16,29 +16,16 @@ MOUNTPOINT="$TS_MOUNTPOINT"
|
|||
TS_NOEXIST="$TS_OUTDIR/${TS_TESTNAME}-${TS_SUBNAME}-noex"
|
||||
[ -d $TS_NOEXIST ] && rmdir $TS_NOEXIST
|
||||
|
||||
#set -x
|
||||
|
||||
[ -x $TESTPROG ] || ts_skip "test not compiled"
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
ts_log "Init device"
|
||||
umount $MOUNTPOINT &> /dev/null
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=100
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
udevadm settle
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=100)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
|
||||
$TS_CMD_FDISK ${DEVICE} &> /dev/null <<EOF
|
||||
n
|
||||
p
|
||||
1
|
||||
|
@ -48,9 +35,17 @@ w
|
|||
q
|
||||
EOF
|
||||
|
||||
DEVICE="/dev/${DEVNAME}1"
|
||||
DEVICE="${DEVICE}1"
|
||||
|
||||
sleep 1
|
||||
udevadm settle
|
||||
|
||||
grep -q $DEVNAME /proc/partitions
|
||||
if [ $? -ne 0 ]; then
|
||||
rmmod scsi_debug
|
||||
ts_skip "no partition!"
|
||||
fi
|
||||
|
||||
ts_log "Create filesystem"
|
||||
mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
|
||||
|
||||
|
@ -60,6 +55,7 @@ export LIBMOUNT_MTAB=$TS_OUTPUT.mtab
|
|||
> $LIBMOUNT_MTAB
|
||||
|
||||
udevadm settle
|
||||
ts_device_has "TYPE" "ext4" $DEVICE || ts_die "Cannot find ext3 on $DEVICE" $DEVICE
|
||||
|
||||
ts_init_subtest "mount-by-devname"
|
||||
mkdir -p $MOUNTPOINT &> /dev/null
|
||||
|
|
|
@ -16,24 +16,11 @@ MOUNTPOINT="$TS_MOUNTPOINT"
|
|||
|
||||
[ -x $TESTPROG ] || ts_skip "test not compiled"
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
ts_log "Init device"
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=260
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
udevadm settle
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=100)
|
||||
DEVNAME=$(basename $DEVICE)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} >> /dev/null 2>&1 <<EOF
|
||||
$TS_CMD_FDISK ${DEVICE} &> /dev/null <<EOF
|
||||
n
|
||||
p
|
||||
1
|
||||
|
@ -43,10 +30,17 @@ w
|
|||
q
|
||||
EOF
|
||||
|
||||
DEVICE="/dev/${DEVNAME}1"
|
||||
DEVICE="${DEVICE}1"
|
||||
|
||||
sleep 1
|
||||
udevadm settle
|
||||
|
||||
grep -q $DEVNAME /proc/partitions
|
||||
if [ $? -ne 0 ]; then
|
||||
rmmod scsi_debug
|
||||
ts_skip "no partition!"
|
||||
fi
|
||||
|
||||
ts_log "Create filesystem"
|
||||
mkfs.ext4 -L "$LABEL" -U "$UUID" $DEVICE &> /dev/null
|
||||
|
||||
|
|
|
@ -11,22 +11,7 @@ TESTPROG="$TS_HELPER_LIBMOUNT_TAB"
|
|||
|
||||
[ -x $TESTPROG ] || ts_skip "test not compiled"
|
||||
|
||||
#
|
||||
# Init device
|
||||
#
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50 sector_size=512
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50 sector_size=512)
|
||||
LABEL="testLibmount"
|
||||
UUID="de1bc6e9-34ab-4151-a1d7-900042eee8d9"
|
||||
|
||||
|
|
|
@ -9,21 +9,7 @@ TS_DESC="umount-all-targets"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
ts_log "Init device"
|
||||
$TS_CMD_UMOUNT --recursive $MOUNTPOINT &> /dev/null
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} &> /dev/null <<EOF
|
||||
|
|
|
@ -9,21 +9,8 @@ TS_DESC="umount-recursive"
|
|||
ts_init "$*"
|
||||
ts_skip_nonroot
|
||||
|
||||
modprobe --dry-run --quiet scsi_debug
|
||||
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
|
||||
|
||||
ts_log "Init device"
|
||||
$TS_CMD_UMOUNT --recursive $MOUNTPOINT &> /dev/null
|
||||
rmmod scsi_debug &> /dev/null
|
||||
modprobe scsi_debug dev_size_mb=50
|
||||
[ "$?" == 0 ] || ts_die "Cannot init device"
|
||||
|
||||
sleep 3
|
||||
|
||||
DEVNAME=$(grep scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
|
||||
[ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
|
||||
|
||||
DEVICE="/dev/${DEVNAME}"
|
||||
DEVICE=$(ts_scsi_debug_init dev_size_mb=50)
|
||||
|
||||
ts_log "Create partitions"
|
||||
$TS_CMD_FDISK ${DEVICE} &> /dev/null <<EOF
|
||||
|
|
Loading…
Reference in New Issue