Skip to contentSkip to conversation

lib/tst_test: introduce tst_test->some_filesystems

PATCH New Murphy Zhou 3 participants 9 messages May 30, 2019 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 lib/tst_test: introduce tst_test->some_filesystems

Like all_filesystems, some_filesystems option let tcase to run on specific filesystems.
In order to implement this, change run_tcases_per_fs to accept a parameter indicating which filesystems need to test.

To let tcase use this option, we need some other flags set Eg:
static char *some_filesystems[] = {"ext4", "xfs", "btrfs"};

.mount_device = 0,
.needs_device = 1,
.format_device = 1,
.mntpoint = MNTPOINT,
.some_filesystems = some_filesystems,

---
 include/tst_test.h |  1 +
 lib/tst_test.c     | 13 ++++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)
include/tst_test.h +1 -0
index e4b935c45..8dc4fb6b4 100644
@@ -137,6 +137,7 @@ struct tst_test {
 	 * to the test function.
 	 */
 	int all_filesystems:1;
+	char **some_filesystems;
 
 	/*
 	 * If set non-zero denotes number of test variant, the test is executed
lib/tst_test.c +8 -5
index 2d88adbd7..72260f027 100644
@@ -867,7 +867,7 @@ static void do_setup(int argc, char *argv[])
 		else
 			tdev.fs_type = tst_dev_fs_type();
 
-		if (!tst_test->all_filesystems)
+		if (!tst_test->all_filesystems && !tst_test->some_filesystems)
 			prepare_device();
 	}
 
@@ -1143,11 +1143,11 @@ static int fork_testrun(void)
 	return 0;
 }
 
-static int run_tcases_per_fs(void)
+static int run_tcases_per_fs(char **fses)
 {
 	int ret = 0;
 	unsigned int i;
-	const char *const *filesystems = tst_get_supported_fs_types();
+	const char *const *filesystems = fses;
 
 	if (!filesystems[0])
 		tst_brk(TCONF, "There are no supported filesystems");
@@ -1202,8 +1202,11 @@ void tst_run_tcases(int argc, char *argv[], struct tst_test *self)
 
 	for (tst_variant = 0; tst_variant < test_variants; tst_variant++) {
 		if (tst_test->all_filesystems)
-			ret |= run_tcases_per_fs();
-		else
+			ret |= run_tcases_per_fs(tst_get_supported_fs_types());
+		else if (tst_test->some_filesystems) {
+			tst_test->mount_device = 1;
+			ret |= run_tcases_per_fs(tst_test->some_filesystems);
+		} else
 			ret |= fork_testrun();
 
 		if (ret & ~(TCONF))
Signature · 1 line
2.21.0
#1 lore raw

PATCH 2/2 syscalls: update tcases using dev_fs_type to use some_filesystems

Not all of them. Some tests need to run specific filesystem.

---
 .../kernel/syscalls/copy_file_range/copy_file_range02.c   | 8 ++++++--
 testcases/kernel/syscalls/getxattr/getxattr04.c           | 7 +++++--
 2 files changed, 11 insertions(+), 4 deletions(-)
testcases/kernel/syscalls/copy_file_range/copy_file_range02.c +6 -2
index 07c0207c2..de200febe 100644
@@ -47,6 +47,8 @@ static struct tcase {
 	{&fd_dest,	-1,	EINVAL},
 };
 
+static char *some_filesystems[] = {"ext4", "xfs"};
+
 static void verify_copy_file_range(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
@@ -111,8 +113,10 @@ static struct tst_test test = {
 	.setup = setup,
 	.cleanup = cleanup,
 	.needs_root = 1,
-	.mount_device = 1,
+	.mount_device = 0,
+	.needs_device = 1,
+	.format_device = 1,
 	.mntpoint = MNTPOINT,
-	.dev_fs_type = "ext4",
+	.some_filesystems = some_filesystems,
 	.test_variants = TEST_VARIANTS,
 };
testcases/kernel/syscalls/getxattr/getxattr04.c +5 -2
index 1dcb14da3..c5ae03f46 100644
@@ -54,6 +54,7 @@
 static volatile int end;
 static char big_value[512];
 static char small_value[32];
+static char *some_filesystems[] = {"ext4", "xfs"};
 
 static void sigproc(int sig)
 {
@@ -120,9 +121,11 @@ static void setup(void)
 static struct tst_test test = {
 	.needs_tmpdir = 1,
 	.needs_root = 1,
-	.mount_device = 1,
-	.dev_fs_type = "xfs",
+	.mount_device = 0,
+	.needs_device = 1,
+	.format_device = 1,
 	.mntpoint = MNTPOINT,
+	.some_filesystems = some_filesystems,
 	.forks_child = 1,
 	.test_all = verify_getxattr,
 	.setup = setup
Signature · 1 line
2.21.0
#2 lore raw

PATCH 2/2 syscalls: update tcases using dev_fs_type to use some_filesystems

Hi!

Quoted 3 lines
---
 .../kernel/syscalls/copy_file_range/copy_file_range02.c   | 8 ++++++--

I guess that we can enable the this test for all filesystems, there is in-kernel fallback for filesystems that does not support the syscall so it should work on all filesystems and the fallback code should be tested as well.

Quoted 1 line
 testcases/kernel/syscalls/getxattr/getxattr04.c           | 7 +++++--

Well I would be slightly in favor of enabling this test for all filesystems as well.

If we ever want to maintain list of filesystems that support extended attributes there should be only one somewhere in the test library so that we don't have to change thousand testcases later on.

Signature · 2 lines
Cyril Hrubis
[email protected]
#3 lore raw

PATCH 2/2 syscalls: update tcases using dev_fs_type to use some_filesystems

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 3 lines
---
 .../kernel/syscalls/copy_file_range/copy_file_range02.c   | 8 ++++++--

I guess that we can enable the this test for all filesystems, there is in-kernel fallback for filesystems that does not support the syscall so it should work on all filesystems and the fallback code should be tested as well.

Quoted 8 lines
Quoted 1 line
 testcases/kernel/syscalls/getxattr/getxattr04.c           | 7 +++++--

Well I would be slightly in favor of enabling this test for all filesystems as well.

If we ever want to maintain list of filesystems that support extended attributes there should be only one somewhere in the test library so that we don't have to change thousand testcases later on.

Hmm.. So we actually don't need this array. Just enable some proper tests for all filesystems.

Quoted 4 lines
Signature · 3 lines
-- 
Cyril Hrubis
[email protected]
#4 lore raw

PATCH 2/2 syscalls: update tcases using dev_fs_type to use some_filesystems

Hi!

Quoted 10 lines
Quoted 10 lines

I guess that we can enable the this test for all filesystems, there is in-kernel fallback for filesystems that does not support the syscall so it should work on all filesystems and the fallback code should be tested as well.

Quoted 1 line
 testcases/kernel/syscalls/getxattr/getxattr04.c           | 7 +++++--

Well I would be slightly in favor of enabling this test for all filesystems as well.

Quoted 6 lines
Quoted 3 lines

If we ever want to maintain list of filesystems that support extended attributes there should be only one somewhere in the test library so that we don't have to change thousand testcases later on.

Hmm.. So we actually don't need this array. Just enable some proper tests for all filesystems.

Looks like that, I've checked the fgetxattr01.c test and we only skip fat and vfat when the test is executed, all the other filesystems do support extended attributes. Disabling fat and vfat does not seem to speed up the test at all, I guess that the mkfs + mount is fast enough so that the difference is not measureable.

Signature · 2 lines
Cyril Hrubis
[email protected]
#5 lore raw

PATCH 1/2 lib/tst_test: introduce tst_test->some_filesystems

In reply to Murphy Zhou

----- Original Message -----

Quoted 8 lines

Like all_filesystems, some_filesystems option let tcase to run on specific filesystems.
In order to implement this, change run_tcases_per_fs to accept a parameter indicating which filesystems need to test.

To let tcase use this option, we need some other flags set Eg:
static char *some_filesystems[] = {"ext4", "xfs", "btrfs"};

What happens if one of them is not supported/available? Will it be skipped/TCONF?

#6 lore raw

PATCH 1/2 lib/tst_test: introduce tst_test->some_filesystems

Quoted 7 lines · Jan Stancek

----- Original Message -----

Quoted 5 lines

Like all_filesystems, some_filesystems option let tcase to run on specific filesystems.
In order to implement this, change run_tcases_per_fs to accept a parameter indicating which filesystems need to test.

Quoted 7 lines
Quoted 3 lines

To let tcase use this option, we need some other flags set Eg:
static char *some_filesystems[] = {"ext4", "xfs", "btrfs"};

What happens if one of them is not supported/available? Will it be skipped/TCONF?

Very good question! Now it breaks TCONF if not available because availability is not checked like all_filesystems config does. It's better to add it. If it's not supported, we should not list it in the fs type array.

Thanks,
Murphy

#7 lore raw

PATCH 1/2 lib/tst_test: introduce tst_test->some_filesystems

In reply to Murphy Zhou

Hi!

Quoted 9 lines

Like all_filesystems, some_filesystems option let tcase to run on specific filesystems.
In order to implement this, change run_tcases_per_fs to accept a parameter indicating which filesystems need to test.

To let tcase use this option, we need some other flags set Eg:
static char *some_filesystems[] = {"ext4", "xfs", "btrfs"};

Quoted 5 lines

.mount_device = 0,
.needs_device = 1,
.format_device = 1,
.mntpoint = MNTPOINT,
.some_filesystems = some_filesystems,

Can't we just change the dev_fs_type to dev_fs_types array instead?

Signature · 2 lines
Cyril Hrubis
[email protected]
#8 lore raw

PATCH 1/2 lib/tst_test: introduce tst_test->some_filesystems

Quoted 10 lines · Cyril Hrubis

Hi!

Quoted 9 lines

Like all_filesystems, some_filesystems option let tcase to run on specific filesystems.
In order to implement this, change run_tcases_per_fs to accept a parameter indicating which filesystems need to test.

To let tcase use this option, we need some other flags set Eg:
static char *some_filesystems[] = {"ext4", "xfs", "btrfs"};

Quoted 7 lines
Quoted 5 lines

.mount_device = 0,
.needs_device = 1,
.format_device = 1,
.mntpoint = MNTPOINT,
.some_filesystems = some_filesystems,

Can't we just change the dev_fs_type to dev_fs_types array instead?

Sure. That's a much better name! My naming taste needs much improvement...

Thanks!

Quoted 4 lines
Signature · 3 lines
-- 
Cyril Hrubis
[email protected]