summaryrefslogtreecommitdiffstats
path: root/tests/functions.sh
diff options
context:
space:
mode:
authorKarel Zak2014-05-14 14:15:58 +0200
committerKarel Zak2014-05-14 14:15:58 +0200
commit37bc9a51c8aed637fb5243f6852da39d85cb98f9 (patch)
tree8a407bbb92b38503bca0c5d359b8da9044984cb2 /tests/functions.sh
parenttests: add .BE hexdump test results (from s390) (diff)
parenttravis-ci: enable root checks (diff)
downloadkernel-qcow2-util-linux-37bc9a51c8aed637fb5243f6852da39d85cb98f9.tar.gz
kernel-qcow2-util-linux-37bc9a51c8aed637fb5243f6852da39d85cb98f9.tar.xz
kernel-qcow2-util-linux-37bc9a51c8aed637fb5243f6852da39d85cb98f9.zip
Merge branch 'travis-root-checks-v2' of https://github.com/rudimeier/util-linux
* 'travis-root-checks-v2' of https://github.com/rudimeier/util-linux: travis-ci: enable root checks travis-ci: minor cleanup and speedup tests: introduce TS_CMD_UUIDGEN (never use installed one) tests, don't write TS_DEVICE to stdout anymore tests: ts_scsi_debug_init must not run in a subshell tests: cleanup ts_scsi_debug_init tests: some more tests need loop support tests: ts_device_init requires loop support tests: use ts_check_losetup in losetup test tests: add function ts_check_losetup tests: ts_device_init remove useless error handling
Diffstat (limited to 'tests/functions.sh')
-rw-r--r--tests/functions.sh35
1 files changed, 22 insertions, 13 deletions
diff --git a/tests/functions.sh b/tests/functions.sh
index 7174a35af..3888f0dcd 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -45,6 +45,18 @@ function ts_check_test_command {
fi
}
+function ts_check_losetup {
+ local tmp
+ ts_check_test_command "$TS_CMD_LOSETUP"
+
+ # assuming that losetup -f works ... to be checked somewhere else
+ tmp=$($TS_CMD_LOSETUP -f 2>/dev/null)
+ if test -b "$tmp"; then
+ return 0
+ fi
+ ts_skip "no loop device support"
+}
+
function ts_skip_subtest {
ts_report " IGNORE ($1)"
}
@@ -425,16 +437,13 @@ function ts_image_init {
}
function ts_device_init {
- local img=$(ts_image_init $1 $2)
- local dev=$($TS_CMD_LOSETUP --show -f "$img")
+ local img
+ local dev
- if [ -z "$dev" ]; then
- ts_device_deinit $dev
- return 1 # error
- fi
+ img=$(ts_image_init $1 $2)
+ dev=$($TS_CMD_LOSETUP --show -f "$img")
echo $dev
- return 0 # succes
}
function ts_device_deinit {
@@ -546,21 +555,21 @@ function ts_fdisk_clean {
}
function ts_scsi_debug_init {
+ local devname
+ TS_DEVICE="none"
- modprobe --dry-run --quiet scsi_debug
+ modprobe --dry-run --quiet scsi_debug &>/dev/null
[ "$?" == 0 ] || ts_skip "missing scsi_debug module"
rmmod scsi_debug &> /dev/null
modprobe scsi_debug $*
[ "$?" == 0 ] || ts_die "Cannot init device"
- DEVNAME=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
- [ "x${DEVNAME}" == "x" ] && ts_die "Cannot find device"
-
- DEVICE="/dev/${DEVNAME}"
+ devname=$(grep --with-filename scsi_debug /sys/block/*/device/model | awk -F '/' '{print $4}')
+ [ "x${devname}" == "x" ] && ts_die "Cannot find device"
sleep 1
udevadm settle
- echo $DEVICE
+ TS_DEVICE="/dev/${devname}"
}