Skip to contentSkip to conversation

Add support for .max_kver

PATCH Superseded Petr Vorel 3 participants 13 messages Jul 29 – Jul 30 Library code

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Petr Vorel

author
#0 lore raw

v2 cover Add support for .max_kver

Changes v1->v2:
* Fixed version 6.11 => 6.10 (execve04, creat07)
* Fixed version 7.2 => 7.1 (fanotify20)

Link to v1:
https://lore.kernel.org/ltp/[email protected]/T/#t
https://patchwork.ozlabs.org/project/ltp/list/?series=516120&state=*

More changes needed => v2. I'm sorry for the noise.

Petr Vorel (5):
lib: Rename function check_kver() => check_min_kver()
lib: Add support for max_kver to struct tst_test and tst_fs
execve04: Use .max_kver
creat07: Use .max_kver
fanotify20: Skip on v7.2

 include/tst_test.h                            |  9 +++-
 lib/tst_test.c                                | 49 +++++++++++++++++--
 testcases/kernel/syscalls/creat/creat07.c     | 14 ++----
 testcases/kernel/syscalls/execve/execve04.c   | 14 ++----
 .../kernel/syscalls/fanotify/fanotify20.c     |  4 ++
 5 files changed, 64 insertions(+), 26 deletions(-)
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#1 lore raw

PATCH v2 1/5 lib: Rename function check_kver() => check_min_kver()

Preparation for a next commit.

---
The same as v1.

 lib/tst_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
lib/tst_test.c +5 -5
index 5c3607016e..778a1fed40 100644
@@ -1058,11 +1058,11 @@ static void do_exit(int ret)
 }
 
 /*
- * Check for the required kernel version.
+ * Check for the minimal required kernel version.
  *
  * return: true if the kernel version is high enough, false otherwise.
  */
-static bool check_kver(const char *min_kver, const int brk_nosupp)
+static bool check_min_kver(const char *min_kver, const int brk_nosupp)
 {
 	char *msg;
 	int v1, v2, v3;
@@ -1461,7 +1461,7 @@ static void do_setup(int argc, char *argv[])
 		tst_brk(TCONF, "Test needs to be run as root");
 
 	if (tst_test->min_kver)
-		check_kver(tst_test->min_kver, 1);
+		check_min_kver(tst_test->min_kver, 1);
 
 	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
 		tst_brk(TCONF, "Kernel is locked down, skipping test");
@@ -1584,7 +1584,7 @@ static void do_setup(int argc, char *argv[])
 				tst_check_cmd(tst_test->filesystems->mkfs_ver, 1);
 
 			if (tst_test->filesystems && tst_test->filesystems->min_kver)
-				check_kver(tst_test->filesystems->min_kver, 1);
+				check_min_kver(tst_test->filesystems->min_kver, 1);
 
 			prepare_device(tst_test->filesystems);
 		}
@@ -1988,7 +1988,7 @@ static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
 	if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
 		return;
 
-	if (fs->min_kver && !check_kver(fs->min_kver, 0))
+	if (fs->min_kver && !check_min_kver(fs->min_kver, 0))
 		return;
 
 	prepare_device(fs);
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by Avinesh Kumar on v2 1/5
#2 lore raw

Re: [LTP] [PATCH v2 1/5] lib: Rename function check_kver() => check_min_kver()

Hi Petr,

Thanks,
Avinesh

Quoted 54 lines · Petr Vorel

Preparation for a next commit.

---
The same as v1.

  lib/tst_test.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
lib/tst_test.c +5 -5
index 5c3607016e..778a1fed40 100644
@@ -1058,11 +1058,11 @@ static void do_exit(int ret)
  }
 
  /*
- * Check for the required kernel version.
+ * Check for the minimal required kernel version.
   *
   * return: true if the kernel version is high enough, false otherwise.
   */
-static bool check_kver(const char *min_kver, const int brk_nosupp)
+static bool check_min_kver(const char *min_kver, const int brk_nosupp)
  {
  	char *msg;
  	int v1, v2, v3;
@@ -1461,7 +1461,7 @@ static void do_setup(int argc, char *argv[])
  		tst_brk(TCONF, "Test needs to be run as root");
 
  	if (tst_test->min_kver)
-		check_kver(tst_test->min_kver, 1);
+		check_min_kver(tst_test->min_kver, 1);
 
  	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
  		tst_brk(TCONF, "Kernel is locked down, skipping test");
@@ -1584,7 +1584,7 @@ static void do_setup(int argc, char *argv[])
  				tst_check_cmd(tst_test->filesystems->mkfs_ver, 1);
 
  			if (tst_test->filesystems && tst_test->filesystems->min_kver)
-				check_kver(tst_test->filesystems->min_kver, 1);
+				check_min_kver(tst_test->filesystems->min_kver, 1);
 
  			prepare_device(tst_test->filesystems);
  		}
@@ -1988,7 +1988,7 @@ static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
  	if (fs->mkfs_ver && !tst_check_cmd(fs->mkfs_ver, 0))
  		return;
 
-	if (fs->min_kver && !check_kver(fs->min_kver, 0))
+	if (fs->min_kver && !check_min_kver(fs->min_kver, 0))
  		return;
 
  	prepare_device(fs);
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#3 lore raw

PATCH v2 2/5 lib: Add support for max_kver to struct tst_test and tst_fs

In reply to Petr Vorel

---
The same as v1.

 include/tst_test.h |  9 ++++++++-
 lib/tst_test.c     | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
include/tst_test.h +8 -1
index c69362485e..0910660827 100644
@@ -280,6 +280,9 @@ struct tst_ulimit_val {
  *
  * @min_kver: A minimum kernel version supporting the filesystem which has been
  *            created with mkfs.
+ *
+ * @max_kver: A maximum kernel version supporting the filesystem which has been
+ *            created with mkfs.
  */
 struct tst_fs {
 	const char *type;
@@ -292,6 +295,7 @@ struct tst_fs {
 	const void *mnt_data;
 
 	const char *min_kver;
+	const char *max_kver;
 };
 
 /**
@@ -301,7 +305,9 @@ struct tst_fs {
  *        and each time passed an increasing counter value.
  * @options: An NULL optstr terminated array of struct tst_option.
  *
- * @min_kver: A minimal kernel version the test can run on. e.g. "3.10".
+ * @min_kver: A minimal kernel version the test can run on. e.g. "4.4".
+ *
+ * @max_kver: A maximal kernel version the test can run on. e.g. "7.2".
  *
  * @supported_archs: A NULL terminated array of architectures the test runs on
  *                   e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to
@@ -551,6 +557,7 @@ struct tst_fs {
 	struct tst_option *options;
 
 	const char *min_kver;
+	const char *max_kver;
 
 	const char *const *supported_archs;
 
lib/tst_test.c +39 -0
index 778a1fed40..fa38b3a7a3 100644
@@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp)
 	return true;
 }
 
+/*
+ * Check for the maximal required kernel version.
+ *
+ * return: true if the kernel version is low enough, false otherwise.
+ */
+static bool check_max_kver(const char *max_kver, const int brk_nosupp)
+{
+	char *msg;
+	int v1, v2, v3;
+
+	if (tst_parse_kver(max_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+			"Invalid kernel version %s, expected %%d.%%d.%%d",
+			max_kver);
+	}
+
+	if (tst_kvercmp(v1, v2, v3) > 0) {
+		msg = "The test requires kernel %s or older";
+
+		if (brk_nosupp)
+			tst_brk(TCONF, msg, max_kver);
+		else
+			tst_res(TCONF, msg, max_kver);
+
+		return false;
+	}
+
+	return true;
+}
+
 /*
  * Checks if the struct results values are equal.
  *
@@ -1463,6 +1493,9 @@ static void do_setup(int argc, char *argv[])
 	if (tst_test->min_kver)
 		check_min_kver(tst_test->min_kver, 1);
 
+	if (tst_test->max_kver)
+		check_max_kver(tst_test->max_kver, 1);
+
 	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
 		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
@@ -1586,6 +1619,9 @@ static void do_setup(int argc, char *argv[])
 			if (tst_test->filesystems && tst_test->filesystems->min_kver)
 				check_min_kver(tst_test->filesystems->min_kver, 1);
 
+			if (tst_test->filesystems && tst_test->filesystems->max_kver)
+				check_max_kver(tst_test->filesystems->max_kver, 1);
+
 			prepare_device(tst_test->filesystems);
 		}
 	}
@@ -1991,6 +2027,9 @@ static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
 	if (fs->min_kver && !check_min_kver(fs->min_kver, 0))
 		return;
 
+	if (fs->max_kver && !check_max_kver(fs->max_kver, 0))
+		return;
+
 	prepare_device(fs);
 
 	fork_testrun();
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
#4 lore raw

Re: [LTP] [PATCH v2 2/5] lib: Add support for max_kver to struct tst_test and tst_fs

Hi Petr,

few comments below

Quoted 31 lines · Petr Vorel

---
The same as v1.

  include/tst_test.h |  9 ++++++++-
  lib/tst_test.c     | 39 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 47 insertions(+), 1 deletion(-)
include/tst_test.h +4 -0
index c69362485e..0910660827 100644
@@ -280,6 +280,9 @@ struct tst_ulimit_val {
   *
   * @min_kver: A minimum kernel version supporting the filesystem which has been
   *            created with mkfs.
+ *
+ * @max_kver: A maximum kernel version supporting the filesystem which has been
+ *            created with mkfs.
   */
  struct tst_fs {
  	const char *type;
@@ -292,6 +295,7 @@ struct tst_fs {
  	const void *mnt_data;
 
  	const char *min_kver;
+	const char *max_kver;
  };
 
  /**

include/tst_test.h struct tst_fs { · line 308

Quoted 5 lines
include/tst_test.h +1 -1
@@ -301,7 +305,9 @@ struct tst_fs {
   *        and each time passed an increasing counter value.
   * @options: An NULL optstr terminated array of struct tst_option.
   *
- * @min_kver: A minimal kernel version the test can run on. e.g. "3.10".
+ * @min_kver: A minimal kernel version the test can run on. e.g. "4.4".

s/minimal/minimum

include/tst_test.h struct tst_fs { · line 310

Quoted 2 lines
include/tst_test.h +2 -0
+ *
+ * @max_kver: A maximal kernel version the test can run on. e.g. "7.2".

s/maximal/maximum

Also, I assume test will *not be skipped* on kernel versions 7.1.1, 7.1.2 etc just with
.max_kver="7.1"

maybe we should clarify.

Quoted 16 lines
include/tst_test.h +1 -0
   *
   * @supported_archs: A NULL terminated array of architectures the test runs on
   *                   e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to
@@ -551,6 +557,7 @@ struct tst_fs {
  	struct tst_option *options;
 
  	const char *min_kver;
+	const char *max_kver;
 
  	const char *const *supported_archs;
 
lib/tst_test.c +0 -0
index 778a1fed40..fa38b3a7a3 100644

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1093

Quoted 7 lines
lib/tst_test.c +4 -0
@@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp)
  	return true;
  }
 
+/*
+ * Check for the maximal required kernel version.
+ *
+ * return: true if the kernel version is low enough, false otherwise.

This sounds a bit confusing. How about-

Check the running kernel against the last version the test applies to.

return: true if the kernel is old enough, false otherwise.

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1102

Quoted 9 lines
lib/tst_test.c +9 -0
+ */
+static bool check_max_kver(const char *max_kver, const int brk_nosupp)
+{
+	char *msg;
+	int v1, v2, v3;
+
+	if (tst_parse_kver(max_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+			"Invalid kernel version %s, expected %%d.%%d.%%d",

I wouldn't say 'kernel version is invalid'. maybe test isn't supported/applicable on..

Quoted 41 lines
lib/tst_test.c +23 -0
+			max_kver);
+	}
+
+	if (tst_kvercmp(v1, v2, v3) > 0) {
+		msg = "The test requires kernel %s or older";
+
+		if (brk_nosupp)
+			tst_brk(TCONF, msg, max_kver);
+		else
+			tst_res(TCONF, msg, max_kver);
+
+		return false;
+	}
+
+	return true;
+}
+
  /*
   * Checks if the struct results values are equal.
   *
@@ -1463,6 +1493,9 @@ static void do_setup(int argc, char *argv[])
  	if (tst_test->min_kver)
  		check_min_kver(tst_test->min_kver, 1);
 
+	if (tst_test->max_kver)
+		check_max_kver(tst_test->max_kver, 1);
+
  	if (tst_test->skip_in_lockdown && tst_lockdown_enabled() > 0)
  		tst_brk(TCONF, "Kernel is locked down, skipping test");
 
@@ -1586,6 +1619,9 @@ static void do_setup(int argc, char *argv[])
  			if (tst_test->filesystems && tst_test->filesystems->min_kver)
  				check_min_kver(tst_test->filesystems->min_kver, 1);
 
+			if (tst_test->filesystems && tst_test->filesystems->max_kver)
+				check_max_kver(tst_test->filesystems->max_kver, 1);
+
  			prepare_device(tst_test->filesystems);
  		}
  	}

lib/tst_test.c static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type) · line 2035

Quoted 9 lines
lib/tst_test.c +3 -0
@@ -1991,6 +2027,9 @@ static void run_tcase_on_fs(struct tst_fs *fs, const char *fs_type)
  	if (fs->min_kver && !check_min_kver(fs->min_kver, 0))
  		return;
 
+	if (fs->max_kver && !check_max_kver(fs->max_kver, 0))
+		return;
+
  	prepare_device(fs);
 
  	fork_testrun();

Thanks,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#5 lore raw

Re: [LTP] [PATCH v2 2/5] lib: Add support for max_kver to struct tst_test and tst_fs

Hi Avinesh,

Quoted 3 lines

Hi Petr,

few comments below

Thanks!

Quoted 28 lines · Petr Vorel
Quoted 27 lines

---
The same as v1.

  include/tst_test.h |  9 ++++++++-
  lib/tst_test.c     | 39 +++++++++++++++++++++++++++++++++++++++
  2 files changed, 47 insertions(+), 1 deletion(-)
include/tst_test.h +4 -0
index c69362485e..0910660827 100644
@@ -280,6 +280,9 @@ struct tst_ulimit_val {
   *
   * @min_kver: A minimum kernel version supporting the filesystem which has been
   *            created with mkfs.
+ *
+ * @max_kver: A maximum kernel version supporting the filesystem which has been
+ *            created with mkfs.
   */
  struct tst_fs {
  	const char *type;
@@ -292,6 +295,7 @@ struct tst_fs {
  	const void *mnt_data;
  	const char *min_kver;
+	const char *max_kver;
  };
Quoted 8 lines

include/tst_test.h struct tst_fs { · line 308

Quoted 7 lines
include/tst_test.h +1 -1
  /**
@@ -301,7 +305,9 @@ struct tst_fs {
   *        and each time passed an increasing counter value.
   * @options: An NULL optstr terminated array of struct tst_option.
   *
- * @min_kver: A minimal kernel version the test can run on. e.g. "3.10".
+ * @min_kver: A minimal kernel version the test can run on. e.g. "4.4".

s/minimal/minimum

You spotted more grammar errors so I trust you :). But can you please double check that it'đ really correct? Minimal is an adjective, minimum is an adjective but also a noun and an adverb.

When googling I even found use of both in the same document :)
https://kubernetes.io/docs/reference/node/kernel-version-requirements/
"have minimum kernel version requirements"
"minimal kernel version requirement"

Quoted 3 lines

include/tst_test.h struct tst_fs { · line 310

Quoted 2 lines
include/tst_test.h +2 -0
+ *
+ * @max_kver: A maximal kernel version the test can run on. e.g. "7.2".

s/maximal/maximum

dtto

Quoted 3 lines

Also, I assume test will *not be skipped* on kernel versions 7.1.1, 7.1.2 etc just with
.max_kver="7.1"

Good point, thanks => v3 (sigh).

check_max_kver() needs to have this condition to take an account the sublevel.

-if (tst_kvercmp(v1, v2, v3) > 0) {

+if (tst_kvercmp(v1, v2, v3) >= 1024) {
		msg = "The test requires kernel %s or older";

...

Sublevel can be above 255 since 4.4.256
https://lwn.net/ml/linux-kernel/[email protected]/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b82f13e7ef3

But it should be below 1024 (practically the highest sublevel has been 337).

Kind regards,
Petr

Quoted 24 lines

maybe we should clarify.

Quoted 13 lines
include/tst_test.h +1 -0
   *
   * @supported_archs: A NULL terminated array of architectures the test runs on
   *                   e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to
@@ -551,6 +557,7 @@ struct tst_fs {
  	struct tst_option *options;
  	const char *min_kver;
+	const char *max_kver;
  	const char *const *supported_archs;
lib/tst_test.c +0 -0
index 778a1fed40..fa38b3a7a3 100644

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1092

Quoted 6 lines
lib/tst_test.c +4 -0
@@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp)
  	return true;
  }
+/*
+ * Check for the maximal required kernel version.
+ *
+ * return: true if the kernel version is low enough, false otherwise.

This sounds a bit confusing. How about-

Quoted 1 line

Check the running kernel against the last version the test applies to.

Makes sense. Based on check_min_kver(), which was renamed from check_kver() in the previous commit. Could you have look on these as well. Anyway, if you have time, having a look on docs wording as a separate effort would help.

Quoted 1 line

return: true if the kernel is old enough, false otherwise.

+1

Quoted 11 lines

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1102

Quoted 9 lines
lib/tst_test.c +9 -0
+ */
+static bool check_max_kver(const char *max_kver, const int brk_nosupp)
+{
+	char *msg;
+	int v1, v2, v3;
+
+	if (tst_parse_kver(max_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+			"Invalid kernel version %s, expected %%d.%%d.%%d",

I wouldn't say 'kernel version is invalid'. maybe test isn't supported/applicable on..

tst_parse_kver() returns 1 on error => this is really an error check. Other thing is that the same error handling is on both places, but that's very minor.

Kind regards,
Petr
...

Quoted 2 lines

Thanks,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
#6 lore raw

Re: [LTP] [PATCH v2 2/5] lib: Add support for max_kver to struct tst_test and tst_fs

Quoted 44 lines · Petr Vorel

Hi Avinesh,

Quoted 3 lines

Hi Petr,

few comments below

Thanks!

Quoted 28 lines · Petr Vorel
Quoted 27 lines

---
The same as v1.

   include/tst_test.h |  9 ++++++++-
   lib/tst_test.c     | 39 +++++++++++++++++++++++++++++++++++++++
   2 files changed, 47 insertions(+), 1 deletion(-)
include/tst_test.h +4 -0
index c69362485e..0910660827 100644
@@ -280,6 +280,9 @@ struct tst_ulimit_val {
    *
    * @min_kver: A minimum kernel version supporting the filesystem which has been
    *            created with mkfs.
+ *
+ * @max_kver: A maximum kernel version supporting the filesystem which has been
+ *            created with mkfs.
    */
   struct tst_fs {
   	const char *type;
@@ -292,6 +295,7 @@ struct tst_fs {
   	const void *mnt_data;
   	const char *min_kver;
+	const char *max_kver;
   };
Quoted 8 lines

include/tst_test.h struct tst_fs { · line 308

Quoted 7 lines
include/tst_test.h +1 -1
   /**
@@ -301,7 +305,9 @@ struct tst_fs {
    *        and each time passed an increasing counter value.
    * @options: An NULL optstr terminated array of struct tst_option.
    *
- * @min_kver: A minimal kernel version the test can run on. e.g. "3.10".
+ * @min_kver: A minimal kernel version the test can run on. e.g. "4.4".

s/minimal/minimum

Quoted 8 lines

You spotted more grammar errors so I trust you :). But can you please double check that it'đ really correct? Minimal is an adjective, minimum is an adjective but also a noun and an adverb.

When googling I even found use of both in the same document :)
https://kubernetes.io/docs/reference/node/kernel-version-requirements/
"have minimum kernel version requirements"
"minimal kernel version requirement"

I see we are using minimal in many places already. I think both wordings are correct. Just that 'maximal kernel version' sounded a bit odd to me. So please ignore my comment here.

Quoted 16 lines
Quoted 4 lines

include/tst_test.h struct tst_fs { · line 310

Quoted 3 lines
include/tst_test.h +2 -0
+ *
+ * @max_kver: A maximal kernel version the test can run on. e.g. "7.2".

s/maximal/maximum

dtto

Quoted 3 lines

Also, I assume test will *not be skipped* on kernel versions 7.1.1, 7.1.2 etc just with
.max_kver="7.1"

Good point, thanks => v3 (sigh).

check_max_kver() needs to have this condition to take an account the sublevel.

(quoted diff) +1 -1
-if (tst_kvercmp(v1, v2, v3) > 0) {
+if (tst_kvercmp(v1, v2, v3) >= 1024) {
Quoted 1 line
		msg = "The test requires kernel %s or older";

And will this be fine with -
.max_kver="7.1.5"
on SUT with v7.2.0 ?

sorry, haven't tested yet.

Quoted 35 lines

...

Sublevel can be above 255 since 4.4.256
https://lwn.net/ml/linux-kernel/[email protected]/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b82f13e7ef3

But it should be below 1024 (practically the highest sublevel has been 337).

Kind regards,
Petr

Quoted 23 lines

maybe we should clarify.

Quoted 13 lines
include/tst_test.h +1 -0
    *
    * @supported_archs: A NULL terminated array of architectures the test runs on
    *                   e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to
@@ -551,6 +557,7 @@ struct tst_fs {
   	struct tst_option *options;
   	const char *min_kver;
+	const char *max_kver;
   	const char *const *supported_archs;
lib/tst_test.c +0 -0
index 778a1fed40..fa38b3a7a3 100644

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1092

Quoted 6 lines
lib/tst_test.c +4 -0
@@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp)
   	return true;
   }
+/*
+ * Check for the maximal required kernel version.
+ *
+ * return: true if the kernel version is low enough, false otherwise.

This sounds a bit confusing. How about-

Quoted 5 lines
Quoted 1 line

Check the running kernel against the last version the test applies to.

Makes sense. Based on check_min_kver(), which was renamed from check_kver() in the previous commit. Could you have look on these as well. Anyway, if you have time, having a look on docs wording as a separate effort would help.

sure, I will see if I find something worth reporting.

Quoted 17 lines
Quoted 2 lines

return: true if the kernel is old enough, false otherwise.

+1

Quoted 11 lines

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1102

Quoted 9 lines
lib/tst_test.c +9 -0
+ */
+static bool check_max_kver(const char *max_kver, const int brk_nosupp)
+{
+	char *msg;
+	int v1, v2, v3;
+
+	if (tst_parse_kver(max_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+			"Invalid kernel version %s, expected %%d.%%d.%%d",

I wouldn't say 'kernel version is invalid'. maybe test isn't supported/applicable on..

Quoted 3 lines

tst_parse_kver() returns 1 on error => this is really an error check. Other thing is that the same error handling is on both places, but that's very minor.

sorry, my bad. I misunderstood this. Please ignore.

Quoted 7 lines

Kind regards,
Petr
...

Quoted 2 lines

Thanks,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#7 lore raw

Re: [LTP] [PATCH v2 2/5] lib: Add support for max_kver to struct tst_test and tst_fs

Hi Avinesh,

Quoted 8 lines
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines

- * @min_kver: A minimal kernel version the test can run on. e.g. "3.10".
+ * @min_kver: A minimal kernel version the test can run on. e.g. "4.4".

s/minimal/minimum

You spotted more grammar errors so I trust you :). But can you please double check that it'đ really correct? Minimal is an adjective, minimum is an adjective but also a noun and an adverb.

Quoted 7 lines
Quoted 4 lines

When googling I even found use of both in the same document :)
https://kubernetes.io/docs/reference/node/kernel-version-requirements/
"have minimum kernel version requirements"
"minimal kernel version requirement"

I see we are using minimal in many places already. I think both wordings are correct. Just that 'maximal kernel version' sounded a bit odd to me. So please ignore my comment here.

Np.

Quoted 11 lines
Quoted 10 lines
Quoted 3 lines
Quoted 2 lines

+ *
+ * @max_kver: A maximal kernel version the test can run on. e.g. "7.2".

s/maximal/maximum

dtto

Quoted 3 lines

Also, I assume test will *not be skipped* on kernel versions 7.1.1, 7.1.2 etc just with
.max_kver="7.1"

Good point, thanks => v3 (sigh).

Quoted 8 lines
Quoted 5 lines

check_max_kver() needs to have this condition to take an account the sublevel.

(quoted diff) +1 -1
-if (tst_kvercmp(v1, v2, v3) > 0) {
+if (tst_kvercmp(v1, v2, v3) >= 1024) {
		msg = "The test requires kernel %s or older";

And will this be fine with -
.max_kver="7.1.5"
on SUT with v7.2.0 ?

Indeed, this will not be skipped. The reason is that for .max_kver="7.1" (e.g. without the 3rd number) we want to behave like 7.1.1023 (i.e. 3rd number being the highest possible number so that any 7.1 version is ok, which is achieved by > 1024 instead of 0). If we want also .max_kver="7.1.5" compare as is (i.e. 7.1.5), it should be something like (untested):

if (tst_kvercmp(v1, v2, v3) > (!v3 ? 1023 : 0)) {
	msg = "The test requires kernel %s or older";

And that behavior would have to be for sure well documented. WDYT?

Quoted 37 lines

sorry, haven't tested yet.

Quoted 34 lines

...

Sublevel can be above 255 since 4.4.256
https://lwn.net/ml/linux-kernel/[email protected]/
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=9b82f13e7ef3

But it should be below 1024 (practically the highest sublevel has been 337).

Kind regards,
Petr

Quoted 23 lines

maybe we should clarify.

Quoted 13 lines

*
* @supported_archs: A NULL terminated array of architectures the test runs on
* e.g. {"x86_64, "x86", NULL}. Calls tst_is_on_arch() to

include/tst_test.h +1 -0
@@ -551,6 +557,7 @@ struct tst_fs {
   	struct tst_option *options;
   	const char *min_kver;
+	const char *max_kver;
   	const char *const *supported_archs;
lib/tst_test.c +0 -0
index 778a1fed40..fa38b3a7a3 100644

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1092

Quoted 6 lines
lib/tst_test.c +4 -0
@@ -1087,6 +1087,36 @@ static bool check_min_kver(const char *min_kver, const int brk_nosupp)
   	return true;
   }
+/*
+ * Check for the maximal required kernel version.
+ *
+ * return: true if the kernel version is low enough, false otherwise.

This sounds a bit confusing. How about-

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

Check the running kernel against the last version the test applies to.

Makes sense. Based on check_min_kver(), which was renamed from check_kver() in the previous commit. Could you have look on these as well. Anyway, if you have time, having a look on docs wording as a separate effort would help.

sure, I will see if I find something worth reporting.

+1

Quoted 16 lines
Quoted 15 lines
Quoted 1 line

return: true if the kernel is old enough, false otherwise.

+1

Quoted 11 lines

lib/tst_test.c static bool check_min_kver(const char *min_kver, const int brk_nosupp) · line 1102

Quoted 9 lines
lib/tst_test.c +9 -0
+ */
+static bool check_max_kver(const char *max_kver, const int brk_nosupp)
+{
+	char *msg;
+	int v1, v2, v3;
+
+	if (tst_parse_kver(max_kver, &v1, &v2, &v3)) {
+		tst_res(TWARN,
+			"Invalid kernel version %s, expected %%d.%%d.%%d",

I wouldn't say 'kernel version is invalid'. maybe test isn't supported/applicable on..

Quoted 4 lines
Quoted 3 lines

tst_parse_kver() returns 1 on error => this is really an error check. Other thing is that the same error handling is on both places, but that's very minor.

sorry, my bad. I misunderstood this. Please ignore.

np.

Kind regards,
Petr

Quoted 6 lines
Quoted 6 lines

Kind regards,
Petr
...

Quoted 2 lines

Thanks,
Avinesh

Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#8 lore raw

PATCH v2 3/5 execve04: Use .max_kver

In reply to Petr Vorel

---
Changes v1->v2:
* Fixed version 6.11 => 6.10

 testcases/kernel/syscalls/execve/execve04.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
testcases/kernel/syscalls/execve/execve04.c +4 -10
index 35ec882a07..6f06a4a4cc 100644
@@ -11,6 +11,9 @@
 /*\
  * Attempt to :manpage:`execve(2)` a file which is being opened by another process for
  * writing fails with ETXTBSY.
+ *
+ * NOTE: write to executed file is allowed since 6.11-rc1:
+ * 2a010c412853 ("fs: don't block i_writecount during exec")
  */
 
 #define _GNU_SOURCE
@@ -62,19 +65,10 @@ static void do_child(void)
 	exit(0);
 }
 
-static void setup(void)
-{
-	if ((tst_kvercmp(6, 11, 0)) >= 0) {
-		tst_brk(TCONF, "Skipping test, write to executed file is "
-			"allowed since 6.11-rc1.\n"
-			"2a010c412853 (\"fs: don't block i_writecount during exec\")");
-	}
-}
-
 static struct tst_test test = {
-	.setup = setup,
 	.test_all = verify_execve,
 	.forks_child = 1,
+	.max_kver = "6.10",
 	.child_needs_reinit = 1,
 	.needs_checkpoints = 1,
 	.resource_files = (const char *const []) {
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#9 lore raw

PATCH v2 4/5 creat07: Use .max_kver

In reply to Petr Vorel

---
Changes v1->v2:
* Fixed version 6.11 => 6.10

 testcases/kernel/syscalls/creat/creat07.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)
testcases/kernel/syscalls/creat/creat07.c +4 -10
index c7b85ee694..2b15d79b47 100644
@@ -6,6 +6,9 @@
 
 /*\
  * Check that :manpage:`creat(2)` sets ETXTBSY correctly.
+ *
+ * NOTE: write to executed file is allowed since 6.11-rc1:
+ * 2a010c412853 ("fs: don't block i_writecount during exec")
  */
 
 #include <sys/types.h>
@@ -47,19 +50,10 @@ static void verify_creat(void)
 	SAFE_WAITPID(pid, NULL, 0);
 }
 
-static void setup(void)
-{
-	if ((tst_kvercmp(6, 11, 0)) >= 0) {
-		tst_brk(TCONF, "Skipping test, write to executed file is "
-			"allowed since 6.11-rc1.\n"
-			"2a010c412853 (\"fs: don't block i_writecount during exec\")");
-	}
-}
-
 static struct tst_test test = {
-	.setup = setup,
 	.test_all = verify_creat,
 	.needs_checkpoints = 1,
+	.max_kver = "6.10",
 	.forks_child = 1,
 	.resource_files = (const char *const []) {
 		TEST_APP,
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
author
#10 lore raw

PATCH v2 5/5 fanotify20: Skip on v7.2

In reply to Petr Vorel

fanotify_init() used to reject FAN_REPORT_PIDFD combined with FAN_REPORT_TID with EINVAL. Since Linux v7.2, fanotify supports reporting pidfds for thread IDs, so this combination is expected to succeed.

The test that these flag combinations are allowed:
FLAGS_DESC(FAN_REPORT_PIDFD | FAN_REPORT_TID), FLAGS_DESC(FAN_REPORT_PIDFD | FAN_REPORT_FID |
FAN_REPORT_DFID_NAME),

Because the above flag combinations are already "tested" by the tests that use them and we don't have any tests that >= 5.10 has support for FAN_MARK_FILESYSTEM etc just simply skip the test on v7.2.

---
Changes v1->v2:
* Fixed version 7.2 => 7.1

More changes needed => v2. I'm sorry for the noise.

 testcases/kernel/syscalls/fanotify/fanotify20.c | 4 ++++
 1 file changed, 4 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify20.c +4 -0
index b32ecf6aa3..db4a5ba63b 100644
@@ -15,6 +15,9 @@
  *
  * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in
  * af579beb666a ("fanotify: add pidfd support to the fanotify API").
+ *
+ * NOTE: since v7.2, fanotify supports reporting pidfds for thread IDs => skip
+ * the test.
  */
 
 #define _GNU_SOURCE
@@ -75,6 +78,7 @@ static void do_cleanup(void)
 
 static struct tst_test test = {
 	.setup = do_setup,
+	.max_kver = "7.1",
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(test_cases),
 	.cleanup = do_cleanup,
Signature · 5 lines
2.55.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp
Reviewed-by on v2 5/5
#11 lore raw

Re: [LTP] [PATCH v2 5/5] fanotify20: Skip on v7.2

Quoted 10 lines · Petr Vorel

fanotify_init() used to reject FAN_REPORT_PIDFD combined with FAN_REPORT_TID with EINVAL. Since Linux v7.2, fanotify supports reporting pidfds for thread IDs, so this combination is expected to succeed.

The test that these flag combinations are allowed:
FLAGS_DESC(FAN_REPORT_PIDFD | FAN_REPORT_TID), FLAGS_DESC(FAN_REPORT_PIDFD | FAN_REPORT_FID |
FAN_REPORT_DFID_NAME),

Quoted 7 lines

Because the above flag combinations are already "tested" by the tests that use them and we don't have any tests that >= 5.10 has support for FAN_MARK_FILESYSTEM etc just simply skip the test on v7.2.

Looks good. Feel free to add:

Honza

Quoted 34 lines

---
Changes v1->v2:
* Fixed version 7.2 => 7.1

More changes needed => v2. I'm sorry for the noise.

 testcases/kernel/syscalls/fanotify/fanotify20.c | 4 ++++
 1 file changed, 4 insertions(+)
testcases/kernel/syscalls/fanotify/fanotify20.c +4 -0
index b32ecf6aa3..db4a5ba63b 100644
@@ -15,6 +15,9 @@
  *
  * NOTE: FAN_REPORT_PIDFD support was added in v5.15-rc1 in
  * af579beb666a ("fanotify: add pidfd support to the fanotify API").
+ *
+ * NOTE: since v7.2, fanotify supports reporting pidfds for thread IDs => skip
+ * the test.
  */
 
 #define _GNU_SOURCE
@@ -75,6 +78,7 @@ static void do_cleanup(void)
 
 static struct tst_test test = {
 	.setup = do_setup,
+	.max_kver = "7.1",
 	.test = do_test,
 	.tcnt = ARRAY_SIZE(test_cases),
 	.cleanup = do_cleanup,
Signature · 1 line
2.55.0
Signature · 5 lines
Jan Kara <[email protected]>
SUSE Labs, CR

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp