All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [RFC][PATCH 0/2] Add support to mount 'tmpfs' for EROFS testing
@ 2017-08-29  0:11 Sandeep Patil
  2017-08-29  0:11 ` [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs Sandeep Patil
  2017-08-29  0:11 ` [LTP] [RFC][PATCH 2/2] access04: use the new tmpfs mount for EROFS testing Sandeep Patil
  0 siblings, 2 replies; 6+ messages in thread
From: Sandeep Patil @ 2017-08-29  0:11 UTC (permalink / raw)
  To: ltp

There are several tests in LTP (especially the syscalls) that test for EROFS
error return in case of "read-only filesystem" that fail on Android (and possibly
other systems) because of the fact that they need to find a free
loopback device, create, format and mount a filesystem by default.

This makes all those tests flaky for number of reasons
 - Loopback device paths are different on Android (i.e. /dev/block/loopN)
	- This is very easily fixable though.
 - Filesystem tools are different on Android and in some cases non-existent.

For a test that checks for EROFS, going through the whole filesystem generation
and mounting is an overkill since the filesystem is unused after the mount anyway.

So, add support to mount 'tmpfs' (read-only if required) in libltp instead
of creating a filesystem and mounting a device. This simplifies a lot of tests
as mentioned in the changelog for PATCH 1/2.

Note: I've tested this on Android system as well as an ubuntu based machine.

Sandeep Patil (2):
  libltp: add support to mount tmpfs
  access04: use the new tmpfs mount for EROFS testing

 include/tst_test.h                          |  6 ++++++
 lib/tst_test.c                              | 17 +++++++++++++++++
 testcases/kernel/syscalls/access/access04.c |  6 +++---
 3 files changed, 26 insertions(+), 3 deletions(-)

-- 
2.14.1.342.g6490525c54-goog


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

* [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs
  2017-08-29  0:11 [LTP] [RFC][PATCH 0/2] Add support to mount 'tmpfs' for EROFS testing Sandeep Patil
@ 2017-08-29  0:11 ` Sandeep Patil
  2017-08-29 10:16   ` Cyril Hrubis
  2017-08-29  0:11 ` [LTP] [RFC][PATCH 2/2] access04: use the new tmpfs mount for EROFS testing Sandeep Patil
  1 sibling, 1 reply; 6+ messages in thread
From: Sandeep Patil @ 2017-08-29  0:11 UTC (permalink / raw)
  To: ltp

Some tests go through losetup, create, format and mount
filesystems only to run tests for 'EROFS' return value from
system calls. The tests end up being flaky depending on the tools
available on the platform. e.g. mkfs.<filesystem> tool is required for
mounting a device with filesystem.

If the test is only to check for EROFS, this can be achieved by simply
doing a 'tmpfs' read-only mount in $tmpdir.

Example of tests that can benefit from this are:
  access04, mkdirat02, mknodat02, acct01, fchown04, mknod07 etc.

This also allows for these tests to successfully run on Android.

Signed-off-by: Sandeep Patil <sspatil@google.com>
---
 include/tst_test.h |  6 ++++++
 lib/tst_test.c     | 17 +++++++++++++++++
 2 files changed, 23 insertions(+)

diff --git a/include/tst_test.h b/include/tst_test.h
index e90312ae3..abd787bd2 100644
--- a/include/tst_test.h
+++ b/include/tst_test.h
@@ -124,6 +124,7 @@ struct tst_test {
 	int needs_checkpoints:1;
 	int format_device:1;
 	int mount_device:1;
+	int mount_tmpfs:1;
 
 	/* Minimal device size in megabytes */
 	unsigned int dev_min_size;
@@ -140,6 +141,11 @@ struct tst_test {
 	unsigned int mnt_flags;
 	void *mnt_data;
 
+	/* tmpfs mount options, used if mount_tmpfs is set */
+	const char *tmpfs_mntpoint;
+	unsigned int tmpfs_flags;
+	void *tmpfs_data;
+
 	/* override default timeout per test run, disabled == -1 */
 	int timeout;
 
diff --git a/lib/tst_test.c b/lib/tst_test.c
index 4c30edab5..4404b27e0 100644
--- a/lib/tst_test.c
+++ b/lib/tst_test.c
@@ -42,6 +42,7 @@ static int iterations = 1;
 static float duration = -1;
 static pid_t main_pid, lib_pid;
 static int device_mounted;
+static int tmpfs_mounted;
 
 struct results {
 	int passed;
@@ -734,6 +735,19 @@ static void do_setup(int argc, char *argv[])
 		}
 	}
 
+	if (tst_test->mount_tmpfs) {
+		if (!tst_test->tmpfs_mntpoint) {
+			tst_brk(TBROK,
+				"tst_test->tmpfs_mntpoint must be set!");
+		}
+
+		SAFE_MKDIR(tst_test->tmpfs_mntpoint, 0777);
+		SAFE_MOUNT("none", tst_test->tmpfs_mntpoint, "tmpfs",
+			   tst_test->tmpfs_flags, tst_test->tmpfs_data);
+
+		tmpfs_mounted = 1;
+	}
+
 	if (tst_test->resource_files)
 		copy_resources();
 }
@@ -751,6 +765,9 @@ static void do_test_setup(void)
 
 static void do_cleanup(void)
 {
+	if (tmpfs_mounted)
+		tst_umount(tst_test->tmpfs_mntpoint);
+
 	if (device_mounted)
 		tst_umount(tst_test->mntpoint);
 
-- 
2.14.1.342.g6490525c54-goog


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

* [LTP] [RFC][PATCH 2/2] access04: use the new tmpfs mount for EROFS testing
  2017-08-29  0:11 [LTP] [RFC][PATCH 0/2] Add support to mount 'tmpfs' for EROFS testing Sandeep Patil
  2017-08-29  0:11 ` [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs Sandeep Patil
@ 2017-08-29  0:11 ` Sandeep Patil
  1 sibling, 0 replies; 6+ messages in thread
From: Sandeep Patil @ 2017-08-29  0:11 UTC (permalink / raw)
  To: ltp

Use the 'tmpfs' read-only mount to test for EROFS return from
system call instead of finding a loop device and create, format,
mount a file system

Signed-off-by: Sandeep Patil <sspatil@google.com>
---
 testcases/kernel/syscalls/access/access04.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/testcases/kernel/syscalls/access/access04.c b/testcases/kernel/syscalls/access/access04.c
index dbb6d271a..b369a952f 100644
--- a/testcases/kernel/syscalls/access/access04.c
+++ b/testcases/kernel/syscalls/access/access04.c
@@ -125,9 +125,9 @@ static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.needs_root = 1,
 	.forks_child = 1,
-	.mount_device = 1,
-	.mntpoint = MNT_POINT,
-	.mnt_flags = MS_RDONLY,
+	.mount_tmpfs = 1,
+	.tmpfs_mntpoint = MNT_POINT,
+	.tmpfs_flags = MS_RDONLY,
 	.setup = setup,
 	.test = verify_access,
 };
-- 
2.14.1.342.g6490525c54-goog


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

* [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs
  2017-08-29  0:11 ` [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs Sandeep Patil
@ 2017-08-29 10:16   ` Cyril Hrubis
  2017-08-30 11:27     ` Jan Stancek
  0 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2017-08-29 10:16 UTC (permalink / raw)
  To: ltp

Hi!
> Some tests go through losetup, create, format and mount
> filesystems only to run tests for 'EROFS' return value from
> system calls. The tests end up being flaky depending on the tools
> available on the platform. e.g. mkfs.<filesystem> tool is required for
> mounting a device with filesystem.
> 
> If the test is only to check for EROFS, this can be achieved by simply
> doing a 'tmpfs' read-only mount in $tmpdir.

Using tmpfs for EROFS sounds like a good idea, that should be much
faster than loop device as well, but there is a catch. There most likely
are embedded Linux devices that do not have tmpfs support compiled in
and as it is this would break these testcases on such platforms.

What about we created even more high-level interface for this? For
instance we can add .needs_rofs flag to the tst_test structure (reuse
the mntpoint to mount it) and let the library handle the details. I.e.
go for tmpfs and if that fails fall back to loop mounted device.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs
  2017-08-29 10:16   ` Cyril Hrubis
@ 2017-08-30 11:27     ` Jan Stancek
  2017-09-05 23:45       ` Sandeep Patil
  0 siblings, 1 reply; 6+ messages in thread
From: Jan Stancek @ 2017-08-30 11:27 UTC (permalink / raw)
  To: ltp


----- Original Message -----
> Hi!
> > Some tests go through losetup, create, format and mount
> > filesystems only to run tests for 'EROFS' return value from
> > system calls. The tests end up being flaky depending on the tools
> > available on the platform. e.g. mkfs.<filesystem> tool is required for
> > mounting a device with filesystem.
> > 
> > If the test is only to check for EROFS, this can be achieved by simply
> > doing a 'tmpfs' read-only mount in $tmpdir.
> 
> Using tmpfs for EROFS sounds like a good idea, that should be much
> faster than loop device as well, but there is a catch. There most likely
> are embedded Linux devices that do not have tmpfs support compiled in
> and as it is this would break these testcases on such platforms.
> 
> What about we created even more high-level interface for this? For
> instance we can add .needs_rofs flag to the tst_test structure (reuse
> the mntpoint to mount it) and let the library handle the details. I.e.
> go for tmpfs and if that fails fall back to loop mounted device.

Can we bind mount "/" as read-only somewhere to $tmpdir? That should be
widely supported (MS_BIND since 2.4).

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

* [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs
  2017-08-30 11:27     ` Jan Stancek
@ 2017-09-05 23:45       ` Sandeep Patil
  0 siblings, 0 replies; 6+ messages in thread
From: Sandeep Patil @ 2017-09-05 23:45 UTC (permalink / raw)
  To: ltp

On Wed, Aug 30, 2017 at 07:27:45AM -0400, Jan Stancek wrote:
> 
> ----- Original Message -----
> > Hi!
> > > Some tests go through losetup, create, format and mount
> > > filesystems only to run tests for 'EROFS' return value from
> > > system calls. The tests end up being flaky depending on the tools
> > > available on the platform. e.g. mkfs.<filesystem> tool is required for
> > > mounting a device with filesystem.
> > > 
> > > If the test is only to check for EROFS, this can be achieved by simply
> > > doing a 'tmpfs' read-only mount in $tmpdir.
> > 
> > Using tmpfs for EROFS sounds like a good idea, that should be much
> > faster than loop device as well, but there is a catch. There most likely
> > are embedded Linux devices that do not have tmpfs support compiled in
> > and as it is this would break these testcases on such platforms.
> > 
> > What about we created even more high-level interface for this? For
> > instance we can add .needs_rofs flag to the tst_test structure (reuse
> > the mntpoint to mount it) and let the library handle the details. I.e.
> > go for tmpfs and if that fails fall back to loop mounted device.
> 
> Can we bind mount "/" as read-only somewhere to $tmpdir? That should be
> widely supported (MS_BIND since 2.4).

That sounds like a simpler, more readily available solution than 'tmpfs'.
I'll change this to read-only bind mount //

- ssp

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

end of thread, other threads:[~2017-09-05 23:45 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-29  0:11 [LTP] [RFC][PATCH 0/2] Add support to mount 'tmpfs' for EROFS testing Sandeep Patil
2017-08-29  0:11 ` [LTP] [RFC][PATCH 1/2] libltp: add support to mount tmpfs Sandeep Patil
2017-08-29 10:16   ` Cyril Hrubis
2017-08-30 11:27     ` Jan Stancek
2017-09-05 23:45       ` Sandeep Patil
2017-08-29  0:11 ` [LTP] [RFC][PATCH 2/2] access04: use the new tmpfs mount for EROFS testing Sandeep Patil

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.