All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01
@ 2018-11-13 15:17 Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 1/3] lapi/rt_sigaction.h: Make it usable for newlib tests Cyril Hrubis
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Cyril Hrubis @ 2018-11-13 15:17 UTC (permalink / raw)
  To: ltp

This set lays out interface for converting rt signal tests to new
library and also converts the rt_sigsuspend01 test.

Cyril Hrubis (3):
  lapi/rt_sigaction.h: Make it usable for newlib tests
  lapi/safe_rt_signal.h: Add.
  syscalls/rt_sigsuspend01: Cleanup && convert to newlib

 include/lapi/rt_sigaction.h                        |  10 +-
 include/lapi/safe_rt_signal.h                      |  50 ++++++++
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       | 135 +++++++--------------
 3 files changed, 101 insertions(+), 94 deletions(-)
 create mode 100644 include/lapi/safe_rt_signal.h

-- 
2.16.4


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

* [LTP] [PATCH 1/3] lapi/rt_sigaction.h: Make it usable for newlib tests
  2018-11-13 15:17 [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
@ 2018-11-13 15:17 ` Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 2/3] lapi/safe_rt_signal.h: Add Cyril Hrubis
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2018-11-13 15:17 UTC (permalink / raw)
  To: ltp

We only need to switch between ltp_syscall() and tst_syscall().

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/lapi/rt_sigaction.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/include/lapi/rt_sigaction.h b/include/lapi/rt_sigaction.h
index 18236db62..2dbbc7672 100644
--- a/include/lapi/rt_sigaction.h
+++ b/include/lapi/rt_sigaction.h
@@ -177,6 +177,12 @@ __attribute__ ((optimize("Os"))) __attribute__((used)) restore_rt(void)
 }
 #endif
 
+#ifdef TST_TEST_H__
+# define TST_SYSCALL tst_syscall
+#else
+# define TST_SYSCALL ltp_syscall
+#endif
+
 /* This is a wrapper for __NR_rt_sigaction syscall.
  * act/oact values of INVAL_SA_PTR is used to pass
  * an invalid pointer to syscall(__NR_rt_sigaction)
@@ -232,11 +238,11 @@ static int ltp_rt_sigaction(int signum, const struct sigaction *act,
 
 
 #ifdef __sparc__
-	ret = ltp_syscall(__NR_rt_sigaction, signum,
+	ret = TST_SYSCALL(__NR_rt_sigaction, signum,
 			kact_p, koact_p,
 			stub, sigsetsize);
 #else
-	ret = ltp_syscall(__NR_rt_sigaction, signum,
+	ret = TST_SYSCALL(__NR_rt_sigaction, signum,
 			kact_p, koact_p,
 			sigsetsize);
 #endif
-- 
2.16.4


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

* [LTP] [PATCH 2/3] lapi/safe_rt_signal.h: Add.
  2018-11-13 15:17 [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 1/3] lapi/rt_sigaction.h: Make it usable for newlib tests Cyril Hrubis
@ 2018-11-13 15:17 ` Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib Cyril Hrubis
  2018-11-19 13:36 ` [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
  3 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2018-11-13 15:17 UTC (permalink / raw)
  To: ltp

This commits adds SAFE_RT_* calls, the file is created in lapi/ because
these are wrappers around low level kernel syscalls rather than around
the libc interfaces.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 include/lapi/safe_rt_signal.h | 50 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100644 include/lapi/safe_rt_signal.h

diff --git a/include/lapi/safe_rt_signal.h b/include/lapi/safe_rt_signal.h
new file mode 100644
index 000000000..67fa44417
--- /dev/null
+++ b/include/lapi/safe_rt_signal.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018 Cyril Hrubis <chrubis@suse.cz>
+ */
+
+#ifndef SAFE_RT_SIGNAL_H__
+#define SAFE_RT_SIGNAL_H__
+
+#include <signal.h>
+#include "lapi/rt_sigaction.h"
+
+static inline int safe_rt_sigaction(const char *file, const int lineno,
+                                    int signum, const struct sigaction *act,
+                                    struct sigaction *oact, size_t sigsetsize)
+{
+	int ret;
+
+	ret = ltp_rt_sigaction(signum, act, oact, sigsetsize);
+	if (ret < 0) {
+		tst_brk(TBROK | TERRNO,
+			"%s:%d: ltp_rt_sigaction(%i, %p, %p, %zu) failed",
+			file, lineno, signum, act, oact, sigsetsize);
+	}
+
+	return ret;
+}
+
+#define SAFE_RT_SIGACTION(signum, act, oldact, sigsetsize) \
+	safe_rt_sigaction(__FILE__, __LINE__, signum, act, oldact, sigsetsize)
+
+
+static inline int safe_rt_sigprocmask(const char *file, const int lineno,
+                                      int how, const sigset_t *set,
+                                      sigset_t *oldset, size_t sigsetsize)
+{
+	int ret;
+
+	ret = tst_syscall(__NR_rt_sigprocmask, how, set, oldset, sigsetsize);
+	if (ret < 0) {
+		tst_brk(TBROK | TERRNO,
+		        "%s:%d: rt_sigprocmask(%i, %p, %p, %zu) failed",
+			file, lineno, how, set, oldset, sigsetsize);
+	}
+
+	return ret;
+}
+
+#define SAFE_RT_SIGPROCMASK(how, set, oldset, sigsetsize) \
+	safe_rt_sigprocmask(__FILE__, __LINE__, how, set, oldset, sigsetsize)
+
+#endif /* SAFE_RT_SIGNAL_H__ */
-- 
2.16.4


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

* [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib
  2018-11-13 15:17 [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 1/3] lapi/rt_sigaction.h: Make it usable for newlib tests Cyril Hrubis
  2018-11-13 15:17 ` [LTP] [PATCH 2/3] lapi/safe_rt_signal.h: Add Cyril Hrubis
@ 2018-11-13 15:17 ` Cyril Hrubis
  2018-11-13 20:18   ` Steve Muckle
  2018-11-19 13:36 ` [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
  3 siblings, 1 reply; 6+ messages in thread
From: Cyril Hrubis @ 2018-11-13 15:17 UTC (permalink / raw)
  To: ltp

Also there is no need to sleep for 5 seconds so we only sleep for 1 now.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Steve Muckle <smuckle@google.com>
---
 .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       | 135 +++++++--------------
 1 file changed, 43 insertions(+), 92 deletions(-)

diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
index c8c228a47..14b6bb332 100644
--- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
+++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
@@ -1,112 +1,63 @@
 /******************************************************************************/
 /* Copyright (c) Crackerjack Project., 2007                                   */
 /*                                                                            */
-/* This program is free software;  you can redistribute it and/or modify      */
-/* it under the terms of the GNU General Public License as published by       */
-/* the Free Software Foundation; either version 2 of the License, or          */
-/* (at your option) any later version.                                        */
-/*                                                                            */
-/* This program is distributed in the hope that it will be useful,            */
-/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
-/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
-/* the GNU General Public License for more details.                           */
-/*                                                                            */
-/* You should have received a copy of the GNU General Public License          */
-/* along with this program;  if not, write to the Free Software Foundation,   */
-/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
-/*                                                                            */
 /* History:     Porting from Crackerjack to LTP is done by                    */
 /*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
 /******************************************************************************/
 
-/******************************************************************************/
-/* Description: This tests the rt_sigsuspend() syscall.                       */
-/******************************************************************************/
+/*
+ * Description: This tests the rt_sigsuspend() syscall.
+ *
+ * Waits for SIGALRM in rt_sigsuspend() then checks that process mask wasn't
+ * modified.
+ */
 
-#include <stdio.h>
 #include <signal.h>
 #include <errno.h>
-#include <string.h>
 
-#include "test.h"
+#include "tst_test.h"
 #include "lapi/syscalls.h"
-#include "lapi/rt_sigaction.h"
-
-char *TCID = "rt_sigsuspend01";
-int TST_TOTAL = 1;
-
-static void cleanup(void)
-{
-	tst_rmdir();
-}
-
-static void setup(void)
-{
-	TEST_PAUSE;
-	tst_tmpdir();
-}
+#include "lapi/safe_rt_signal.h"
 
 static void sig_handler(int sig)
 {
+	(void) sig;
 }
 
-int main(int ac, char **av)
+static void verify_rt_sigsuspend(void)
 {
 	sigset_t set, set1, set2;
-	int lc;
-
-	tst_parse_opts(ac, av, NULL, NULL);
-
-	setup();
-
-	for (lc = 0; TEST_LOOPING(lc); ++lc) {
-
-		tst_count = 0;
-
-		if (sigemptyset(&set) < 0)
-			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
-		struct sigaction act, oact;
-		memset(&act, 0, sizeof(act));
-		memset(&oact, 0, sizeof(oact));
-		act.sa_handler = sig_handler;
-
-		TEST(ltp_rt_sigaction(SIGALRM, &act, &oact, SIGSETSIZE));
-		if (TEST_RETURN == -1)
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "rt_sigaction failed");
-
-		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
-			     &set1, SIGSETSIZE));
-		if (TEST_RETURN == -1)
-			tst_brkm(TFAIL | TTERRNO, cleanup,
-				 "rt_sigprocmask failed");
-
-		TEST(alarm(5));
-		int result;
-		TEST(result = ltp_syscall(__NR_rt_sigsuspend, &set,
-			SIGSETSIZE));
-		TEST(alarm(0));
-		if (result == -1 && TEST_ERRNO != EINTR) {
-			TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
-				&set2, SIGSETSIZE));
-			if (TEST_RETURN == -1) {
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "rt_sigprocmask failed");
-			} else if (memcmp(&set1, &set2,
-				   sizeof(unsigned long))) {
-				tst_brkm(TFAIL | TTERRNO, cleanup,
-					 "rt_sigsuspend failed to "
-					 "preserve signal mask");
-			} else {
-				tst_resm(TPASS, "rt_sigsuspend PASSED");
-			}
-		} else {
-			tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
-		}
-
-	}
-
-	cleanup();
-
-	tst_exit();
+	struct sigaction act = {.sa_handler = sig_handler};
+
+	if (sigemptyset(&set) < 0)
+		tst_brk(TFAIL | TERRNO, "sigemptyset failed");
+
+	SAFE_RT_SIGACTION(SIGALRM, &act, NULL, SIGSETSIZE);
+
+	SAFE_RT_SIGPROCMASK(0, NULL, &set1, SIGSETSIZE);
+
+	alarm(1);
+
+	TEST(tst_syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
+
+	alarm(0);
+
+	if (TST_RET != -1)
+		tst_brk(TFAIL, "rt_sigsuspend returned %ld", TST_RET);
+
+	if (TST_ERR != EINTR)
+		tst_brk(TFAIL | TTERRNO, "rt_sigsuspend() failed unexpectedly");
+
+	tst_res(TPASS, "rt_sigsuspend() returned with -1 and EINTR");
+
+	SAFE_RT_SIGPROCMASK(0, NULL, &set2, SIGSETSIZE);
+
+	if (memcmp(&set1, &set2, sizeof(unsigned long)))
+		tst_res(TFAIL, "signal mask not preserved");
+	else
+		tst_res(TPASS, "signal mask preserved");
 }
+
+static struct tst_test test = {
+	.test_all = verify_rt_sigsuspend,
+};
-- 
2.16.4


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

* [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib
  2018-11-13 15:17 ` [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib Cyril Hrubis
@ 2018-11-13 20:18   ` Steve Muckle
  0 siblings, 0 replies; 6+ messages in thread
From: Steve Muckle @ 2018-11-13 20:18 UTC (permalink / raw)
  To: ltp

LGTM

On 11/13/2018 07:17 AM, Cyril Hrubis wrote:
> Also there is no need to sleep for 5 seconds so we only sleep for 1 now.
> 
> Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
> CC: Steve Muckle <smuckle@google.com>
> ---
>   .../syscalls/rt_sigsuspend/rt_sigsuspend01.c       | 135 +++++++--------------
>   1 file changed, 43 insertions(+), 92 deletions(-)
> 
> diff --git a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> index c8c228a47..14b6bb332 100644
> --- a/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> +++ b/testcases/kernel/syscalls/rt_sigsuspend/rt_sigsuspend01.c
> @@ -1,112 +1,63 @@
>   /******************************************************************************/
>   /* Copyright (c) Crackerjack Project., 2007                                   */
>   /*                                                                            */
> -/* This program is free software;  you can redistribute it and/or modify      */
> -/* it under the terms of the GNU General Public License as published by       */
> -/* the Free Software Foundation; either version 2 of the License, or          */
> -/* (at your option) any later version.                                        */
> -/*                                                                            */
> -/* This program is distributed in the hope that it will be useful,            */
> -/* but WITHOUT ANY WARRANTY;  without even the implied warranty of            */
> -/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See                  */
> -/* the GNU General Public License for more details.                           */
> -/*                                                                            */
> -/* You should have received a copy of the GNU General Public License          */
> -/* along with this program;  if not, write to the Free Software Foundation,   */
> -/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA           */
> -/*                                                                            */
>   /* History:     Porting from Crackerjack to LTP is done by                    */
>   /*              Manas Kumar Nayak maknayak@in.ibm.com>                        */
>   /******************************************************************************/
>   
> -/******************************************************************************/
> -/* Description: This tests the rt_sigsuspend() syscall.                       */
> -/******************************************************************************/
> +/*
> + * Description: This tests the rt_sigsuspend() syscall.
> + *
> + * Waits for SIGALRM in rt_sigsuspend() then checks that process mask wasn't
> + * modified.
> + */
>   
> -#include <stdio.h>
>   #include <signal.h>
>   #include <errno.h>
> -#include <string.h>
>   
> -#include "test.h"
> +#include "tst_test.h"
>   #include "lapi/syscalls.h"
> -#include "lapi/rt_sigaction.h"
> -
> -char *TCID = "rt_sigsuspend01";
> -int TST_TOTAL = 1;
> -
> -static void cleanup(void)
> -{
> -	tst_rmdir();
> -}
> -
> -static void setup(void)
> -{
> -	TEST_PAUSE;
> -	tst_tmpdir();
> -}
> +#include "lapi/safe_rt_signal.h"
>   
>   static void sig_handler(int sig)
>   {
> +	(void) sig;
>   }
>   
> -int main(int ac, char **av)
> +static void verify_rt_sigsuspend(void)
>   {
>   	sigset_t set, set1, set2;
> -	int lc;
> -
> -	tst_parse_opts(ac, av, NULL, NULL);
> -
> -	setup();
> -
> -	for (lc = 0; TEST_LOOPING(lc); ++lc) {
> -
> -		tst_count = 0;
> -
> -		if (sigemptyset(&set) < 0)
> -			tst_brkm(TFAIL | TERRNO, cleanup, "sigemptyset failed");
> -		struct sigaction act, oact;
> -		memset(&act, 0, sizeof(act));
> -		memset(&oact, 0, sizeof(oact));
> -		act.sa_handler = sig_handler;
> -
> -		TEST(ltp_rt_sigaction(SIGALRM, &act, &oact, SIGSETSIZE));
> -		if (TEST_RETURN == -1)
> -			tst_brkm(TFAIL | TTERRNO, cleanup,
> -				 "rt_sigaction failed");
> -
> -		TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
> -			     &set1, SIGSETSIZE));
> -		if (TEST_RETURN == -1)
> -			tst_brkm(TFAIL | TTERRNO, cleanup,
> -				 "rt_sigprocmask failed");
> -
> -		TEST(alarm(5));
> -		int result;
> -		TEST(result = ltp_syscall(__NR_rt_sigsuspend, &set,
> -			SIGSETSIZE));
> -		TEST(alarm(0));
> -		if (result == -1 && TEST_ERRNO != EINTR) {
> -			TEST(ltp_syscall(__NR_rt_sigprocmask, SIG_UNBLOCK, 0,
> -				&set2, SIGSETSIZE));
> -			if (TEST_RETURN == -1) {
> -				tst_brkm(TFAIL | TTERRNO, cleanup,
> -					 "rt_sigprocmask failed");
> -			} else if (memcmp(&set1, &set2,
> -				   sizeof(unsigned long))) {
> -				tst_brkm(TFAIL | TTERRNO, cleanup,
> -					 "rt_sigsuspend failed to "
> -					 "preserve signal mask");
> -			} else {
> -				tst_resm(TPASS, "rt_sigsuspend PASSED");
> -			}
> -		} else {
> -			tst_resm(TFAIL | TTERRNO, "rt_sigsuspend failed");
> -		}
> -
> -	}
> -
> -	cleanup();
> -
> -	tst_exit();
> +	struct sigaction act = {.sa_handler = sig_handler};
> +
> +	if (sigemptyset(&set) < 0)
> +		tst_brk(TFAIL | TERRNO, "sigemptyset failed");
> +
> +	SAFE_RT_SIGACTION(SIGALRM, &act, NULL, SIGSETSIZE);
> +
> +	SAFE_RT_SIGPROCMASK(0, NULL, &set1, SIGSETSIZE);
> +
> +	alarm(1);
> +
> +	TEST(tst_syscall(__NR_rt_sigsuspend, &set, SIGSETSIZE));
> +
> +	alarm(0);
> +
> +	if (TST_RET != -1)
> +		tst_brk(TFAIL, "rt_sigsuspend returned %ld", TST_RET);
> +
> +	if (TST_ERR != EINTR)
> +		tst_brk(TFAIL | TTERRNO, "rt_sigsuspend() failed unexpectedly");
> +
> +	tst_res(TPASS, "rt_sigsuspend() returned with -1 and EINTR");
> +
> +	SAFE_RT_SIGPROCMASK(0, NULL, &set2, SIGSETSIZE);
> +
> +	if (memcmp(&set1, &set2, sizeof(unsigned long)))
> +		tst_res(TFAIL, "signal mask not preserved");
> +	else
> +		tst_res(TPASS, "signal mask preserved");
>   }
> +
> +static struct tst_test test = {
> +	.test_all = verify_rt_sigsuspend,
> +};
> 


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

* [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01
  2018-11-13 15:17 [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
                   ` (2 preceding siblings ...)
  2018-11-13 15:17 ` [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib Cyril Hrubis
@ 2018-11-19 13:36 ` Cyril Hrubis
  3 siblings, 0 replies; 6+ messages in thread
From: Cyril Hrubis @ 2018-11-19 13:36 UTC (permalink / raw)
  To: ltp

Hi!
Pushed.

-- 
Cyril Hrubis
chrubis@suse.cz

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

end of thread, other threads:[~2018-11-19 13:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-13 15:17 [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 Cyril Hrubis
2018-11-13 15:17 ` [LTP] [PATCH 1/3] lapi/rt_sigaction.h: Make it usable for newlib tests Cyril Hrubis
2018-11-13 15:17 ` [LTP] [PATCH 2/3] lapi/safe_rt_signal.h: Add Cyril Hrubis
2018-11-13 15:17 ` [LTP] [PATCH 3/3] syscalls/rt_sigsuspend01: Cleanup && convert to newlib Cyril Hrubis
2018-11-13 20:18   ` Steve Muckle
2018-11-19 13:36 ` [LTP] [PATCH 0/3] Add rt signal newlib support + convert rt_sigsuspend01 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.