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