public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] New sigwaitinfo test
@ 2009-12-04 16:46 Jiri Palecek
  0 siblings, 0 replies; 4+ messages in thread
From: Jiri Palecek @ 2009-12-04 16:46 UTC (permalink / raw)
  Cc: ltp-list

Hello,

this is the test for the rt_sigtimedwait et al. functions I promised earlier. The code is unchanged since I sent it for the first time, but the Makefiles are adapted to the new build system, with the help of Garret Cooper.

Regards
    Jiri Palecek

Signed-off-by: Jiri Palecek <jpalecek@web.de>
---
 testcases/kernel/syscalls/rt_sigtimedwait/Makefile |   31 ++
 testcases/kernel/syscalls/sigtimedwait/Makefile    |   30 ++
 testcases/kernel/syscalls/sigwait/Makefile         |   30 ++
 testcases/kernel/syscalls/sigwaitinfo/Makefile     |   25 ++
 .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    |  432 ++++++++++++++++++++
 5 files changed, 548 insertions(+), 0 deletions(-)
 create mode 100644 testcases/kernel/syscalls/rt_sigtimedwait/Makefile
 create mode 100644 testcases/kernel/syscalls/sigtimedwait/Makefile
 create mode 100644 testcases/kernel/syscalls/sigwait/Makefile
 create mode 100644 testcases/kernel/syscalls/sigwaitinfo/Makefile
 create mode 100644 testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c

diff --git a/testcases/kernel/syscalls/rt_sigtimedwait/Makefile b/testcases/kernel/syscalls/rt_sigtimedwait/Makefile
new file mode 100644
index 0000000..27a9e9e
--- /dev/null
+++ b/testcases/kernel/syscalls/rt_sigtimedwait/Makefile
@@ -0,0 +1,31 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk 
+
+CPPFLAGS += -DTEST_RT_SIGTIMEDWAIT
+
+rt_sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
+	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
+
+MAKE_TARGETS := rt_sigtimedwait01
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk 
+
diff --git a/testcases/kernel/syscalls/sigtimedwait/Makefile b/testcases/kernel/syscalls/sigtimedwait/Makefile
new file mode 100644
index 0000000..ce1096e
--- /dev/null
+++ b/testcases/kernel/syscalls/sigtimedwait/Makefile
@@ -0,0 +1,30 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+CPPFLAGS += -DTEST_SIGTIMEDWAIT
+
+sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
+	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
+
+MAKE_TARGETS := sigtimedwait01
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigwait/Makefile b/testcases/kernel/syscalls/sigwait/Makefile
new file mode 100644
index 0000000..8725b0a
--- /dev/null
+++ b/testcases/kernel/syscalls/sigwait/Makefile
@@ -0,0 +1,30 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+CPPFLAGS += -DTEST_SIGWAIT
+
+sigwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
+	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
+
+MAKE_TARGETS := sigwait01
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigwaitinfo/Makefile b/testcases/kernel/syscalls/sigwaitinfo/Makefile
new file mode 100644
index 0000000..1246e5e
--- /dev/null
+++ b/testcases/kernel/syscalls/sigwaitinfo/Makefile
@@ -0,0 +1,25 @@
+#
+#  Copyright (c) International Business Machines  Corp., 2009
+#
+#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
+#
+
+top_srcdir ?= ../../../..
+
+include $(top_srcdir)/include/mk/testcases.mk
+
+CPPFLAGS += -DTEST_SIGWAITINFO
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
new file mode 100644
index 0000000..ff9ca8f
--- /dev/null
+++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
@@ -0,0 +1,432 @@
+/*
+ * Copyright (c) Jiri Palecek<jpalecek@web.de>, 2009
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of version 2 of the GNU General Public License as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it would be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ * Further, this software is distributed without any warranty that it is
+ * free of the rightful claim of any third person regarding infringement
+ * or the like.  Any license provided herein, whether implied or
+ * otherwise, applies only to this software file.  Patent licenses, if
+ * any, provided herein do not apply to combinations of this program with
+ * other software, or any other product whatsoever.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write the Free Software Foundation, Inc., 59
+ * Temple Place - Suite 330, Boston MA 02111-1307, USA.
+ */
+#include "test.h"
+#include "usctest.h"
+#include <errno.h>
+#include <signal.h>
+#include "../utils/include_j_h.h"
+#include "../utils/common_j_h.c"
+#include <limits.h>
+#include "linux_syscall_numbers.h"
+
+#define SUCCEED_OR_DIE(syscall, message, ...)														\
+	(errno = 0,																														\
+		({int ret=syscall(__VA_ARGS__);																			\
+			if(ret==-1)																												\
+				tst_brkm(TBROK|TERRNO, cleanup, message);												\
+			ret;}))
+
+/* Report success iff TEST_RETURN and TEST_ERRNO 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, const char* file, int line,
+													 long exp_return, int exp_errno, int condition, char* condition_errmsg)
+{
+	if (exp_return == TEST_RETURN && (exp_return != -1 || exp_errno == TEST_ERRNO))
+		if(condition)
+			tst_resm(TPASS, "Test passed");
+		else
+			tst_resm(TFAIL, "%s (%s: %d): %s", func, file, line, condition_errmsg);
+	else if(TEST_RETURN != -1)
+		tst_resm(TFAIL, "%s (%s: %d): Unexpected return value; expected %ld, got %ld",
+						 func, file, line, exp_return, TEST_RETURN);
+	else
+		tst_resm(TFAIL|TTERRNO, "%s (%s: %d): Unexpected failure", func, file, line);
+}
+
+#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg)	\
+	report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
+
+/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
+	 exp_return and exp_errno, resp.
+*/
+#define REPORT_SUCCESS(exp_return, exp_errno)					\
+	REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
+
+static void cleanup(void) LTP_ATTRIBUTE_NORETURN;
+
+static void empty_handler(int sig)
+{
+}
+
+static void setup(void)
+{
+	tst_sig(FORK, DEF_HANDLER, cleanup);
+	signal(SIGUSR1, empty_handler);
+	signal(SIGALRM, empty_handler);
+	signal(SIGUSR2, SIG_IGN);
+
+	TEST_PAUSE;
+}
+
+static void cleanup(void)
+{
+	TEST_CLEANUP;
+
+	tst_exit();
+}
+
+typedef int (*swi_func)(const sigset_t* set, siginfo_t* info, struct timespec* timeout);
+typedef void (*test_func)(swi_func, int);
+
+static int my_sigwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
+{
+	int ret;
+	int err=sigwait(set, &ret);
+
+	if(err == 0)
+		return ret;
+	errno = err;
+	return -1;
+}
+
+static int my_sigwaitinfo(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
+{
+	return sigwaitinfo(set, info);
+}
+
+static int my_sigtimedwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
+{
+	return sigtimedwait(set, info, timeout);
+}
+
+static int my_rt_sigtimedwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
+{
+	/* The last argument is (number_of_signals)/(bits_per_byte), which are 64 and 8, resp. */
+	return syscall(__NR_rt_sigtimedwait, set, info, timeout, 8);
+}
+
+void test_empty_set(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs;
+	siginfo_t si;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	/* Run a child that will wake us up */
+	child=create_sig_proc(100000, signo, UINT_MAX);
+
+	TEST(sigwaitinfo(&sigs, &si, NULL));
+	REPORT_SUCCESS(-1, EINTR);
+
+	kill(child, SIGTERM);
+}
+
+void test_timeout(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs;
+	siginfo_t si;
+	pid_t child;
+	struct timespec ts = { .tv_sec = 1 };
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+
+	/* Run a child that will wake us up */
+	child=create_sig_proc(100000, signo, UINT_MAX);
+
+	TEST(sigwaitinfo(&sigs, &si, &ts));
+	REPORT_SUCCESS(-1, EAGAIN);
+
+	kill(child, SIGTERM);
+}
+
+/* Note: sigwait-ing for a signal that is not blocked is unspecified
+ * by POSIX; but works for non-ignored signals under Linux
+ */
+void test_unmasked_matching(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs;
+	siginfo_t si;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+
+	/* Run a child that will wake us up */
+	child=create_sig_proc(100000, signo, UINT_MAX);
+
+	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");
+
+	kill(child, SIGTERM);
+}
+
+void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+	/* Run a child that will wake us up */
+	child=create_sig_proc(100000, signo, UINT_MAX);
+
+	TEST(sigwaitinfo(&sigs, NULL, NULL));
+	REPORT_SUCCESS(signo, 0);
+
+	kill(child, SIGTERM);
+}
+
+void test_masked_matching(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs, oldmask;
+	siginfo_t si;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+	/* let's not get interrupted by our dying child */
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
+
+	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
+
+	/* don't wait on a SIGCHLD */
+	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
+
+	/* Run a child that will wake us up */
+	child=create_sig_proc(0, signo, 1);
+
+	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");
+
+	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
+
+	Tst_count--;
+
+	if(sigismember(&oldmask, signo))
+		tst_resm(TPASS, "sigwaitinfo restored the original mask");
+	else
+		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
+}
+
+void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs, oldmask;
+	siginfo_t si;
+	pid_t child[2];
+
+	signo = SIGRTMIN+1;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo+1);
+	/* let's not get interrupted by our dying child */
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
+
+	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
+
+	/* don't wait on a SIGCHLD */
+	SUCCEED_OR_DIE(sigdelset, "sigdelset failed", &sigs, SIGCHLD);
+
+	/* Run a child that will wake us up */
+	child[0]=create_sig_proc(0, signo, 1);
+	child[1]=create_sig_proc(0, signo+1, 1);
+
+	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");
+
+	/* eat the other signal */
+	Tst_count--;
+	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");
+
+	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
+
+	Tst_count--;
+
+	if(sigismember(&oldmask, signo))
+		tst_resm(TPASS, "sigwaitinfo restored the original mask");
+	else
+		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
+}
+
+void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs, oldmask;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+	/* let's not get interrupted by our dying child */
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
+
+	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
+
+	/* don't wait on a SIGCHLD */
+	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
+
+	/* Run a child that will wake us up */
+	child=create_sig_proc(0, signo, 1);
+
+	TEST(sigwaitinfo(&sigs, NULL, NULL));
+	REPORT_SUCCESS(signo, 0);
+
+	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
+
+	Tst_count--;
+
+	if(sigismember(&oldmask, signo))
+		tst_resm(TPASS, "sigwaitinfo restored the original mask");
+	else
+		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
+
+}
+
+void test_bad_address(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs, oldmask;
+	pid_t child;
+
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
+	/* let's not get interrupted by our dying child */
+	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
+
+	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
+
+	/* don't wait on a SIGCHLD */
+	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
+
+	/* Run a child that will wake us up */
+	child=create_sig_proc(0, signo, 1);
+
+	TEST(sigwaitinfo(&sigs, (void*)1, NULL));
+	REPORT_SUCCESS(-1, EFAULT);
+
+	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &oldmask, &oldmask);
+
+	kill(child, SIGTERM);
+}
+
+void test_bad_address2(swi_func sigwaitinfo, int signo)
+{
+	TEST(sigwaitinfo((void*)1, NULL, NULL));
+	REPORT_SUCCESS(-1, EFAULT);
+}
+
+void test_bad_address3(swi_func sigwaitinfo, int signo)
+{
+	sigset_t sigs;
+	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
+
+	TEST(sigwaitinfo(&sigs, NULL, (void*)1));
+	REPORT_SUCCESS(-1, EFAULT);
+}
+
+struct test_desc {
+	test_func tf;
+	swi_func swi;
+	int signo;
+} tests[]={
+#if defined TEST_RT_SIGTIMEDWAIT
+	test_empty_set, my_rt_sigtimedwait, SIGUSR1,
+	test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1,
+	test_masked_matching, my_rt_sigtimedwait, SIGUSR1,
+	test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1,
+	test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1,
+	test_bad_address, my_rt_sigtimedwait, SIGUSR1,
+	test_bad_address2, my_rt_sigtimedwait, SIGUSR1,
+	test_bad_address3, my_rt_sigtimedwait, SIGUSR1,
+	test_timeout, my_rt_sigtimedwait, 0,
+
+	/* Special cases */
+	/* 1: sigwaitinfo does respond to ignored signal */
+	test_masked_matching, my_rt_sigtimedwait, SIGUSR2,
+
+	/* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */
+	test_timeout, my_rt_sigtimedwait, SIGUSR2,
+
+	/* 3: The handler is not called when the signal is waited for by sigwaitinfo */
+	test_masked_matching, my_rt_sigtimedwait, SIGTERM,
+
+	/* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */
+	test_masked_matching_rt, my_rt_sigtimedwait, -1,
+#endif
+#if defined TEST_SIGWAIT
+	test_unmasked_matching_noinfo, my_sigwait, SIGUSR1,
+	test_masked_matching_noinfo, my_sigwait, SIGUSR1,
+#endif
+#if defined TEST_SIGWAITINFO
+	test_empty_set, my_sigwaitinfo, SIGUSR1,
+	test_unmasked_matching, my_sigwaitinfo, SIGUSR1,
+	test_masked_matching, my_sigwaitinfo, SIGUSR1,
+	test_unmasked_matching_noinfo, my_sigwaitinfo, SIGUSR1,
+	test_masked_matching_noinfo, my_sigwaitinfo, SIGUSR1,
+	test_bad_address, my_sigwaitinfo, SIGUSR1,
+	test_bad_address2, my_sigwaitinfo, SIGUSR1,
+#endif
+#if defined TEST_SIGTIMEDWAIT
+	test_empty_set, my_sigtimedwait, SIGUSR1,
+	test_unmasked_matching, my_sigtimedwait, SIGUSR1,
+	test_masked_matching, my_sigtimedwait, SIGUSR1,
+	test_unmasked_matching_noinfo, my_sigtimedwait, SIGUSR1,
+	test_masked_matching_noinfo, my_sigtimedwait, SIGUSR1,
+	test_bad_address, my_sigtimedwait, SIGUSR1,
+	test_bad_address2, my_sigtimedwait, SIGUSR1,
+	test_bad_address3, my_sigtimedwait, SIGUSR1,
+	test_timeout, my_sigtimedwait, 0,
+#endif
+};
+
+#if defined TEST_SIGWAITINFO
+const char* TCID="sigwaitinfo01";
+#elif defined TEST_RT_SIGTIMEDWAIT
+const char* TCID="rt_sigtimedwait01";
+#elif defined TEST_SIGTIMEDWAIT
+const char* TCID="sigtimedwait01";
+#elif defined TEST_SIGWAIT
+const char* TCID="sigwait01";
+#endif
+
+extern int Tst_count;
+
+int TST_TOTAL = sizeof(tests)/sizeof(*tests);
+
+int main(int argc, char** argv)
+{
+	unsigned i;
+	int lc;
+	char* msg;
+
+	/* parse standard options */
+	if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) !=
+			(char *)NULL) {
+		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
+		/*NOT REACHED */
+	}
+
+	setup();
+
+	for(lc = 0; TEST_LOOPING(lc); ++lc) {
+		Tst_count = 0;
+
+		for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
+			alarm(10); /* arrange a 10 second timeout */
+			tests[i].tf(tests[i].swi, tests[i].signo);
+		}
+		alarm(0);
+	}
+
+	cleanup();
+}
-- 
1.6.4.3




------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] New sigwaitinfo test
       [not found] <200912041649.nB4GnQbj014719@e35.co.us.ibm.com>
@ 2009-12-07 11:54 ` Subrata Modak
  2009-12-07 18:42   ` Garrett Cooper
  0 siblings, 1 reply; 4+ messages in thread
From: Subrata Modak @ 2009-12-07 11:54 UTC (permalink / raw)
  To: Jiri Palecek; +Cc: ltp-list

On Fri, 2009-12-04 at 17:46 +0100, Jiri Palecek wrote: 
> Hello,
> 
> this is the test for the rt_sigtimedwait et al. functions I promised earlier. The code is unchanged since I sent it for the first time, but the Makefiles are adapted to the new build system, with the help of Garret Cooper.
> 
> Regards
>     Jiri Palecek
> 
> Signed-off-by: Jiri Palecek <jpalecek@web.de>

Thanks Jiri. Would you also take the trouble to make entries in the
runtest/syscalls file for these tests to run ?

Regards--
Subrata

> ---
>  testcases/kernel/syscalls/rt_sigtimedwait/Makefile |   31 ++
>  testcases/kernel/syscalls/sigtimedwait/Makefile    |   30 ++
>  testcases/kernel/syscalls/sigwait/Makefile         |   30 ++
>  testcases/kernel/syscalls/sigwaitinfo/Makefile     |   25 ++
>  .../kernel/syscalls/sigwaitinfo/sigwaitinfo01.c    |  432 ++++++++++++++++++++
>  5 files changed, 548 insertions(+), 0 deletions(-)
>  create mode 100644 testcases/kernel/syscalls/rt_sigtimedwait/Makefile
>  create mode 100644 testcases/kernel/syscalls/sigtimedwait/Makefile
>  create mode 100644 testcases/kernel/syscalls/sigwait/Makefile
>  create mode 100644 testcases/kernel/syscalls/sigwaitinfo/Makefile
>  create mode 100644 testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> 
> diff --git a/testcases/kernel/syscalls/rt_sigtimedwait/Makefile b/testcases/kernel/syscalls/rt_sigtimedwait/Makefile
> new file mode 100644
> index 0000000..27a9e9e
> --- /dev/null
> +++ b/testcases/kernel/syscalls/rt_sigtimedwait/Makefile
> @@ -0,0 +1,31 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk 
> +
> +CPPFLAGS += -DTEST_RT_SIGTIMEDWAIT
> +
> +rt_sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
> +	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
> +
> +MAKE_TARGETS := rt_sigtimedwait01
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk 
> +
> diff --git a/testcases/kernel/syscalls/sigtimedwait/Makefile b/testcases/kernel/syscalls/sigtimedwait/Makefile
> new file mode 100644
> index 0000000..ce1096e
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sigtimedwait/Makefile
> @@ -0,0 +1,30 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +
> +CPPFLAGS += -DTEST_SIGTIMEDWAIT
> +
> +sigtimedwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
> +	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
> +
> +MAKE_TARGETS := sigtimedwait01
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/sigwait/Makefile b/testcases/kernel/syscalls/sigwait/Makefile
> new file mode 100644
> index 0000000..8725b0a
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sigwait/Makefile
> @@ -0,0 +1,30 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +
> +CPPFLAGS += -DTEST_SIGWAIT
> +
> +sigwait01: $(abs_srcdir)/../sigwaitinfo/sigwaitinfo01.c
> +	$(LINK.c) $^ $(LOADLIBES) $(LDLIBS) $(OUTPUT_OPTION)
> +
> +MAKE_TARGETS := sigwait01
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/sigwaitinfo/Makefile b/testcases/kernel/syscalls/sigwaitinfo/Makefile
> new file mode 100644
> index 0000000..1246e5e
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sigwaitinfo/Makefile
> @@ -0,0 +1,25 @@
> +#
> +#  Copyright (c) International Business Machines  Corp., 2009
> +#
> +#  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 St, Fifth Floor, Boston, MA  02110-1301  USA
> +#
> +
> +top_srcdir ?= ../../../..
> +
> +include $(top_srcdir)/include/mk/testcases.mk
> +
> +CPPFLAGS += -DTEST_SIGWAITINFO
> +
> +include $(top_srcdir)/include/mk/generic_leaf_target.mk
> diff --git a/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> new file mode 100644
> index 0000000..ff9ca8f
> --- /dev/null
> +++ b/testcases/kernel/syscalls/sigwaitinfo/sigwaitinfo01.c
> @@ -0,0 +1,432 @@
> +/*
> + * Copyright (c) Jiri Palecek<jpalecek@web.de>, 2009
> + *
> + * This program is free software; you can redistribute it and/or modify it
> + * under the terms of version 2 of the GNU General Public License as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it would be useful, but
> + * WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> + *
> + * Further, this software is distributed without any warranty that it is
> + * free of the rightful claim of any third person regarding infringement
> + * or the like.  Any license provided herein, whether implied or
> + * otherwise, applies only to this software file.  Patent licenses, if
> + * any, provided herein do not apply to combinations of this program with
> + * other software, or any other product whatsoever.
> + *
> + * You should have received a copy of the GNU General Public License along
> + * with this program; if not, write the Free Software Foundation, Inc., 59
> + * Temple Place - Suite 330, Boston MA 02111-1307, USA.
> + */
> +#include "test.h"
> +#include "usctest.h"
> +#include <errno.h>
> +#include <signal.h>
> +#include "../utils/include_j_h.h"
> +#include "../utils/common_j_h.c"
> +#include <limits.h>
> +#include "linux_syscall_numbers.h"
> +
> +#define SUCCEED_OR_DIE(syscall, message, ...)														\
> +	(errno = 0,																														\
> +		({int ret=syscall(__VA_ARGS__);																			\
> +			if(ret==-1)																												\
> +				tst_brkm(TBROK|TERRNO, cleanup, message);												\
> +			ret;}))
> +
> +/* Report success iff TEST_RETURN and TEST_ERRNO 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, const char* file, int line,
> +													 long exp_return, int exp_errno, int condition, char* condition_errmsg)
> +{
> +	if (exp_return == TEST_RETURN && (exp_return != -1 || exp_errno == TEST_ERRNO))
> +		if(condition)
> +			tst_resm(TPASS, "Test passed");
> +		else
> +			tst_resm(TFAIL, "%s (%s: %d): %s", func, file, line, condition_errmsg);
> +	else if(TEST_RETURN != -1)
> +		tst_resm(TFAIL, "%s (%s: %d): Unexpected return value; expected %ld, got %ld",
> +						 func, file, line, exp_return, TEST_RETURN);
> +	else
> +		tst_resm(TFAIL|TTERRNO, "%s (%s: %d): Unexpected failure", func, file, line);
> +}
> +
> +#define REPORT_SUCCESS_COND(exp_return, exp_errno, condition, condition_errmsg)	\
> +	report_success_cond(__FUNCTION__, __FILE__, __LINE__, exp_return, exp_errno, condition, condition_errmsg);
> +
> +/* Report success iff TEST_RETURN and TEST_ERRNO are equal to
> +	 exp_return and exp_errno, resp.
> +*/
> +#define REPORT_SUCCESS(exp_return, exp_errno)					\
> +	REPORT_SUCCESS_COND(exp_return, exp_errno, 1, "");
> +
> +static void cleanup(void) LTP_ATTRIBUTE_NORETURN;
> +
> +static void empty_handler(int sig)
> +{
> +}
> +
> +static void setup(void)
> +{
> +	tst_sig(FORK, DEF_HANDLER, cleanup);
> +	signal(SIGUSR1, empty_handler);
> +	signal(SIGALRM, empty_handler);
> +	signal(SIGUSR2, SIG_IGN);
> +
> +	TEST_PAUSE;
> +}
> +
> +static void cleanup(void)
> +{
> +	TEST_CLEANUP;
> +
> +	tst_exit();
> +}
> +
> +typedef int (*swi_func)(const sigset_t* set, siginfo_t* info, struct timespec* timeout);
> +typedef void (*test_func)(swi_func, int);
> +
> +static int my_sigwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
> +{
> +	int ret;
> +	int err=sigwait(set, &ret);
> +
> +	if(err == 0)
> +		return ret;
> +	errno = err;
> +	return -1;
> +}
> +
> +static int my_sigwaitinfo(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
> +{
> +	return sigwaitinfo(set, info);
> +}
> +
> +static int my_sigtimedwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
> +{
> +	return sigtimedwait(set, info, timeout);
> +}
> +
> +static int my_rt_sigtimedwait(const sigset_t* set, siginfo_t* info, struct timespec* timeout)
> +{
> +	/* The last argument is (number_of_signals)/(bits_per_byte), which are 64 and 8, resp. */
> +	return syscall(__NR_rt_sigtimedwait, set, info, timeout, 8);
> +}
> +
> +void test_empty_set(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs;
> +	siginfo_t si;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(100000, signo, UINT_MAX);
> +
> +	TEST(sigwaitinfo(&sigs, &si, NULL));
> +	REPORT_SUCCESS(-1, EINTR);
> +
> +	kill(child, SIGTERM);
> +}
> +
> +void test_timeout(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs;
> +	siginfo_t si;
> +	pid_t child;
> +	struct timespec ts = { .tv_sec = 1 };
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(100000, signo, UINT_MAX);
> +
> +	TEST(sigwaitinfo(&sigs, &si, &ts));
> +	REPORT_SUCCESS(-1, EAGAIN);
> +
> +	kill(child, SIGTERM);
> +}
> +
> +/* Note: sigwait-ing for a signal that is not blocked is unspecified
> + * by POSIX; but works for non-ignored signals under Linux
> + */
> +void test_unmasked_matching(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs;
> +	siginfo_t si;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(100000, signo, UINT_MAX);
> +
> +	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");
> +
> +	kill(child, SIGTERM);
> +}
> +
> +void test_unmasked_matching_noinfo(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(100000, signo, UINT_MAX);
> +
> +	TEST(sigwaitinfo(&sigs, NULL, NULL));
> +	REPORT_SUCCESS(signo, 0);
> +
> +	kill(child, SIGTERM);
> +}
> +
> +void test_masked_matching(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs, oldmask;
> +	siginfo_t si;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +	/* let's not get interrupted by our dying child */
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
> +
> +	/* don't wait on a SIGCHLD */
> +	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(0, signo, 1);
> +
> +	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");
> +
> +	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
> +
> +	Tst_count--;
> +
> +	if(sigismember(&oldmask, signo))
> +		tst_resm(TPASS, "sigwaitinfo restored the original mask");
> +	else
> +		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
> +}
> +
> +void test_masked_matching_rt(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs, oldmask;
> +	siginfo_t si;
> +	pid_t child[2];
> +
> +	signo = SIGRTMIN+1;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo+1);
> +	/* let's not get interrupted by our dying child */
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
> +
> +	/* don't wait on a SIGCHLD */
> +	SUCCEED_OR_DIE(sigdelset, "sigdelset failed", &sigs, SIGCHLD);
> +
> +	/* Run a child that will wake us up */
> +	child[0]=create_sig_proc(0, signo, 1);
> +	child[1]=create_sig_proc(0, signo+1, 1);
> +
> +	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");
> +
> +	/* eat the other signal */
> +	Tst_count--;
> +	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");
> +
> +	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
> +
> +	Tst_count--;
> +
> +	if(sigismember(&oldmask, signo))
> +		tst_resm(TPASS, "sigwaitinfo restored the original mask");
> +	else
> +		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
> +}
> +
> +void test_masked_matching_noinfo(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs, oldmask;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +	/* let's not get interrupted by our dying child */
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
> +
> +	/* don't wait on a SIGCHLD */
> +	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(0, signo, 1);
> +
> +	TEST(sigwaitinfo(&sigs, NULL, NULL));
> +	REPORT_SUCCESS(signo, 0);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "restoring original signal mask failed", SIG_SETMASK, &oldmask, &oldmask);
> +
> +	Tst_count--;
> +
> +	if(sigismember(&oldmask, signo))
> +		tst_resm(TPASS, "sigwaitinfo restored the original mask");
> +	else
> +		tst_resm(TFAIL, "sigwaitinfo failed to restore the original mask");
> +
> +}
> +
> +void test_bad_address(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs, oldmask;
> +	pid_t child;
> +
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, signo);
> +	/* let's not get interrupted by our dying child */
> +	SUCCEED_OR_DIE(sigaddset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &sigs, &oldmask);
> +
> +	/* don't wait on a SIGCHLD */
> +	SUCCEED_OR_DIE(sigdelset, "sigaddset failed", &sigs, SIGCHLD);
> +
> +	/* Run a child that will wake us up */
> +	child=create_sig_proc(0, signo, 1);
> +
> +	TEST(sigwaitinfo(&sigs, (void*)1, NULL));
> +	REPORT_SUCCESS(-1, EFAULT);
> +
> +	SUCCEED_OR_DIE(sigprocmask, "sigprocmask failed", SIG_SETMASK, &oldmask, &oldmask);
> +
> +	kill(child, SIGTERM);
> +}
> +
> +void test_bad_address2(swi_func sigwaitinfo, int signo)
> +{
> +	TEST(sigwaitinfo((void*)1, NULL, NULL));
> +	REPORT_SUCCESS(-1, EFAULT);
> +}
> +
> +void test_bad_address3(swi_func sigwaitinfo, int signo)
> +{
> +	sigset_t sigs;
> +	SUCCEED_OR_DIE(sigemptyset, "sigemptyset failed", &sigs);
> +
> +	TEST(sigwaitinfo(&sigs, NULL, (void*)1));
> +	REPORT_SUCCESS(-1, EFAULT);
> +}
> +
> +struct test_desc {
> +	test_func tf;
> +	swi_func swi;
> +	int signo;
> +} tests[]={
> +#if defined TEST_RT_SIGTIMEDWAIT
> +	test_empty_set, my_rt_sigtimedwait, SIGUSR1,
> +	test_unmasked_matching, my_rt_sigtimedwait, SIGUSR1,
> +	test_masked_matching, my_rt_sigtimedwait, SIGUSR1,
> +	test_unmasked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1,
> +	test_masked_matching_noinfo, my_rt_sigtimedwait, SIGUSR1,
> +	test_bad_address, my_rt_sigtimedwait, SIGUSR1,
> +	test_bad_address2, my_rt_sigtimedwait, SIGUSR1,
> +	test_bad_address3, my_rt_sigtimedwait, SIGUSR1,
> +	test_timeout, my_rt_sigtimedwait, 0,
> +
> +	/* Special cases */
> +	/* 1: sigwaitinfo does respond to ignored signal */
> +	test_masked_matching, my_rt_sigtimedwait, SIGUSR2,
> +
> +	/* 2: An ignored signal doesn't cause sigwaitinfo to return EINTR */
> +	test_timeout, my_rt_sigtimedwait, SIGUSR2,
> +
> +	/* 3: The handler is not called when the signal is waited for by sigwaitinfo */
> +	test_masked_matching, my_rt_sigtimedwait, SIGTERM,
> +
> +	/* 4: Simultaneous realtime signals are delivered in the order of increasing signal number */
> +	test_masked_matching_rt, my_rt_sigtimedwait, -1,
> +#endif
> +#if defined TEST_SIGWAIT
> +	test_unmasked_matching_noinfo, my_sigwait, SIGUSR1,
> +	test_masked_matching_noinfo, my_sigwait, SIGUSR1,
> +#endif
> +#if defined TEST_SIGWAITINFO
> +	test_empty_set, my_sigwaitinfo, SIGUSR1,
> +	test_unmasked_matching, my_sigwaitinfo, SIGUSR1,
> +	test_masked_matching, my_sigwaitinfo, SIGUSR1,
> +	test_unmasked_matching_noinfo, my_sigwaitinfo, SIGUSR1,
> +	test_masked_matching_noinfo, my_sigwaitinfo, SIGUSR1,
> +	test_bad_address, my_sigwaitinfo, SIGUSR1,
> +	test_bad_address2, my_sigwaitinfo, SIGUSR1,
> +#endif
> +#if defined TEST_SIGTIMEDWAIT
> +	test_empty_set, my_sigtimedwait, SIGUSR1,
> +	test_unmasked_matching, my_sigtimedwait, SIGUSR1,
> +	test_masked_matching, my_sigtimedwait, SIGUSR1,
> +	test_unmasked_matching_noinfo, my_sigtimedwait, SIGUSR1,
> +	test_masked_matching_noinfo, my_sigtimedwait, SIGUSR1,
> +	test_bad_address, my_sigtimedwait, SIGUSR1,
> +	test_bad_address2, my_sigtimedwait, SIGUSR1,
> +	test_bad_address3, my_sigtimedwait, SIGUSR1,
> +	test_timeout, my_sigtimedwait, 0,
> +#endif
> +};
> +
> +#if defined TEST_SIGWAITINFO
> +const char* TCID="sigwaitinfo01";
> +#elif defined TEST_RT_SIGTIMEDWAIT
> +const char* TCID="rt_sigtimedwait01";
> +#elif defined TEST_SIGTIMEDWAIT
> +const char* TCID="sigtimedwait01";
> +#elif defined TEST_SIGWAIT
> +const char* TCID="sigwait01";
> +#endif
> +
> +extern int Tst_count;
> +
> +int TST_TOTAL = sizeof(tests)/sizeof(*tests);
> +
> +int main(int argc, char** argv)
> +{
> +	unsigned i;
> +	int lc;
> +	char* msg;
> +
> +	/* parse standard options */
> +	if ((msg = parse_opts(argc, argv, (option_t *) NULL, NULL)) !=
> +			(char *)NULL) {
> +		tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
> +		/*NOT REACHED */
> +	}
> +
> +	setup();
> +
> +	for(lc = 0; TEST_LOOPING(lc); ++lc) {
> +		Tst_count = 0;
> +
> +		for(i=0; i<sizeof(tests)/sizeof(*tests); i++) {
> +			alarm(10); /* arrange a 10 second timeout */
> +			tests[i].tf(tests[i].swi, tests[i].signo);
> +		}
> +		alarm(0);
> +	}
> +
> +	cleanup();
> +}
> -- 
> 1.6.4.3
> 
> 
> 
> 
> ------------------------------------------------------------------------------
> Join us December 9, 2009 for the Red Hat Virtual Experience,
> a free event focused on virtualization and cloud computing. 
> Attend in-depth sessions from your desk. Your couch. Anywhere.
> http://p.sf.net/sfu/redhat-sfdev2dev
> _______________________________________________
> Ltp-list mailing list
> Ltp-list@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/ltp-list


------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] New sigwaitinfo test
  2009-12-07 11:54 ` [LTP] [PATCH] New sigwaitinfo test Subrata Modak
@ 2009-12-07 18:42   ` Garrett Cooper
  2009-12-19  2:05     ` Jiří Paleček
  0 siblings, 1 reply; 4+ messages in thread
From: Garrett Cooper @ 2009-12-07 18:42 UTC (permalink / raw)
  To: subrata; +Cc: Jiri Palecek, ltp-list

On Mon, Dec 7, 2009 at 3:54 AM, Subrata Modak
<subrata@linux.vnet.ibm.com> wrote:
> On Fri, 2009-12-04 at 17:46 +0100, Jiri Palecek wrote:
>> Hello,
>>
>> this is the test for the rt_sigtimedwait et al. functions I promised earlier. The code is unchanged since I sent it for the first time, but the Makefiles are adapted to the new build system, with the help of Garret Cooper.
>>
>> Regards
>>     Jiri Palecek
>>
>> Signed-off-by: Jiri Palecek <jpalecek@web.de>
>
> Thanks Jiri. Would you also take the trouble to make entries in the
> runtest/syscalls file for these tests to run ?

Someone needs to verify whether or not the rt_* test is functional on
x86_64 as well, because these tests require additional setup for
x86_64; unfortunately my desktop is disconnected (and will remain so
for the next week while I move), so I can't verify this.
Thanks,
-Garrett

------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] New sigwaitinfo test
  2009-12-07 18:42   ` Garrett Cooper
@ 2009-12-19  2:05     ` Jiří Paleček
  0 siblings, 0 replies; 4+ messages in thread
From: Jiří Paleček @ 2009-12-19  2:05 UTC (permalink / raw)
  To: Garrett Cooper, subrata; +Cc: ltp-list

On Mon, 07 Dec 2009 19:42:13 +0100, Garrett Cooper <yanegomi@gmail.com>  
wrote:

> On Mon, Dec 7, 2009 at 3:54 AM, Subrata Modak
> <subrata@linux.vnet.ibm.com> wrote:
>> On Fri, 2009-12-04 at 17:46 +0100, Jiri Palecek wrote:
>>> Hello,
>>>
>>> this is the test for the rt_sigtimedwait et al. functions I promised  
>>> earlier. The code is unchanged since I sent it for the first time, but  
>>> the Makefiles are adapted to the new build system, with the help of  
>>> Garret Cooper.
>>>
>>> Regards
>>>     Jiri Palecek
>>>
>>> Signed-off-by: Jiri Palecek <jpalecek@web.de>
>>
>> Thanks Jiri. Would you also take the trouble to make entries in the
>> runtest/syscalls file for these tests to run ?
>
> Someone needs to verify whether or not the rt_* test is functional on
> x86_64 as well, because these tests require additional setup for
> x86_64; unfortunately my desktop is disconnected (and will remain so
> for the next week while I move), so I can't verify this.

Could you, please? IMHO there shouldn't be a problem with SA_RESTORER  
(because the test doesn't use rt_sigaction), but there may be problems  
with SIGSETSIZE.

   Jiri Palecek

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev 
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2009-12-19  2:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200912041649.nB4GnQbj014719@e35.co.us.ibm.com>
2009-12-07 11:54 ` [LTP] [PATCH] New sigwaitinfo test Subrata Modak
2009-12-07 18:42   ` Garrett Cooper
2009-12-19  2:05     ` Jiří Paleček
2009-12-04 16:46 Jiri Palecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox