Module Name:    src
Committed By:   christos
Date:           Mon Jan 10 04:57:56 UTC 2011

Modified Files:
        src/tests/lib/libc: Makefile
Added Files:
        src/tests/lib/libc/sys: Makefile t_sigqueue.c

Log Message:
test for sigqueue


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libc/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/Makefile \
    src/tests/lib/libc/sys/t_sigqueue.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/Makefile
diff -u src/tests/lib/libc/Makefile:1.26 src/tests/lib/libc/Makefile:1.27
--- src/tests/lib/libc/Makefile:1.26	Sat Jan  8 13:10:31 2011
+++ src/tests/lib/libc/Makefile	Sun Jan  9 23:57:56 2011
@@ -1,9 +1,10 @@
-# $NetBSD: Makefile,v 1.26 2011/01/08 18:10:31 pgoyette Exp $
+# $NetBSD: Makefile,v 1.27 2011/01/10 04:57:56 christos Exp $
 
 .include <bsd.own.mk>
 .include <bsd.sys.mk>
 
-TESTS_SUBDIRS+=	db gen hash ieeefp regex rpc setjmp stdlib stdio string ttyio
+TESTS_SUBDIRS+=	db gen hash ieeefp regex rpc setjmp stdlib stdio string sys
+TESTS_SUBDIRS+=	ttyio
 
 .if ${HAS_SSP} == "yes"
 TESTS_SUBDIRS+=	ssp

Added files:

Index: src/tests/lib/libc/sys/Makefile
diff -u /dev/null src/tests/lib/libc/sys/Makefile:1.1
--- /dev/null	Sun Jan  9 23:57:56 2011
+++ src/tests/lib/libc/sys/Makefile	Sun Jan  9 23:57:56 2011
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1 2011/01/10 04:57:56 christos Exp $
+
+MKMAN=	no
+
+.include <bsd.own.mk>
+
+TESTSDIR=		${TESTSBASE}/lib/libc/sys
+
+TESTS_C=		t_sigqueue
+
+.include <bsd.test.mk>
+
Index: src/tests/lib/libc/sys/t_sigqueue.c
diff -u /dev/null src/tests/lib/libc/sys/t_sigqueue.c:1.1
--- /dev/null	Sun Jan  9 23:57:56 2011
+++ src/tests/lib/libc/sys/t_sigqueue.c	Sun Jan  9 23:57:56 2011
@@ -0,0 +1,92 @@
+/* $NetBSD: t_sigqueue.c,v 1.1 2011/01/10 04:57:56 christos Exp $ */
+
+/*-
+ * Copyright (c) 2011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *        This product includes software developed by the NetBSD
+ *        Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+__RCSID("$NetBSD: t_sigqueue.c,v 1.1 2011/01/10 04:57:56 christos Exp $");
+
+#include <signal.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <sched.h>
+#include <err.h>
+
+#include <atf-c.h>
+
+ATF_TC(sigqueue);
+ATF_TC_HEAD(sigqueue, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks sigqueue sigval delivery");
+}
+
+#define VALUE (int)0xc001dadd1
+static int value;
+
+static void
+/*ARGSUSED*/
+handler(int signo, siginfo_t *info, void *data)
+{
+	value = info->si_value.sival_int;
+	kill(0, SIGINFO);
+}
+
+ATF_TC_BODY(sigqueue, tc)
+{
+	struct sigaction sa;
+	union sigval sv;
+
+	sa.sa_sigaction = handler;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = SA_SIGINFO;
+
+	if (sigaction(SIGUSR1, &sa, NULL) == -1)
+		err(1, "sigaction");
+
+	sv.sival_int = VALUE;
+	if (sigqueue(0, SIGUSR1, sv) == -1)
+		err(1, "sigqueue");
+
+	sched_yield();
+	ATF_REQUIRE_EQ(sv.sival_int, value);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, sigqueue);
+
+	return atf_no_error();
+}

Reply via email to