All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] LVM support scripts for OpenQA
@ 2020-01-29 14:49 Martin Doucha
  2020-01-29 14:49 ` [LTP] [PATCH 1/3] Fix releasing loop devices in shell API Martin Doucha
                   ` (2 more replies)
  0 siblings, 3 replies; 16+ messages in thread
From: Martin Doucha @ 2020-01-29 14:49 UTC (permalink / raw)
  To: ltp

The old support script for LVM tests (testscripts/ltpfslvm.sh) doesn't work
very well with external testing tools so LVM tests currently cannot be run
in OpenQA. Create new LVM support scripts that focus exclusively on setup
and cleanup. One of the scripts also generates a new LVM runfile that'll test
only file systems supported by the test machine.

Martin Doucha (3):
  Fix releasing loop devices in shell API
  Allow acquiring multiple loop devices
  Add LVM support scripts

 include/old/old_device.h                 |  19 +++++
 lib/tst_device.c                         |  36 +++++---
 testcases/lib/tst_device.c               |  20 +++--
 testcases/misc/lvm/Makefile              |  29 +++++++
 testcases/misc/lvm/cleanup_lvm.sh        |  34 ++++++++
 testcases/misc/lvm/datafiles/Makefile    |  19 +++++
 testcases/misc/lvm/datafiles/runfile.tpl |  36 ++++++++
 testcases/misc/lvm/generate_runfile.sh   |  27 ++++++
 testcases/misc/lvm/prepare_lvm.sh        | 102 +++++++++++++++++++++++
 9 files changed, 304 insertions(+), 18 deletions(-)
 create mode 100644 testcases/misc/lvm/Makefile
 create mode 100755 testcases/misc/lvm/cleanup_lvm.sh
 create mode 100644 testcases/misc/lvm/datafiles/Makefile
 create mode 100644 testcases/misc/lvm/datafiles/runfile.tpl
 create mode 100755 testcases/misc/lvm/generate_runfile.sh
 create mode 100755 testcases/misc/lvm/prepare_lvm.sh

-- 
2.24.1


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 1/3] Fix releasing loop devices in shell API
  2020-01-29 14:49 [LTP] [PATCH 0/3] LVM support scripts for OpenQA Martin Doucha
@ 2020-01-29 14:49 ` Martin Doucha
  2020-02-03 15:05   ` Petr Vorel
  2020-01-29 14:49 ` [LTP] [PATCH 2/3] Allow acquiring multiple loop devices Martin Doucha
  2020-01-29 14:49 ` [LTP] [PATCH 3/3] Add LVM support scripts Martin Doucha
  2 siblings, 1 reply; 16+ messages in thread
From: Martin Doucha @ 2020-01-29 14:49 UTC (permalink / raw)
  To: ltp

tst_device helper program currently cannot release any loop devices because
tst_release_device() checks whether any loop device was acquired by the same
process. If not, it'll do nothing. And since loop devices for shell test
scripts are always acquired by a different tst_device process, the check always
fails.

Call tst_detach_device() instead to bypass the check.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/old/old_device.h   | 6 ++++++
 testcases/lib/tst_device.c | 8 +++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/include/old/old_device.h b/include/old/old_device.h
index 17da57e1f..d2f1ecde5 100644
--- a/include/old/old_device.h
+++ b/include/old/old_device.h
@@ -41,6 +41,7 @@ const char *tst_dev_fs_type(void);
  * Note that you have to call tst_tmpdir() beforehand.
  *
  * Returns path to the device or NULL if it cannot be created.
+ * Call tst_release_device() when you're done.
  */
 const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size);
 
@@ -56,6 +57,11 @@ static inline const char *tst_acquire_device(void (cleanup_fn)(void))
  */
 int tst_release_device(const char *dev);
 
+/*
+ * @dev: device path returned by the tst_acquire_device()
+ */
+int tst_detach_device(const char *dev);
+
 /*
  * Just like umount() but retries several times on failure.
  * @path: Path to umount
diff --git a/testcases/lib/tst_device.c b/testcases/lib/tst_device.c
index dc47d6f03..a657db30b 100644
--- a/testcases/lib/tst_device.c
+++ b/testcases/lib/tst_device.c
@@ -60,7 +60,13 @@ static int release_device(int argc, char *argv[])
 	if (argc != 3)
 		return 1;
 
-	return tst_release_device(argv[2]);
+	/*
+	 * tst_acquire_device() was called in a different process.
+	 * tst_release_device() would think that no device was acquired yet
+	 * and do nothing. Call tst_detach_device() directly to bypass
+	 * the check.
+	 */
+	return tst_detach_device(argv[2]);
 }
 
 int main(int argc, char *argv[])
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-01-29 14:49 [LTP] [PATCH 0/3] LVM support scripts for OpenQA Martin Doucha
  2020-01-29 14:49 ` [LTP] [PATCH 1/3] Fix releasing loop devices in shell API Martin Doucha
@ 2020-01-29 14:49 ` Martin Doucha
  2020-02-03 15:24   ` Petr Vorel
  2020-02-07 16:49   ` Cyril Hrubis
  2020-01-29 14:49 ` [LTP] [PATCH 3/3] Add LVM support scripts Martin Doucha
  2 siblings, 2 replies; 16+ messages in thread
From: Martin Doucha @ 2020-01-29 14:49 UTC (permalink / raw)
  To: ltp

tst_acquire_device__() currently uses a hardcoded filename so only one loop
device can be used at a time. Allow setting arbitrary temp filename so that
multiple different loop devices can be acquired.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 include/old/old_device.h   | 15 ++++++++++++++-
 lib/tst_device.c           | 36 +++++++++++++++++++++++-------------
 testcases/lib/tst_device.c | 14 +++++++++-----
 3 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/include/old/old_device.h b/include/old/old_device.h
index d2f1ecde5..a6e9fea86 100644
--- a/include/old/old_device.h
+++ b/include/old/old_device.h
@@ -52,13 +52,26 @@ static inline const char *tst_acquire_device(void (cleanup_fn)(void))
 	return tst_acquire_device_(cleanup_fn, 0);
 }
 
+/*
+ * Acquire a loop device with specified temp filename. This function allows
+ * you to acquire multiple devices at the same time. LTP_DEV is ignored.
+ * If you call this function directly, use tst_detach_device() to release
+ * the devices. tst_release_device() will not work correctly.
+ *
+ * The return value points to a static buffer and additional calls of
+ * tst_acquire_loop_device() or tst_acquire_device() will overwrite it.
+ */
+const char *tst_acquire_loop_device(unsigned int size, const char *filename);
+
 /*
  * @dev: device path returned by the tst_acquire_device()
  */
 int tst_release_device(const char *dev);
 
 /*
- * @dev: device path returned by the tst_acquire_device()
+ * Cleanup function for tst_acquire_loop_device(). If you have acquired
+ * a device using tst_acquire_device(), use tst_release_device() instead.
+ * @dev: device path returned by the tst_acquire_loop_device()
  */
 int tst_detach_device(const char *dev);
 
diff --git a/lib/tst_device.c b/lib/tst_device.c
index 89b9c96de..ac6806e43 100644
--- a/lib/tst_device.c
+++ b/lib/tst_device.c
@@ -228,10 +228,28 @@ int tst_dev_sync(int fd)
 	return syscall(__NR_syncfs, fd);
 }
 
+const char *tst_acquire_loop_device(unsigned int size, const char *filename)
+{
+	unsigned int acq_dev_size = MAX(size, DEV_SIZE_MB);
+
+	if (tst_fill_file(filename, 0, 1024 * 1024, acq_dev_size)) {
+		tst_resm(TWARN | TERRNO, "Failed to create %s", filename);
+		return NULL;
+	}
+
+	if (tst_find_free_loopdev(dev_path, sizeof(dev_path)) == -1)
+		return NULL;
+
+	if (tst_attach_device(dev_path, filename))
+		return NULL;
+
+	return dev_path;
+}
+
 const char *tst_acquire_device__(unsigned int size)
 {
 	int fd;
-	char *dev;
+	const char *dev;
 	struct stat st;
 	unsigned int acq_dev_size;
 	uint64_t ltp_dev_size;
@@ -282,20 +300,12 @@ const char *tst_acquire_device__(unsigned int size)
 				ltp_dev_size, acq_dev_size);
 	}
 
-	if (tst_fill_file(DEV_FILE, 0, 1024 * 1024, acq_dev_size)) {
-		tst_resm(TWARN | TERRNO, "Failed to create " DEV_FILE);
-		return NULL;
-	}
-
-	if (tst_find_free_loopdev(dev_path, sizeof(dev_path)) == -1)
-		return NULL;
+	dev = tst_acquire_loop_device(acq_dev_size, DEV_FILE);
 
-	if (tst_attach_device(dev_path, DEV_FILE))
-		return NULL;
+	if (dev)
+		device_acquired = 1;
 
-	device_acquired = 1;
-
-	return dev_path;
+	return dev;
 }
 
 const char *tst_acquire_device_(void (cleanup_fn)(void), unsigned int size)
diff --git a/testcases/lib/tst_device.c b/testcases/lib/tst_device.c
index a657db30b..2a3ab1222 100644
--- a/testcases/lib/tst_device.c
+++ b/testcases/lib/tst_device.c
@@ -18,7 +18,7 @@ static struct tst_test test = {
 
 static void print_help(void)
 {
-	fprintf(stderr, "\nUsage: tst_device acquire [size]\n");
+	fprintf(stderr, "\nUsage: tst_device acquire [size [filename]]\n");
 	fprintf(stderr, "   or: tst_device release /path/to/device\n\n");
 }
 
@@ -27,10 +27,10 @@ static int acquire_device(int argc, char *argv[])
 	unsigned int size = 0;
 	const char *device;
 
-	if (argc > 3)
+	if (argc > 4)
 		return 1;
 
-	if (argc == 3) {
+	if (argc >= 3) {
 		size = atoi(argv[2]);
 
 		if (!size) {
@@ -40,7 +40,11 @@ static int acquire_device(int argc, char *argv[])
 		}
 	}
 
-	device = tst_acquire_device__(size);
+	if (argc >= 4) {
+		device = tst_acquire_loop_device(size, argv[3]);
+	} else {
+		device = tst_acquire_device__(size);
+	}
 
 	if (!device)
 		return 1;
@@ -61,7 +65,7 @@ static int release_device(int argc, char *argv[])
 		return 1;
 
 	/*
-	 * tst_acquire_device() was called in a different process.
+	 * tst_acquire_[loop_]device() was called in a different process.
 	 * tst_release_device() would think that no device was acquired yet
 	 * and do nothing. Call tst_detach_device() directly to bypass
 	 * the check.
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 3/3] Add LVM support scripts
  2020-01-29 14:49 [LTP] [PATCH 0/3] LVM support scripts for OpenQA Martin Doucha
  2020-01-29 14:49 ` [LTP] [PATCH 1/3] Fix releasing loop devices in shell API Martin Doucha
  2020-01-29 14:49 ` [LTP] [PATCH 2/3] Allow acquiring multiple loop devices Martin Doucha
@ 2020-01-29 14:49 ` Martin Doucha
  2020-01-30 12:36   ` [LTP] [PATCH v2 " Martin Doucha
  2 siblings, 1 reply; 16+ messages in thread
From: Martin Doucha @ 2020-01-29 14:49 UTC (permalink / raw)
  To: ltp

Add support scripts for LVM tests that can be used with external testing tools.
- generate_runfile.sh - Creates runtest/lvm.local with testcases for all
  locally supported FS types
- prepare_lvm.sh - Creates 2 LVM volume groups and mounts logical volumes
  for all locally supported FS types

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---
 testcases/misc/lvm/Makefile              |  29 +++++++
 testcases/misc/lvm/cleanup_lvm.sh        |  34 ++++++++
 testcases/misc/lvm/datafiles/Makefile    |  19 +++++
 testcases/misc/lvm/datafiles/runfile.tpl |  36 ++++++++
 testcases/misc/lvm/generate_runfile.sh   |  27 ++++++
 testcases/misc/lvm/prepare_lvm.sh        | 102 +++++++++++++++++++++++
 6 files changed, 247 insertions(+)
 create mode 100644 testcases/misc/lvm/Makefile
 create mode 100755 testcases/misc/lvm/cleanup_lvm.sh
 create mode 100644 testcases/misc/lvm/datafiles/Makefile
 create mode 100644 testcases/misc/lvm/datafiles/runfile.tpl
 create mode 100755 testcases/misc/lvm/generate_runfile.sh
 create mode 100755 testcases/misc/lvm/prepare_lvm.sh

diff --git a/testcases/misc/lvm/Makefile b/testcases/misc/lvm/Makefile
new file mode 100644
index 000000000..a803dd9f4
--- /dev/null
+++ b/testcases/misc/lvm/Makefile
@@ -0,0 +1,29 @@
+#
+#    misc/lvm testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Ngie Cooper, July 2009
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= generate_runfile.sh prepare_lvm.sh cleanup_lvm.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/lvm/cleanup_lvm.sh b/testcases/misc/lvm/cleanup_lvm.sh
new file mode 100755
index 000000000..e18efe2b0
--- /dev/null
+++ b/testcases/misc/lvm/cleanup_lvm.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Clean up LVM volume groups created by prepare_lvm.sh
+
+TST_TESTFUNC=cleanup_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="losetup umount vgremove"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+cleanup_lvm()
+{
+	DEVLIST=`losetup -lnO NAME,BACK-FILE | grep "$LVM_IMGDIR" | cut -d ' ' -f 1`
+
+	for dir in "$LVM_TMPDIR/"*; do
+		tst_umount $dir
+	done
+
+	ROD vgremove -y ltp_test_vg1
+	ROD vgremove -y ltp_test_vg2
+
+	for devname in $DEVLIST; do
+		ROD tst_device release $devname
+	done
+
+	rm -rf /tmp/ltp
+	tst_res TPASS "LVM configuration for LTP removed successfully."
+}
+
+tst_run
diff --git a/testcases/misc/lvm/datafiles/Makefile b/testcases/misc/lvm/datafiles/Makefile
new file mode 100644
index 000000000..25455ccbf
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/Makefile
@@ -0,0 +1,19 @@
+#
+#    Copyright (C) 2020, Linux Test Project.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+INSTALL_DIR		:= testcases/data/lvm
+INSTALL_TARGETS		:= runfile.tpl
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/lvm/datafiles/runfile.tpl b/testcases/misc/lvm/datafiles/runfile.tpl
new file mode 100644
index 000000000..9c64c68df
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/runfile.tpl
@@ -0,0 +1,36 @@
+# Check the {fsname} filesystem
+{fsname}_gf02 growfiles -W {fsname}_gf02 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
+{fsname}_gf03 growfiles -W {fsname}_gf03 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
+{fsname}_gf04 growfiles -W {fsname}_gf04 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 4090 -i 500 -t 39000 -u -f gf06_
+{fsname}_gf05 growfiles -W {fsname}_gf05 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -u -f gf07_
+{fsname}_gf16 growfiles -W {fsname}_gf16 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 4090 -T 100 -t 408990 -l -C 10 -c 1000 -S 10 -f Lgf02_
+{fsname}_gf17 growfiles -W {fsname}_gf17 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 5000 -T 100 -t 499990 -l -C 10 -c 1000 -S 10 -f Lgf03_
+{fsname}_gf18 growfiles -W {fsname}_gf18 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -w -u -r 10-5000 -I r -T 10 -l -S 2 -f Lgf04_
+{fsname}_gf19 growfiles -W {fsname}_gf19 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -o O_RDWR,O_CREAT,O_TRUNC -u -f gf08i_
+{fsname}_gf12 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo17; growfiles -W {fsname}_gf12 -b -e 1 -u -i 0 -L 30 /tmp/ltp/growfiles/{fsname}/gffifo17
+{fsname}_gf13 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo18; growfiles -W {fsname}_gf13 -b -e 1 -u -i 0 -L 30 -I r -r 1-4096 /tmp/ltp/growfiles/{fsname}/gffifo18
+{fsname}_gf01 growfiles -W {fsname}_gf01 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 /tmp/ltp/growfiles/{fsname}/glseek20 /tmp/ltp/growfiles/{fsname}/glseek20.2
+{fsname}_gf06 growfiles -W {fsname}_gf06 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand10 /tmp/ltp/growfiles/{fsname}/g_rand10.2
+{fsname}_gf07 growfiles -W {fsname}_gf07 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand13 /tmp/ltp/growfiles/{fsname}/g_rand13.2
+{fsname}_gf08 growfiles -W {fsname}_gf08 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand11 /tmp/ltp/growfiles/{fsname}/g_rand11.2
+{fsname}_gf09 growfiles -W {fsname}_gf09 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand12 /tmp/ltp/growfiles/{fsname}/g_rand12.2
+{fsname}_gf10 growfiles -W {fsname}_gf10 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I l /tmp/ltp/growfiles/{fsname}/g_lio14 /tmp/ltp/growfiles/{fsname}/g_lio14.2
+{fsname}_gf11 growfiles -W {fsname}_gf11 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I L /tmp/ltp/growfiles/{fsname}/g_lio15 /tmp/ltp/growfiles/{fsname}/g_lio15.2
+{fsname}_gf14 growfiles -W {fsname}_gf14 -b -e 1 -u -i 0 -L 20 -w -l -C 1 -T 10 /tmp/ltp/growfiles/{fsname}/glseek19 /tmp/ltp/growfiles/{fsname}/glseek19.2
+{fsname}_gf15 growfiles -W {fsname}_gf15 -b -e 1 -u -r 1-49600 -I r -u -i 0 -L 120 /tmp/ltp/growfiles/{fsname}/Lgfile1
+{fsname}_gf20 growfiles -W {fsname}_gf20 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1-256000:512 -R 512-256000 -T 4 /tmp/ltp/growfiles/{fsname}/gfbigio-$$
+{fsname}_gf21 growfiles -W {fsname}_gf21 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bld-$$
+{fsname}_gf22 growfiles -W {fsname}_gf22 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bldf-$$
+{fsname}_gf23 growfiles -W {fsname}_gf23 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 512-64000:1024 -R 1-384000 -T 4 /tmp/ltp/growfiles/{fsname}/gf-inf-$$
+{fsname}_gf24 growfiles -W {fsname}_gf24 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 /tmp/ltp/growfiles/{fsname}/gf-jbld-$$
+{fsname}_gf25 growfiles -W {fsname}_gf25 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1024000-2048000:2048 -R 4095-2048000 -T 1 /tmp/ltp/growfiles/{fsname}/gf-large-gs-$$
+{fsname}_gf26 growfiles -W {fsname}_gf26 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 128-32768:128 -R 512-64000 -T 4 /tmp/ltp/growfiles/{fsname}/gfsmallio-$$
+{fsname}_gf27 growfiles -W {fsname}_gf27 -b -D 0 -w -g 8b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-1-$$
+{fsname}_gf28 growfiles -W {fsname}_gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-2-$$
+{fsname}_gf29 growfiles -W {fsname}_gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /tmp/ltp/growfiles/{fsname}/gfsparse-3-$$
+{fsname}_gf30 growfiles -W {fsname}_gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-sync-$$
+{fsname}_rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest01%f
+{fsname}_rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest02%f
+{fsname}_rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest03%f
+{fsname}_rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest04%f
+{fsname}_rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/ltp/growfiles/{fsname}/rwtest05%f
diff --git a/testcases/misc/lvm/generate_runfile.sh b/testcases/misc/lvm/generate_runfile.sh
new file mode 100755
index 000000000..b5e979e6b
--- /dev/null
+++ b/testcases/misc/lvm/generate_runfile.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Generate LTP runfile for LVM tests (runtest/lvm.local)
+
+TST_TESTFUNC=generate_runfile
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="sed"
+. tst_test.sh
+
+generate_runfile()
+{
+	trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
+	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
+	OUTFILE="$LTPROOT/runtest/lvm.local"
+	FS_LIST=`tst_supported_fs`
+	echo -n "" >"$OUTFILE"
+
+	for fsname in $FS_LIST; do
+		sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+	done
+
+	tst_res TPASS "Runfile $OUTFILE successfully created"
+}
+
+tst_run
diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
new file mode 100755
index 000000000..64678e3b2
--- /dev/null
+++ b/testcases/misc/lvm/prepare_lvm.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Create and mount LVM volume groups for lvm.local runfile
+
+TST_TESTFUNC=prepare_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="mount pvcreate vgcreate lvcreate"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+error_check()
+{
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "LVM setup failed"
+	fi
+}
+
+create_volume()
+{
+	fsname=$2
+	ROD mkdir -p $fsname
+
+	# If the FS isn't supported, only create the mountpoint and exit
+	if ! tst_supported_fs $fsname; then
+		return
+	fi
+
+	vgname=$1
+	lvname="ltp_lv_$fsname"
+	lvdev="/dev/$vgname/$lvname"
+
+	if [ "$fsname" = "btrfs" ]; then
+		ROD lvcreate -L 512m $vgname -n "$lvname"
+	else
+		ROD lvcreate -L 256m $vgname -n "$lvname"
+	fi
+
+	tst_mkfs $fsname "$lvdev"
+	ROD mount "$lvdev" $fsname
+}
+
+prepare_mounts()
+{
+	FSNAME1=$1
+	FSNAME2=$2
+	shift 2
+	FSCOUNT=$#
+	LVM_DEV1=`tst_device acquire 272 "$LVM_IMGDIR/lvm_pv1.img"`
+	error_check
+
+	# 
+	if [ $FSNAME1 = btrfs -o $FSNAME2 = btrfs ]; then
+		LVM_DEV2=`ROD tst_device acquire 544 "$LVM_IMGDIR/lvm_pv2.img"`
+	else
+		LVM_DEV2=`ROD tst_device acquire 272 "$LVM_IMGDIR/lvm_pv2.img"`
+	fi
+
+	error_check
+
+	# DEVSIZE=($FSCOUNT * 256MB / 2) + 16MB. Btrfs gets 512MB
+	# The extra 16MB is for LVM physical volume headers
+	for fsname in $@; do
+		if [ "$fsname" = "btrfs" ]; then
+			FSCOUNT=$(( $FSCOUNT + 1 ))
+		fi
+	done
+
+	DEVSIZE=$(( $FSCOUNT * 128 + 16 ))
+	LVM_DEV3=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv3.img"`
+	error_check
+	LVM_DEV4=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv4.img"`
+	error_check
+	ROD pvcreate $LVM_DEV1 $LVM_DEV2 $LVM_DEV3 $LVM_DEV4
+	ROD vgcreate ltp_test_vg1 $LVM_DEV1 $LVM_DEV2
+	ROD vgcreate ltp_test_vg2 $LVM_DEV3 $LVM_DEV4
+
+	for fsname in $FSNAME1 $FSNAME2; do
+		create_volume ltp_test_vg1 $fsname
+	done
+
+	for fsname in $@; do
+		create_volume ltp_test_vg2 $fsname
+	done
+}
+
+prepare_lvm()
+{
+	FS_LIST=`tst_supported_fs | sort -u`
+	ROD mkdir -p "$LVM_TMPDIR"
+	ROD mkdir -p "$LVM_IMGDIR"
+	chmod 777 "$LVM_TMPDIR"
+	cd "$LVM_TMPDIR"
+	error_check
+	prepare_mounts $FS_LIST
+	tst_res TPASS "LVM mounts are ready"
+}
+
+tst_run
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH v2 3/3] Add LVM support scripts
  2020-01-29 14:49 ` [LTP] [PATCH 3/3] Add LVM support scripts Martin Doucha
@ 2020-01-30 12:36   ` Martin Doucha
  2020-01-30 14:41     ` [LTP] [PATCH v3 " Martin Doucha
  0 siblings, 1 reply; 16+ messages in thread
From: Martin Doucha @ 2020-01-30 12:36 UTC (permalink / raw)
  To: ltp

Add support scripts for LVM tests that can be used with external testing tools.
- generate_lvm_runfile.sh - Creates runtest/lvm.local with testcases for all
  locally supported FS types
- prepare_lvm.sh - Creates 2 LVM volume groups and mounts logical volumes
  for all locally supported FS types
- cleanup_lvm.sh - remove LVM volume groups created by prepare_lvm.sh and
  release the associated loop devices

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- rename generate_runfile.sh to generate_lvm_runfile.sh
- update above commit message

 testcases/misc/lvm/Makefile                |  29 ++++++
 testcases/misc/lvm/cleanup_lvm.sh          |  34 +++++++
 testcases/misc/lvm/datafiles/Makefile      |  19 ++++
 testcases/misc/lvm/datafiles/runfile.tpl   |  36 ++++++++
 testcases/misc/lvm/generate_lvm_runfile.sh |  27 ++++++
 testcases/misc/lvm/prepare_lvm.sh          | 102 +++++++++++++++++++++
 6 files changed, 247 insertions(+)
 create mode 100644 testcases/misc/lvm/Makefile
 create mode 100755 testcases/misc/lvm/cleanup_lvm.sh
 create mode 100644 testcases/misc/lvm/datafiles/Makefile
 create mode 100644 testcases/misc/lvm/datafiles/runfile.tpl
 create mode 100755 testcases/misc/lvm/generate_lvm_runfile.sh
 create mode 100755 testcases/misc/lvm/prepare_lvm.sh

diff --git a/testcases/misc/lvm/Makefile b/testcases/misc/lvm/Makefile
new file mode 100644
index 000000000..a803dd9f4
--- /dev/null
+++ b/testcases/misc/lvm/Makefile
@@ -0,0 +1,29 @@
+#
+#    misc/lvm testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Ngie Cooper, July 2009
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= generate_runfile.sh prepare_lvm.sh cleanup_lvm.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/lvm/cleanup_lvm.sh b/testcases/misc/lvm/cleanup_lvm.sh
new file mode 100755
index 000000000..e18efe2b0
--- /dev/null
+++ b/testcases/misc/lvm/cleanup_lvm.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Clean up LVM volume groups created by prepare_lvm.sh
+
+TST_TESTFUNC=cleanup_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="losetup umount vgremove"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+cleanup_lvm()
+{
+	DEVLIST=`losetup -lnO NAME,BACK-FILE | grep "$LVM_IMGDIR" | cut -d ' ' -f 1`
+
+	for dir in "$LVM_TMPDIR/"*; do
+		tst_umount $dir
+	done
+
+	ROD vgremove -y ltp_test_vg1
+	ROD vgremove -y ltp_test_vg2
+
+	for devname in $DEVLIST; do
+		ROD tst_device release $devname
+	done
+
+	rm -rf /tmp/ltp
+	tst_res TPASS "LVM configuration for LTP removed successfully."
+}
+
+tst_run
diff --git a/testcases/misc/lvm/datafiles/Makefile b/testcases/misc/lvm/datafiles/Makefile
new file mode 100644
index 000000000..25455ccbf
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/Makefile
@@ -0,0 +1,19 @@
+#
+#    Copyright (C) 2020, Linux Test Project.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+INSTALL_DIR		:= testcases/data/lvm
+INSTALL_TARGETS		:= runfile.tpl
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/lvm/datafiles/runfile.tpl b/testcases/misc/lvm/datafiles/runfile.tpl
new file mode 100644
index 000000000..9c64c68df
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/runfile.tpl
@@ -0,0 +1,36 @@
+# Check the {fsname} filesystem
+{fsname}_gf02 growfiles -W {fsname}_gf02 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
+{fsname}_gf03 growfiles -W {fsname}_gf03 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
+{fsname}_gf04 growfiles -W {fsname}_gf04 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 4090 -i 500 -t 39000 -u -f gf06_
+{fsname}_gf05 growfiles -W {fsname}_gf05 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -u -f gf07_
+{fsname}_gf16 growfiles -W {fsname}_gf16 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 4090 -T 100 -t 408990 -l -C 10 -c 1000 -S 10 -f Lgf02_
+{fsname}_gf17 growfiles -W {fsname}_gf17 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 5000 -T 100 -t 499990 -l -C 10 -c 1000 -S 10 -f Lgf03_
+{fsname}_gf18 growfiles -W {fsname}_gf18 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -w -u -r 10-5000 -I r -T 10 -l -S 2 -f Lgf04_
+{fsname}_gf19 growfiles -W {fsname}_gf19 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -o O_RDWR,O_CREAT,O_TRUNC -u -f gf08i_
+{fsname}_gf12 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo17; growfiles -W {fsname}_gf12 -b -e 1 -u -i 0 -L 30 /tmp/ltp/growfiles/{fsname}/gffifo17
+{fsname}_gf13 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo18; growfiles -W {fsname}_gf13 -b -e 1 -u -i 0 -L 30 -I r -r 1-4096 /tmp/ltp/growfiles/{fsname}/gffifo18
+{fsname}_gf01 growfiles -W {fsname}_gf01 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 /tmp/ltp/growfiles/{fsname}/glseek20 /tmp/ltp/growfiles/{fsname}/glseek20.2
+{fsname}_gf06 growfiles -W {fsname}_gf06 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand10 /tmp/ltp/growfiles/{fsname}/g_rand10.2
+{fsname}_gf07 growfiles -W {fsname}_gf07 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand13 /tmp/ltp/growfiles/{fsname}/g_rand13.2
+{fsname}_gf08 growfiles -W {fsname}_gf08 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand11 /tmp/ltp/growfiles/{fsname}/g_rand11.2
+{fsname}_gf09 growfiles -W {fsname}_gf09 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand12 /tmp/ltp/growfiles/{fsname}/g_rand12.2
+{fsname}_gf10 growfiles -W {fsname}_gf10 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I l /tmp/ltp/growfiles/{fsname}/g_lio14 /tmp/ltp/growfiles/{fsname}/g_lio14.2
+{fsname}_gf11 growfiles -W {fsname}_gf11 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I L /tmp/ltp/growfiles/{fsname}/g_lio15 /tmp/ltp/growfiles/{fsname}/g_lio15.2
+{fsname}_gf14 growfiles -W {fsname}_gf14 -b -e 1 -u -i 0 -L 20 -w -l -C 1 -T 10 /tmp/ltp/growfiles/{fsname}/glseek19 /tmp/ltp/growfiles/{fsname}/glseek19.2
+{fsname}_gf15 growfiles -W {fsname}_gf15 -b -e 1 -u -r 1-49600 -I r -u -i 0 -L 120 /tmp/ltp/growfiles/{fsname}/Lgfile1
+{fsname}_gf20 growfiles -W {fsname}_gf20 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1-256000:512 -R 512-256000 -T 4 /tmp/ltp/growfiles/{fsname}/gfbigio-$$
+{fsname}_gf21 growfiles -W {fsname}_gf21 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bld-$$
+{fsname}_gf22 growfiles -W {fsname}_gf22 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bldf-$$
+{fsname}_gf23 growfiles -W {fsname}_gf23 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 512-64000:1024 -R 1-384000 -T 4 /tmp/ltp/growfiles/{fsname}/gf-inf-$$
+{fsname}_gf24 growfiles -W {fsname}_gf24 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 /tmp/ltp/growfiles/{fsname}/gf-jbld-$$
+{fsname}_gf25 growfiles -W {fsname}_gf25 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1024000-2048000:2048 -R 4095-2048000 -T 1 /tmp/ltp/growfiles/{fsname}/gf-large-gs-$$
+{fsname}_gf26 growfiles -W {fsname}_gf26 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 128-32768:128 -R 512-64000 -T 4 /tmp/ltp/growfiles/{fsname}/gfsmallio-$$
+{fsname}_gf27 growfiles -W {fsname}_gf27 -b -D 0 -w -g 8b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-1-$$
+{fsname}_gf28 growfiles -W {fsname}_gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-2-$$
+{fsname}_gf29 growfiles -W {fsname}_gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /tmp/ltp/growfiles/{fsname}/gfsparse-3-$$
+{fsname}_gf30 growfiles -W {fsname}_gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-sync-$$
+{fsname}_rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest01%f
+{fsname}_rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest02%f
+{fsname}_rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest03%f
+{fsname}_rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest04%f
+{fsname}_rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/ltp/growfiles/{fsname}/rwtest05%f
diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
new file mode 100755
index 000000000..b5e979e6b
--- /dev/null
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Generate LTP runfile for LVM tests (runtest/lvm.local)
+
+TST_TESTFUNC=generate_runfile
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="sed"
+. tst_test.sh
+
+generate_runfile()
+{
+	trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
+	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
+	OUTFILE="$LTPROOT/runtest/lvm.local"
+	FS_LIST=`tst_supported_fs`
+	echo -n "" >"$OUTFILE"
+
+	for fsname in $FS_LIST; do
+		sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+	done
+
+	tst_res TPASS "Runfile $OUTFILE successfully created"
+}
+
+tst_run
diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
new file mode 100755
index 000000000..64678e3b2
--- /dev/null
+++ b/testcases/misc/lvm/prepare_lvm.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Create and mount LVM volume groups for lvm.local runfile
+
+TST_TESTFUNC=prepare_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="mount pvcreate vgcreate lvcreate"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+error_check()
+{
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "LVM setup failed"
+	fi
+}
+
+create_volume()
+{
+	fsname=$2
+	ROD mkdir -p $fsname
+
+	# If the FS isn't supported, only create the mountpoint and exit
+	if ! tst_supported_fs $fsname; then
+		return
+	fi
+
+	vgname=$1
+	lvname="ltp_lv_$fsname"
+	lvdev="/dev/$vgname/$lvname"
+
+	if [ "$fsname" = "btrfs" ]; then
+		ROD lvcreate -L 512m $vgname -n "$lvname"
+	else
+		ROD lvcreate -L 256m $vgname -n "$lvname"
+	fi
+
+	tst_mkfs $fsname "$lvdev"
+	ROD mount "$lvdev" $fsname
+}
+
+prepare_mounts()
+{
+	FSNAME1=$1
+	FSNAME2=$2
+	shift 2
+	FSCOUNT=$#
+	LVM_DEV1=`tst_device acquire 272 "$LVM_IMGDIR/lvm_pv1.img"`
+	error_check
+
+	# 
+	if [ $FSNAME1 = btrfs -o $FSNAME2 = btrfs ]; then
+		LVM_DEV2=`ROD tst_device acquire 544 "$LVM_IMGDIR/lvm_pv2.img"`
+	else
+		LVM_DEV2=`ROD tst_device acquire 272 "$LVM_IMGDIR/lvm_pv2.img"`
+	fi
+
+	error_check
+
+	# DEVSIZE=($FSCOUNT * 256MB / 2) + 16MB. Btrfs gets 512MB
+	# The extra 16MB is for LVM physical volume headers
+	for fsname in $@; do
+		if [ "$fsname" = "btrfs" ]; then
+			FSCOUNT=$(( $FSCOUNT + 1 ))
+		fi
+	done
+
+	DEVSIZE=$(( $FSCOUNT * 128 + 16 ))
+	LVM_DEV3=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv3.img"`
+	error_check
+	LVM_DEV4=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv4.img"`
+	error_check
+	ROD pvcreate $LVM_DEV1 $LVM_DEV2 $LVM_DEV3 $LVM_DEV4
+	ROD vgcreate ltp_test_vg1 $LVM_DEV1 $LVM_DEV2
+	ROD vgcreate ltp_test_vg2 $LVM_DEV3 $LVM_DEV4
+
+	for fsname in $FSNAME1 $FSNAME2; do
+		create_volume ltp_test_vg1 $fsname
+	done
+
+	for fsname in $@; do
+		create_volume ltp_test_vg2 $fsname
+	done
+}
+
+prepare_lvm()
+{
+	FS_LIST=`tst_supported_fs | sort -u`
+	ROD mkdir -p "$LVM_TMPDIR"
+	ROD mkdir -p "$LVM_IMGDIR"
+	chmod 777 "$LVM_TMPDIR"
+	cd "$LVM_TMPDIR"
+	error_check
+	prepare_mounts $FS_LIST
+	tst_res TPASS "LVM mounts are ready"
+}
+
+tst_run
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH v3 3/3] Add LVM support scripts
  2020-01-30 12:36   ` [LTP] [PATCH v2 " Martin Doucha
@ 2020-01-30 14:41     ` Martin Doucha
  2020-01-30 15:30       ` Petr Vorel
  2020-02-19  9:37       ` [LTP] [PATCH v4 3/4] " Martin Doucha
  0 siblings, 2 replies; 16+ messages in thread
From: Martin Doucha @ 2020-01-30 14:41 UTC (permalink / raw)
  To: ltp

Add support scripts for LVM tests that can be used with external testing tools.
- generate_lvm_runfile.sh - Creates runtest/lvm.local with testcases for all
  locally supported FS types
- prepare_lvm.sh - Creates 2 LVM volume groups and mounts logical volumes
  for all locally supported FS types
- cleanup_lvm.sh - remove LVM volume groups created by prepare_lvm.sh and
  release the associated loop devices

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Sorry for resubmitting again, I didn't test v2 properly.

Changes since v1:
- rename generate_runfile.sh to generate_lvm_runfile.sh
- update above commit message

Changes since v2:
- fix filename in misc/lvm/Makefile

 testcases/misc/lvm/Makefile                |  29 ++++++
 testcases/misc/lvm/cleanup_lvm.sh          |  34 +++++++
 testcases/misc/lvm/datafiles/Makefile      |  19 ++++
 testcases/misc/lvm/datafiles/runfile.tpl   |  36 ++++++++
 testcases/misc/lvm/generate_lvm_runfile.sh |  27 ++++++
 testcases/misc/lvm/prepare_lvm.sh          | 102 +++++++++++++++++++++
 6 files changed, 247 insertions(+)
 create mode 100644 testcases/misc/lvm/Makefile
 create mode 100755 testcases/misc/lvm/cleanup_lvm.sh
 create mode 100644 testcases/misc/lvm/datafiles/Makefile
 create mode 100644 testcases/misc/lvm/datafiles/runfile.tpl
 create mode 100755 testcases/misc/lvm/generate_lvm_runfile.sh
 create mode 100755 testcases/misc/lvm/prepare_lvm.sh

diff --git a/testcases/misc/lvm/Makefile b/testcases/misc/lvm/Makefile
new file mode 100644
index 000000000..3dbc996c8
--- /dev/null
+++ b/testcases/misc/lvm/Makefile
@@ -0,0 +1,29 @@
+#
+#    misc/lvm testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Ngie Cooper, July 2009
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= generate_lvm_runfile.sh prepare_lvm.sh cleanup_lvm.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/lvm/cleanup_lvm.sh b/testcases/misc/lvm/cleanup_lvm.sh
new file mode 100755
index 000000000..e18efe2b0
--- /dev/null
+++ b/testcases/misc/lvm/cleanup_lvm.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Clean up LVM volume groups created by prepare_lvm.sh
+
+TST_TESTFUNC=cleanup_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="losetup umount vgremove"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+cleanup_lvm()
+{
+	DEVLIST=`losetup -lnO NAME,BACK-FILE | grep "$LVM_IMGDIR" | cut -d ' ' -f 1`
+
+	for dir in "$LVM_TMPDIR/"*; do
+		tst_umount $dir
+	done
+
+	ROD vgremove -y ltp_test_vg1
+	ROD vgremove -y ltp_test_vg2
+
+	for devname in $DEVLIST; do
+		ROD tst_device release $devname
+	done
+
+	rm -rf /tmp/ltp
+	tst_res TPASS "LVM configuration for LTP removed successfully."
+}
+
+tst_run
diff --git a/testcases/misc/lvm/datafiles/Makefile b/testcases/misc/lvm/datafiles/Makefile
new file mode 100644
index 000000000..25455ccbf
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/Makefile
@@ -0,0 +1,19 @@
+#
+#    Copyright (C) 2020, Linux Test Project.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+INSTALL_DIR		:= testcases/data/lvm
+INSTALL_TARGETS		:= runfile.tpl
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/lvm/datafiles/runfile.tpl b/testcases/misc/lvm/datafiles/runfile.tpl
new file mode 100644
index 000000000..9c64c68df
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/runfile.tpl
@@ -0,0 +1,36 @@
+# Check the {fsname} filesystem
+{fsname}_gf02 growfiles -W {fsname}_gf02 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
+{fsname}_gf03 growfiles -W {fsname}_gf03 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
+{fsname}_gf04 growfiles -W {fsname}_gf04 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 4090 -i 500 -t 39000 -u -f gf06_
+{fsname}_gf05 growfiles -W {fsname}_gf05 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -u -f gf07_
+{fsname}_gf16 growfiles -W {fsname}_gf16 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 4090 -T 100 -t 408990 -l -C 10 -c 1000 -S 10 -f Lgf02_
+{fsname}_gf17 growfiles -W {fsname}_gf17 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 5000 -T 100 -t 499990 -l -C 10 -c 1000 -S 10 -f Lgf03_
+{fsname}_gf18 growfiles -W {fsname}_gf18 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -w -u -r 10-5000 -I r -T 10 -l -S 2 -f Lgf04_
+{fsname}_gf19 growfiles -W {fsname}_gf19 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -o O_RDWR,O_CREAT,O_TRUNC -u -f gf08i_
+{fsname}_gf12 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo17; growfiles -W {fsname}_gf12 -b -e 1 -u -i 0 -L 30 /tmp/ltp/growfiles/{fsname}/gffifo17
+{fsname}_gf13 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo18; growfiles -W {fsname}_gf13 -b -e 1 -u -i 0 -L 30 -I r -r 1-4096 /tmp/ltp/growfiles/{fsname}/gffifo18
+{fsname}_gf01 growfiles -W {fsname}_gf01 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 /tmp/ltp/growfiles/{fsname}/glseek20 /tmp/ltp/growfiles/{fsname}/glseek20.2
+{fsname}_gf06 growfiles -W {fsname}_gf06 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand10 /tmp/ltp/growfiles/{fsname}/g_rand10.2
+{fsname}_gf07 growfiles -W {fsname}_gf07 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand13 /tmp/ltp/growfiles/{fsname}/g_rand13.2
+{fsname}_gf08 growfiles -W {fsname}_gf08 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand11 /tmp/ltp/growfiles/{fsname}/g_rand11.2
+{fsname}_gf09 growfiles -W {fsname}_gf09 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand12 /tmp/ltp/growfiles/{fsname}/g_rand12.2
+{fsname}_gf10 growfiles -W {fsname}_gf10 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I l /tmp/ltp/growfiles/{fsname}/g_lio14 /tmp/ltp/growfiles/{fsname}/g_lio14.2
+{fsname}_gf11 growfiles -W {fsname}_gf11 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I L /tmp/ltp/growfiles/{fsname}/g_lio15 /tmp/ltp/growfiles/{fsname}/g_lio15.2
+{fsname}_gf14 growfiles -W {fsname}_gf14 -b -e 1 -u -i 0 -L 20 -w -l -C 1 -T 10 /tmp/ltp/growfiles/{fsname}/glseek19 /tmp/ltp/growfiles/{fsname}/glseek19.2
+{fsname}_gf15 growfiles -W {fsname}_gf15 -b -e 1 -u -r 1-49600 -I r -u -i 0 -L 120 /tmp/ltp/growfiles/{fsname}/Lgfile1
+{fsname}_gf20 growfiles -W {fsname}_gf20 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1-256000:512 -R 512-256000 -T 4 /tmp/ltp/growfiles/{fsname}/gfbigio-$$
+{fsname}_gf21 growfiles -W {fsname}_gf21 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bld-$$
+{fsname}_gf22 growfiles -W {fsname}_gf22 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bldf-$$
+{fsname}_gf23 growfiles -W {fsname}_gf23 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 512-64000:1024 -R 1-384000 -T 4 /tmp/ltp/growfiles/{fsname}/gf-inf-$$
+{fsname}_gf24 growfiles -W {fsname}_gf24 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 /tmp/ltp/growfiles/{fsname}/gf-jbld-$$
+{fsname}_gf25 growfiles -W {fsname}_gf25 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1024000-2048000:2048 -R 4095-2048000 -T 1 /tmp/ltp/growfiles/{fsname}/gf-large-gs-$$
+{fsname}_gf26 growfiles -W {fsname}_gf26 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 128-32768:128 -R 512-64000 -T 4 /tmp/ltp/growfiles/{fsname}/gfsmallio-$$
+{fsname}_gf27 growfiles -W {fsname}_gf27 -b -D 0 -w -g 8b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-1-$$
+{fsname}_gf28 growfiles -W {fsname}_gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-2-$$
+{fsname}_gf29 growfiles -W {fsname}_gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /tmp/ltp/growfiles/{fsname}/gfsparse-3-$$
+{fsname}_gf30 growfiles -W {fsname}_gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-sync-$$
+{fsname}_rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest01%f
+{fsname}_rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest02%f
+{fsname}_rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest03%f
+{fsname}_rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest04%f
+{fsname}_rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/ltp/growfiles/{fsname}/rwtest05%f
diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
new file mode 100755
index 000000000..b5e979e6b
--- /dev/null
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Generate LTP runfile for LVM tests (runtest/lvm.local)
+
+TST_TESTFUNC=generate_runfile
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="sed"
+. tst_test.sh
+
+generate_runfile()
+{
+	trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
+	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
+	OUTFILE="$LTPROOT/runtest/lvm.local"
+	FS_LIST=`tst_supported_fs`
+	echo -n "" >"$OUTFILE"
+
+	for fsname in $FS_LIST; do
+		sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+	done
+
+	tst_res TPASS "Runfile $OUTFILE successfully created"
+}
+
+tst_run
diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
new file mode 100755
index 000000000..64678e3b2
--- /dev/null
+++ b/testcases/misc/lvm/prepare_lvm.sh
@@ -0,0 +1,102 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Create and mount LVM volume groups for lvm.local runfile
+
+TST_TESTFUNC=prepare_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="mount pvcreate vgcreate lvcreate"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+error_check()
+{
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "LVM setup failed"
+	fi
+}
+
+create_volume()
+{
+	fsname=$2
+	ROD mkdir -p $fsname
+
+	# If the FS isn't supported, only create the mountpoint and exit
+	if ! tst_supported_fs $fsname; then
+		return
+	fi
+
+	vgname=$1
+	lvname="ltp_lv_$fsname"
+	lvdev="/dev/$vgname/$lvname"
+
+	if [ "$fsname" = "btrfs" ]; then
+		ROD lvcreate -L 512m $vgname -n "$lvname"
+	else
+		ROD lvcreate -L 256m $vgname -n "$lvname"
+	fi
+
+	tst_mkfs $fsname "$lvdev"
+	ROD mount "$lvdev" $fsname
+}
+
+prepare_mounts()
+{
+	FSNAME1=$1
+	FSNAME2=$2
+	shift 2
+	FSCOUNT=$#
+	LVM_DEV1=`tst_device acquire 272 "$LVM_IMGDIR/lvm_pv1.img"`
+	error_check
+
+	# 
+	if [ $FSNAME1 = btrfs -o $FSNAME2 = btrfs ]; then
+		LVM_DEV2=`ROD tst_device acquire 544 "$LVM_IMGDIR/lvm_pv2.img"`
+	else
+		LVM_DEV2=`ROD tst_device acquire 272 "$LVM_IMGDIR/lvm_pv2.img"`
+	fi
+
+	error_check
+
+	# DEVSIZE=($FSCOUNT * 256MB / 2) + 16MB. Btrfs gets 512MB
+	# The extra 16MB is for LVM physical volume headers
+	for fsname in $@; do
+		if [ "$fsname" = "btrfs" ]; then
+			FSCOUNT=$(( $FSCOUNT + 1 ))
+		fi
+	done
+
+	DEVSIZE=$(( $FSCOUNT * 128 + 16 ))
+	LVM_DEV3=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv3.img"`
+	error_check
+	LVM_DEV4=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv4.img"`
+	error_check
+	ROD pvcreate $LVM_DEV1 $LVM_DEV2 $LVM_DEV3 $LVM_DEV4
+	ROD vgcreate ltp_test_vg1 $LVM_DEV1 $LVM_DEV2
+	ROD vgcreate ltp_test_vg2 $LVM_DEV3 $LVM_DEV4
+
+	for fsname in $FSNAME1 $FSNAME2; do
+		create_volume ltp_test_vg1 $fsname
+	done
+
+	for fsname in $@; do
+		create_volume ltp_test_vg2 $fsname
+	done
+}
+
+prepare_lvm()
+{
+	FS_LIST=`tst_supported_fs | sort -u`
+	ROD mkdir -p "$LVM_TMPDIR"
+	ROD mkdir -p "$LVM_IMGDIR"
+	chmod 777 "$LVM_TMPDIR"
+	cd "$LVM_TMPDIR"
+	error_check
+	prepare_mounts $FS_LIST
+	tst_res TPASS "LVM mounts are ready"
+}
+
+tst_run
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH v3 3/3] Add LVM support scripts
  2020-01-30 14:41     ` [LTP] [PATCH v3 " Martin Doucha
@ 2020-01-30 15:30       ` Petr Vorel
  2020-02-19  9:37       ` [LTP] [PATCH v4 3/4] " Martin Doucha
  1 sibling, 0 replies; 16+ messages in thread
From: Petr Vorel @ 2020-01-30 15:30 UTC (permalink / raw)
  To: ltp

Hi Martin,

thanks for fixing these scripts, they were waiting long for it :).

> Changes since v2:
> - fix filename in misc/lvm/Makefile
You can just use *.sh next time.

> +++ b/testcases/misc/lvm/cleanup_lvm.sh
Maybe we can move them to testcases/lvm, but that's tiny detail.

> @@ -0,0 +1,34 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0-or-later
> +# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
> +#
> +# Clean up LVM volume groups created by prepare_lvm.sh
> +
> +TST_TESTFUNC=cleanup_lvm
> +TST_NEEDS_ROOT=1
> +TST_NEEDS_CMDS="losetup umount vgremove"
> +. tst_test.sh
> +
> +LVM_TMPDIR="/tmp/ltp/growfiles"
> +LVM_IMGDIR="/tmp/ltp/imgfiles"
Can we use TST_NEEDS_TMPDIR=1 and relative paths?

> +
> +cleanup_lvm()
> +{
> +	DEVLIST=`losetup -lnO NAME,BACK-FILE | grep "$LVM_IMGDIR" | cut -d ' ' -f 1`
> +
> +	for dir in "$LVM_TMPDIR/"*; do
> +		tst_umount $dir
> +	done
> +
> +	ROD vgremove -y ltp_test_vg1
> +	ROD vgremove -y ltp_test_vg2
> +
> +	for devname in $DEVLIST; do
> +		ROD tst_device release $devname
> +	done
> +
> +	rm -rf /tmp/ltp
> +	tst_res TPASS "LVM configuration for LTP removed successfully."
> +}
> +
> +tst_run
...
> --- /dev/null
> +++ b/testcases/misc/lvm/datafiles/runfile.tpl
> @@ -0,0 +1,36 @@
> +# Check the {fsname} filesystem
> +{fsname}_gf02 growfiles -W {fsname}_gf02 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -L 10 -i 100 -I p -S 2 -u -f gf03_
> +{fsname}_gf03 growfiles -W {fsname}_gf03 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
> +{fsname}_gf04 growfiles -W {fsname}_gf04 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 4090 -i 500 -t 39000 -u -f gf06_
> +{fsname}_gf05 growfiles -W {fsname}_gf05 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -u -f gf07_
> +{fsname}_gf16 growfiles -W {fsname}_gf16 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 4090 -T 100 -t 408990 -l -C 10 -c 1000 -S 10 -f Lgf02_
> +{fsname}_gf17 growfiles -W {fsname}_gf17 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -u -g 5000 -T 100 -t 499990 -l -C 10 -c 1000 -S 10 -f Lgf03_
> +{fsname}_gf18 growfiles -W {fsname}_gf18 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -w -u -r 10-5000 -I r -T 10 -l -S 2 -f Lgf04_
> +{fsname}_gf19 growfiles -W {fsname}_gf19 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -o O_RDWR,O_CREAT,O_TRUNC -u -f gf08i_
> +{fsname}_gf12 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo17; growfiles -W {fsname}_gf12 -b -e 1 -u -i 0 -L 30 /tmp/ltp/growfiles/{fsname}/gffifo17
> +{fsname}_gf13 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo18; growfiles -W {fsname}_gf13 -b -e 1 -u -i 0 -L 30 -I r -r 1-4096 /tmp/ltp/growfiles/{fsname}/gffifo18
> +{fsname}_gf01 growfiles -W {fsname}_gf01 -b -e 1 -u -i 0 -L 20 -w -C 1 -l -I r -T 10 /tmp/ltp/growfiles/{fsname}/glseek20 /tmp/ltp/growfiles/{fsname}/glseek20.2
> +{fsname}_gf06 growfiles -W {fsname}_gf06 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand10 /tmp/ltp/growfiles/{fsname}/g_rand10.2
> +{fsname}_gf07 growfiles -W {fsname}_gf07 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand13 /tmp/ltp/growfiles/{fsname}/g_rand13.2
> +{fsname}_gf08 growfiles -W {fsname}_gf08 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand11 /tmp/ltp/growfiles/{fsname}/g_rand11.2
> +{fsname}_gf09 growfiles -W {fsname}_gf09 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand12 /tmp/ltp/growfiles/{fsname}/g_rand12.2
> +{fsname}_gf10 growfiles -W {fsname}_gf10 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I l /tmp/ltp/growfiles/{fsname}/g_lio14 /tmp/ltp/growfiles/{fsname}/g_lio14.2
> +{fsname}_gf11 growfiles -W {fsname}_gf11 -b -e 1 -u -r 1-5000 -i 0 -L 30 -C 1 -I L /tmp/ltp/growfiles/{fsname}/g_lio15 /tmp/ltp/growfiles/{fsname}/g_lio15.2
> +{fsname}_gf14 growfiles -W {fsname}_gf14 -b -e 1 -u -i 0 -L 20 -w -l -C 1 -T 10 /tmp/ltp/growfiles/{fsname}/glseek19 /tmp/ltp/growfiles/{fsname}/glseek19.2
> +{fsname}_gf15 growfiles -W {fsname}_gf15 -b -e 1 -u -r 1-49600 -I r -u -i 0 -L 120 /tmp/ltp/growfiles/{fsname}/Lgfile1
> +{fsname}_gf20 growfiles -W {fsname}_gf20 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1-256000:512 -R 512-256000 -T 4 /tmp/ltp/growfiles/{fsname}/gfbigio-$$
> +{fsname}_gf21 growfiles -W {fsname}_gf21 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bld-$$
> +{fsname}_gf22 growfiles -W {fsname}_gf22 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bldf-$$
> +{fsname}_gf23 growfiles -W {fsname}_gf23 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 512-64000:1024 -R 1-384000 -T 4 /tmp/ltp/growfiles/{fsname}/gf-inf-$$
> +{fsname}_gf24 growfiles -W {fsname}_gf24 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 /tmp/ltp/growfiles/{fsname}/gf-jbld-$$
> +{fsname}_gf25 growfiles -W {fsname}_gf25 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1024000-2048000:2048 -R 4095-2048000 -T 1 /tmp/ltp/growfiles/{fsname}/gf-large-gs-$$
> +{fsname}_gf26 growfiles -W {fsname}_gf26 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 128-32768:128 -R 512-64000 -T 4 /tmp/ltp/growfiles/{fsname}/gfsmallio-$$
> +{fsname}_gf27 growfiles -W {fsname}_gf27 -b -D 0 -w -g 8b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-1-$$
> +{fsname}_gf28 growfiles -W {fsname}_gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-2-$$
> +{fsname}_gf29 growfiles -W {fsname}_gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -C 1 -u /tmp/ltp/growfiles/{fsname}/gfsparse-3-$$
> +{fsname}_gf30 growfiles -W {fsname}_gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-sync-$$
> +{fsname}_rwtest01 export LTPROOT; rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest01%f
> +{fsname}_rwtest02 export LTPROOT; rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest02%f
> +{fsname}_rwtest03 export LTPROOT; rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest03%f
> +{fsname}_rwtest04 export LTPROOT; rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest04%f
> +{fsname}_rwtest05 export LTPROOT; rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/ltp/growfiles/{fsname}/rwtest05%f
BTW part of the cleanup it'd be nice to get rid of 'export LTPROOT;'

BTW I wonder whether we still need testscripts/ltpfslvm.sh testscripts/ltpfsnolvm.sh,
which use runtest/lvm.part1 and runtest/lvm.part1?


Kind regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 1/3] Fix releasing loop devices in shell API
  2020-01-29 14:49 ` [LTP] [PATCH 1/3] Fix releasing loop devices in shell API Martin Doucha
@ 2020-02-03 15:05   ` Petr Vorel
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Vorel @ 2020-02-03 15:05 UTC (permalink / raw)
  To: ltp

Hi Martin,

> tst_device helper program currently cannot release any loop devices because
> tst_release_device() checks whether any loop device was acquired by the same
> process. If not, it'll do nothing. And since loop devices for shell test
> scripts are always acquired by a different tst_device process, the check always
> fails.

> Call tst_detach_device() instead to bypass the check.

Indeed losetup --list shows increasing list of the devices.
Thanks for a fix, pushed.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-01-29 14:49 ` [LTP] [PATCH 2/3] Allow acquiring multiple loop devices Martin Doucha
@ 2020-02-03 15:24   ` Petr Vorel
  2020-02-07 16:45     ` Cyril Hrubis
  2020-02-07 16:49   ` Cyril Hrubis
  1 sibling, 1 reply; 16+ messages in thread
From: Petr Vorel @ 2020-02-03 15:24 UTC (permalink / raw)
  To: ltp

Hi Martin,

> tst_acquire_device__() currently uses a hardcoded filename so only one loop
> device can be used at a time. Allow setting arbitrary temp filename so that
> multiple different loop devices can be acquired.

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
Reviewed-by: Petr Vorel <pvorel@suse.cz>
Good idea, thanks!

BTW IMHO DEV_FILE should be #define DEV_FILE "test_dev.%d.img", where %d would
be PID to fix clash when tests run in paralel (e.g. mkswap01.sh and df01.sh).
I'll send a patch tomorrow, based on this one.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-02-03 15:24   ` Petr Vorel
@ 2020-02-07 16:45     ` Cyril Hrubis
  2020-02-07 17:07       ` Petr Vorel
  0 siblings, 1 reply; 16+ messages in thread
From: Cyril Hrubis @ 2020-02-07 16:45 UTC (permalink / raw)
  To: ltp

Hi!
> > tst_acquire_device__() currently uses a hardcoded filename so only one loop
> > device can be used at a time. Allow setting arbitrary temp filename so that
> > multiple different loop devices can be acquired.
> 
> > Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> Reviewed-by: Petr Vorel <pvorel@suse.cz>
> Good idea, thanks!
> 
> BTW IMHO DEV_FILE should be #define DEV_FILE "test_dev.%d.img", where %d would
> be PID to fix clash when tests run in paralel (e.g. mkswap01.sh and df01.sh).
> I'll send a patch tomorrow, based on this one.

Huh, do we even attempt to support parallel runs at this point? I doubt
so.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-01-29 14:49 ` [LTP] [PATCH 2/3] Allow acquiring multiple loop devices Martin Doucha
  2020-02-03 15:24   ` Petr Vorel
@ 2020-02-07 16:49   ` Cyril Hrubis
  1 sibling, 0 replies; 16+ messages in thread
From: Cyril Hrubis @ 2020-02-07 16:49 UTC (permalink / raw)
  To: ltp

Hi!
This part looks fine.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-02-07 16:45     ` Cyril Hrubis
@ 2020-02-07 17:07       ` Petr Vorel
  2020-02-07 17:11         ` Cyril Hrubis
  0 siblings, 1 reply; 16+ messages in thread
From: Petr Vorel @ 2020-02-07 17:07 UTC (permalink / raw)
  To: ltp

Hi Cyril,

> > BTW IMHO DEV_FILE should be #define DEV_FILE "test_dev.%d.img", where %d would
> > be PID to fix clash when tests run in paralel (e.g. mkswap01.sh and df01.sh).
> > I'll send a patch tomorrow, based on this one.

> Huh, do we even attempt to support parallel runs at this point? I doubt
> so.
No, but I'd expect it'd be nice to have this support for runltp-ng. Or not?

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-02-07 17:07       ` Petr Vorel
@ 2020-02-07 17:11         ` Cyril Hrubis
  2020-02-10 15:48           ` Petr Vorel
  0 siblings, 1 reply; 16+ messages in thread
From: Cyril Hrubis @ 2020-02-07 17:11 UTC (permalink / raw)
  To: ltp

Hi!
> > > BTW IMHO DEV_FILE should be #define DEV_FILE "test_dev.%d.img", where %d would
> > > be PID to fix clash when tests run in paralel (e.g. mkswap01.sh and df01.sh).
> > > I'll send a patch tomorrow, based on this one.
> 
> > Huh, do we even attempt to support parallel runs at this point? I doubt
> > so.
> No, but I'd expect it'd be nice to have this support for runltp-ng. Or not?

We will fix this, when we get there. Also thinking of it the file that
is backing the device is actually created in the test temporary
directory, which has unique name anyways.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH 2/3] Allow acquiring multiple loop devices
  2020-02-07 17:11         ` Cyril Hrubis
@ 2020-02-10 15:48           ` Petr Vorel
  0 siblings, 0 replies; 16+ messages in thread
From: Petr Vorel @ 2020-02-10 15:48 UTC (permalink / raw)
  To: ltp

Hi,

> > > > BTW IMHO DEV_FILE should be #define DEV_FILE "test_dev.%d.img", where %d would
> > > > be PID to fix clash when tests run in paralel (e.g. mkswap01.sh and df01.sh).
> > > > I'll send a patch tomorrow, based on this one.

> > > Huh, do we even attempt to support parallel runs at this point? I doubt
> > > so.
> > No, but I'd expect it'd be nice to have this support for runltp-ng. Or not?

> We will fix this, when we get there. Also thinking of it the file that
> is backing the device is actually created in the test temporary
> directory, which has unique name anyways.
If I remember it correctly, the file was in /tmp directory (the default)
(probably before creating temporary directory and cd into it).
I was really able to crash on tests, when running 2 in paralel.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [LTP] [PATCH v4 3/4] Add LVM support scripts
  2020-01-30 14:41     ` [LTP] [PATCH v3 " Martin Doucha
  2020-01-30 15:30       ` Petr Vorel
@ 2020-02-19  9:37       ` Martin Doucha
  2020-02-19  9:37         ` [LTP] [PATCH v4 4/4] Skip Btrfs in LVM stress tests Martin Doucha
  1 sibling, 1 reply; 16+ messages in thread
From: Martin Doucha @ 2020-02-19  9:37 UTC (permalink / raw)
  To: ltp

Add support scripts for LVM tests that can be used with external testing tools.
- generate_lvm_runfile.sh - Creates runtest/lvm.local with testcases for all
  locally supported FS types
- prepare_lvm.sh - Creates 2 LVM volume groups and mounts logical volumes
  for all locally supported FS types
- cleanup_lvm.sh - remove LVM volume groups created by prepare_lvm.sh and
  release the associated loop devices

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v1:
- rename generate_runfile.sh to generate_lvm_runfile.sh
- update above commit message

Changes since v2:
- fix filename in misc/lvm/Makefile

Changes since v3:
- LVM volume size increased to 1GB
- cleaned up some useless code in runfile template
- test cases with `growfiles -L ...` limited to 768MB of disk space

 testcases/misc/lvm/Makefile                | 29 ++++++++
 testcases/misc/lvm/cleanup_lvm.sh          | 34 +++++++++
 testcases/misc/lvm/datafiles/Makefile      | 19 +++++
 testcases/misc/lvm/datafiles/runfile.tpl   | 36 ++++++++++
 testcases/misc/lvm/generate_lvm_runfile.sh | 27 +++++++
 testcases/misc/lvm/prepare_lvm.sh          | 83 ++++++++++++++++++++++
 6 files changed, 228 insertions(+)
 create mode 100644 testcases/misc/lvm/Makefile
 create mode 100755 testcases/misc/lvm/cleanup_lvm.sh
 create mode 100644 testcases/misc/lvm/datafiles/Makefile
 create mode 100644 testcases/misc/lvm/datafiles/runfile.tpl
 create mode 100755 testcases/misc/lvm/generate_lvm_runfile.sh
 create mode 100755 testcases/misc/lvm/prepare_lvm.sh

diff --git a/testcases/misc/lvm/Makefile b/testcases/misc/lvm/Makefile
new file mode 100644
index 000000000..3dbc996c8
--- /dev/null
+++ b/testcases/misc/lvm/Makefile
@@ -0,0 +1,29 @@
+#
+#    misc/lvm testcases Makefile.
+#
+#    Copyright (C) 2009, Cisco Systems Inc.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+#
+#    You should have received a copy of the GNU General Public License along
+#    with this program; if not, write to the Free Software Foundation, Inc.,
+#    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Ngie Cooper, July 2009
+#
+
+top_srcdir		?= ../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+
+INSTALL_TARGETS		:= generate_lvm_runfile.sh prepare_lvm.sh cleanup_lvm.sh
+
+include $(top_srcdir)/include/mk/generic_trunk_target.mk
diff --git a/testcases/misc/lvm/cleanup_lvm.sh b/testcases/misc/lvm/cleanup_lvm.sh
new file mode 100755
index 000000000..e18efe2b0
--- /dev/null
+++ b/testcases/misc/lvm/cleanup_lvm.sh
@@ -0,0 +1,34 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Clean up LVM volume groups created by prepare_lvm.sh
+
+TST_TESTFUNC=cleanup_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="losetup umount vgremove"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+cleanup_lvm()
+{
+	DEVLIST=`losetup -lnO NAME,BACK-FILE | grep "$LVM_IMGDIR" | cut -d ' ' -f 1`
+
+	for dir in "$LVM_TMPDIR/"*; do
+		tst_umount $dir
+	done
+
+	ROD vgremove -y ltp_test_vg1
+	ROD vgremove -y ltp_test_vg2
+
+	for devname in $DEVLIST; do
+		ROD tst_device release $devname
+	done
+
+	rm -rf /tmp/ltp
+	tst_res TPASS "LVM configuration for LTP removed successfully."
+}
+
+tst_run
diff --git a/testcases/misc/lvm/datafiles/Makefile b/testcases/misc/lvm/datafiles/Makefile
new file mode 100644
index 000000000..25455ccbf
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/Makefile
@@ -0,0 +1,19 @@
+#
+#    Copyright (C) 2020, Linux Test Project.
+#
+#    This program is free software; you can redistribute it and/or modify
+#    it under the terms of the GNU General Public License as published by
+#    the Free Software Foundation; either version 2 of the License, or
+#    (at your option) any later version.
+#
+#    This program is distributed in the hope that it will be useful,
+#    but WITHOUT ANY WARRANTY; without even the implied warranty of
+#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#    GNU General Public License for more details.
+
+top_srcdir		?= ../../../..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+INSTALL_DIR		:= testcases/data/lvm
+INSTALL_TARGETS		:= runfile.tpl
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/misc/lvm/datafiles/runfile.tpl b/testcases/misc/lvm/datafiles/runfile.tpl
new file mode 100644
index 000000000..0c6080236
--- /dev/null
+++ b/testcases/misc/lvm/datafiles/runfile.tpl
@@ -0,0 +1,36 @@
+# Check the {fsname} filesystem
+{fsname}_gf02 growfiles -W {fsname}_gf02 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -L 10 -B 805306368 -i 100 -I p -S 2 -u -f gf03_
+{fsname}_gf03 growfiles -W {fsname}_gf03 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 1 -i 1 -S 150 -u -f gf05_
+{fsname}_gf04 growfiles -W {fsname}_gf04 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 4090 -i 500 -t 39000 -u -f gf06_
+{fsname}_gf05 growfiles -W {fsname}_gf05 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -u -f gf07_
+{fsname}_gf16 growfiles -W {fsname}_gf16 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -B 805306368 -u -g 4090 -T 100 -t 408990 -l -C 10 -c 1000 -S 10 -f Lgf02_
+{fsname}_gf17 growfiles -W {fsname}_gf17 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -B 805306368 -u -g 5000 -T 100 -t 499990 -l -C 10 -c 1000 -S 10 -f Lgf03_
+{fsname}_gf18 growfiles -W {fsname}_gf18 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -i 0 -L 120 -B 805306368 -w -u -r 10-5000 -I r -T 10 -l -S 2 -f Lgf04_
+{fsname}_gf19 growfiles -W {fsname}_gf19 -d /tmp/ltp/growfiles/{fsname} -b -e 1 -g 5000 -i 500 -t 49900 -T10 -c9 -I p -o O_RDWR,O_CREAT,O_TRUNC -u -f gf08i_
+{fsname}_gf12 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo17; growfiles -W {fsname}_gf12 -b -e 1 -u -i 0 -L 30 -B 805306368 /tmp/ltp/growfiles/{fsname}/gffifo17
+{fsname}_gf13 mkfifo /tmp/ltp/growfiles/{fsname}/gffifo18; growfiles -W {fsname}_gf13 -b -e 1 -u -i 0 -L 30 -B 805306368 -I r -r 1-4096 /tmp/ltp/growfiles/{fsname}/gffifo18
+{fsname}_gf01 growfiles -W {fsname}_gf01 -b -e 1 -u -i 0 -L 20 -B 805306368 -w -C 1 -l -I r -T 10 /tmp/ltp/growfiles/{fsname}/glseek20 /tmp/ltp/growfiles/{fsname}/glseek20.2
+{fsname}_gf06 growfiles -W {fsname}_gf06 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -B 805306368 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand10 /tmp/ltp/growfiles/{fsname}/g_rand10.2
+{fsname}_gf07 growfiles -W {fsname}_gf07 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -B 805306368 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand13 /tmp/ltp/growfiles/{fsname}/g_rand13.2
+{fsname}_gf08 growfiles -W {fsname}_gf08 -b -e 1 -u -r 1-5000 -R 0--2 -i 0 -L 30 -B 805306368 -C 1 /tmp/ltp/growfiles/{fsname}/g_rand11 /tmp/ltp/growfiles/{fsname}/g_rand11.2
+{fsname}_gf09 growfiles -W {fsname}_gf09 -b -e 1 -u -r 1-5000 -R 0--1 -i 0 -L 30 -B 805306368 -C 1 -I p /tmp/ltp/growfiles/{fsname}/g_rand12 /tmp/ltp/growfiles/{fsname}/g_rand12.2
+{fsname}_gf10 growfiles -W {fsname}_gf10 -b -e 1 -u -r 1-5000 -i 0 -L 30 -B 805306368 -C 1 -I l /tmp/ltp/growfiles/{fsname}/g_lio14 /tmp/ltp/growfiles/{fsname}/g_lio14.2
+{fsname}_gf11 growfiles -W {fsname}_gf11 -b -e 1 -u -r 1-5000 -i 0 -L 30 -B 805306368 -C 1 -I L /tmp/ltp/growfiles/{fsname}/g_lio15 /tmp/ltp/growfiles/{fsname}/g_lio15.2
+{fsname}_gf14 growfiles -W {fsname}_gf14 -b -e 1 -u -i 0 -L 20 -B 805306368 -w -l -C 1 -T 10 /tmp/ltp/growfiles/{fsname}/glseek19 /tmp/ltp/growfiles/{fsname}/glseek19.2
+{fsname}_gf15 growfiles -W {fsname}_gf15 -b -e 1 -u -r 1-49600 -I r -u -i 0 -L 120 -B 805306368 /tmp/ltp/growfiles/{fsname}/Lgfile1
+{fsname}_gf20 growfiles -W {fsname}_gf20 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1-256000:512 -R 512-256000 -T 4 /tmp/ltp/growfiles/{fsname}/gfbigio-$$
+{fsname}_gf21 growfiles -W {fsname}_gf21 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bld-$$
+{fsname}_gf22 growfiles -W {fsname}_gf22 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-bldf-$$
+{fsname}_gf23 growfiles -W {fsname}_gf23 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 512-64000:1024 -R 1-384000 -T 4 /tmp/ltp/growfiles/{fsname}/gf-inf-$$
+{fsname}_gf24 growfiles -W {fsname}_gf24 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -g 20480 /tmp/ltp/growfiles/{fsname}/gf-jbld-$$
+{fsname}_gf25 growfiles -W {fsname}_gf25 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 1024000-2048000:2048 -R 4095-2048000 -T 1 /tmp/ltp/growfiles/{fsname}/gf-large-gs-$$
+{fsname}_gf26 growfiles -W {fsname}_gf26 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -r 128-32768:128 -R 512-64000 -T 4 /tmp/ltp/growfiles/{fsname}/gfsmallio-$$
+{fsname}_gf27 growfiles -W {fsname}_gf27 -b -D 0 -w -g 8b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-1-$$
+{fsname}_gf28 growfiles -W {fsname}_gf28 -b -D 0 -w -g 16b -C 1 -b -i 1000 -u /tmp/ltp/growfiles/{fsname}/gfsparse-2-$$
+{fsname}_gf29 growfiles -W {fsname}_gf29 -b -D 0 -r 1-4096 -R 0-33554432 -i 0 -L 60 -B 805306368 -C 1 -u /tmp/ltp/growfiles/{fsname}/gfsparse-3-$$
+{fsname}_gf30 growfiles -W {fsname}_gf30 -D 0 -b -i 0 -L 60 -u -B 1000b -e 1 -o O_RDWR,O_CREAT,O_SYNC -g 20480 -T 10 -t 20480 /tmp/ltp/growfiles/{fsname}/gf-sync-$$
+{fsname}_rwtest01 rwtest -N rwtest01 -c -q -i 60s  -f sync 10%25000:rw-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest01%f
+{fsname}_rwtest02 rwtest -N rwtest02 -c -q -i 60s  -f buffered 10%25000:rw-buffered-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest02%f
+{fsname}_rwtest03 rwtest -N rwtest03 -c -q -i 60s -n 2  -f buffered -s mmread,mmwrite -m random -Dv 10%25000:mm-buff-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest03%f
+{fsname}_rwtest04 rwtest -N rwtest04 -c -q -i 60s -n 2  -f sync -s mmread,mmwrite -m random -Dv 10%25000:mm-sync-$$ 500b:/tmp/ltp/growfiles/{fsname}/rwtest04%f
+{fsname}_rwtest05 rwtest -N rwtest05 -c -q -i 50 -T 64b 500b:/tmp/ltp/growfiles/{fsname}/rwtest05%f
diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
new file mode 100755
index 000000000..b5e979e6b
--- /dev/null
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -0,0 +1,27 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Generate LTP runfile for LVM tests (runtest/lvm.local)
+
+TST_TESTFUNC=generate_runfile
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="sed"
+. tst_test.sh
+
+generate_runfile()
+{
+	trap 'tst_brk TBROK "Cannot create LVM runfile"' ERR
+	INFILE="$LTPROOT/testcases/data/lvm/runfile.tpl"
+	OUTFILE="$LTPROOT/runtest/lvm.local"
+	FS_LIST=`tst_supported_fs`
+	echo -n "" >"$OUTFILE"
+
+	for fsname in $FS_LIST; do
+		sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+	done
+
+	tst_res TPASS "Runfile $OUTFILE successfully created"
+}
+
+tst_run
diff --git a/testcases/misc/lvm/prepare_lvm.sh b/testcases/misc/lvm/prepare_lvm.sh
new file mode 100755
index 000000000..a9acd50e0
--- /dev/null
+++ b/testcases/misc/lvm/prepare_lvm.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 SUSE LLC <mdoucha@suse.cz>
+#
+# Create and mount LVM volume groups for lvm.local runfile
+
+TST_TESTFUNC=prepare_lvm
+TST_NEEDS_ROOT=1
+TST_NEEDS_CMDS="mount pvcreate vgcreate lvcreate"
+. tst_test.sh
+
+LVM_TMPDIR="/tmp/ltp/growfiles"
+LVM_IMGDIR="/tmp/ltp/imgfiles"
+
+error_check()
+{
+	if [ $? -ne 0 ]; then
+		tst_brk TBROK "LVM setup failed"
+	fi
+}
+
+create_volume()
+{
+	fsname=$2
+	ROD mkdir -p $fsname
+
+	# If the FS isn't supported, only create the mountpoint and exit
+	if ! tst_supported_fs $fsname; then
+		return
+	fi
+
+	vgname=$1
+	lvname="ltp_lv_$fsname"
+	lvdev="/dev/$vgname/$lvname"
+
+	ROD lvcreate -L 1G $vgname -n "$lvname"
+	tst_mkfs $fsname "$lvdev"
+	ROD mount "$lvdev" $fsname
+}
+
+prepare_mounts()
+{
+	FSNAME1=$1
+	FSNAME2=$2
+	shift 2
+	LVM_DEV1=`tst_device acquire 1040 "$LVM_IMGDIR/lvm_pv1.img"`
+	error_check
+	LVM_DEV2=`ROD tst_device acquire 1040 "$LVM_IMGDIR/lvm_pv2.img"`
+	error_check
+
+	# DEVSIZE=($# * 1GB / 2) + 16MB. The extra 16MB is for LVM physical
+	# volume headers
+	DEVSIZE=$(( $# * 512 + 16 ))
+	LVM_DEV3=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv3.img"`
+	error_check
+	LVM_DEV4=`tst_device acquire $DEVSIZE "$LVM_IMGDIR/lvm_pv4.img"`
+	error_check
+	ROD pvcreate $LVM_DEV1 $LVM_DEV2 $LVM_DEV3 $LVM_DEV4
+	ROD vgcreate ltp_test_vg1 $LVM_DEV1 $LVM_DEV2
+	ROD vgcreate ltp_test_vg2 $LVM_DEV3 $LVM_DEV4
+
+	for fsname in $FSNAME1 $FSNAME2; do
+		create_volume ltp_test_vg1 $fsname
+	done
+
+	for fsname in $@; do
+		create_volume ltp_test_vg2 $fsname
+	done
+}
+
+prepare_lvm()
+{
+	FS_LIST=`tst_supported_fs | sort -u`
+	ROD mkdir -p "$LVM_TMPDIR"
+	ROD mkdir -p "$LVM_IMGDIR"
+	chmod 777 "$LVM_TMPDIR"
+	cd "$LVM_TMPDIR"
+	error_check
+	prepare_mounts $FS_LIST
+	tst_res TPASS "LVM mounts are ready"
+}
+
+tst_run
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [LTP] [PATCH v4 4/4] Skip Btrfs in LVM stress tests
  2020-02-19  9:37       ` [LTP] [PATCH v4 3/4] " Martin Doucha
@ 2020-02-19  9:37         ` Martin Doucha
  0 siblings, 0 replies; 16+ messages in thread
From: Martin Doucha @ 2020-02-19  9:37 UTC (permalink / raw)
  To: ltp

Delayed file deletion makes stress testing Btrfs on small block devices
difficult. Each test case would require explicit FS cleanup synchronization.
Drop Btrfs tests from LVM runfile for now.

Signed-off-by: Martin Doucha <mdoucha@suse.cz>
---

Changes since v3: New patch.

 testcases/misc/lvm/generate_lvm_runfile.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/testcases/misc/lvm/generate_lvm_runfile.sh b/testcases/misc/lvm/generate_lvm_runfile.sh
index b5e979e6b..5ca035f22 100755
--- a/testcases/misc/lvm/generate_lvm_runfile.sh
+++ b/testcases/misc/lvm/generate_lvm_runfile.sh
@@ -18,7 +18,10 @@ generate_runfile()
 	echo -n "" >"$OUTFILE"
 
 	for fsname in $FS_LIST; do
-		sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+		# Btrfs needs too much space for reliable stress testing
+		if [ "x$fsname" != "xbtrfs" ]; then
+			sed -e "s/{fsname}/$fsname/g" "$INFILE" >>"$OUTFILE"
+		fi
 	done
 
 	tst_res TPASS "Runfile $OUTFILE successfully created"
-- 
2.25.0


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2020-02-19  9:37 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29 14:49 [LTP] [PATCH 0/3] LVM support scripts for OpenQA Martin Doucha
2020-01-29 14:49 ` [LTP] [PATCH 1/3] Fix releasing loop devices in shell API Martin Doucha
2020-02-03 15:05   ` Petr Vorel
2020-01-29 14:49 ` [LTP] [PATCH 2/3] Allow acquiring multiple loop devices Martin Doucha
2020-02-03 15:24   ` Petr Vorel
2020-02-07 16:45     ` Cyril Hrubis
2020-02-07 17:07       ` Petr Vorel
2020-02-07 17:11         ` Cyril Hrubis
2020-02-10 15:48           ` Petr Vorel
2020-02-07 16:49   ` Cyril Hrubis
2020-01-29 14:49 ` [LTP] [PATCH 3/3] Add LVM support scripts Martin Doucha
2020-01-30 12:36   ` [LTP] [PATCH v2 " Martin Doucha
2020-01-30 14:41     ` [LTP] [PATCH v3 " Martin Doucha
2020-01-30 15:30       ` Petr Vorel
2020-02-19  9:37       ` [LTP] [PATCH v4 3/4] " Martin Doucha
2020-02-19  9:37         ` [LTP] [PATCH v4 4/4] Skip Btrfs in LVM stress tests Martin Doucha

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.