Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc test for sigqueue



details:   https://anonhg.NetBSD.org/src/rev/0feadcf63ad3
branches:  trunk
changeset: 760645:0feadcf63ad3
user:      christos <christos%NetBSD.org@localhost>
date:      Mon Jan 10 04:57:56 2011 +0000

description:
test for sigqueue

diffstat:

 tests/lib/libc/Makefile         |   5 +-
 tests/lib/libc/sys/Makefile     |  12 +++++
 tests/lib/libc/sys/t_sigqueue.c |  92 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 107 insertions(+), 2 deletions(-)

diffs (128 lines):

diff -r ac431b21880c -r 0feadcf63ad3 tests/lib/libc/Makefile
--- a/tests/lib/libc/Makefile   Mon Jan 10 04:43:48 2011 +0000
+++ b/tests/lib/libc/Makefile   Mon Jan 10 04:57:56 2011 +0000
@@ -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
diff -r ac431b21880c -r 0feadcf63ad3 tests/lib/libc/sys/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/sys/Makefile       Mon Jan 10 04:57:56 2011 +0000
@@ -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>
+
diff -r ac431b21880c -r 0feadcf63ad3 tests/lib/libc/sys/t_sigqueue.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/lib/libc/sys/t_sigqueue.c   Mon Jan 10 04:57:56 2011 +0000
@@ -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();
+}



Home | Main Index | Thread Index | Old Index