All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask()
@ 2020-07-27  9:40 Viresh Kumar
  2020-07-27  9:40 ` [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Viresh Kumar @ 2020-07-27  9:40 UTC (permalink / raw)
  To: ltp

Newer gcc generates following warnings currently:

sigwait.c: In function ?test_masked_matching?:
sigwait.c:157:42: warning: passing argument 3 to restrict-qualified parameter aliases with argument 2 [-Wrestrict]
  157 |  TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));

Fix these by using different pointers for new and old masks.

Reported-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V2: New patch

 libs/libltpsigwait/sigwait.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index dbd33a61f2b1..0a34e6cc3deb 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -156,11 +156,11 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 			    && si.si_code == SI_USER
 			    && si.si_signo == signo, "Struct siginfo mismatch");
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -214,11 +214,11 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 			    && si.si_signo == signo + 1,
 			    "Struct siginfo mismatch");
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -250,11 +250,11 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
 	REPORT_SUCCESS(signo, 0);
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -289,7 +289,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
 	REPORT_SUCCESS(-1, EFAULT);
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "sigprocmask() failed");
 
-- 
2.14.1


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

* [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
@ 2020-07-27  9:40 ` Viresh Kumar
  2020-07-29 14:40   ` Cyril Hrubis
  2020-07-28 13:02 ` [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Cyril Hrubis
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2020-07-27  9:40 UTC (permalink / raw)
  To: ltp

This is rather making the code difficult to read, get rid of it and its
associated functions.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V2: Improved print messages.

 libs/libltpsigwait/sigwait.c | 133 +++++++++++++++++++++++++------------------
 1 file changed, 78 insertions(+), 55 deletions(-)

diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index 0a34e6cc3deb..56b7722d0dbf 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -9,39 +9,6 @@
 #include "libsigwait.h"
 #include "tst_sig_proc.h"
 
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp., and cond is true. If cond is not
-	 true, report condition_errmsg
-*/
-static void report_success_cond(const char *func, int line,
-				long exp_return, int exp_errno, int condition,
-				char *condition_errmsg)
-{
-	if (exp_return == TST_RET
-	    && (exp_return != -1 || exp_errno == TST_ERR))
-		if (condition)
-			tst_res(TPASS, "%s (%d): Test passed", func, line);
-		else
-			tst_res(TFAIL, "%s (%d): %s", func, line,
-				 condition_errmsg);
-	else if (TST_RET != -1)
-		tst_res(TFAIL,
-			 "%s (%d): Unexpected return value; expected %ld, got %ld",
-			 func, line, exp_return, TST_RET);
-	else
-		tst_res(TFAIL | TTERRNO, "%s (%d): Unexpected failure",
-			 func, line);
-}
-
-#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg)	\
-	report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
-
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp.
-*/
-#define REPORT_SUCCESS(exp_return, exp_errno)					\
-	REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
-
 void test_empty_set(swi_func sigwaitinfo, int signo,
 		    enum tst_ts_type type LTP_ATTRIBUTE_UNUSED)
 {
@@ -55,7 +22,14 @@ void test_empty_set(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS(-1, EINTR);
+	if (TST_RET == -1) {
+		if (TST_ERR == EINTR)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EINTR, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -78,7 +52,14 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts)));
-	REPORT_SUCCESS(-1, EAGAIN);
+	if (TST_RET == -1) {
+		if (TST_ERR == EAGAIN)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EAGAIN, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -101,9 +82,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -122,7 +109,10 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by a signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -152,9 +142,15 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
@@ -203,16 +199,27 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 	SAFE_WAITPID(child[1], &status, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child[0] && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	/* eat the other signal */
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo + 1,
-			    "Struct siginfo mismatch");
+	if (TST_RET == signo + 1) {
+		if (si.si_pid == child[1] && si.si_code == SI_USER &&
+		    si.si_signo == signo + 1)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
@@ -248,7 +255,10 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by a signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
@@ -287,7 +297,14 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
 	if (TST_RET == -1)
@@ -316,8 +333,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 		if (TST_RET == -1 && TST_ERR == EFAULT)
 			_exit(0);
 
-		tst_res(TINFO | TTERRNO, "swi_func returned: %ld",
-			TST_RET);
+		tst_res(TINFO | TTERRNO, "swi_func returned: %ld", TST_RET);
 		_exit(1);
 	}
 
@@ -325,7 +341,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)
 		|| (WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
-		tst_res(TPASS, "Test passed");
+		tst_res(TPASS, "Wait interrupted by a signal");
 		return;
 	}
 
@@ -346,7 +362,14 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	SAFE_SIGEMPTYSET(&sigs);
 	TEST(sigwaitinfo(&sigs, NULL, (void *)1));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 }
 
 static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)
-- 
2.14.1


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

* [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask()
  2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
  2020-07-27  9:40 ` [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
@ 2020-07-28 13:02 ` Cyril Hrubis
  2020-07-29 12:55 ` [LTP] [PATCH V3 " Viresh Kumar
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2020-07-28 13:02 UTC (permalink / raw)
  To: ltp

Hi!
> sigwait.c: In function ???test_masked_matching???:
> sigwait.c:157:42: warning: passing argument 3 to restrict-qualified parameter aliases with argument 2 [-Wrestrict]
>   157 |  TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
> 
> Fix these by using different pointers for new and old masks.
> 
> Reported-by: Petr Vorel <pvorel@suse.cz>
> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
> ---
> V2: New patch
> 
>  libs/libltpsigwait/sigwait.c | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
> 
> diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
> index dbd33a61f2b1..0a34e6cc3deb 100644
> --- a/libs/libltpsigwait/sigwait.c
> +++ b/libs/libltpsigwait/sigwait.c
> @@ -156,11 +156,11 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
>  			    && si.si_code == SI_USER
>  			    && si.si_signo == signo, "Struct siginfo mismatch");
>  
> -	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
> +	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
>  	if (TST_RET == -1)
>  		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");

It says "restoring the original signal mask" so shouldn't that be
sigprocmask(SIG_SETMASK, &oldmask, &sigs) ?

> -	if (sigismember(&oldmask, signo))
> +	if (sigismember(&sigs, signo))
>  		tst_res(TPASS, "sigwaitinfo restored the original mask");
>  	else
>  		tst_res(TFAIL,
> @@ -214,11 +214,11 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
>  			    && si.si_signo == signo + 1,
>  			    "Struct siginfo mismatch");
>  
> -	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
> +	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
>  	if (TST_RET == -1)
>  		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
>  
> -	if (sigismember(&oldmask, signo))
> +	if (sigismember(&sigs, signo))
>  		tst_res(TPASS, "sigwaitinfo restored the original mask");
>  	else
>  		tst_res(TFAIL,
> @@ -250,11 +250,11 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
>  	TEST(sigwaitinfo(&sigs, NULL, NULL));
>  	REPORT_SUCCESS(signo, 0);
>  
> -	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
> +	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
>  	if (TST_RET == -1)
>  		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");

Here as well?

> -	if (sigismember(&oldmask, signo))
> +	if (sigismember(&sigs, signo))
>  		tst_res(TPASS, "sigwaitinfo restored the original mask");
>  	else
>  		tst_res(TFAIL,
> @@ -289,7 +289,7 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
>  	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
>  	REPORT_SUCCESS(-1, EFAULT);
>  
> -	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
> +	TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
>  	if (TST_RET == -1)
>  		tst_brk(TBROK | TTERRNO, "sigprocmask() failed");

And here?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH V3 1/2] libs: sigwait: Fix compilation warning around sigprocmask()
  2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
  2020-07-27  9:40 ` [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
  2020-07-28 13:02 ` [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Cyril Hrubis
@ 2020-07-29 12:55 ` Viresh Kumar
  2020-07-29 14:39   ` Cyril Hrubis
  2020-07-29 15:13 ` [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
  2020-08-04  7:57 ` [LTP] [PATCH V3 " Viresh Kumar
  4 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2020-07-29 12:55 UTC (permalink / raw)
  To: ltp

Newer gcc generates following warnings currently:

sigwait.c: In function ?test_masked_matching?:
sigwait.c:157:42: warning: passing argument 3 to restrict-qualified parameter aliases with argument 2 [-Wrestrict]
  157 |  TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));

Fix these by replacing the third argument with sigs or removing it if
not required.

Also improve a comment while at it.

Reported-by: Petr Vorel <pvorel@suse.cz>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V3:
- Fix function arguments.
- Fix print message.

 libs/libltpsigwait/sigwait.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index dbd33a61f2b1..fd32efd8aa9f 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -156,11 +156,11 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 			    && si.si_code == SI_USER
 			    && si.si_signo == signo, "Struct siginfo mismatch");
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -214,11 +214,11 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 			    && si.si_signo == signo + 1,
 			    "Struct siginfo mismatch");
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -250,11 +250,11 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
 	REPORT_SUCCESS(signo, 0);
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
 		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
-	if (sigismember(&oldmask, signo))
+	if (sigismember(&sigs, signo))
 		tst_res(TPASS, "sigwaitinfo restored the original mask");
 	else
 		tst_res(TFAIL,
@@ -289,9 +289,9 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
 	REPORT_SUCCESS(-1, EFAULT);
 
-	TEST(sigprocmask(SIG_SETMASK, &oldmask, &oldmask));
+	TEST(sigprocmask(SIG_SETMASK, &oldmask, NULL));
 	if (TST_RET == -1)
-		tst_brk(TBROK | TTERRNO, "sigprocmask() failed");
+		tst_brk(TBROK | TTERRNO, "restoring original signal mask failed");
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
-- 
2.14.1


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

* [LTP] [PATCH V3 1/2] libs: sigwait: Fix compilation warning around sigprocmask()
  2020-07-29 12:55 ` [LTP] [PATCH V3 " Viresh Kumar
@ 2020-07-29 14:39   ` Cyril Hrubis
  0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2020-07-29 14:39 UTC (permalink / raw)
  To: ltp

Hi!
Applied, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-27  9:40 ` [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
@ 2020-07-29 14:40   ` Cyril Hrubis
  2020-07-29 15:13     ` Viresh Kumar
  0 siblings, 1 reply; 12+ messages in thread
From: Cyril Hrubis @ 2020-07-29 14:40 UTC (permalink / raw)
  To: ltp

Hi!
Unfortunately half of this patch does not apply after the changes in the
first one, can you please rebase?

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-29 14:40   ` Cyril Hrubis
@ 2020-07-29 15:13     ` Viresh Kumar
  2020-07-30 15:25       ` Cyril Hrubis
  0 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2020-07-29 15:13 UTC (permalink / raw)
  To: ltp

On 29-07-20, 16:40, Cyril Hrubis wrote:
> Hi!
> Unfortunately half of this patch does not apply after the changes in the
> first one, can you please rebase?

I didn't see any issues with normal rebase of this patch over the other one, git
probably resolved issues itself.

I just now tried to apply this one with "git am -3" and it worked for me at
least (maybe git took some references from my tree).

But anyway, I will resend it now.

-- 
viresh

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

* [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
                   ` (2 preceding siblings ...)
  2020-07-29 12:55 ` [LTP] [PATCH V3 " Viresh Kumar
@ 2020-07-29 15:13 ` Viresh Kumar
  2020-07-30 15:34   ` Cyril Hrubis
  2020-08-04  7:57 ` [LTP] [PATCH V3 " Viresh Kumar
  4 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2020-07-29 15:13 UTC (permalink / raw)
  To: ltp

This is rather making the code difficult to read, get rid of it and its
associated functions.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 libs/libltpsigwait/sigwait.c | 133 +++++++++++++++++++++++++------------------
 1 file changed, 78 insertions(+), 55 deletions(-)

diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index fd32efd8aa9f..1eecdc59a772 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -9,39 +9,6 @@
 #include "libsigwait.h"
 #include "tst_sig_proc.h"
 
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp., and cond is true. If cond is not
-	 true, report condition_errmsg
-*/
-static void report_success_cond(const char *func, int line,
-				long exp_return, int exp_errno, int condition,
-				char *condition_errmsg)
-{
-	if (exp_return == TST_RET
-	    && (exp_return != -1 || exp_errno == TST_ERR))
-		if (condition)
-			tst_res(TPASS, "%s (%d): Test passed", func, line);
-		else
-			tst_res(TFAIL, "%s (%d): %s", func, line,
-				 condition_errmsg);
-	else if (TST_RET != -1)
-		tst_res(TFAIL,
-			 "%s (%d): Unexpected return value; expected %ld, got %ld",
-			 func, line, exp_return, TST_RET);
-	else
-		tst_res(TFAIL | TTERRNO, "%s (%d): Unexpected failure",
-			 func, line);
-}
-
-#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg)	\
-	report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
-
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp.
-*/
-#define REPORT_SUCCESS(exp_return, exp_errno)					\
-	REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
-
 void test_empty_set(swi_func sigwaitinfo, int signo,
 		    enum tst_ts_type type LTP_ATTRIBUTE_UNUSED)
 {
@@ -55,7 +22,14 @@ void test_empty_set(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS(-1, EINTR);
+	if (TST_RET == -1) {
+		if (TST_ERR == EINTR)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EINTR, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -78,7 +52,14 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts)));
-	REPORT_SUCCESS(-1, EAGAIN);
+	if (TST_RET == -1) {
+		if (TST_ERR == EAGAIN)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EAGAIN, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -101,9 +82,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -122,7 +109,10 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by a signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -152,9 +142,15 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -203,16 +199,27 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 	SAFE_WAITPID(child[1], &status, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child[0] && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	/* eat the other signal */
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo + 1,
-			    "Struct siginfo mismatch");
+	if (TST_RET == signo + 1) {
+		if (si.si_pid == child[1] && si.si_code == SI_USER &&
+		    si.si_signo == signo + 1)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -248,7 +255,10 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by a signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -287,7 +297,14 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, NULL));
 	if (TST_RET == -1)
@@ -316,8 +333,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 		if (TST_RET == -1 && TST_ERR == EFAULT)
 			_exit(0);
 
-		tst_res(TINFO | TTERRNO, "swi_func returned: %ld",
-			TST_RET);
+		tst_res(TINFO | TTERRNO, "swi_func returned: %ld", TST_RET);
 		_exit(1);
 	}
 
@@ -325,7 +341,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)
 		|| (WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
-		tst_res(TPASS, "Test passed");
+		tst_res(TPASS, "Wait interrupted by a signal");
 		return;
 	}
 
@@ -346,7 +362,14 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	SAFE_SIGEMPTYSET(&sigs);
 	TEST(sigwaitinfo(&sigs, NULL, (void *)1));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Wait interrupted by a signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 }
 
 static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)
-- 
2.14.1


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

* [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-29 15:13     ` Viresh Kumar
@ 2020-07-30 15:25       ` Cyril Hrubis
  0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2020-07-30 15:25 UTC (permalink / raw)
  To: ltp

Hi!
> > Unfortunately half of this patch does not apply after the changes in the
> > first one, can you please rebase?
> 
> I didn't see any issues with normal rebase of this patch over the other one, git
> probably resolved issues itself.

Well the original v2 patch contains references to the sigprocmask()
lines that the previous patch changes, what I got bunch of these:

Checking patch libs/libltpsigwait/sigwait.c...
error: while searching for:
        child = create_sig_proc(signo, 1, 0);

        TEST(sigwaitinfo(&sigs, &si, NULL));
        REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
                            && si.si_code == SI_USER
                            && si.si_signo == signo, "Struct siginfo mismatch");

        TEST(sigprocmask(SIG_SETMASK, &sigs, &oldmask));
        if (TST_RET == -1)

Because the sigprocmask(SIG_SETMASK, &sigs, &oldmask)); couldn't be found.

The patch that you resend has corrected these.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-29 15:13 ` [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
@ 2020-07-30 15:34   ` Cyril Hrubis
  0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2020-07-30 15:34 UTC (permalink / raw)
  To: ltp

Hi!
>  	SAFE_KILL(child, SIGTERM);
>  	SAFE_WAIT(NULL);
> @@ -78,7 +52,14 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)
>  	child = create_sig_proc(signo, INT_MAX, 100000);
>  
>  	TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts)));
> -	REPORT_SUCCESS(-1, EAGAIN);
> +	if (TST_RET == -1) {
> +		if (TST_ERR == EAGAIN)
> +			tst_res(TPASS, "Wait interrupted by a signal");

Can we please fix these messages as well so that it's not copy & paste
of the same message all over?

This one should say "Wait interrupted by a timeout"

> +		else
> +			tst_res(TFAIL | TTERRNO, "Expected error number EAGAIN, got");
> +	} else {
> +		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
> +	}
>  
>  	SAFE_KILL(child, SIGTERM);
>  	SAFE_WAIT(NULL);
> @@ -101,9 +82,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,
>  	child = create_sig_proc(signo, INT_MAX, 100000);
>  
>  	TEST(sigwaitinfo(&sigs, &si, NULL));
> -	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
> -			    && si.si_code == SI_USER
> -			    && si.si_signo == signo, "Struct siginfo mismatch");
> +	if (TST_RET == signo) {
> +		if (si.si_pid == child && si.si_code == SI_USER &&
> +		    si.si_signo == signo)
> +			tst_res(TPASS, "Wait interrupted by a signal");

And this one "struct siginfo is correct"


etc.

-- 
Cyril Hrubis
chrubis@suse.cz

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

* [LTP] [PATCH V3 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
                   ` (3 preceding siblings ...)
  2020-07-29 15:13 ` [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
@ 2020-08-04  7:57 ` Viresh Kumar
  2020-08-06 12:26   ` Cyril Hrubis
  4 siblings, 1 reply; 12+ messages in thread
From: Viresh Kumar @ 2020-08-04  7:57 UTC (permalink / raw)
  To: ltp

This is rather making the code difficult to read, get rid of it and its
associated functions.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
V3: Improved print messages.

 libs/libltpsigwait/sigwait.c | 133 +++++++++++++++++++++++++------------------
 1 file changed, 78 insertions(+), 55 deletions(-)

diff --git a/libs/libltpsigwait/sigwait.c b/libs/libltpsigwait/sigwait.c
index fd32efd8aa9f..2be949929fb1 100644
--- a/libs/libltpsigwait/sigwait.c
+++ b/libs/libltpsigwait/sigwait.c
@@ -9,39 +9,6 @@
 #include "libsigwait.h"
 #include "tst_sig_proc.h"
 
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp., and cond is true. If cond is not
-	 true, report condition_errmsg
-*/
-static void report_success_cond(const char *func, int line,
-				long exp_return, int exp_errno, int condition,
-				char *condition_errmsg)
-{
-	if (exp_return == TST_RET
-	    && (exp_return != -1 || exp_errno == TST_ERR))
-		if (condition)
-			tst_res(TPASS, "%s (%d): Test passed", func, line);
-		else
-			tst_res(TFAIL, "%s (%d): %s", func, line,
-				 condition_errmsg);
-	else if (TST_RET != -1)
-		tst_res(TFAIL,
-			 "%s (%d): Unexpected return value; expected %ld, got %ld",
-			 func, line, exp_return, TST_RET);
-	else
-		tst_res(TFAIL | TTERRNO, "%s (%d): Unexpected failure",
-			 func, line);
-}
-
-#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg)	\
-	report_success_cond(__FUNCTION__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
-
-/* Report success iff TST_RET and TST_ERR are equal to
-	 exp_return and exp_errno, resp.
-*/
-#define REPORT_SUCCESS(exp_return, exp_errno)					\
-	REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
-
 void test_empty_set(swi_func sigwaitinfo, int signo,
 		    enum tst_ts_type type LTP_ATTRIBUTE_UNUSED)
 {
@@ -55,7 +22,14 @@ void test_empty_set(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS(-1, EINTR);
+	if (TST_RET == -1) {
+		if (TST_ERR == EINTR)
+			tst_res(TPASS, "Wait interrupted by expected signal");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EINTR, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -78,7 +52,14 @@ void test_timeout(swi_func sigwaitinfo, int signo, enum tst_ts_type type)
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, tst_ts_get(&ts)));
-	REPORT_SUCCESS(-1, EAGAIN);
+	if (TST_RET == -1) {
+		if (TST_ERR == EAGAIN)
+			tst_res(TPASS, "Wait interrupted by timeout");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EAGAIN, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -101,9 +82,15 @@ void test_unmasked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "struct siginfo is correct");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -122,7 +109,10 @@ void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, INT_MAX, 100000);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by expected signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	SAFE_KILL(child, SIGTERM);
 	SAFE_WAIT(NULL);
@@ -152,9 +142,15 @@ void test_masked_matching(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "struct siginfo is correct");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -203,16 +199,27 @@ void test_masked_matching_rt(swi_func sigwaitinfo, int signo,
 	SAFE_WAITPID(child[1], &status, 0);
 
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo, 0, si.si_pid == child[0]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo, "Struct siginfo mismatch");
+	if (TST_RET == signo) {
+		if (si.si_pid == child[0] && si.si_code == SI_USER &&
+		    si.si_signo == signo)
+			tst_res(TPASS, "struct siginfo is correct");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	/* eat the other signal */
 	TEST(sigwaitinfo(&sigs, &si, NULL));
-	REPORT_SUCCESS_COND(signo + 1, 0, si.si_pid == child[1]
-			    && si.si_code == SI_USER
-			    && si.si_signo == signo + 1,
-			    "Struct siginfo mismatch");
+	if (TST_RET == signo + 1) {
+		if (si.si_pid == child[1] && si.si_code == SI_USER &&
+		    si.si_signo == signo + 1)
+			tst_res(TPASS, "struct siginfo is correct");
+		else
+			tst_res(TFAIL, "struct siginfo mismatch");
+	} else {
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -248,7 +255,10 @@ void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, NULL, NULL));
-	REPORT_SUCCESS(signo, 0);
+	if (TST_RET == signo)
+		tst_res(TPASS, "Wait interrupted by expected signal");
+	else
+		tst_res(TFAIL | TTERRNO, "sigwaitinfo() failed");
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, &sigs));
 	if (TST_RET == -1)
@@ -287,7 +297,14 @@ void test_bad_address(swi_func sigwaitinfo, int signo,
 	child = create_sig_proc(signo, 1, 0);
 
 	TEST(sigwaitinfo(&sigs, (void *)1, NULL));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Fault occurred while accessing the buffers");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 
 	TEST(sigprocmask(SIG_SETMASK, &oldmask, NULL));
 	if (TST_RET == -1)
@@ -316,8 +333,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 		if (TST_RET == -1 && TST_ERR == EFAULT)
 			_exit(0);
 
-		tst_res(TINFO | TTERRNO, "swi_func returned: %ld",
-			TST_RET);
+		tst_res(TINFO | TTERRNO, "swi_func returned: %ld", TST_RET);
 		_exit(1);
 	}
 
@@ -325,7 +341,7 @@ void test_bad_address2(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	if ((WIFSIGNALED(status) && WTERMSIG(status) == SIGSEGV)
 		|| (WIFEXITED(status) && WEXITSTATUS(status) == 0)) {
-		tst_res(TPASS, "Test passed");
+		tst_res(TPASS, "Child exited with expected code");
 		return;
 	}
 
@@ -346,7 +362,14 @@ void test_bad_address3(swi_func sigwaitinfo, int signo LTP_ATTRIBUTE_UNUSED,
 
 	SAFE_SIGEMPTYSET(&sigs);
 	TEST(sigwaitinfo(&sigs, NULL, (void *)1));
-	REPORT_SUCCESS(-1, EFAULT);
+	if (TST_RET == -1) {
+		if (TST_ERR == EFAULT)
+			tst_res(TPASS, "Fault occurred while accessing the buffers");
+		else
+			tst_res(TFAIL | TTERRNO, "Expected error number EFAULT, got");
+	} else {
+		tst_res(TFAIL, "Expected return value -1, got: %ld", TST_RET);
+	}
 }
 
 static void empty_handler(int sig LTP_ATTRIBUTE_UNUSED)
-- 
2.14.1


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

* [LTP] [PATCH V3 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro
  2020-08-04  7:57 ` [LTP] [PATCH V3 " Viresh Kumar
@ 2020-08-06 12:26   ` Cyril Hrubis
  0 siblings, 0 replies; 12+ messages in thread
From: Cyril Hrubis @ 2020-08-06 12:26 UTC (permalink / raw)
  To: ltp

Hi!
Pushed, thanks.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2020-08-06 12:26 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-27  9:40 [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Viresh Kumar
2020-07-27  9:40 ` [LTP] [PATCH V2 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
2020-07-29 14:40   ` Cyril Hrubis
2020-07-29 15:13     ` Viresh Kumar
2020-07-30 15:25       ` Cyril Hrubis
2020-07-28 13:02 ` [LTP] [PATCH V2 1/2] libs: sigwait: Fix compilation warning around sigprocmask() Cyril Hrubis
2020-07-29 12:55 ` [LTP] [PATCH V3 " Viresh Kumar
2020-07-29 14:39   ` Cyril Hrubis
2020-07-29 15:13 ` [LTP] [PATCH V2 resend 2/2] libs: sigwait: Get rid of REPORT_SUCCESS() macro Viresh Kumar
2020-07-30 15:34   ` Cyril Hrubis
2020-08-04  7:57 ` [LTP] [PATCH V3 " Viresh Kumar
2020-08-06 12:26   ` Cyril Hrubis

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.