summaryrefslogtreecommitdiffstats
path: root/tests/ts
diff options
context:
space:
mode:
authorRuediger Meier2018-03-09 18:27:44 +0100
committerKarel Zak2018-03-19 11:46:11 +0100
commitec182d8b9da7596809aab9aab4fc931e9ccb7494 (patch)
tree5b5127ff66d0d027da6238e105eb3dfa5bbfc3b3 /tests/ts
parenttests: handle xargs errors and invalid args (diff)
downloadkernel-qcow2-util-linux-ec182d8b9da7596809aab9aab4fc931e9ccb7494.tar.gz
kernel-qcow2-util-linux-ec182d8b9da7596809aab9aab4fc931e9ccb7494.tar.xz
kernel-qcow2-util-linux-ec182d8b9da7596809aab9aab4fc931e9ccb7494.zip
tests: fix grep expressions for devices
ts_is_mounted "/dev/loop1" returned true if /dev/loop17 was mounted. A very annoying source of sporadic failures since many years. This issue became more visible since running the checks in parallel, which increases the probability to get bigger loop device numbers. Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Diffstat (limited to 'tests/ts')
-rwxr-xr-xtests/ts/libmount/context2
-rwxr-xr-xtests/ts/libmount/context-py4
-rwxr-xr-xtests/ts/libmount/context-utab14
-rwxr-xr-xtests/ts/libmount/context-utab-py12
-rwxr-xr-xtests/ts/losetup/losetup-loop2
-rwxr-xr-xtests/ts/mount/devname4
-rwxr-xr-xtests/ts/swapon/devname2
-rwxr-xr-xtests/ts/swapon/fixpgsz2
-rwxr-xr-xtests/ts/swapon/fixsig2
-rwxr-xr-xtests/ts/swapon/label2
-rwxr-xr-xtests/ts/swapon/uuid2
11 files changed, 24 insertions, 24 deletions
diff --git a/tests/ts/libmount/context b/tests/ts/libmount/context
index 5a4f36afa..3750c701f 100755
--- a/tests/ts/libmount/context
+++ b/tests/ts/libmount/context
@@ -53,7 +53,7 @@ DEVICE="${TS_DEVICE}1"
udevadm settle
-grep -q $DEVNAME /proc/partitions
+grep -q " $DEVNAME\$" /proc/partitions
if [ $? -ne 0 ]; then
ts_skip "no partition!"
fi
diff --git a/tests/ts/libmount/context-py b/tests/ts/libmount/context-py
index b4e22b400..dfc8faaee 100755
--- a/tests/ts/libmount/context-py
+++ b/tests/ts/libmount/context-py
@@ -58,7 +58,7 @@ DEVICE="${TS_DEVICE}1"
udevadm settle
-grep -q $DEVNAME /proc/partitions
+grep -q " $DEVNAME\$" /proc/partitions
if [ $? -ne 0 ]; then
ts_skip "no partition!"
fi
@@ -77,7 +77,7 @@ function is_mounted {
ts_is_mounted "$1"
return $?
fi
- grep -q "$1" $LIBMOUNT_MTAB && return 0
+ grep -q "\(^\| \)$1 " $LIBMOUNT_MTAB && return 0
return 1
}
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
index 24d528d87..a63ba57d6 100755
--- a/tests/ts/libmount/context-utab
+++ b/tests/ts/libmount/context-utab
@@ -44,7 +44,7 @@ DEVICE="${TS_DEVICE}1"
udevadm settle
-grep -q $DEVNAME /proc/partitions
+grep -q " $DEVNAME\$" /proc/partitions
if [ $? -ne 0 ]; then
ts_skip "no partition!"
fi
@@ -67,14 +67,14 @@ udevadm settle
ts_init_subtest "mount-by-devname"
mkdir -p $MOUNTPOINT &> /dev/null
ts_run $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/mounts || \
+ts_is_mounted "$DEVICE" || \
echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
ts_init_subtest "umount-by-devname"
ts_run $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/mounts &&
+ts_is_mounted "$DEVICE" &&
echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -82,14 +82,14 @@ ts_finalize_subtest
ts_init_subtest "mount-uhelper"
mkdir -p $MOUNTPOINT &> /dev/null
ts_run $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE $LIBMOUNT_UTAB || \
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
ts_init_subtest "umount"
ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE $LIBMOUNT_UTAB && \
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -109,7 +109,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then
ts_init_subtest "mount-uhelper-subvol"
mkdir -p $MOUNTPOINT &> /dev/null
ts_run $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB || \
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -123,7 +123,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then
ts_init_subtest "umount-subvol"
ts_run $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB && \
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
fi
diff --git a/tests/ts/libmount/context-utab-py b/tests/ts/libmount/context-utab-py
index 94c957d91..89fc0c157 100755
--- a/tests/ts/libmount/context-utab-py
+++ b/tests/ts/libmount/context-utab-py
@@ -45,7 +45,7 @@ DEVICE="${TS_DEVICE}1"
udevadm settle
-grep -q $DEVNAME /proc/partitions
+grep -q " $DEVNAME\$" /proc/partitions
if [ $? -ne 0 ]; then
ts_skip "no partition!"
fi
@@ -68,14 +68,14 @@ udevadm settle
ts_init_subtest "mount-by-devname"
mkdir -p $MOUNTPOINT &> /dev/null
$PYTHON $TESTPROG --mount $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/mounts || \
+ts_is_mounted "$DEVICE" || \
echo "(by device) cannot find $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
ts_init_subtest "umount-by-devname"
$PYTHON $TESTPROG --umount $DEVICE >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/mounts &&
+ts_is_mounted "$DEVICE" &&
echo "umount (device) failed: found $DEVICE in /proc/mounts" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -83,14 +83,14 @@ ts_finalize_subtest
ts_init_subtest "mount-uhelper"
mkdir -p $MOUNTPOINT &> /dev/null
$PYTHON $TESTPROG --mount -o uhelper=foo,rw LABEL="$LABEL" $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE $LIBMOUNT_UTAB || \
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
echo "(by label) cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
ts_init_subtest "umount"
$PYTHON $TESTPROG --umount $MOUNTPOINT >> $TS_OUTPUT 2>&1
-grep -q $DEVICE $LIBMOUNT_UTAB && \
+grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" && \
echo "umount (mountpoint) failed: found $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
@@ -110,7 +110,7 @@ if type "mkfs.btrfs" &>/dev/null && mkfs.btrfs --version &>/dev/null; then
ts_init_subtest "mount-uhelper-subvol"
mkdir -p $MOUNTPOINT &> /dev/null
$PYTHON $TESTPROG --mount -o uhelper=foo,rw,subvol=sub $DEVICE $MOUNTPOINT >> $TS_OUTPUT 2>&1
- grep -q $DEVICE $LIBMOUNT_UTAB || \
+ grep -q "SRC=$DEVICE\b" "$LIBMOUNT_UTAB" || \
echo "cannot find $DEVICE in $LIBMOUNT_UTAB" >> $TS_OUTPUT 2>&1
ts_finalize_subtest
diff --git a/tests/ts/losetup/losetup-loop b/tests/ts/losetup/losetup-loop
index 6d1ef21bc..037e5c7c6 100755
--- a/tests/ts/losetup/losetup-loop
+++ b/tests/ts/losetup/losetup-loop
@@ -47,7 +47,7 @@ $TS_CMD_LOSETUP -d "$LODEV"
LODEV=$( $TS_CMD_LOSETUP --find --nooverlap --show $BACKFILE )
udevadm settle
dd if=/dev/zero of="$LODEV" count=1 bs=1 >/dev/null 2>&1
-$TS_CMD_LOSETUP --list | grep -q "$LODEV"
+$TS_CMD_LOSETUP --list | grep -q "$LODEV\b"
ts_log $?
udevadm settle
$TS_CMD_LOSETUP -d "$LODEV" >/dev/null 2>&1
diff --git a/tests/ts/mount/devname b/tests/ts/mount/devname
index 65a1ba217..4db878bb6 100755
--- a/tests/ts/mount/devname
+++ b/tests/ts/mount/devname
@@ -48,12 +48,12 @@ $TS_CMD_MOUNT $DEVICE $TS_MOUNTPOINT >> $TS_OUTPUT 2>&1
ts_is_mounted $DEVICE || ts_die "Cannot find $DEVICE in /proc/mounts"
-grep -q $DEVICE $MTAB_FILE ||
+grep -q "\(^\| \)$DEVICE " $MTAB_FILE ||
echo "mount failed: cannot find $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1
$TS_CMD_UMOUNT $DEVICE || ts_die "Cannot umount $DEVICE"
-grep -q $DEVICE $MTAB_FILE &&
+grep -q "\(^\| \)$DEVICE " $MTAB_FILE &&
echo "umount failed: found $DEVICE in $MTAB_FILE" >> $TS_OUTPUT 2>&1
ts_log "Success"
diff --git a/tests/ts/swapon/devname b/tests/ts/swapon/devname
index de9a5f20c..7469dcb18 100755
--- a/tests/ts/swapon/devname
+++ b/tests/ts/swapon/devname
@@ -38,7 +38,7 @@ ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE"
$TS_CMD_SWAPON $DEVICE >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
diff --git a/tests/ts/swapon/fixpgsz b/tests/ts/swapon/fixpgsz
index 01b2e9aff..4479cd8f9 100755
--- a/tests/ts/swapon/fixpgsz
+++ b/tests/ts/swapon/fixpgsz
@@ -40,7 +40,7 @@ ts_device_has "TYPE" "swap" $DEVICE || ts_die "Cannot find swap on $DEVICE"
#
$TS_CMD_SWAPON --fixpgsz $DEVICE &> /dev/null
-grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
diff --git a/tests/ts/swapon/fixsig b/tests/ts/swapon/fixsig
index 3f9e3ff84..c3104a23e 100755
--- a/tests/ts/swapon/fixsig
+++ b/tests/ts/swapon/fixsig
@@ -41,7 +41,7 @@ ts_device_has "TYPE" "swsuspend" $DEVICE || ts_die "Cannot find swsuspend on $DE
#
$TS_CMD_SWAPON $DEVICE &> /dev/null
-grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
diff --git a/tests/ts/swapon/label b/tests/ts/swapon/label
index 056953a29..210a12c97 100755
--- a/tests/ts/swapon/label
+++ b/tests/ts/swapon/label
@@ -42,7 +42,7 @@ ts_device_has "LABEL" $LABEL $DEVICE \
$TS_CMD_SWAPON -L $LABEL >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE
diff --git a/tests/ts/swapon/uuid b/tests/ts/swapon/uuid
index 9f244f39a..65af6cb6d 100755
--- a/tests/ts/swapon/uuid
+++ b/tests/ts/swapon/uuid
@@ -40,7 +40,7 @@ UUID=$(ts_uuid_by_devname $DEVICE)
$TS_CMD_SWAPON -U $UUID >> $TS_OUTPUT 2>&1
-grep -q $DEVICE /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
+grep -q "^$DEVICE\b" /proc/swaps || ts_die "Cannot find $DEVICE in /proc/swaps"
$TS_CMD_SWAPOFF $DEVICE