Module Name:    src
Committed By:   jruoho
Date:           Mon May  9 09:27:37 UTC 2011

Modified Files:
        src/tests/lib/libc/gen: t_raise.c

Log Message:
Add one more naive unit test.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_raise.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/tests/lib/libc/gen/t_raise.c
diff -u src/tests/lib/libc/gen/t_raise.c:1.3 src/tests/lib/libc/gen/t_raise.c:1.4
--- src/tests/lib/libc/gen/t_raise.c:1.3	Tue Apr  5 14:04:42 2011
+++ src/tests/lib/libc/gen/t_raise.c	Mon May  9 09:27:37 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_raise.c,v 1.3 2011/04/05 14:04:42 jruoho Exp $ */
+/*	$NetBSD: t_raise.c,v 1.4 2011/05/09 09:27:37 jruoho Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_raise.c,v 1.3 2011/04/05 14:04:42 jruoho Exp $");
+__RCSID("$NetBSD: t_raise.c,v 1.4 2011/05/09 09:27:37 jruoho Exp $");
 
 #include <atf-c.h>
 
@@ -39,11 +39,12 @@
 #include <unistd.h>
 
 static bool	fail;
-static void	handler(int);
+static void	handler_err(int);
+static void	handler_ret(int);
 static int	sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2, SIGPWR };
 
 static void
-handler(int signo)
+handler_err(int signo)
 {
 	size_t i;
 
@@ -56,6 +57,15 @@
 	}
 }
 
+static void
+handler_ret(int signo)
+{
+
+	(void)sleep(1);
+
+	fail = false;
+}
+
 ATF_TC(raise_err);
 ATF_TC_HEAD(raise_err, tc)
 {
@@ -74,6 +84,33 @@
 	}
 }
 
+ATF_TC(raise_ret);
+ATF_TC_HEAD(raise_ret, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test return order of raise(3)");
+}
+
+ATF_TC_BODY(raise_ret, tc)
+{
+	struct sigaction sa;
+
+	fail = true;
+
+	sa.sa_flags = 0;
+	sa.sa_handler = handler_ret;
+
+	/*
+	 * Verify that raise(3) does not return
+	 * before the signal handler returns.
+	 */
+	ATF_REQUIRE(sigemptyset(&sa.sa_mask) == 0);
+	ATF_REQUIRE(sigaction(SIGUSR1, &sa, 0) == 0);
+	ATF_REQUIRE(raise(SIGUSR1) == 0);
+
+	if (fail != false)
+		atf_tc_fail("raise(3) returned before signal handler");
+}
+
 ATF_TC(raise_sig);
 ATF_TC_HEAD(raise_sig, tc)
 {
@@ -96,7 +133,7 @@
 		tv.tv_nsec = 2;
 
 		sa.sa_flags = 0;
-		sa.sa_handler = handler;
+		sa.sa_handler = handler_err;
 
 		ATF_REQUIRE(sigemptyset(&sa.sa_mask) == 0);
 		ATF_REQUIRE(sigaction(sig[i], &sa, 0) == 0);
@@ -112,6 +149,7 @@
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, raise_err);
+	ATF_TP_ADD_TC(tp, raise_ret);
 	ATF_TP_ADD_TC(tp, raise_sig);
 
 	return atf_no_error();

Reply via email to