Module Name: src
Committed By: jruoho
Date: Tue May 10 12:43:42 UTC 2011
Modified Files:
src/tests/lib/libc/gen: t_raise.c
Log Message:
Add also a simplistic stress unit test.
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 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.4 src/tests/lib/libc/gen/t_raise.c:1.5
--- src/tests/lib/libc/gen/t_raise.c:1.4 Mon May 9 09:27:37 2011
+++ src/tests/lib/libc/gen/t_raise.c Tue May 10 12:43:42 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: t_raise.c,v 1.4 2011/05/09 09:27:37 jruoho Exp $ */
+/* $NetBSD: t_raise.c,v 1.5 2011/05/10 12:43:42 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.4 2011/05/09 09:27:37 jruoho Exp $");
+__RCSID("$NetBSD: t_raise.c,v 1.5 2011/05/10 12:43:42 jruoho Exp $");
#include <atf-c.h>
@@ -39,11 +39,19 @@
#include <unistd.h>
static bool fail;
+static int count;
static void handler_err(int);
static void handler_ret(int);
+static void handler_stress(int);
static int sig[] = { SIGALRM, SIGIO, SIGUSR1, SIGUSR2, SIGPWR };
static void
+handler_stress(int signo)
+{
+ count++;
+}
+
+static void
handler_err(int signo)
{
size_t i;
@@ -146,11 +154,37 @@
}
}
+ATF_TC(raise_stress);
+ATF_TC_HEAD(raise_stress, tc)
+{
+ atf_tc_set_md_var(tc, "descr", "A basic stress test with raise(3)");
+}
+
+ATF_TC_BODY(raise_stress, tc)
+{
+ static const int maxiter = 1000 * 10;
+ struct sigaction sa;
+ int i;
+
+ sa.sa_flags = 0;
+ sa.sa_handler = handler_stress;
+
+ ATF_REQUIRE(sigemptyset(&sa.sa_mask) == 0);
+ ATF_REQUIRE(sigaction(SIGUSR1, &sa, 0) == 0);
+
+ for (count = i = 0; i < maxiter; i++)
+ (void)raise(SIGUSR1);
+
+ if (count != maxiter)
+ atf_tc_fail("not all signals were catched");
+}
+
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);
+ ATF_TP_ADD_TC(tp, raise_stress);
return atf_no_error();
}