diff mbox series

[2/2] swapon01: Simplify code, add copyright

Message ID 20231011162428.583911-3-pvorel@suse.cz
State Accepted
Headers show
Series swapon01: Test on all filesystems, cleanup | expand

Commit Message

Petr Vorel Oct. 11, 2023, 4:24 p.m. UTC
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(-)

Comments

Cyril Hrubis Jan. 19, 2024, 11:59 a.m. UTC | #1
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
>
Petr Vorel Jan. 19, 2024, 1:36 p.m. UTC | #2
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
diff mbox series

Patch

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");
 	}
 }