dcavalca / rpms / util-linux

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