summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/functions.sh27
-rwxr-xr-xtests/ts/blkid/md-raid0-whole1
-rwxr-xr-xtests/ts/blkid/md-raid1-part17
-rwxr-xr-xtests/ts/eject/umount16
-rwxr-xr-xtests/ts/fdisk/align-512-4K17
-rwxr-xr-xtests/ts/fdisk/align-512-4K-6317
-rwxr-xr-xtests/ts/fdisk/align-512-4K-md18
-rwxr-xr-xtests/ts/fdisk/align-512-512-topology16
-rwxr-xr-xtests/ts/libmount/context30
-rwxr-xr-xtests/ts/libmount/context-utab28
-rwxr-xr-xtests/ts/libmount/tabfiles-tags17
-rwxr-xr-xtests/ts/mount/umount-alltargets16
-rwxr-xr-xtests/ts/mount/umount-recursive15
13 files changed, 69 insertions, 166 deletions
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/# <!-- 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
+}
diff --git a/tests/ts/blkid/md-raid0-whole b/tests/ts/blkid/md-raid0-whole
index b1faf3f1a..45c5bb0ec 100755
--- a/tests/ts/blkid/md-raid0-whole
+++ b/tests/ts/blkid/md-raid0-whole
@@ -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
diff --git a/tests/ts/blkid/md-raid1-part b/tests/ts/blkid/md-raid1-part
index f627217f8..46bde0ec8 100755
--- a/tests/ts/blkid/md-raid1-part
+++ b/tests/ts/blkid/md-raid1-part
@@ -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__/' \
diff --git a/tests/ts/eject/umount b/tests/ts/eject/umount
index 20f4e1238..3c1f84edf 100755
--- a/tests/ts/eject/umount
+++ b/tests/ts/eject/umount
@@ -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 {
diff --git a/tests/ts/fdisk/align-512-4K b/tests/ts/fdisk/align-512-4K
index d72c96c1a..c5ea72e7a 100755
--- a/tests/ts/fdisk/align-512-4K
+++ b/tests/ts/fdisk/align-512-4K
@@ -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
diff --git a/tests/ts/fdisk/align-512-4K-63 b/tests/ts/fdisk/align-512-4K-63
index e1b03fda4..4ec81982f 100755
--- a/tests/ts/fdisk/align-512-4K-63
+++ b/tests/ts/fdisk/align-512-4K-63
@@ -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
diff --git a/tests/ts/fdisk/align-512-4K-md b/tests/ts/fdisk/align-512-4K-md
index bd7bb0f0c..09947ff9e 100755
--- a/tests/ts/fdisk/align-512-4K-md
+++ b/tests/ts/fdisk/align-512-4K-md
@@ -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
diff --git a/tests/ts/fdisk/align-512-512-topology b/tests/ts/fdisk/align-512-512-topology
index 2a83e0839..9354e45c7 100755
--- a/tests/ts/fdisk/align-512-512-topology
+++ b/tests/ts/fdisk/align-512-512-topology
@@ -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
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
index c1c1fb74b..0c3bce986 100755
--- a/tests/ts/libmount/context
+++ b/tests/ts/libmount/context
@@ -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
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
index 3d3f5c6c0..35851628d 100755
--- a/tests/ts/libmount/context-utab
+++ b/tests/ts/libmount/context-utab
@@ -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
diff --git a/tests/ts/libmount/tabfiles-tags b/tests/ts/libmount/tabfiles-tags
index 799149a7c..f52c4047c 100755
--- a/tests/ts/libmount/tabfiles-tags
+++ b/tests/ts/libmount/tabfiles-tags
@@ -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"
diff --git a/tests/ts/mount/umount-alltargets b/tests/ts/mount/umount-alltargets
index 3c5731af0..1b09112d4 100755
--- a/tests/ts/mount/umount-alltargets
+++ b/tests/ts/mount/umount-alltargets
@@ -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
diff --git a/tests/ts/mount/umount-recursive b/tests/ts/mount/umount-recursive
index 13a075f67..128df885a 100755
--- a/tests/ts/mount/umount-recursive
+++ b/tests/ts/mount/umount-recursive
@@ -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