Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/regress/lib/libpthread add regression test for siginfo and t...
details: https://anonhg.NetBSD.org/src/rev/fcb2ccb65264
branches: trunk
changeset: 551839:fcb2ccb65264
user: christos <christos%NetBSD.org@localhost>
date: Fri Sep 12 21:15:05 2003 +0000
description:
add regression test for siginfo and threaded signal delivery.
diffstat:
regress/lib/libpthread/Makefile | 4 +-
regress/lib/libpthread/sigalarm/Makefile | 14 +++++
regress/lib/libpthread/sigalarm/sigalarm.c | 71 ++++++++++++++++++++++++++++++
3 files changed, 87 insertions(+), 2 deletions(-)
diffs (111 lines):
diff -r 13a9ac0b1242 -r fcb2ccb65264 regress/lib/libpthread/Makefile
--- a/regress/lib/libpthread/Makefile Fri Sep 12 20:42:15 2003 +0000
+++ b/regress/lib/libpthread/Makefile Fri Sep 12 21:15:05 2003 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.15 2003/07/22 21:28:23 nathanw Exp $
+# $NetBSD: Makefile,v 1.16 2003/09/12 21:15:05 christos Exp $
.include <bsd.own.mk>
@@ -17,7 +17,7 @@
SUBDIR+= atexit barrier1 cancel2 cond1 cond2 cond3 cond4 cond5 exit1 \
fork mutex1 mutex2 mutex3 mutex4 name once1 once2 preempt1 sem \
- sigsuspend
+ sigalarm sigsuspend
.endif
diff -r 13a9ac0b1242 -r fcb2ccb65264 regress/lib/libpthread/sigalarm/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libpthread/sigalarm/Makefile Fri Sep 12 21:15:05 2003 +0000
@@ -0,0 +1,14 @@
+# $NetBSD: Makefile,v 1.1 2003/09/12 21:15:06 christos Exp $
+
+WARNS=1
+
+PROG= sigalarm
+
+LDADD= -lpthread
+
+NOMAN=
+
+regress:
+ ./sigalarm
+
+.include <bsd.prog.mk>
diff -r 13a9ac0b1242 -r fcb2ccb65264 regress/lib/libpthread/sigalarm/sigalarm.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/regress/lib/libpthread/sigalarm/sigalarm.c Fri Sep 12 21:15:05 2003 +0000
@@ -0,0 +1,71 @@
+/* $NetBSD: sigalarm.c,v 1.1 2003/09/12 21:15:06 christos Exp $ */
+
+/*
+ * Regression test for sigsuspend in libpthread when pthread lib is
+ * initialized.
+ */
+
+#include <assert.h>
+#include <err.h>
+#include <stdio.h>
+#include <signal.h>
+#include <unistd.h>
+#include <pthread.h>
+
+
+int alarm_set;
+
+#ifdef SA_SIGINFO
+static void alarm_handler(int, siginfo_t *, void *);
+static void
+alarm_handler(int signo, siginfo_t *si, void *ctx)
+{
+ if (si->si_signo != signo)
+ errx(1, "Received unexpected signal %d", signo);
+ alarm_set = 1;
+}
+#else
+static void alarm_handler(int);
+static void
+alarm_handler(int signo)
+{
+ if (SIGALRM != signo)
+ errx(1, "Received unexpected signal %d", signo);
+ alarm_set = 1;
+}
+#endif
+
+static void *
+setup(void *dummy)
+{
+ struct sigaction sa;
+#ifdef SA_SIGINFO
+ sa.sa_flags = SA_SIGINFO;
+ sa.sa_sigaction = alarm_handler;
+#else
+ sa.sa_flags = 0;
+ sa.sa_handler = alarm_handler;
+#endif
+ sigemptyset(&sa.sa_mask);
+ sigaction(SIGALRM, &sa, NULL);
+ alarm(1);
+ return NULL;
+}
+
+int
+main(int argc, char **argv)
+{
+ sigset_t set;
+ pthread_t self = pthread_self();
+
+ if (pthread_create(&self, NULL, setup, NULL) != 0)
+ err(1, "Cannot create thread");
+
+ sigemptyset(&set);
+ sigsuspend(&set);
+ alarm(0);
+
+ if (!alarm_set)
+ errx(1, "alarm_set not set");
+ return 0;
+}
Home |
Main Index |
Thread Index |
Old Index