CVS commit: src/tests/lib/libc/gen/exect

2016-12-12 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Dec 12 10:34:55 UTC 2016

Modified Files:
src/tests/lib/libc/gen/exect: t_exect.c

Log Message:
sig_atomic_t does not include volatile. Prevent static analysis from
understanding that the test function is dead.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/exect/t_exect.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/exect/t_exect.c
diff -u src/tests/lib/libc/gen/exect/t_exect.c:1.5 src/tests/lib/libc/gen/exect/t_exect.c:1.6
--- src/tests/lib/libc/gen/exect/t_exect.c:1.5	Sun Dec 11 03:38:09 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Mon Dec 12 10:34:55 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exect.c,v 1.5 2016/12/11 03:38:09 kamil Exp $	*/
+/*	$NetBSD: t_exect.c,v 1.6 2016/12/12 10:34:55 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,7 +42,7 @@ ATF_TC_HEAD(t_exect_null, tc)
 	"Tests an empty exect(2) executing");
 }
 
-static sig_atomic_t caught = 0;
+static volatile sig_atomic_t caught = 0;
 
 static void
 sigtrap_handler(int sig, siginfo_t *info, void *ctx)
@@ -66,8 +66,9 @@ ATF_TC_BODY(t_exect_null, tc)
 	 * designed and implemented and is breaking tests - skip it
 	 * unconditionally for all ports.
 	 */
-
-	atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700");
+	/* Prevent static analysis from requiring t_exec_null to be __dead. */
+	if (!caught) 
+		atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700");
 
 	ATF_REQUIRE(sigemptyset(_mask) == 0);
 	act.sa_sigaction = sigtrap_handler;



CVS commit: src/tests/lib/libc/gen/exect

2016-12-10 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sun Dec 11 03:38:09 UTC 2016

Modified Files:
src/tests/lib/libc/gen/exect: t_exect.c

Log Message:
Skip t_exect test because it makes test machines to hang

exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64
Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it
needs to be redone from scratch.

This test affects amd64 releng machines causing tests to hang or
fail. As there is little point to test interface that is still not,
designed and implemented and implemented and is breaking tests - skip it
unconditionally for all ports.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/exect/t_exect.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/exect/t_exect.c
diff -u src/tests/lib/libc/gen/exect/t_exect.c:1.4 src/tests/lib/libc/gen/exect/t_exect.c:1.5
--- src/tests/lib/libc/gen/exect/t_exect.c:1.4	Fri Dec  9 08:34:37 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Sun Dec 11 03:38:09 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exect.c,v 1.4 2016/12/09 08:34:37 kamil Exp $	*/
+/*	$NetBSD: t_exect.c,v 1.5 2016/12/11 03:38:09 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -57,12 +57,17 @@ ATF_TC_BODY(t_exect_null, tc)
 {
 	struct sigaction act;
 
-#if defined(__x86_64__)
 	/*
-	 * exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64
+	 * Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it
+	 * needs to be redone from scratch.
+	 *
+	 * This test affects amd64 releng machines causing tests to hang or
+	 * fail. As there is little point to test interface that is still not,
+	 * designed and implemented and is breaking tests - skip it
+	 * unconditionally for all ports.
 	 */
-	atf_tc_expect_fail("PR port-amd64/51700");
-#endif
+
+	atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700");
 
 	ATF_REQUIRE(sigemptyset(_mask) == 0);
 	act.sa_sigaction = sigtrap_handler;



CVS commit: src/tests/lib/libc/gen/exect

2016-12-09 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  9 08:34:38 UTC 2016

Modified Files:
src/tests/lib/libc/gen/exect: t_exect.c

Log Message:
Restrict atf_tc_expect_fail(PR port-amd64/51700) only for amd64 (x86_64)

Other ports than amd64 have their own issues, mostly keeping this call as
unimplemented.

While there cast sig_atomic_t to int in the printf(3)-like call -- pointed
out by 

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/exect/t_exect.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/exect/t_exect.c
diff -u src/tests/lib/libc/gen/exect/t_exect.c:1.3 src/tests/lib/libc/gen/exect/t_exect.c:1.4
--- src/tests/lib/libc/gen/exect/t_exect.c:1.3	Fri Dec  9 06:47:48 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Fri Dec  9 08:34:37 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exect.c,v 1.3 2016/12/09 06:47:48 kamil Exp $	*/
+/*	$NetBSD: t_exect.c,v 1.4 2016/12/09 08:34:37 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -57,10 +57,12 @@ ATF_TC_BODY(t_exect_null, tc)
 {
 	struct sigaction act;
 
+#if defined(__x86_64__)
 	/*
 	 * exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64
 	 */
 	atf_tc_expect_fail("PR port-amd64/51700");
+#endif
 
 	ATF_REQUIRE(sigemptyset(_mask) == 0);
 	act.sa_sigaction = sigtrap_handler;
@@ -71,7 +73,7 @@ ATF_TC_BODY(t_exect_null, tc)
 	ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1);
 
 	ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)",
-	caught);
+	(int)caught);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/gen/exect

2016-12-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  9 06:47:48 UTC 2016

Modified Files:
src/tests/lib/libc/gen/exect: t_exect.c

Log Message:
Add check in t_exect_null to verify that SIGTRAP was emitted only once

Currently this test fails on amd64.

PR port-amd64/51700
exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64

On FreeBSD/amd64 this tests passes correctly.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/exect/t_exect.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/exect/t_exect.c
diff -u src/tests/lib/libc/gen/exect/t_exect.c:1.2 src/tests/lib/libc/gen/exect/t_exect.c:1.3
--- src/tests/lib/libc/gen/exect/t_exect.c:1.2	Fri Dec  9 06:12:02 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Fri Dec  9 06:47:48 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exect.c,v 1.2 2016/12/09 06:12:02 kamil Exp $	*/
+/*	$NetBSD: t_exect.c,v 1.3 2016/12/09 06:47:48 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -42,17 +42,26 @@ ATF_TC_HEAD(t_exect_null, tc)
 	"Tests an empty exect(2) executing");
 }
 
+static sig_atomic_t caught = 0;
+
 static void
 sigtrap_handler(int sig, siginfo_t *info, void *ctx)
 {
 	ATF_REQUIRE_EQ(sig, SIGTRAP);
 	ATF_REQUIRE_EQ(info->si_code, TRAP_TRACE);
+
+	++caught;
 }
 
 ATF_TC_BODY(t_exect_null, tc)
 {
 	struct sigaction act;
 
+	/*
+	 * exect(NULL,NULL,NULL) generates 15859 times SIGTRAP on amd64
+	 */
+	atf_tc_expect_fail("PR port-amd64/51700");
+
 	ATF_REQUIRE(sigemptyset(_mask) == 0);
 	act.sa_sigaction = sigtrap_handler;
 	act.sa_flags = SA_SIGINFO;
@@ -60,6 +69,9 @@ ATF_TC_BODY(t_exect_null, tc)
 	ATF_REQUIRE(sigaction(SIGTRAP, , 0) == 0);
 
 	ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1);
+
+	ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)",
+	caught);
 }
 
 ATF_TP_ADD_TCS(tp)



CVS commit: src/tests/lib/libc/gen/exect

2016-12-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Dec  9 04:00:36 UTC 2016

Added Files:
src/tests/lib/libc/gen/exect: Makefile t_exect.c

Log Message:
Add new test t_exect to verify exect(2)

This test is a clone of tests/lib/libc/gen/execve/t_execve

t_exect_null:
Tests an empty exect(2) executing

The function exect() executes a file with the program tracing facilities
enabled (see ptrace(2)).
-- exect(2)

This test will be attached to build afterwards.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/gen/exect/Makefile \
src/tests/lib/libc/gen/exect/t_exect.c

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

Added files:

Index: src/tests/lib/libc/gen/exect/Makefile
diff -u /dev/null src/tests/lib/libc/gen/exect/Makefile:1.1
--- /dev/null	Fri Dec  9 04:00:36 2016
+++ src/tests/lib/libc/gen/exect/Makefile	Fri Dec  9 04:00:36 2016
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2016/12/09 04:00:36 kamil Exp $
+
+NOMAN=		# defined
+WARNS=4
+
+.include 
+
+TESTSDIR=	${TESTSBASE}/lib/libc/gen/exect
+
+TESTS_C=	t_exect
+
+BINDIR=		${TESTSDIR}
+SCRIPTSDIR=	${TESTSDIR}
+
+.include 
Index: src/tests/lib/libc/gen/exect/t_exect.c
diff -u /dev/null src/tests/lib/libc/gen/exect/t_exect.c:1.1
--- /dev/null	Fri Dec  9 04:00:36 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Fri Dec  9 04:00:36 2016
@@ -0,0 +1,59 @@
+/*	$NetBSD: t_exect.c,v 1.1 2016/12/09 04:00:36 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2014 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.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+ATF_TC(t_exect_null);
+
+ATF_TC_HEAD(t_exect_null, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Tests an empty exect(2) executing");
+}
+
+ATF_TC_BODY(t_exect_null, tc)
+{
+	int err;
+
+	err = exect(NULL, NULL, NULL);
+	ATF_REQUIRE(err == -1);
+	ATF_REQUIRE_MSG(errno == EFAULT,
+	"wrong error returned %d instead of %d", errno, EFAULT);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, t_exect_null);
+
+	return atf_no_error();
+}