All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS
@ 2021-03-19 13:45 QI Fuli
  2021-03-19 14:41 ` Xiao Yang
  2021-03-20  8:55 ` Xiao Yang
  0 siblings, 2 replies; 4+ messages in thread
From: QI Fuli @ 2021-03-19 13:45 UTC (permalink / raw)
  To: ltp

remove redundant tasks as BTRFS is checked in is_swap_supported()
Fixes: caf453532("syscalls/swapon/swapon0{1..3}: use helpers to check
	support status")

Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
---
 testcases/kernel/syscalls/swapon/swapon01.c |  7 -------
 testcases/kernel/syscalls/swapon/swapon02.c | 14 +++-----------
 testcases/kernel/syscalls/swapon/swapon03.c | 15 +--------------
 3 files changed, 4 insertions(+), 32 deletions(-)

diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
index f95ce0ab2..aff842e4c 100644
--- a/testcases/kernel/syscalls/swapon/swapon01.c
+++ b/testcases/kernel/syscalls/swapon/swapon01.c
@@ -32,18 +32,11 @@ static void cleanup(void);
 char *TCID = "swapon01";
 int TST_TOTAL = 1;

-static long fs_type;
-
 static void verify_swapon(void)
 {
 	TEST(ltp_syscall(__NR_swapon, "./swapfile01", 0));

 	if (TEST_RETURN == -1) {
-		if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
-			tst_brkm(TCONF, cleanup,
-			         "Swapfile on BTRFS not implemeted");
-			return;
-		}
 		tst_resm(TFAIL | TTERRNO, "Failed to turn on swapfile");
 	} else {
 		tst_resm(TPASS, "Succeeded to turn on swapfile");
diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
index 3d49d0c6b..f0f99619d 100644
--- a/testcases/kernel/syscalls/swapon/swapon02.c
+++ b/testcases/kernel/syscalls/swapon/swapon02.c
@@ -47,7 +47,6 @@ int TST_TOTAL = 4;

 static uid_t nobody_uid;
 static int do_swapoff;
-static long fs_type;

 static struct test_case_t {
 	char *err_desc;
@@ -81,11 +80,6 @@ static void verify_swapon(struct test_case_t *test)
 		return;
 	}

-	if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
-		tst_resm(TCONF, "Swapfile on BTRFS not implemeted");
-			return;
-	}
-
 	tst_resm(TFAIL, "swapon(2) failed to produce expected error:"
 	         " %d, errno: %s and got %d.", test->exp_errno,
 	         test->exp_errval, TEST_ERRNO);
@@ -138,12 +132,10 @@ static void setup(void)
 	make_swapfile(cleanup, "swapfile01", 0);
 	make_swapfile(cleanup, "alreadyused", 0);

-	if (ltp_syscall(__NR_swapon, "alreadyused", 0)) {
-		if (fs_type != TST_BTRFS_MAGIC || errno != EINVAL)
-			tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
-	} else {
+	if (ltp_syscall(__NR_swapon, "alreadyused", 0))
+		tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
+	else
 		do_swapoff = 1;
-	}

 	TEST_PAUSE;
 }
diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
index cef57150c..19455bfe6 100644
--- a/testcases/kernel/syscalls/swapon/swapon03.c
+++ b/testcases/kernel/syscalls/swapon/swapon03.c
@@ -52,8 +52,6 @@ int TST_TOTAL = 1;

 static int swapfiles;

-static long fs_type;
-
 int testfiles = 3;
 static struct swap_testfile_t {
 	char *filename;
@@ -215,9 +213,6 @@ static int setup_swap(void)
 			/* turn on the swap file */
 			res = ltp_syscall(__NR_swapon, filename, 0);
 			if (res != 0) {
-				if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL)
-					exit(2);
-
 				if (errno == EPERM) {
 					printf("Successfully created %d "
 					       "swapfiles\n", j);
@@ -233,16 +228,8 @@ static int setup_swap(void)
 	} else
 		waitpid(pid, &status, 0);

-	switch (WEXITSTATUS(status)) {
-	case 0:
-	break;
-	case 2:
-		tst_brkm(TCONF, cleanup, "Swapfile on BTRFS not implemeted");
-	break;
-	default:
+	if (WEXITSTATUS(status) == 1)
 		tst_brkm(TFAIL, cleanup, "Failed to setup swaps");
-	break;
-	}

 	/* Create all needed extra swapfiles for testing */
 	for (j = 0; j < testfiles; j++)
--
2.29.2


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

* [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS
  2021-03-19 13:45 [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS QI Fuli
@ 2021-03-19 14:41 ` Xiao Yang
  2021-03-20  8:55 ` Xiao Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Xiao Yang @ 2021-03-19 14:41 UTC (permalink / raw)
  To: ltp

Hi Qi,

LGTM.

Reviewed-by: Xiao Yang <yangx.jy@cn.fujitsu.com>

Best Regards,

Xiao Yang

On 3/19/21 9:45 PM, QI Fuli wrote:
> remove redundant tasks as BTRFS is checked in is_swap_supported()
> Fixes: caf453532("syscalls/swapon/swapon0{1..3}: use helpers to check
> 	support status")
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/swapon/swapon01.c |  7 -------
>   testcases/kernel/syscalls/swapon/swapon02.c | 14 +++-----------
>   testcases/kernel/syscalls/swapon/swapon03.c | 15 +--------------
>   3 files changed, 4 insertions(+), 32 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
> index f95ce0ab2..aff842e4c 100644
> --- a/testcases/kernel/syscalls/swapon/swapon01.c
> +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> @@ -32,18 +32,11 @@ static void cleanup(void);
>   char *TCID = "swapon01";
>   int TST_TOTAL = 1;
>
> -static long fs_type;
> -
>   static void verify_swapon(void)
>   {
>   	TEST(ltp_syscall(__NR_swapon, "./swapfile01", 0));
>
>   	if (TEST_RETURN == -1) {
> -		if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
> -			tst_brkm(TCONF, cleanup,
> -			         "Swapfile on BTRFS not implemeted");
> -			return;
> -		}
>   		tst_resm(TFAIL | TTERRNO, "Failed to turn on swapfile");
>   	} else {
>   		tst_resm(TPASS, "Succeeded to turn on swapfile");
> diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
> index 3d49d0c6b..f0f99619d 100644
> --- a/testcases/kernel/syscalls/swapon/swapon02.c
> +++ b/testcases/kernel/syscalls/swapon/swapon02.c
> @@ -47,7 +47,6 @@ int TST_TOTAL = 4;
>
>   static uid_t nobody_uid;
>   static int do_swapoff;
> -static long fs_type;
>
>   static struct test_case_t {
>   	char *err_desc;
> @@ -81,11 +80,6 @@ static void verify_swapon(struct test_case_t *test)
>   		return;
>   	}
>
> -	if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
> -		tst_resm(TCONF, "Swapfile on BTRFS not implemeted");
> -			return;
> -	}
> -
>   	tst_resm(TFAIL, "swapon(2) failed to produce expected error:"
>   	         " %d, errno: %s and got %d.", test->exp_errno,
>   	         test->exp_errval, TEST_ERRNO);
> @@ -138,12 +132,10 @@ static void setup(void)
>   	make_swapfile(cleanup, "swapfile01", 0);
>   	make_swapfile(cleanup, "alreadyused", 0);
>
> -	if (ltp_syscall(__NR_swapon, "alreadyused", 0)) {
> -		if (fs_type != TST_BTRFS_MAGIC || errno != EINVAL)
> -			tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
> -	} else {
> +	if (ltp_syscall(__NR_swapon, "alreadyused", 0))
> +		tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
> +	else
>   		do_swapoff = 1;
> -	}
>
>   	TEST_PAUSE;
>   }
> diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
> index cef57150c..19455bfe6 100644
> --- a/testcases/kernel/syscalls/swapon/swapon03.c
> +++ b/testcases/kernel/syscalls/swapon/swapon03.c
> @@ -52,8 +52,6 @@ int TST_TOTAL = 1;
>
>   static int swapfiles;
>
> -static long fs_type;
> -
>   int testfiles = 3;
>   static struct swap_testfile_t {
>   	char *filename;
> @@ -215,9 +213,6 @@ static int setup_swap(void)
>   			/* turn on the swap file */
>   			res = ltp_syscall(__NR_swapon, filename, 0);
>   			if (res != 0) {
> -				if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL)
> -					exit(2);
> -
>   				if (errno == EPERM) {
>   					printf("Successfully created %d "
>   					       "swapfiles\n", j);
> @@ -233,16 +228,8 @@ static int setup_swap(void)
>   	} else
>   		waitpid(pid, &status, 0);
>
> -	switch (WEXITSTATUS(status)) {
> -	case 0:
> -	break;
> -	case 2:
> -		tst_brkm(TCONF, cleanup, "Swapfile on BTRFS not implemeted");
> -	break;
> -	default:
> +	if (WEXITSTATUS(status) == 1)
>   		tst_brkm(TFAIL, cleanup, "Failed to setup swaps");
> -	break;
> -	}
>
>   	/* Create all needed extra swapfiles for testing */
>   	for (j = 0; j < testfiles; j++)
> --
> 2.29.2
>
>


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

* [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS
  2021-03-19 13:45 [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS QI Fuli
  2021-03-19 14:41 ` Xiao Yang
@ 2021-03-20  8:55 ` Xiao Yang
  2021-03-21  4:40   ` QI Fuli
  1 sibling, 1 reply; 4+ messages in thread
From: Xiao Yang @ 2021-03-20  8:55 UTC (permalink / raw)
  To: ltp

Hi Qi,

Pushed with a minor change:

s/WEXITSTATUS(status) == 1/WEXITSTATUS(status)/

Thanks for your patch.

Best Regards,

Xiao Yang

On 3/19/21 9:45 PM, QI Fuli wrote:
> remove redundant tasks as BTRFS is checked in is_swap_supported()
> Fixes: caf453532("syscalls/swapon/swapon0{1..3}: use helpers to check
> 	support status")
>
> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
> ---
>   testcases/kernel/syscalls/swapon/swapon01.c |  7 -------
>   testcases/kernel/syscalls/swapon/swapon02.c | 14 +++-----------
>   testcases/kernel/syscalls/swapon/swapon03.c | 15 +--------------
>   3 files changed, 4 insertions(+), 32 deletions(-)
>
> diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
> index f95ce0ab2..aff842e4c 100644
> --- a/testcases/kernel/syscalls/swapon/swapon01.c
> +++ b/testcases/kernel/syscalls/swapon/swapon01.c
> @@ -32,18 +32,11 @@ static void cleanup(void);
>   char *TCID = "swapon01";
>   int TST_TOTAL = 1;
>
> -static long fs_type;
> -
>   static void verify_swapon(void)
>   {
>   	TEST(ltp_syscall(__NR_swapon, "./swapfile01", 0));
>
>   	if (TEST_RETURN == -1) {
> -		if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
> -			tst_brkm(TCONF, cleanup,
> -			         "Swapfile on BTRFS not implemeted");
> -			return;
> -		}
>   		tst_resm(TFAIL | TTERRNO, "Failed to turn on swapfile");
>   	} else {
>   		tst_resm(TPASS, "Succeeded to turn on swapfile");
> diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
> index 3d49d0c6b..f0f99619d 100644
> --- a/testcases/kernel/syscalls/swapon/swapon02.c
> +++ b/testcases/kernel/syscalls/swapon/swapon02.c
> @@ -47,7 +47,6 @@ int TST_TOTAL = 4;
>
>   static uid_t nobody_uid;
>   static int do_swapoff;
> -static long fs_type;
>
>   static struct test_case_t {
>   	char *err_desc;
> @@ -81,11 +80,6 @@ static void verify_swapon(struct test_case_t *test)
>   		return;
>   	}
>
> -	if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
> -		tst_resm(TCONF, "Swapfile on BTRFS not implemeted");
> -			return;
> -	}
> -
>   	tst_resm(TFAIL, "swapon(2) failed to produce expected error:"
>   	         " %d, errno: %s and got %d.", test->exp_errno,
>   	         test->exp_errval, TEST_ERRNO);
> @@ -138,12 +132,10 @@ static void setup(void)
>   	make_swapfile(cleanup, "swapfile01", 0);
>   	make_swapfile(cleanup, "alreadyused", 0);
>
> -	if (ltp_syscall(__NR_swapon, "alreadyused", 0)) {
> -		if (fs_type != TST_BTRFS_MAGIC || errno != EINVAL)
> -			tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
> -	} else {
> +	if (ltp_syscall(__NR_swapon, "alreadyused", 0))
> +		tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
> +	else
>   		do_swapoff = 1;
> -	}
>
>   	TEST_PAUSE;
>   }
> diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
> index cef57150c..19455bfe6 100644
> --- a/testcases/kernel/syscalls/swapon/swapon03.c
> +++ b/testcases/kernel/syscalls/swapon/swapon03.c
> @@ -52,8 +52,6 @@ int TST_TOTAL = 1;
>
>   static int swapfiles;
>
> -static long fs_type;
> -
>   int testfiles = 3;
>   static struct swap_testfile_t {
>   	char *filename;
> @@ -215,9 +213,6 @@ static int setup_swap(void)
>   			/* turn on the swap file */
>   			res = ltp_syscall(__NR_swapon, filename, 0);
>   			if (res != 0) {
> -				if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL)
> -					exit(2);
> -
>   				if (errno == EPERM) {
>   					printf("Successfully created %d "
>   					       "swapfiles\n", j);
> @@ -233,16 +228,8 @@ static int setup_swap(void)
>   	} else
>   		waitpid(pid, &status, 0);
>
> -	switch (WEXITSTATUS(status)) {
> -	case 0:
> -	break;
> -	case 2:
> -		tst_brkm(TCONF, cleanup, "Swapfile on BTRFS not implemeted");
> -	break;
> -	default:
> +	if (WEXITSTATUS(status) == 1)
>   		tst_brkm(TFAIL, cleanup, "Failed to setup swaps");
> -	break;
> -	}
>
>   	/* Create all needed extra swapfiles for testing */
>   	for (j = 0; j < testfiles; j++)
> --
> 2.29.2
>
>


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

* [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS
  2021-03-20  8:55 ` Xiao Yang
@ 2021-03-21  4:40   ` QI Fuli
  0 siblings, 0 replies; 4+ messages in thread
From: QI Fuli @ 2021-03-21  4:40 UTC (permalink / raw)
  To: ltp



> On Mar 20, 2021, at 17:55, Xiao Yang <ice_yangxiao@163.com> wrote:
> 
> Hi Qi,
> 
> Pushed with a minor change:
> 
> s/WEXITSTATUS(status) == 1/WEXITSTATUS(status)/
> 
> Thanks for your patch.
> 
> Best Regards,
> 
> Xiao Yang

Thank you very much.

QI

> 
> On 3/19/21 9:45 PM, QI Fuli wrote:
>> remove redundant tasks as BTRFS is checked in is_swap_supported()
>> Fixes: caf453532("syscalls/swapon/swapon0{1..3}: use helpers to check
>> 	support status")
>> 
>> Signed-off-by: QI Fuli <qi.fuli@fujitsu.com>
>> ---
>>  testcases/kernel/syscalls/swapon/swapon01.c |  7 -------
>>  testcases/kernel/syscalls/swapon/swapon02.c | 14 +++-----------
>>  testcases/kernel/syscalls/swapon/swapon03.c | 15 +--------------
>>  3 files changed, 4 insertions(+), 32 deletions(-)
>> 
>> diff --git a/testcases/kernel/syscalls/swapon/swapon01.c b/testcases/kernel/syscalls/swapon/swapon01.c
>> index f95ce0ab2..aff842e4c 100644
>> --- a/testcases/kernel/syscalls/swapon/swapon01.c
>> +++ b/testcases/kernel/syscalls/swapon/swapon01.c
>> @@ -32,18 +32,11 @@ static void cleanup(void);
>>  char *TCID = "swapon01";
>>  int TST_TOTAL = 1;
>> 
>> -static long fs_type;
>> -
>>  static void verify_swapon(void)
>>  {
>>  	TEST(ltp_syscall(__NR_swapon, "./swapfile01", 0));
>> 
>>  	if (TEST_RETURN == -1) {
>> -		if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
>> -			tst_brkm(TCONF, cleanup,
>> -			         "Swapfile on BTRFS not implemeted");
>> -			return;
>> -		}
>>  		tst_resm(TFAIL | TTERRNO, "Failed to turn on swapfile");
>>  	} else {
>>  		tst_resm(TPASS, "Succeeded to turn on swapfile");
>> diff --git a/testcases/kernel/syscalls/swapon/swapon02.c b/testcases/kernel/syscalls/swapon/swapon02.c
>> index 3d49d0c6b..f0f99619d 100644
>> --- a/testcases/kernel/syscalls/swapon/swapon02.c
>> +++ b/testcases/kernel/syscalls/swapon/swapon02.c
>> @@ -47,7 +47,6 @@ int TST_TOTAL = 4;
>> 
>>  static uid_t nobody_uid;
>>  static int do_swapoff;
>> -static long fs_type;
>> 
>>  static struct test_case_t {
>>  	char *err_desc;
>> @@ -81,11 +80,6 @@ static void verify_swapon(struct test_case_t *test)
>>  		return;
>>  	}
>> 
>> -	if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL) {
>> -		tst_resm(TCONF, "Swapfile on BTRFS not implemeted");
>> -			return;
>> -	}
>> -
>>  	tst_resm(TFAIL, "swapon(2) failed to produce expected error:"
>>  	         " %d, errno: %s and got %d.", test->exp_errno,
>>  	         test->exp_errval, TEST_ERRNO);
>> @@ -138,12 +132,10 @@ static void setup(void)
>>  	make_swapfile(cleanup, "swapfile01", 0);
>>  	make_swapfile(cleanup, "alreadyused", 0);
>> 
>> -	if (ltp_syscall(__NR_swapon, "alreadyused", 0)) {
>> -		if (fs_type != TST_BTRFS_MAGIC || errno != EINVAL)
>> -			tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
>> -	} else {
>> +	if (ltp_syscall(__NR_swapon, "alreadyused", 0))
>> +		tst_resm(TWARN | TERRNO, "swapon(alreadyused) failed");
>> +	else
>>  		do_swapoff = 1;
>> -	}
>> 
>>  	TEST_PAUSE;
>>  }
>> diff --git a/testcases/kernel/syscalls/swapon/swapon03.c b/testcases/kernel/syscalls/swapon/swapon03.c
>> index cef57150c..19455bfe6 100644
>> --- a/testcases/kernel/syscalls/swapon/swapon03.c
>> +++ b/testcases/kernel/syscalls/swapon/swapon03.c
>> @@ -52,8 +52,6 @@ int TST_TOTAL = 1;
>> 
>>  static int swapfiles;
>> 
>> -static long fs_type;
>> -
>>  int testfiles = 3;
>>  static struct swap_testfile_t {
>>  	char *filename;
>> @@ -215,9 +213,6 @@ static int setup_swap(void)
>>  			/* turn on the swap file */
>>  			res = ltp_syscall(__NR_swapon, filename, 0);
>>  			if (res != 0) {
>> -				if (fs_type == TST_BTRFS_MAGIC && errno == EINVAL)
>> -					exit(2);
>> -
>>  				if (errno == EPERM) {
>>  					printf("Successfully created %d "
>>  					       "swapfiles\n", j);
>> @@ -233,16 +228,8 @@ static int setup_swap(void)
>>  	} else
>>  		waitpid(pid, &status, 0);
>> 
>> -	switch (WEXITSTATUS(status)) {
>> -	case 0:
>> -	break;
>> -	case 2:
>> -		tst_brkm(TCONF, cleanup, "Swapfile on BTRFS not implemeted");
>> -	break;
>> -	default:
>> +	if (WEXITSTATUS(status) == 1)
>>  		tst_brkm(TFAIL, cleanup, "Failed to setup swaps");
>> -	break;
>> -	}
>> 
>>  	/* Create all needed extra swapfiles for testing */
>>  	for (j = 0; j < testfiles; j++)
>> --
>> 2.29.2
>> 
>> 
> 


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

end of thread, other threads:[~2021-03-21  4:40 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 13:45 [LTP] [PATCH v2] syscalls/swapon/swapon0{1..3}: Remove the check for BTRFS QI Fuli
2021-03-19 14:41 ` Xiao Yang
2021-03-20  8:55 ` Xiao Yang
2021-03-21  4:40   ` QI Fuli

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.