All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup
@ 2023-10-11 16:24 Petr Vorel
  2023-10-11 16:24 ` [LTP] [PATCH 1/2] swapon01: Test on all filesystems Petr Vorel
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Petr Vorel @ 2023-10-11 16:24 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Hi,

this is based on patch from Marius:

https://patchwork.ozlabs.org/project/ltp/patch/20231011152900.4274-1-mkittler@suse.de/
https://lore.kernel.org/ltp/20231011152900.4274-1-mkittler@suse.de/

It's also related to (but independent on it):
https://patchwork.ozlabs.org/project/ltp/list/?series=377166

Kind regards,
Petr

Petr Vorel (2):
  swapon01: Test on all filesystems
  swapon01: Simplify code, add copyright

 testcases/kernel/syscalls/swapon/swapon01.c | 29 ++++++++++-----------
 1 file changed, 14 insertions(+), 15 deletions(-)

-- 
2.42.0


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

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

* [LTP] [PATCH 1/2] swapon01: Test on all filesystems
  2023-10-11 16:24 [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Petr Vorel
@ 2023-10-11 16:24 ` Petr Vorel
  2024-01-19 11:42   ` Cyril Hrubis
  2023-10-11 16:24 ` [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright Petr Vorel
  2023-10-12  9:28 ` [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Marius Kittler
  2 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2023-10-11 16:24 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Test on all filesystems to increase coverage.  btrfs and tmpfs
currently does not support swap file, but keep it in case this get
changed in the future.

Testing on all filesystems usually requests root, but we don't require
it with .needs_root = 1. But using swapon() requires it as well, thus
keep it defined.

Also detect the support on the same file as which is being tested.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
IMHO it's not a big slowdown thus I keep btrfs and tmpfs.
They might get support one day.

 testcases/kernel/syscalls/swapon/swapon01.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index b5c3f359c..6b7f96cf7 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -9,6 +9,9 @@
  * Checks that swapon() succeds with swapfile.
  */
 
+#define MNTPOINT	"mntpoint"
+#define SWAP_FILE	MNTPOINT"/swapfile01"
+
 #include <unistd.h>
 #include <errno.h>
 #include <stdlib.h>
@@ -18,14 +21,14 @@
 
 static void verify_swapon(void)
 {
-	TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
+	TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
 
 	if (TST_RET == -1) {
 		tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
 	} else {
 		tst_res(TPASS, "Succeeded to turn on swapfile");
 		/*we need to turn this swap file off for -i option */
-		if (tst_syscall(__NR_swapoff, "./swapfile01") != 0) {
+		if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
 			tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
 				" system reboot after execution of LTP "
 				"test suite is recommended.");
@@ -35,13 +38,15 @@ static void verify_swapon(void)
 
 static void setup(void)
 {
-	is_swap_supported("./tstswap");
-	make_swapfile("swapfile01", 0);
+	is_swap_supported(SWAP_FILE);
+	make_swapfile(SWAP_FILE, 0);
 }
 
 static struct tst_test test = {
-	.needs_root = 1,
-	.needs_tmpdir = 1,
+	.mntpoint = MNTPOINT,
+	.mount_device = 1,
+	.needs_root = 1, /* for swapon() */
+	.all_filesystems = 1,
 	.test_all = verify_swapon,
 	.setup = setup
 };
-- 
2.42.0


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

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

* [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright
  2023-10-11 16:24 [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Petr Vorel
  2023-10-11 16:24 ` [LTP] [PATCH 1/2] swapon01: Test on all filesystems Petr Vorel
@ 2023-10-11 16:24 ` Petr Vorel
  2024-01-19 11:59   ` Cyril Hrubis
  2023-10-12  9:28 ` [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Marius Kittler
  2 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2023-10-11 16:24 UTC (permalink / raw)
  To: ltp; +Cc: Richard Palethorpe

Remove  ambiguous comment with -i option during swapoff,
it's needed for a test cleanup anyway.

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
I wonder which command's -i option is meant. runltp -i ? swapon does not
have -i option.

Kind regards,
Petr

 testcases/kernel/syscalls/swapon/swapon01.c | 16 +++++-----------
 1 file changed, 5 insertions(+), 11 deletions(-)

diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index 6b7f96cf7..9286751a3 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (c) Wipro Technologies Ltd, 2002.  All Rights Reserved.
+ * Copyright (c) Linux Test Project, 2003-2023
  */
 
 /*\
@@ -21,18 +22,11 @@
 
 static void verify_swapon(void)
 {
-	TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
+	TST_EXP_PASS(tst_syscall(__NR_swapon, SWAP_FILE, 0));
 
-	if (TST_RET == -1) {
-		tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
-	} else {
-		tst_res(TPASS, "Succeeded to turn on swapfile");
-		/*we need to turn this swap file off for -i option */
-		if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
-			tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
-				" system reboot after execution of LTP "
-				"test suite is recommended.");
-		}
+	if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
+		tst_brk(TBROK | TERRNO,
+				"Failed to turn off swapfile, system reboot recommended");
 	}
 }
 
-- 
2.42.0


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

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

* Re: [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup
  2023-10-11 16:24 [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Petr Vorel
  2023-10-11 16:24 ` [LTP] [PATCH 1/2] swapon01: Test on all filesystems Petr Vorel
  2023-10-11 16:24 ` [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright Petr Vorel
@ 2023-10-12  9:28 ` Marius Kittler
  2024-01-12  7:18   ` Li Wang
  2 siblings, 1 reply; 11+ messages in thread
From: Marius Kittler @ 2023-10-12  9:28 UTC (permalink / raw)
  To: ltp

I guess the code would work and looks generally good to merge. In fact, I 
tested `.all_filesystems = 1`  myself yesterday. It is just the question 
whether we actually want it. Is there really coverage to be gained (or does 
the kernel just the same under the hood anyway regardless of the filesystem)?

> Test on all filesystems to increase coverage.  btrfs and tmpfs
> currently does not support swap file, but keep it in case this get
> changed in the future.

Considering btrfs does not support it I guess that means the kernel does 
indeed different things under the hood so the coverage might be beneficial. (If 
it was just about tmpfs then I'd say it makes no sense to put a swapfile there 
in any case and it will therefore likely never be supported.)

Reviewed-by: Marius Kittler <mkittler@suse.de>




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

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

* Re: [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup
  2023-10-12  9:28 ` [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Marius Kittler
@ 2024-01-12  7:18   ` Li Wang
  0 siblings, 0 replies; 11+ messages in thread
From: Li Wang @ 2024-01-12  7:18 UTC (permalink / raw)
  To: Marius Kittler; +Cc: ltp

Hi Marius, Petr,

On Thu, Oct 12, 2023 at 5:29 PM Marius Kittler <mkittler@suse.de> wrote:

> I guess the code would work and looks generally good to merge. In fact, I
> tested `.all_filesystems = 1`  myself yesterday. It is just the question
> whether we actually want it. Is there really coverage to be gained (or
> does
> the kernel just the same under the hood anyway regardless of the
> filesystem)?
>

After a rough looking at the swapon() related code achieved in the kernel
source.
I think the swapon coverage are same on whatever the swapfile filesystem is,
the only difference may be about the `make_swapfile` part which
highly depends
on the filesystem type, and the filesystem's characteristics can impact the
performance and effectiveness of swapping operations.

So in a word, if we just check the swapon() succeed with swapfile, the
'.all_filesystems = 1' is useless in patch1/2, but if we do more action in
writing/using swapfile that probably raises the coverage.

Reviewed-by: Li Wang <liwang@redhat.com>



>
> > Test on all filesystems to increase coverage.  btrfs and tmpfs
> > currently does not support swap file, but keep it in case this get
> > changed in the future.
>
> Considering btrfs does not support it I guess that means the kernel does
> indeed different things under the hood so the coverage might be
> beneficial. (If
> it was just about tmpfs then I'd say it makes no sense to put a swapfile
> there
> in any case and it will therefore likely never be supported.)
>
> Reviewed-by: Marius Kittler <mkittler@suse.de>
>
>
>
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang

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

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

* Re: [LTP] [PATCH 1/2] swapon01: Test on all filesystems
  2023-10-11 16:24 ` [LTP] [PATCH 1/2] swapon01: Test on all filesystems Petr Vorel
@ 2024-01-19 11:42   ` Cyril Hrubis
  2024-01-19 12:26     ` Li Wang
  0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2024-01-19 11:42 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
> Test on all filesystems to increase coverage.  btrfs and tmpfs
> currently does not support swap file, but keep it in case this get
> changed in the future.
> 
> Testing on all filesystems usually requests root, but we don't require
> it with .needs_root = 1. But using swapon() requires it as well, thus
> keep it defined.
> 
> Also detect the support on the same file as which is being tested.

For the previous iteration of this patch Li wasn't sure if this adds
enough value since there isn't ton of filesystem specific code involved
unless we actually start writing to the swapfile.

And as the patch is I would agree with that. What may make sense I think
is to require certain filesystem to support swap, i.e. fail the test in
the case that we haven't managed to create and enable the swapfile where
it's supposed to work. That would guard about accidental breakages, as
it is the test would not catch these because it woult TCONF in the
setup.

> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> IMHO it's not a big slowdown thus I keep btrfs and tmpfs.
> They might get support one day.
> 
>  testcases/kernel/syscalls/swapon/swapon01.c | 17 +++++++++++------
>  1 file changed, 11 insertions(+), 6 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
> index b5c3f359c..6b7f96cf7 100644
> --- a/testcases/kernel/syscalls/swapon/swapon01.c
> +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> @@ -9,6 +9,9 @@
>   * Checks that swapon() succeds with swapfile.
>   */
>  
> +#define MNTPOINT	"mntpoint"
> +#define SWAP_FILE	MNTPOINT"/swapfile01"
> +
>  #include <unistd.h>
>  #include <errno.h>
>  #include <stdlib.h>
> @@ -18,14 +21,14 @@
>  
>  static void verify_swapon(void)
>  {
> -	TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
> +	TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
>  
>  	if (TST_RET == -1) {
>  		tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
>  	} else {
>  		tst_res(TPASS, "Succeeded to turn on swapfile");
>  		/*we need to turn this swap file off for -i option */
> -		if (tst_syscall(__NR_swapoff, "./swapfile01") != 0) {
> +		if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
>  			tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
>  				" system reboot after execution of LTP "
>  				"test suite is recommended.");
> @@ -35,13 +38,15 @@ static void verify_swapon(void)
>  
>  static void setup(void)
>  {
> -	is_swap_supported("./tstswap");
> -	make_swapfile("swapfile01", 0);
> +	is_swap_supported(SWAP_FILE);
> +	make_swapfile(SWAP_FILE, 0);
>  }
>  
>  static struct tst_test test = {
> -	.needs_root = 1,
> -	.needs_tmpdir = 1,
> +	.mntpoint = MNTPOINT,
> +	.mount_device = 1,
> +	.needs_root = 1, /* for swapon() */
> +	.all_filesystems = 1,
>  	.test_all = verify_swapon,
>  	.setup = setup
>  };
> -- 
> 2.42.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright
  2023-10-11 16:24 ` [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright Petr Vorel
@ 2024-01-19 11:59   ` Cyril Hrubis
  2024-01-19 13:36     ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Cyril Hrubis @ 2024-01-19 11:59 UTC (permalink / raw)
  To: Petr Vorel; +Cc: Richard Palethorpe, ltp

Hi!
>  /*\
> @@ -21,18 +22,11 @@
>  
>  static void verify_swapon(void)
>  {
> -	TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
> +	TST_EXP_PASS(tst_syscall(__NR_swapon, SWAP_FILE, 0));
>  
> -	if (TST_RET == -1) {
> -		tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
> -	} else {
> -		tst_res(TPASS, "Succeeded to turn on swapfile");
> -		/*we need to turn this swap file off for -i option */
> -		if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
> -			tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
> -				" system reboot after execution of LTP "
> -				"test suite is recommended.");
> -		}
> +	if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {

Maybe if (TST_PASS && tst_syscall(__NR_swapoff, ...) != 0) {


Otherwise it looks good, with that change:

Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

> +		tst_brk(TBROK | TERRNO,
> +				"Failed to turn off swapfile, system reboot recommended");
>  	}
>  }
>  
> -- 
> 2.42.0
> 

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

* Re: [LTP] [PATCH 1/2] swapon01: Test on all filesystems
  2024-01-19 11:42   ` Cyril Hrubis
@ 2024-01-19 12:26     ` Li Wang
  2024-01-19 14:33       ` Petr Vorel
  0 siblings, 1 reply; 11+ messages in thread
From: Li Wang @ 2024-01-19 12:26 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: Richard Palethorpe, ltp

On Fri, Jan 19, 2024 at 7:42 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> Hi!
> > Test on all filesystems to increase coverage.  btrfs and tmpfs
> > currently does not support swap file, but keep it in case this get
> > changed in the future.
> >
> > Testing on all filesystems usually requests root, but we don't require
> > it with .needs_root = 1. But using swapon() requires it as well, thus
> > keep it defined.
> >
> > Also detect the support on the same file as which is being tested.
>
> For the previous iteration of this patch Li wasn't sure if this adds
> enough value since there isn't ton of filesystem specific code involved
> unless we actually start writing to the swapfile.
>

Yes, if testing with all_filesystems, only make_swapfile process makes
sense IMO.
The reset swapon() operation does the same thing to the kernel.



>
> And as the patch is I would agree with that. What may make sense I think
> is to require certain filesystem to support swap, i.e. fail the test in
> the case that we haven't managed to create and enable the swapfile where
> it's supposed to work. That would guard about accidental breakages, as
> it is the test would not catch these because it woult TCONF in the
> setup.
>

+1

This sounds reasonable, looks like we need a whitelist to guarantee
those filesystems that support swapfile, otherwise it's easy to miss
some false negatives with report TCONF by is_swap_supported().



>
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > IMHO it's not a big slowdown thus I keep btrfs and tmpfs.
> > They might get support one day.
> >
> >  testcases/kernel/syscalls/swapon/swapon01.c | 17 +++++++++++------
> >  1 file changed, 11 insertions(+), 6 deletions(-)
> >
> > diff --git a/testcases/kernel/syscalls/swapon/swapon01.c
> b/testcases/kernel/syscalls/swapon/swapon01.c
> > index b5c3f359c..6b7f96cf7 100644
> > --- a/testcases/kernel/syscalls/swapon/swapon01.c
> > +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> > @@ -9,6 +9,9 @@
> >   * Checks that swapon() succeds with swapfile.
> >   */
> >
> > +#define MNTPOINT     "mntpoint"
> > +#define SWAP_FILE    MNTPOINT"/swapfile01"
> > +
> >  #include <unistd.h>
> >  #include <errno.h>
> >  #include <stdlib.h>
> > @@ -18,14 +21,14 @@
> >
> >  static void verify_swapon(void)
> >  {
> > -     TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
> > +     TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
> >
> >       if (TST_RET == -1) {
> >               tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
> >       } else {
> >               tst_res(TPASS, "Succeeded to turn on swapfile");
> >               /*we need to turn this swap file off for -i option */
> > -             if (tst_syscall(__NR_swapoff, "./swapfile01") != 0) {
> > +             if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
> >                       tst_brk(TBROK | TERRNO, "Failed to turn off
> swapfile,"
> >                               " system reboot after execution of LTP "
> >                               "test suite is recommended.");
> > @@ -35,13 +38,15 @@ static void verify_swapon(void)
> >
> >  static void setup(void)
> >  {
> > -     is_swap_supported("./tstswap");
> > -     make_swapfile("swapfile01", 0);
> > +     is_swap_supported(SWAP_FILE);
> > +     make_swapfile(SWAP_FILE, 0);
> >  }
> >
> >  static struct tst_test test = {
> > -     .needs_root = 1,
> > -     .needs_tmpdir = 1,
> > +     .mntpoint = MNTPOINT,
> > +     .mount_device = 1,
> > +     .needs_root = 1, /* for swapon() */
> > +     .all_filesystems = 1,
> >       .test_all = verify_swapon,
> >       .setup = setup
> >  };
> > --
> > 2.42.0
> >
>
> --
> Cyril Hrubis
> chrubis@suse.cz
>
> --
> Mailing list info: https://lists.linux.it/listinfo/ltp
>
>

-- 
Regards,
Li Wang

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

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

* Re: [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright
  2024-01-19 11:59   ` Cyril Hrubis
@ 2024-01-19 13:36     ` Petr Vorel
  0 siblings, 0 replies; 11+ messages in thread
From: Petr Vorel @ 2024-01-19 13:36 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril,

> Hi!
> >  /*\
> > @@ -21,18 +22,11 @@

> >  static void verify_swapon(void)
> >  {
> > -	TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));
> > +	TST_EXP_PASS(tst_syscall(__NR_swapon, SWAP_FILE, 0));

> > -	if (TST_RET == -1) {
> > -		tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
> > -	} else {
> > -		tst_res(TPASS, "Succeeded to turn on swapfile");
> > -		/*we need to turn this swap file off for -i option */
> > -		if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
> > -			tst_brk(TBROK | TERRNO, "Failed to turn off swapfile,"
> > -				" system reboot after execution of LTP "
> > -				"test suite is recommended.");
> > -		}
> > +	if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {

> Maybe if (TST_PASS && tst_syscall(__NR_swapoff, ...) != 0) {

Rebased, add this change and merged. Thanks!

Kind regards,
Petr


> Otherwise it looks good, with that change:

> Reviewed-by: Cyril Hrubis <chrubis@suse.cz>

> > +		tst_brk(TBROK | TERRNO,
> > +				"Failed to turn off swapfile, system reboot recommended");
> >  	}
> >  }

> > -- 
> > 2.42.0

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

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

* Re: [LTP] [PATCH 1/2] swapon01: Test on all filesystems
  2024-01-19 12:26     ` Li Wang
@ 2024-01-19 14:33       ` Petr Vorel
  2024-01-19 14:53         ` Cyril Hrubis
  0 siblings, 1 reply; 11+ messages in thread
From: Petr Vorel @ 2024-01-19 14:33 UTC (permalink / raw)
  To: Li Wang; +Cc: ltp

> On Fri, Jan 19, 2024 at 7:42 PM Cyril Hrubis <chrubis@suse.cz> wrote:

> > Hi!
> > > Test on all filesystems to increase coverage.  btrfs and tmpfs
> > > currently does not support swap file, but keep it in case this get
> > > changed in the future.

> > > Testing on all filesystems usually requests root, but we don't require
> > > it with .needs_root = 1. But using swapon() requires it as well, thus
> > > keep it defined.

> > > Also detect the support on the same file as which is being tested.

> > For the previous iteration of this patch Li wasn't sure if this adds
> > enough value since there isn't ton of filesystem specific code involved
> > unless we actually start writing to the swapfile.

I wonder how to force. We could setup

sysctl vm.swappiness=100

But how to consume enough RAM to be actually written?

> Yes, if testing with all_filesystems, only make_swapfile process makes
> sense IMO.

> The reset swapon() operation does the same thing to the kernel.

> > And as the patch is I would agree with that. What may make sense I think
> > is to require certain filesystem to support swap, i.e. fail the test in
> > the case that we haven't managed to create and enable the swapfile where
> > it's supposed to work. That would guard about accidental breakages, as
> > it is the test would not catch these because it woult TCONF in the
> > setup.


> +1

> This sounds reasonable, looks like we need a whitelist to guarantee
> those filesystems that support swapfile, otherwise it's easy to miss
> some false negatives with report TCONF by is_swap_supported().

OK, even without writing it would make sense to test on all filesystems.

Replacing is_swap_supported() with a static list sounds good to me.
We might endup to check kernel release for certain filesystem
(if it got swap support later). Going to send a patch.

Kind regards,
Petr


> > > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > > ---
> > > IMHO it's not a big slowdown thus I keep btrfs and tmpfs.
> > > They might get support one day.

> > >  testcases/kernel/syscalls/swapon/swapon01.c | 17 +++++++++++------
> > >  1 file changed, 11 insertions(+), 6 deletions(-)

> > > diff --git a/testcases/kernel/syscalls/swapon/swapon01.c
> > b/testcases/kernel/syscalls/swapon/swapon01.c
> > > index b5c3f359c..6b7f96cf7 100644
> > > --- a/testcases/kernel/syscalls/swapon/swapon01.c
> > > +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> > > @@ -9,6 +9,9 @@
> > >   * Checks that swapon() succeds with swapfile.
> > >   */

> > > +#define MNTPOINT     "mntpoint"
> > > +#define SWAP_FILE    MNTPOINT"/swapfile01"
> > > +
> > >  #include <unistd.h>
> > >  #include <errno.h>
> > >  #include <stdlib.h>
> > > @@ -18,14 +21,14 @@

> > >  static void verify_swapon(void)
> > >  {
> > > -     TEST(tst_syscall(__NR_swapon, "./swapfile01", 0));
> > > +     TEST(tst_syscall(__NR_swapon, SWAP_FILE, 0));

> > >       if (TST_RET == -1) {
> > >               tst_res(TFAIL | TTERRNO, "Failed to turn on swapfile");
> > >       } else {
> > >               tst_res(TPASS, "Succeeded to turn on swapfile");
> > >               /*we need to turn this swap file off for -i option */
> > > -             if (tst_syscall(__NR_swapoff, "./swapfile01") != 0) {
> > > +             if (tst_syscall(__NR_swapoff, SWAP_FILE) != 0) {
> > >                       tst_brk(TBROK | TERRNO, "Failed to turn off
> > swapfile,"
> > >                               " system reboot after execution of LTP "
> > >                               "test suite is recommended.");
> > > @@ -35,13 +38,15 @@ static void verify_swapon(void)

> > >  static void setup(void)
> > >  {
> > > -     is_swap_supported("./tstswap");
> > > -     make_swapfile("swapfile01", 0);
> > > +     is_swap_supported(SWAP_FILE);
> > > +     make_swapfile(SWAP_FILE, 0);
> > >  }

> > >  static struct tst_test test = {
> > > -     .needs_root = 1,
> > > -     .needs_tmpdir = 1,
> > > +     .mntpoint = MNTPOINT,
> > > +     .mount_device = 1,
> > > +     .needs_root = 1, /* for swapon() */
> > > +     .all_filesystems = 1,
> > >       .test_all = verify_swapon,
> > >       .setup = setup
> > >  };
> > > --
> > > 2.42.0


> > --
> > Cyril Hrubis
> > chrubis@suse.cz

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

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

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

* Re: [LTP] [PATCH 1/2] swapon01: Test on all filesystems
  2024-01-19 14:33       ` Petr Vorel
@ 2024-01-19 14:53         ` Cyril Hrubis
  0 siblings, 0 replies; 11+ messages in thread
From: Cyril Hrubis @ 2024-01-19 14:53 UTC (permalink / raw)
  To: Petr Vorel; +Cc: ltp

Hi!
> > > For the previous iteration of this patch Li wasn't sure if this adds
> > > enough value since there isn't ton of filesystem specific code involved
> > > unless we actually start writing to the swapfile.
> 
> I wonder how to force. We could setup
> 
> sysctl vm.swappiness=100
> 
> But how to consume enough RAM to be actually written?

One way is put the process into a cgroup with fairly small RAM limit and
then allocate and fault memory, getting this right is not that easy
though.

-- 
Cyril Hrubis
chrubis@suse.cz

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

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

end of thread, other threads:[~2024-01-19 14:53 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-11 16:24 [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Petr Vorel
2023-10-11 16:24 ` [LTP] [PATCH 1/2] swapon01: Test on all filesystems Petr Vorel
2024-01-19 11:42   ` Cyril Hrubis
2024-01-19 12:26     ` Li Wang
2024-01-19 14:33       ` Petr Vorel
2024-01-19 14:53         ` Cyril Hrubis
2023-10-11 16:24 ` [LTP] [PATCH 2/2] swapon01: Simplify code, add copyright Petr Vorel
2024-01-19 11:59   ` Cyril Hrubis
2024-01-19 13:36     ` Petr Vorel
2023-10-12  9:28 ` [LTP] [PATCH 0/2] swapon01: Test on all filesystems, cleanup Marius Kittler
2024-01-12  7:18   ` Li Wang

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.