dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone
b394b9
From d35dfbe11f7c6b84d40a6e54611dc3a8c9c27b4d Mon Sep 17 00:00:00 2001
b394b9
From: Karel Zak <kzak@redhat.com>
b394b9
Date: Thu, 30 Jun 2016 11:00:54 +0200
b394b9
Subject: [PATCH 83/86] tests: cleanup tests
b394b9
b394b9
... mostly to be more portable to the new kernels and userspace.
b394b9
b394b9
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1153770
b394b9
Signed-off-by: Karel Zak <kzak@redhat.com>
b394b9
---
b394b9
 tests/commands.sh                           |  1 +
b394b9
 tests/expected/blkid/md-raid0-whole         |  2 +-
b394b9
 tests/expected/blkid/md-raid1-part          |  2 +-
b394b9
 tests/expected/blkid/md-raid1-whole         |  2 +-
b394b9
 tests/expected/fdisk/align-512-4K           |  2 +-
b394b9
 tests/expected/fdisk/align-512-4K-63        |  2 +-
b394b9
 tests/expected/fdisk/align-512-4K-md        |  4 ++--
b394b9
 tests/expected/fdisk/align-512-512          |  2 +-
b394b9
 tests/expected/fdisk/align-512-512-topology |  2 +-
b394b9
 tests/expected/ipcs/limits                  |  4 ----
b394b9
 tests/functions.sh                          | 29 +++++++++++++++++++++++------
b394b9
 tests/ts/ipcs/limits                        |  5 +----
b394b9
 tests/ts/ipcs/limits2                       |  2 ++
b394b9
 tests/ts/libmount/context-utab              | 10 ++++++++--
b394b9
 14 files changed, 44 insertions(+), 25 deletions(-)
b394b9
b394b9
diff --git a/tests/commands.sh b/tests/commands.sh
b394b9
index a2948c9..e769b5d 100644
b394b9
--- a/tests/commands.sh
b394b9
+++ b/tests/commands.sh
b394b9
@@ -64,3 +64,4 @@ TS_CMD_UL=${TS_CMD_UL-"$top_builddir/ul"}
b394b9
 TS_CMD_UMOUNT=${TS_CMD_UMOUNT:-"$top_builddir/umount"}
b394b9
 TS_CMD_UTMPDUMP=${TS_CMD_UTMPDUMP-"$top_builddir/utmpdump"}
b394b9
 TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"$top_builddir/whereis"}
b394b9
+TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"$top_builddir/wipefs"}
b394b9
diff --git a/tests/expected/blkid/md-raid0-whole b/tests/expected/blkid/md-raid0-whole
b394b9
index 37dabf3..30825de 100644
b394b9
--- a/tests/expected/blkid/md-raid0-whole
b394b9
+++ b/tests/expected/blkid/md-raid0-whole
b394b9
@@ -26,7 +26,7 @@ Command (m for help):
b394b9
 Disk /dev/md8: 104 MB, 104726528 bytes, 204544 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 512 bytes
b394b9
-I/O size (minimum/optimal): 65536 bytes / 131072 bytes
b394b9
+I/O size (minimum/optimal): 65536 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/blkid/md-raid1-part b/tests/expected/blkid/md-raid1-part
b394b9
index f409952..3d1b38c 100644
b394b9
--- a/tests/expected/blkid/md-raid1-part
b394b9
+++ b/tests/expected/blkid/md-raid1-part
b394b9
@@ -24,7 +24,7 @@ Command (m for help):
b394b9
 Disk /dev/...: 53 MB, 53477376 bytes, 104448 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 512 bytes
b394b9
-I/O size (minimum/optimal): 512 bytes / 32768 bytes
b394b9
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/blkid/md-raid1-whole b/tests/expected/blkid/md-raid1-whole
b394b9
index 8977312..8ab1da2 100644
b394b9
--- a/tests/expected/blkid/md-raid1-whole
b394b9
+++ b/tests/expected/blkid/md-raid1-whole
b394b9
@@ -25,7 +25,7 @@ Command (m for help):
b394b9
 Disk /dev/md8: 52 MB, 52363264 bytes, 102272 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 512 bytes
b394b9
-I/O size (minimum/optimal): 512 bytes / 512 bytes
b394b9
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/fdisk/align-512-4K b/tests/expected/fdisk/align-512-4K
b394b9
index e5a28f5..7b52fd2 100644
b394b9
--- a/tests/expected/fdisk/align-512-4K
b394b9
+++ b/tests/expected/fdisk/align-512-4K
b394b9
@@ -57,7 +57,7 @@ Command (m for help):
b394b9
 Disk /dev/...: 52 MB, 52428800 bytes, 102400 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 4096 bytes
b394b9
-I/O size (minimum/optimal): 4096 bytes / 32768 bytes
b394b9
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/fdisk/align-512-4K-63 b/tests/expected/fdisk/align-512-4K-63
b394b9
index 7e236ce..302a429 100644
b394b9
--- a/tests/expected/fdisk/align-512-4K-63
b394b9
+++ b/tests/expected/fdisk/align-512-4K-63
b394b9
@@ -57,7 +57,7 @@ Command (m for help):
b394b9
 Disk /dev/...: 52 MB, 52428800 bytes, 102400 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 4096 bytes
b394b9
-I/O size (minimum/optimal): 4096 bytes / 32768 bytes
b394b9
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
b394b9
 Alignment offset: 3584 bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
diff --git a/tests/expected/fdisk/align-512-4K-md b/tests/expected/fdisk/align-512-4K-md
b394b9
index dbbbc05..e8f6ba1 100644
b394b9
--- a/tests/expected/fdisk/align-512-4K-md
b394b9
+++ b/tests/expected/fdisk/align-512-4K-md
b394b9
@@ -28,7 +28,7 @@ Command (m for help):
b394b9
 Disk /dev/...: 52 MB, 52428800 bytes, 102400 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 4096 bytes
b394b9
-I/O size (minimum/optimal): 4096 bytes / 32768 bytes
b394b9
+I/O size (minimum/optimal): 4096 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
@@ -72,7 +72,7 @@ Command (m for help):
b394b9
 Disk /dev/md8: 51 MB, 51249152 bytes, 100096 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 4096 bytes
b394b9
-I/O size (minimum/optimal): 65536 bytes / 131072 bytes
b394b9
+I/O size (minimum/optimal): 65536 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/fdisk/align-512-512 b/tests/expected/fdisk/align-512-512
b394b9
index 018322f..8e03d90 100644
b394b9
--- a/tests/expected/fdisk/align-512-512
b394b9
+++ b/tests/expected/fdisk/align-512-512
b394b9
@@ -53,7 +53,7 @@ Command (m for help):
b394b9
 Disk /dev/loop0: 52 MB, 52428800 bytes, 102400 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 512 bytes
b394b9
-I/O size (minimum/optimal): 512 bytes / 512 bytes
b394b9
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/fdisk/align-512-512-topology b/tests/expected/fdisk/align-512-512-topology
b394b9
index b3d3114..fd57f60 100644
b394b9
--- a/tests/expected/fdisk/align-512-512-topology
b394b9
+++ b/tests/expected/fdisk/align-512-512-topology
b394b9
@@ -53,7 +53,7 @@ Command (m for help):
b394b9
 Disk /dev/...: 52 MB, 52428800 bytes, 102400 sectors
b394b9
 Units = sectors of 1 * 512 = 512 bytes
b394b9
 Sector size (logical/physical): 512 bytes / 512 bytes
b394b9
-I/O size (minimum/optimal): 512 bytes / 32768 bytes
b394b9
+I/O size (minimum/optimal): 512 bytes / <removed> bytes
b394b9
 Disk label type: dos
b394b9
 
b394b9
 
b394b9
diff --git a/tests/expected/ipcs/limits b/tests/expected/ipcs/limits
b394b9
index 7480a1e..e08fa54 100644
b394b9
--- a/tests/expected/ipcs/limits
b394b9
+++ b/tests/expected/ipcs/limits
b394b9
@@ -1,8 +1,4 @@
b394b9
 load original values
b394b9
-check for difference between kernel and IPC
b394b9
-/proc/sys/kernel/shmmni OK
b394b9
-/proc/sys/kernel/shmall OK
b394b9
-/proc/sys/kernel/shmmax OK
b394b9
 maximalize kernel setting
b394b9
 re-check for difference between kernel and IPC
b394b9
 /proc/sys/kernel/shmmni OK
b394b9
diff --git a/tests/functions.sh b/tests/functions.sh
b394b9
index b2d493c..0d1c9c8 100644
b394b9
--- a/tests/functions.sh
b394b9
+++ b/tests/functions.sh
b394b9
@@ -31,6 +31,17 @@ function ts_canonicalize {
b394b9
 	fi
b394b9
 }
b394b9
 
b394b9
+function ts_check_test_command {
b394b9
+	if [ ! -x "$1" ]; then
b394b9
+		ts_skip "${1##*/} not found"
b394b9
+	fi
b394b9
+}
b394b9
+
b394b9
+function ts_check_prog {
b394b9
+	local cmd=$1
b394b9
+	type "$cmd" >/dev/null 2>&1 || ts_skip "missing in PATH: $cmd"
b394b9
+}
b394b9
+
b394b9
 function ts_skip_subtest {
b394b9
 	echo " IGNORE ($1)"
b394b9
 }
b394b9
@@ -474,14 +485,20 @@ function ts_fdisk_clean {
b394b9
 	local DEVNAME=$(basename "$1")
b394b9
 
b394b9
 	# remove non comparable parts of fdisk output
b394b9
-	if [ x"${DEVNAME}" != x"" ]; then
b394b9
-	       sed -i -e "s/\/dev\/${DEVNAME}/\/dev\/.../g" $TS_OUTPUT
b394b9
+	if [ -n "${DEVNAME}" ]; then
b394b9
+		sed -i -e "s@${DEVNAME}@...@;" $TS_OUTPUT
b394b9
 	fi
b394b9
 
b394b9
-	sed -i -e 's/Disk identifier:.*//g' \
b394b9
-	       -e 's/Building a new.*//g' \
b394b9
-	       -e 's/Welcome to fdisk.*//g' \
b394b9
-	       $TS_OUTPUT
b394b9
+	sed -i \
b394b9
+		-e 's/Disk identifier:.*//' \
b394b9
+		-e 's/Building a new.*//' \
b394b9
+		-e 's/Created a new.*//' \
b394b9
+		-e 's/^Device[[:blank:]]*Start/Device             Start/' \
b394b9
+		-e 's/^Device[[:blank:]]*Boot/Device     Boot/' \
b394b9
+		-e 's/Welcome to fdisk.*//' \
b394b9
+		-e 's/typescript file.*/typescript file <removed>./' \
b394b9
+		-e 's@^\(I/O size (minimum/op.* bytes /\) [1-9][0-9]* @\1 <removed> @' \
b394b9
+		$TS_OUTPUT
b394b9
 }
b394b9
 
b394b9
 function ts_scsi_debug_init {
b394b9
diff --git a/tests/ts/ipcs/limits b/tests/ts/ipcs/limits
b394b9
index b44adb1..c4717c3 100755
b394b9
--- a/tests/ts/ipcs/limits
b394b9
+++ b/tests/ts/ipcs/limits
b394b9
@@ -23,7 +23,7 @@ TS_DESC="limits overflow"
b394b9
 
b394b9
 ts_init "$*"
b394b9
 ts_skip_nonroot
b394b9
-type bc >/dev/null 2>&1 || ts_skip "cannot find bc command"
b394b9
+ts_check_prog "bc"
b394b9
 
b394b9
 . $TS_SELF/functions.sh
b394b9
 
b394b9
@@ -32,9 +32,6 @@ for i in $IPCS_IDX; do
b394b9
 	SHM_ORG[$i]=$(cat ${IPCS_PROCFILES[$i]})
b394b9
 done >> $TS_OUTPUT
b394b9
 
b394b9
-ts_log "check for difference between kernel and IPC"
b394b9
-ipcs_limits_check >> $TS_OUTPUT
b394b9
-
b394b9
 ts_log "maximalize kernel setting"
b394b9
 for i in $IPCS_IDX; do
b394b9
 	echo ${IPCS_LIMITS[$i]} >> ${IPCS_PROCFILES[$i]}
b394b9
diff --git a/tests/ts/ipcs/limits2 b/tests/ts/ipcs/limits2
b394b9
index 63f834d..2eabfd2 100755
b394b9
--- a/tests/ts/ipcs/limits2
b394b9
+++ b/tests/ts/ipcs/limits2
b394b9
@@ -22,6 +22,8 @@ TS_DESC="basic limits"
b394b9
 . $TS_TOPDIR/functions.sh
b394b9
 ts_init "$*"
b394b9
 
b394b9
+ts_check_prog "bc"
b394b9
+
b394b9
 . $TS_SELF/functions.sh
b394b9
 
b394b9
 # TODO https://github.com/karelzak/util-linux/issues/51
b394b9
diff --git a/tests/ts/libmount/context-utab b/tests/ts/libmount/context-utab
b394b9
index 859fc2b..b2bfefc 100755
b394b9
--- a/tests/ts/libmount/context-utab
b394b9
+++ b/tests/ts/libmount/context-utab
b394b9
@@ -87,14 +87,20 @@ ts_finalize_subtest
b394b9
 
b394b9
 
b394b9
 if [ -x "/sbin/mkfs.btrfs" ]; then
b394b9
+
b394b9
 	$TS_CMD_WIPEFS -a  $DEVICE &> /dev/null
b394b9
 	ts_log "Create filesystem [btrfs]"
b394b9
 	/sbin/mkfs.btrfs -L "$LABEL" $DEVICE &> /dev/null
b394b9
 	udevadm settle
b394b9
 
b394b9
 	mount -t btrfs $DEVICE $MOUNTPOINT &> /dev/null
b394b9
-	/sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null
b394b9
-	umount $MOUNTPOINT &> /dev/null
b394b9
+
b394b9
+	if [ -x "/sbin/btrfsctl" ]; then
b394b9
+		/sbin/btrfsctl -S sub $MOUNTPOINT &> /dev/null
b394b9
+	else
b394b9
+		btrfs subvolume create $MOUNTPOINT/sub &> /dev/null
b394b9
+	fi
b394b9
+	umount $MOUNTPOINT #&> /dev/null
b394b9
 
b394b9
 	udevadm settle
b394b9
 
b394b9
-- 
b394b9
2.7.4
b394b9