summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-x.travis-functions.sh1
-rw-r--r--tests/functions.sh37
-rwxr-xr-xtests/ts/ipcs/limits2
-rwxr-xr-xtests/ts/ipcs/limits22
-rwxr-xr-xtests/ts/libmount/loop48
-rwxr-xr-xtests/ts/libmount/loop-overlay3
6 files changed, 43 insertions, 50 deletions
diff --git a/.travis-functions.sh b/.travis-functions.sh
index 1bf55662f..684c20588 100755
--- a/.travis-functions.sh
+++ b/.travis-functions.sh
@@ -126,7 +126,6 @@ function travis_install_script
function osx_install_script
{
brew update >/dev/null
- brew tap homebrew/dupes
brew install gettext ncurses socat xz
brew link --force gettext
diff --git a/tests/functions.sh b/tests/functions.sh
index 376e78929..fc8f86377 100644
--- a/tests/functions.sh
+++ b/tests/functions.sh
@@ -15,11 +15,6 @@
#
-# Global array to remember all issued lock FDs. It does not seem possible to
-# declare this within a function (ts_init_env).
-declare -A TS_LOCKFILE_FD
-
-
function ts_abspath {
cd $1
pwd
@@ -307,6 +302,7 @@ function ts_init_env {
declare -a TS_SUID_USER
declare -a TS_SUID_GROUP
declare -a TS_LOOP_DEVS
+ declare -a TS_LOCKFILE_FD
if [ -f $TS_TOPDIR/commands.sh ]; then
. $TS_TOPDIR/commands.sh
@@ -512,12 +508,6 @@ function ts_cleanup_on_exit {
done
unset TS_LOOP_DEVS
- # just informative warnings, currently not seen
- for resource in "${!TS_LOCKFILE_FD[@]}"; do
- test -n "${TS_LOCKFILE_FD["resource"]}" || continue
- echo "[$$ $TS_TESTNAME] warning: found unlocked $resource"
- done
-
ts_scsi_debug_rmmod
}
@@ -717,11 +707,24 @@ function ts_find_free_fd()
return 1
}
+function ts_get_lock_fd {
+ local resource=$1
+ local fd
+
+ for fd in "${!TS_LOCKFILE_FD[@]}"; do
+ if [ "${TS_LOCKFILE_FD["$fd"]}" = "$resource" ]; then
+ echo "$fd"
+ return 0
+ fi
+ done
+ return 1
+}
+
function ts_have_lock {
local resource=$1
test "$TS_NOLOCKS" = "yes" && return 0
- test -n "${TS_LOCKFILE_FD["$resource"]}" && return 0
+ ts_get_lock_fd "$resource" >/dev/null && return 0
return 1
}
@@ -735,7 +738,7 @@ function ts_lock {
fi
# Don't lock again
- fd=${TS_LOCKFILE_FD["$resource"]}
+ fd=$(ts_get_lock_fd "$resource")
if [ -n "$fd" ]; then
echo "[$$ $TS_TESTNAME] ${resource} already locked!"
return 0
@@ -745,8 +748,8 @@ function ts_lock {
eval "exec $fd>$lockfile"
flock --exclusive "$fd" || ts_skip "failed to lock $resource"
- TS_LOCKFILE_FD["$resource"]="$fd"
+ TS_LOCKFILE_FD["$fd"]="$resource"
###echo "[$$ $TS_TESTNAME] Locked $resource"
}
@@ -759,13 +762,13 @@ function ts_unlock {
return 0
fi
- fd=${TS_LOCKFILE_FD["$resource"]}
+ fd=$(ts_get_lock_fd "$resource")
if [ -n "$fd" ]; then
eval "exec $fd<&-"
- TS_LOCKFILE_FD["$resource"]=""
+ TS_LOCKFILE_FD["$fd"]=""
###echo "[$$ $TS_TESTNAME] Unlocked $resource"
else
- echo "[$$ $TS_TESTNAME] ${resource} unlocking unlocked $resource!?"
+ echo "[$$ $TS_TESTNAME] unlocking unlocked $resource!?"
fi
}
diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits
index f038b6cd0..7b64b3c17 100755
--- a/tests/ts/ipcs/limits
+++ b/tests/ts/ipcs/limits
@@ -29,6 +29,8 @@ ts_check_prog "bc"
. $TS_SELF/functions.sh
+ts_lock "ipcslimits"
+
ts_log "load original values"
for i in $IPCS_IDX; do
SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2
index 62a4f5bcb..d23c41a35 100755
--- a/tests/ts/ipcs/limits2
+++ b/tests/ts/ipcs/limits2
@@ -27,6 +27,8 @@ ts_check_prog "bc"
. $TS_SELF/functions.sh
+ts_lock "ipcslimits"
+
ts_log "check for difference between kernel and IPC"
ipcs_limits_check >> $TS_OUTPUT
diff --git a/tests/ts/libmount/loop b/tests/ts/libmount/loop
index 09e894761..b52b7476a 100755
--- a/tests/ts/libmount/loop
+++ b/tests/ts/libmount/loop
@@ -117,38 +117,26 @@ ts_log "Success"
ts_finalize_subtest
ts_init_subtest "o-loop-val-initialized"
-if [ "$TS_PARALLEL" = "yes" ]; then
- # There is a race in $LODEV is usage
- ts_skip_subtest "no-reentrant"
-else
- [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
- LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT )
- $TS_CMD_LOSETUP $LODEV "$BACKFILE" >> $TS_OUTPUT 2>&1
- $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
- | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
- $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
- udevadm settle
- ts_log "Success"
- ts_finalize_subtest
-fi
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE" 2>>$TS_OUTPUT)
+$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
+ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
+$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
+udevadm settle
+ts_log "Success"
+ts_finalize_subtest
ts_init_subtest "o-loop-val-conflict"
-if [ "$TS_PARALLEL" = "yes" ]; then
- # There is a race in $LODEV is usage
- ts_skip_subtest "no-reentrant"
-else
- [ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
- cp "$BACKFILE" "$BACKFILE"-2
- LODEV=$( $TS_CMD_LOSETUP --find 2>> $TS_OUTPUT )
- $TS_CMD_LOSETUP $LODEV "$BACKFILE"-2 >> $TS_OUTPUT 2>&1
- $TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
- | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
- $TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
- rm "$BACKFILE"-2
- udevadm settle
- ts_log "Success"
- ts_finalize_subtest
-fi
+[ -d "$TS_MOUNTPOINT" ] || mkdir -p $TS_MOUNTPOINT
+cp "$BACKFILE" "$BACKFILE"-2
+LODEV=$( $TS_CMD_LOSETUP --show -f "$BACKFILE"-2 2>> $TS_OUTPUT)
+$TS_CMD_MOUNT -oloop=$LODEV "$BACKFILE" "$TS_MOUNTPOINT" 2>&1 \
+ | sed 's/:.*:/: <target>/; s/for .*/for <source>/' > $TS_OUTPUT
+$TS_CMD_LOSETUP --detach $LODEV >> $TS_OUTPUT 2>&1
+rm "$BACKFILE"-2
+udevadm settle
+ts_log "Success"
+ts_finalize_subtest
ts_log "Success"
ts_finalize
diff --git a/tests/ts/libmount/loop-overlay b/tests/ts/libmount/loop-overlay
index df096bf30..fffb823c0 100755
--- a/tests/ts/libmount/loop-overlay
+++ b/tests/ts/libmount/loop-overlay
@@ -54,8 +54,7 @@ $TS_CMD_UMOUNT "$TS_MOUNTPOINT-1" >> $TS_OUTPUT 2>&1
$TS_CMD_UMOUNT "$TS_MOUNTPOINT-2" >> $TS_OUTPUT 2>&1
echo "both should fail" >>$TS_OUTPUT
-LOOPDEV=$($TS_CMD_LOSETUP --find)
-$TS_CMD_LOSETUP --offset 1 --sizelimit $OFFSET $LOOPDEV "$IMG"
+LOOPDEV=$($TS_CMD_LOSETUP --show -f --offset 1 --sizelimit $OFFSET "$IMG")
$TS_CMD_MOUNT -oloop,sizelimit=$OFFSET "$IMG" "$TS_MOUNTPOINT-1" 2>&1 \
| sed 's/:.*:/: <target>/; s/for .*/for <source>/' >> $TS_OUTPUT
$TS_CMD_MOUNT -oloop,offset=$OFFSET "$IMG" "$TS_MOUNTPOINT-2" 2>&1 \