Module Name:    src
Committed By:   pgoyette
Date:           Mon Dec 27 19:35:31 UTC 2010

Modified Files:
        src/distrib/sets/lists/tests: mi
        src/etc/mtree: NetBSD.dist.tests
        src/tests/lib/libc: Makefile
Added Files:
        src/tests/lib/libc/setjmp: Makefile t_setjmp.c

Log Message:
Move the various setjmp tests from regress to atf


To generate a diff of this commit:
cvs rdiff -u -r1.193 -r1.194 src/distrib/sets/lists/tests/mi
cvs rdiff -u -r1.8 -r1.9 src/etc/mtree/NetBSD.dist.tests
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/setjmp/Makefile \
    src/tests/lib/libc/setjmp/t_setjmp.c

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

Modified files:

Index: src/distrib/sets/lists/tests/mi
diff -u src/distrib/sets/lists/tests/mi:1.193 src/distrib/sets/lists/tests/mi:1.194
--- src/distrib/sets/lists/tests/mi:1.193	Mon Dec 27 15:31:22 2010
+++ src/distrib/sets/lists/tests/mi	Mon Dec 27 19:35:31 2010
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.193 2010/12/27 15:31:22 njoly Exp $
+# $NetBSD: mi,v 1.194 2010/12/27 19:35:31 pgoyette Exp $
 #
 # Note: don't delete entries from here - mark them as "obsolete" instead.
 #
@@ -324,6 +324,8 @@
 ./usr/libdata/debug/usr/tests/lib/libc/gen/t_siginfo.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/hash				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/hash/t_sha2.debug		tests-lib-debug		debug,atf
+./usr/libdata/debug/usr/tests/lib/libc/setjmp				tests-lib-debug
+./usr/libdata/debug/usr/tests/lib/libc/setjmp/t_setjmp.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/ssp				tests-lib-debug
 ./usr/libdata/debug/usr/tests/lib/libc/ssp/h_fgets.debug		tests-lib-debug		debug,atf
 ./usr/libdata/debug/usr/tests/lib/libc/ssp/h_getcwd.debug		tests-lib-debug		debug,atf
@@ -1576,6 +1578,9 @@
 ./usr/tests/lib/libc/stdlib/t_environment_pth	tests-lib-tests		atf
 ./usr/tests/lib/libc/stdlib/t_mi_vector_hash	tests-lib-tests		atf
 ./usr/tests/lib/libc/stdlib/t_strtox		tests-lib-tests		atf
+./usr/tests/lib/libc/setjmp			tests-lib-tests
+./usr/tests/lib/libc/setjmp/Atffile		tests-lib-tests		atf
+./usr/tests/lib/libc/setjmp/t_setjmp		tests-lib-tests		atf
 ./usr/tests/lib/libc/ssp			tests-lib-tests
 ./usr/tests/lib/libc/ssp/Atffile		tests-lib-tests		atf
 ./usr/tests/lib/libc/ssp/h_fgets		tests-lib-tests		atf

Index: src/etc/mtree/NetBSD.dist.tests
diff -u src/etc/mtree/NetBSD.dist.tests:1.8 src/etc/mtree/NetBSD.dist.tests:1.9
--- src/etc/mtree/NetBSD.dist.tests:1.8	Mon Dec 27 02:04:19 2010
+++ src/etc/mtree/NetBSD.dist.tests	Mon Dec 27 19:35:31 2010
@@ -1,4 +1,4 @@
-#	$NetBSD: NetBSD.dist.tests,v 1.8 2010/12/27 02:04:19 pgoyette Exp $
+#	$NetBSD: NetBSD.dist.tests,v 1.9 2010/12/27 19:35:31 pgoyette Exp $
 
 ./usr/libdata/debug/usr/tests
 ./usr/libdata/debug/usr/tests/atf
@@ -47,6 +47,7 @@
 ./usr/libdata/debug/usr/tests/lib/libc
 ./usr/libdata/debug/usr/tests/lib/libc/gen
 ./usr/libdata/debug/usr/tests/lib/libc/hash
+./usr/libdata/debug/usr/tests/lib/libc/setjmp
 ./usr/libdata/debug/usr/tests/lib/libc/ssp
 ./usr/libdata/debug/usr/tests/lib/libc/stdio
 ./usr/libdata/debug/usr/tests/lib/libc/stdlib
@@ -141,6 +142,7 @@
 ./usr/tests/lib/libc
 ./usr/tests/lib/libc/gen
 ./usr/tests/lib/libc/hash
+./usr/tests/lib/libc/setjmp
 ./usr/tests/lib/libc/ssp
 ./usr/tests/lib/libc/stdio
 ./usr/tests/lib/libc/stdlib

Index: src/tests/lib/libc/Makefile
diff -u src/tests/lib/libc/Makefile:1.11 src/tests/lib/libc/Makefile:1.12
--- src/tests/lib/libc/Makefile:1.11	Mon Dec 27 15:10:33 2010
+++ src/tests/lib/libc/Makefile	Mon Dec 27 19:35:30 2010
@@ -1,9 +1,9 @@
-# $NetBSD: Makefile,v 1.11 2010/12/27 15:10:33 he Exp $
+# $NetBSD: Makefile,v 1.12 2010/12/27 19:35:30 pgoyette Exp $
 
 .include <bsd.own.mk>
 .include <bsd.sys.mk>
 
-TESTS_SUBDIRS+=	gen hash stdlib stdio string
+TESTS_SUBDIRS+=	gen hash setjmp stdlib stdio string
 
 .if ${HAS_SSP} == "yes"
 TESTS_SUBDIRS+=	ssp

Added files:

Index: src/tests/lib/libc/setjmp/Makefile
diff -u /dev/null src/tests/lib/libc/setjmp/Makefile:1.1
--- /dev/null	Mon Dec 27 19:35:31 2010
+++ src/tests/lib/libc/setjmp/Makefile	Mon Dec 27 19:35:31 2010
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2010/12/27 19:35:31 pgoyette Exp $
+
+NOMAN=		# defined
+
+.include <bsd.own.mk>
+
+WARNS=	4
+
+TESTSDIR=	${TESTSBASE}/lib/libc/setjmp
+
+TESTS_C+=	t_setjmp
+
+.include <bsd.test.mk>
Index: src/tests/lib/libc/setjmp/t_setjmp.c
diff -u /dev/null src/tests/lib/libc/setjmp/t_setjmp.c:1.1
--- /dev/null	Mon Dec 27 19:35:31 2010
+++ src/tests/lib/libc/setjmp/t_setjmp.c	Mon Dec 27 19:35:31 2010
@@ -0,0 +1,196 @@
+/* $NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2008 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * 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.
+ *
+ * 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.
+ */
+
+/*
+ * Copyright (c) 1994 Christopher G. Demetriou
+ * All rights reserved.
+ * 
+ * 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 for the
+ *          NetBSD Project.  See http://www.NetBSD.org/ for
+ *          information about NetBSD.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ * 
+ * <<Id: LICENSE,v 1.2 2000/06/14 15:57:33 cgd Exp>>
+ */
+
+#include <sys/cdefs.h>
+__COPYRIGHT("@(#) Copyright (c) 2008\
+ The NetBSD Foundation, inc. All rights reserved.");
+__RCSID("$NetBSD: t_setjmp.c,v 1.1 2010/12/27 19:35:31 pgoyette Exp $");
+
+#include <sys/types.h>
+
+#include <errno.h>
+#include <setjmp.h>
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <atf-c.h>
+
+#define REQUIRE_ERRNO(x) ATF_REQUIRE_MSG(x, "%s", strerror(errno))
+
+#define TEST_SETJMP 0
+#define TEST_U_SETJMP 1
+#define TEST_SIGSETJMP_SAVE 2
+#define TEST_SIGSETJMP_NOSAVE 3
+
+static int expectsignal;
+
+static void
+aborthandler(int signo)
+{
+	ATF_REQUIRE_MSG(expectsignal, "kill(SIGABRT) succeeded");
+	atf_tc_pass();
+}
+
+static void
+h_check(int test)
+{
+	struct sigaction sa;
+	jmp_buf jb;
+	sigjmp_buf sjb;
+	sigset_t ss;
+	int i, x;
+
+	i = getpid();
+
+	if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE)
+		expectsignal = 0;
+	else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE)
+		expectsignal = 1;
+	else
+		atf_tc_fail("unknown test");
+
+	sa.sa_handler = aborthandler;
+	sigemptyset(&sa.sa_mask);
+	sa.sa_flags = 0;
+	REQUIRE_ERRNO(sigaction(SIGABRT, &sa, NULL) != -1);
+	REQUIRE_ERRNO(sigemptyset(&ss) != -1);
+	REQUIRE_ERRNO(sigaddset(&ss, SIGABRT) != -1);
+	REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, &ss, NULL) != -1);
+
+	if (test == TEST_SETJMP)
+		x = setjmp(jb);
+	else if (test == TEST_U_SETJMP)
+		x = _setjmp(jb);
+	else 
+		x = sigsetjmp(sjb, !expectsignal);
+
+	if (x != 0) {
+		ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value");
+		kill(i, SIGABRT);
+		ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed");
+		atf_tc_pass();
+	}
+
+	REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, &ss, NULL) != -1);
+
+	if (test == TEST_SETJMP)
+		longjmp(jb, i);
+	else if (test == TEST_U_SETJMP)
+		_longjmp(jb, i);
+	else 
+		siglongjmp(sjb, i);
+
+	atf_tc_fail("jmp failed");
+}
+
+ATF_TC(setjmp);
+ATF_TC_HEAD(setjmp, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks setjmp(3)");
+}
+ATF_TC_BODY(setjmp, tc)
+{
+	h_check(TEST_SETJMP);
+}
+
+ATF_TC(_setjmp);
+ATF_TC_HEAD(_setjmp, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks _setjmp(3)");
+}
+ATF_TC_BODY(_setjmp, tc)
+{
+	h_check(TEST_U_SETJMP);
+}
+
+ATF_TC(sigsetjmp_save);
+ATF_TC_HEAD(sigsetjmp_save, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask enabled");
+}
+ATF_TC_BODY(sigsetjmp_save, tc)
+{
+	h_check(TEST_SIGSETJMP_SAVE);
+}
+
+ATF_TC(sigsetjmp_nosave);
+ATF_TC_HEAD(sigsetjmp_nosave, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks sigsetjmp(3) with savemask disabled");
+}
+ATF_TC_BODY(sigsetjmp_nosave, tc)
+{
+	h_check(TEST_SIGSETJMP_NOSAVE);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, setjmp);
+	ATF_TP_ADD_TC(tp, _setjmp);
+	ATF_TP_ADD_TC(tp, sigsetjmp_save);
+	ATF_TP_ADD_TC(tp, sigsetjmp_nosave);
+
+	return atf_no_error();
+}

Reply via email to