summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2016-03-09 15:08:50 +0100
committerKarel Zak2016-03-09 15:08:50 +0100
commitedcf032b30994256f79d531e92b4a51a4f720e78 (patch)
tree19f61e6ceb0a9ba8b7acab1eef7093a84ca81082
parentMerge branch 'port-osx' of https://github.com/rudimeier/util-linux (diff)
parenttests: fix non-working udevadm settle for scsi_debug (diff)
downloadkernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.tar.gz
kernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.tar.xz
kernel-qcow2-util-linux-edcf032b30994256f79d531e92b4a51a4f720e78.zip
Merge branch 'test-fixes' of https://github.com/rudimeier/util-linux
* 'test-fixes' of https://github.com/rudimeier/util-linux: tests: fix non-working udevadm settle for scsi_debug tests: hotfix, wait for scsi_debug partion tests: don't use mkfs.btrfs option -f tests: ignore swapon warnings tests: udevadm settle before losetup -d
-rw-r--r--tests/functions.sh17
-rwxr-xr-xtests/ts/losetup/losetup-blkdev4
-rwxr-xr-xtests/ts/minix/mkfs5
-rwxr-xr-xtests/ts/mount/fstab-btrfs2
-rwxr-xr-xtests/ts/swapon/devname3
-rwxr-xr-xtests/ts/swapon/fixsig3
-rwxr-xr-xtests/ts/swapon/label3
-rwxr-xr-xtests/ts/swapon/uuid3
8 files changed, 36 insertions, 4 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 5d54efd96..74622b068 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -629,6 +629,7 @@ function ts_fdisk_clean {
function ts_scsi_debug_init {
local devname
+ local t
TS_DEVICE="none"
# dry run is not really reliable, real modprobe may still fail
@@ -639,6 +640,10 @@ function ts_scsi_debug_init {
modprobe -r scsi_debug &>/dev/null \
|| ts_skip "cannot remove scsi_debug module (rmmod)"
+ # TODO validate that all devices are gone, add function ts_scsi_debug_rmmod
+ # to be used by the tests too. Tests which produce non-removable scsi
+ # devices should fail!
+
modprobe -b scsi_debug "$@" &>/dev/null \
|| ts_skip "cannot load scsi_debug module (modprobe)"
@@ -648,10 +653,18 @@ function ts_scsi_debug_init {
udevadm settle
- devname=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
- [ "x${devname}" == "x" ] && ts_die "cannot find scsi_debug device"
+ # wait for device if udevadm settle does not work
+ for t in 0 0.02 0.05 0.1 1; do
+ sleep $t
+ devname=$(grep --with-filename scsi_debug /sys/block/*/device/model) && break
+ done
+ [ -n "${devname}" ] || ts_die "timeout waiting for scsi_debug device"
+ devname=$(echo $devname | awk -F '/' '{print $4}')
TS_DEVICE="/dev/${devname}"
+
+ # TODO validate that device is really up, for now just a warning on stderr
+ test -b $TS_DEVICE || echo "warning: scsi_debug device is still down"
}
function ts_resolve_host {
diff --git a/tests/ts/losetup/losetup-blkdev b/tests/ts/losetup/losetup-blkdev
index 9c6f7ff28..4e0f95de2 100755
--- a/tests/ts/losetup/losetup-blkdev
+++ b/tests/ts/losetup/losetup-blkdev
@@ -42,6 +42,7 @@ if [ -z "$LODEV" ]; then
ts_log "Failed to create loop device"
fi
lo_print $LODEV >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP -d $LODEV
ts_finalize_subtest
@@ -51,6 +52,7 @@ if [ -z "$LODEV" ]; then
ts_log "Failed to create loop device"
fi
lo_print $LODEV >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP -d $LODEV
ts_finalize_subtest
@@ -61,6 +63,7 @@ if [ -z "$LODEV" ]; then
ts_log "Failed to create loop device"
fi
lo_print $LODEV >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP -d $LODEV
ts_finalize_subtest
@@ -71,6 +74,7 @@ if [ -z "$LODEV" ]; then
ts_log "Failed to create loop device"
fi
lo_print $LODEV >> $TS_OUTPUT
+udevadm settle
$TS_CMD_LOSETUP -d $LODEV
ts_finalize_subtest
diff --git a/tests/ts/minix/mkfs b/tests/ts/minix/mkfs
index 3f0f83f06..3f2e2baa8 100755
--- a/tests/ts/minix/mkfs
+++ b/tests/ts/minix/mkfs
@@ -24,10 +24,13 @@ ts_check_test_command "$TS_CMD_MKMINIX"
ts_skip_nonroot
ts_scsi_debug_init dev_size_mb=10 num_parts=1
+dev=${TS_DEVICE}1
+
+# hotfix, wait for partition to appear (slow on Debian 7/linux-3.2)
+test -b $dev || sleep 1
mkfs_and_mount_minix() {
ts_init_subtest $1
- dev=${TS_DEVICE}1
ts_log "create minix fs $2"
$TS_CMD_MKMINIX $2 $dev >> $TS_OUTPUT 2>&1
echo "mkfs return value: $?" >> $TS_OUTPUT
diff --git a/tests/ts/mount/fstab-btrfs b/tests/ts/mount/fstab-btrfs
index d14ad104d..ed243c30f 100755
--- a/tests/ts/mount/fstab-btrfs
+++ b/tests/ts/mount/fstab-btrfs
@@ -43,7 +43,7 @@ DEVICE=$TS_LODEV
[ -d "$TS_MOUNTPOINT_SUBVOL" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOL"
[ -d "$TS_MOUNTPOINT_SUBVOLID" ] || mkdir -p "$TS_MOUNTPOINT_SUBVOLID"
[ -d "$TS_MOUNTPOINT_BIND" ] || mkdir -p "$TS_MOUNTPOINT_BIND"
-mkfs.btrfs -f -d single -m single $DEVICE &> /dev/null || ts_die "Cannot make btrfs on $DEVICE"
+mkfs.btrfs -d single -m single $DEVICE &> /dev/null || ts_die "Cannot make btrfs on $DEVICE"
$TS_CMD_MOUNT -o loop "$DEVICE" "$TS_MOUNTPOINT_CREATE"
pushd . >/dev/null
diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname
index 978b875a0..de9a5f20c 100755
--- a/tests/ts/swapon/devname
+++ b/tests/ts/swapon/devname
@@ -42,6 +42,9 @@ grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
+# swapon/mkswap warns if system sets different permissions for loop devices
+sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
+
ts_log "Success"
ts_finalize
diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig
index 6fceb79f8..36c7d9f76 100755
--- a/tests/ts/swapon/fixsig
+++ b/tests/ts/swapon/fixsig
@@ -44,6 +44,9 @@ grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
+# swapon/mkswap warns if system sets different permissions for loop devices
+sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
+
ts_log "Success"
ts_finalize
diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label
index af7da4f29..bbcd771be 100755
--- a/tests/ts/swapon/label
+++ b/tests/ts/swapon/label
@@ -44,6 +44,9 @@ grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
+# swapon/mkswap warns if system sets different permissions for loop devices
+sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
+
ts_log "Success"
ts_finalize
diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid
index 954e8cdf4..9f244f39a 100755
--- a/tests/ts/swapon/uuid
+++ b/tests/ts/swapon/uuid
@@ -44,6 +44,9 @@ grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
+# swapon/mkswap warns if system sets different permissions for loop devices
+sed --in-place '/insecure permissions .*, 0660 suggested/d' $TS_OUTPUT
+
ts_log "Success"
ts_finalize