CVS commit: src/tests/lib/libc

2021-08-02 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Mon Aug  2 17:41:07 UTC 2021

Modified Files:
src/tests/lib/libc/locale: t_sprintf.c t_strfmon.c t_toupper.c
src/tests/lib/libc/string: t_strcoll.c

Log Message:
s/diferent/different/


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/locale/t_sprintf.c
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/locale/t_strfmon.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/locale/t_toupper.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/string/t_strcoll.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/locale/t_sprintf.c
diff -u src/tests/lib/libc/locale/t_sprintf.c:1.7 src/tests/lib/libc/locale/t_sprintf.c:1.8
--- src/tests/lib/libc/locale/t_sprintf.c:1.7	Fri Dec  1 01:08:35 2017
+++ src/tests/lib/libc/locale/t_sprintf.c	Mon Aug  2 17:41:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $ */
+/* $NetBSD: t_sprintf.c,v 1.8 2021/08/02 17:41:07 andvar Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_sprintf.c,v 1.7 2017/12/01 01:08:35 kre Exp $");
+__RCSID("$NetBSD: t_sprintf.c,v 1.8 2021/08/02 17:41:07 andvar Exp $");
 
 #include 
 #include 
@@ -193,7 +193,7 @@ ATF_TC(sprintf);
 ATF_TC_HEAD(sprintf, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks sprintf %%'d and %%'f under diferent locales");
+		"Checks sprintf %%'d and %%'f under different locales");
 }
 ATF_TC_BODY(sprintf, tc)
 {
@@ -207,7 +207,7 @@ ATF_TC(strto);
 ATF_TC_HEAD(strto, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks strtol and strtod under diferent locales");
+		"Checks strtol and strtod under different locales");
 }
 ATF_TC_BODY(strto, tc)
 {
@@ -221,7 +221,7 @@ ATF_TC(sscanf);
 ATF_TC_HEAD(sscanf, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks sscanf under diferent locales");
+		"Checks sscanf under different locales");
 }
 ATF_TC_BODY(sscanf, tc)
 {

Index: src/tests/lib/libc/locale/t_strfmon.c
diff -u src/tests/lib/libc/locale/t_strfmon.c:1.2 src/tests/lib/libc/locale/t_strfmon.c:1.3
--- src/tests/lib/libc/locale/t_strfmon.c:1.2	Thu Dec  7 22:23:14 2017
+++ src/tests/lib/libc/locale/t_strfmon.c	Mon Aug  2 17:41:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $ */
+/* $NetBSD: t_strfmon.c,v 1.3 2021/08/02 17:41:07 andvar Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_strfmon.c,v 1.2 2017/12/07 22:23:14 kre Exp $");
+__RCSID("$NetBSD: t_strfmon.c,v 1.3 2021/08/02 17:41:07 andvar Exp $");
 
 #include 
 #include 
@@ -41,7 +41,7 @@ ATF_TC(strfmon);
 ATF_TC_HEAD(strfmon, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks strfmon_l under diferent locales");
+		"Checks strfmon_l under different locales");
 }
 
 ATF_TC_BODY(strfmon, tc)

Index: src/tests/lib/libc/locale/t_toupper.c
diff -u src/tests/lib/libc/locale/t_toupper.c:1.1 src/tests/lib/libc/locale/t_toupper.c:1.2
--- src/tests/lib/libc/locale/t_toupper.c:1.1	Tue May 30 02:11:03 2017
+++ src/tests/lib/libc/locale/t_toupper.c	Mon Aug  2 17:41:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $ */
+/* $NetBSD: t_toupper.c,v 1.2 2021/08/02 17:41:07 andvar Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_toupper.c,v 1.1 2017/05/30 02:11:03 perseant Exp $");
+__RCSID("$NetBSD: t_toupper.c,v 1.2 2021/08/02 17:41:07 andvar Exp $");
 
 #include 
 #include 
@@ -92,7 +92,7 @@ ATF_TC(toupper);
 ATF_TC_HEAD(toupper, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks toupper under diferent locales");
+		"Checks toupper under different locales");
 }
 
 ATF_TC_BODY(toupper, tc)
@@ -108,7 +108,7 @@ ATF_TC(tolower);
 ATF_TC_HEAD(tolower, tc)
 {
 	atf_tc_set_md_var(tc, "descr",
-		"Checks tolower under diferent locales");
+		"Checks tolower under different locales");
 }
 
 ATF_TC_BODY(tolower, tc)

Index: src/tests/lib/libc/string/t_strcoll.c
diff -u src/tests/lib/libc/string/t_strcoll.c:1.1 src/tests/lib/libc/string/t_strcoll.c:1.2
--- src/tests/lib/libc/string/t_strcoll.c:1.1	Fri May 26 01:24:19 2017
+++ src/tests/lib/libc/string/t_strcoll.c	Mon Aug  2 17:41:07 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $ */
+/* $NetBSD: t_strcoll.c,v 1.2 2021/08/02 17:41:07 andvar Exp $ */
 
 /*-
  * Copyright (c) 2017 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2017\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_strcoll.c,v 1.1 2017/05/26 01:24:19 perseant Exp $");
+__RCSID("$NetBSD: t_strcoll.c,v 1.2 

CVS commit: src/tests/lib/libc/sys

2021-07-24 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jul 24 08:39:54 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_ptrace_core_wait.h

Log Message:
For sh3, increment PC when PT_CONTINUE from trigger_trap(), as already
done for aarch64, arm, and powerpc. Otherwise, child is trapped to the
PTRACE_BREAKPOINT_ASM (== trapa) instruction indefinitely.

Fix tests/lib/libc/sys/t_ptrace_wait*:core_dump_procinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_ptrace_core_wait.h

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/sys/t_ptrace_core_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3 src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.4
--- src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3	Thu Oct 15 22:59:50 2020
+++ src/tests/lib/libc/sys/t_ptrace_core_wait.h	Sat Jul 24 08:39:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_core_wait.h,v 1.3 2020/10/15 22:59:50 rin Exp $	*/
+/*	$NetBSD: t_ptrace_core_wait.h,v 1.4 2021/07/24 08:39:54 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -208,7 +208,8 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
 
-#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
+#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__) || \
+defined(__sh3__)
 	/*
 	 * For these archs, program counter is not automatically incremented
 	 * by a trap instruction. We cannot increment PC in the trap handler,
@@ -220,12 +221,7 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 
 	SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1);
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child,
-#  if defined(__aarch64__) || defined(__arm__)
-	(void *)(r.r_pc + PTRACE_BREAKPOINT_SIZE),
-#  elif defined(__powerpc__)
-	(void *)(r.pc + PTRACE_BREAKPOINT_SIZE),
-#  endif
-	0) != -1);
+	(void *)(PTRACE_REG_PC() + PTRACE_BREAKPOINT_SIZE), 0) != -1);
 #else
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 #endif



CVS commit: src/tests/lib/libc/sys

2021-07-17 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul 17 14:03:36 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_wait.c

Log Message:
PR 56313: fix eroneous = that was meant to be ==


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/sys/t_wait.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/sys/t_wait.c
diff -u src/tests/lib/libc/sys/t_wait.c:1.9 src/tests/lib/libc/sys/t_wait.c:1.10
--- src/tests/lib/libc/sys/t_wait.c:1.9	Mon Feb  4 09:35:11 2019
+++ src/tests/lib/libc/sys/t_wait.c	Sat Jul 17 14:03:35 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait.c,v 1.9 2019/02/04 09:35:11 mrg Exp $ */
+/* $NetBSD: t_wait.c,v 1.10 2021/07/17 14:03:35 martin Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_wait.c,v 1.9 2019/02/04 09:35:11 mrg Exp $");
+__RCSID("$NetBSD: t_wait.c,v 1.10 2021/07/17 14:03:35 martin Exp $");
 
 #include 
 #include 
@@ -85,7 +85,7 @@ ATF_TC_BODY(wait6_exited, tc)
 	default:
 		ATF_REQUIRE(wait6(P_PID, pid, , WEXITED, , ) == pid);
 		ATF_REQUIRE(WIFEXITED(st) && WEXITSTATUS(st) == 0x5a);
-		ATF_REQUIRE(si.si_status = 0x5a5a5a5a);
+		ATF_REQUIRE(si.si_status == 0x5a5a5a5a);
 		ATF_REQUIRE(si.si_pid == pid);
 		ATF_REQUIRE(si.si_uid == getuid());
 		ATF_REQUIRE(si.si_code == CLD_EXITED);



CVS commit: src/tests/lib/libc/stdio

2021-07-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jul 10 13:22:01 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: t_fmemopen.c

Log Message:
Use intmax_t to printf an off_t


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/stdio/t_fmemopen.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/stdio/t_fmemopen.c
diff -u src/tests/lib/libc/stdio/t_fmemopen.c:1.5 src/tests/lib/libc/stdio/t_fmemopen.c:1.6
--- src/tests/lib/libc/stdio/t_fmemopen.c:1.5	Sat Jul 10 07:50:33 2021
+++ src/tests/lib/libc/stdio/t_fmemopen.c	Sat Jul 10 13:22:01 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fmemopen.c,v 1.5 2021/07/10 07:50:33 christos Exp $ */
+/* $NetBSD: t_fmemopen.c,v 1.6 2021/07/10 13:22:01 martin Exp $ */
 
 /*-
  * Copyright (c)2010 Takehiko NOZAKI,
@@ -965,7 +965,8 @@ ATF_TC_BODY(test19, tc)
 /* don't accept non nul character at end of buffer */
 			ATF_CHECK(fputc(0x1, fp) == EOF);
 			ATF_CHECK_MSG(ftello(fp) == (off_t)t->n,
-"%td != %td", ftello(fp), (off_t)t->n);
+"%jd != %jd", (intmax_t)ftello(fp),
+(intmax_t)t->n);
 			ATF_CHECK(feof(fp) == 0);
 
 /* accept nul character at end of buffer */



CVS commit: src/tests/lib/libc/stdio

2021-07-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jul 10 07:50:33 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: t_fmemopen.c

Log Message:
add more info to ease future debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdio/t_fmemopen.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/stdio/t_fmemopen.c
diff -u src/tests/lib/libc/stdio/t_fmemopen.c:1.4 src/tests/lib/libc/stdio/t_fmemopen.c:1.5
--- src/tests/lib/libc/stdio/t_fmemopen.c:1.4	Sat Oct 19 13:45:00 2013
+++ src/tests/lib/libc/stdio/t_fmemopen.c	Sat Jul 10 03:50:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fmemopen.c,v 1.4 2013/10/19 17:45:00 christos Exp $ */
+/* $NetBSD: t_fmemopen.c,v 1.5 2021/07/10 07:50:33 christos Exp $ */
 
 /*-
  * Copyright (c)2010 Takehiko NOZAKI,
@@ -964,7 +964,8 @@ ATF_TC_BODY(test19, tc)
 
 /* don't accept non nul character at end of buffer */
 			ATF_CHECK(fputc(0x1, fp) == EOF);
-			ATF_CHECK(ftello(fp) == (off_t)t->n);
+			ATF_CHECK_MSG(ftello(fp) == (off_t)t->n,
+"%td != %td", ftello(fp), (off_t)t->n);
 			ATF_CHECK(feof(fp) == 0);
 
 /* accept nul character at end of buffer */



CVS commit: src/tests/lib/libc/stdio

2021-07-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jul 10 07:50:20 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c

Log Message:
space before star


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/stdio/h_intr.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/stdio/h_intr.c
diff -u src/tests/lib/libc/stdio/h_intr.c:1.4 src/tests/lib/libc/stdio/h_intr.c:1.5
--- src/tests/lib/libc/stdio/h_intr.c:1.4	Fri Jul  9 16:00:26 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Sat Jul 10 03:50:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $	*/
+/*	$NetBSD: h_intr.c,v 1.5 2021/07/10 07:50:20 christos Exp $	*/
 
 /**
  * Test of interrupted I/O to popen()ed commands.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $");
+__RCSID("$NetBSD: h_intr.c,v 1.5 2021/07/10 07:50:20 christos Exp $");
 
 #include 
 #include 
@@ -48,12 +48,12 @@ static int rndmode(void);
 static sig_t xsignal(int signo, sig_t handler);
 static void alarmtimer(int wait);
 static void pr_star(int signo);
-static int do_opts(int argc, char* argv[]);
+static int do_opts(int argc, char *argv[]);
 static void usage(FILE *fp);
 
 /* Globals */
 static struct options {
-	const char* cmd;	/* cmd to run (which must read from stdin) */
+	const char *cmd;	/* cmd to run (which must read from stdin) */
 	size_t bsize;		/* block size to use */
 	size_t asize;		/* alt. stdio buffer size */
 	int btype;		/* buffering type: _IONBF, ... */
@@ -74,8 +74,8 @@ static const struct {
 
 static void (*alarm_fn)(int);/* real/dummy alarm fn. */
 static int (*sintr_fn)(int, int);			/*  " siginterrupt fn. */
-static ssize_t (*rd_fn)(FILE*, void*, size_t);		/* read fn. */
-static ssize_t (*wr_fn)(FILE*, const void*, size_t);	/* write fn. */
+static ssize_t (*rd_fn)(FILE *, void *, size_t);	/* read fn. */
+static ssize_t (*wr_fn)(FILE *, const void *, size_t);	/* write fn. */
 
 enum {
 	MB = 1024 * 1024,	/* a megabyte */
@@ -91,7 +91,7 @@ enum {
  * M A I N
  */
 int
-main(int argc, char* argv[])
+main(int argc, char *argv[])
 {
 	int i, rc = EXIT_SUCCESS;
 
@@ -205,9 +205,9 @@ fail:
  * maxread - syscall version
  */
 ssize_t
-smaxread(FILE* fp, void* buf, size_t size)
+smaxread(FILE* fp, void *buf, size_t size)
 {
-	char* p = buf;
+	char *p = buf;
 	ssize_t nrd = 0;
 	ssize_t n;
 
@@ -231,9 +231,9 @@ smaxread(FILE* fp, void* buf, size_t siz
  * maxread - stdio version
  */
 ssize_t
-maxread(FILE* fp, void* buf, size_t size)
+maxread(FILE* fp, void *buf, size_t size)
 {
-	char* p = buf;
+	char *p = buf;
 	ssize_t nrd = 0;
 	size_t n;
 
@@ -262,9 +262,9 @@ maxread(FILE* fp, void* buf, size_t size
  * maxwrite - syscall version
  */
 ssize_t
-smaxwrite(FILE* fp, const void* buf, size_t size)
+smaxwrite(FILE* fp, const void *buf, size_t size)
 {
-	const char* p = buf;
+	const char *p = buf;
 	ssize_t nwr = 0;
 	ssize_t n;
 
@@ -287,9 +287,9 @@ smaxwrite(FILE* fp, const void* buf, siz
  * maxwrite - stdio version (warning: substrate may be buggy)
  */
 ssize_t
-maxwrite(FILE* fp, const void* buf, size_t size)
+maxwrite(FILE* fp, const void *buf, size_t size)
 {
-	const char* p = buf;
+	const char *p = buf;
 	ssize_t nwr = 0;
 	size_t n;
 
@@ -412,7 +412,7 @@ btype2str(int val)
 }
 
 static int
-str2btype(const char* s)
+str2btype(const char *s)
 {
 	for (size_t i = 0; i < __arraycount(btypes); i++)
 		if (strcmp(btypes[i].name, s) == 0)



CVS commit: src/tests/lib/libc/stdio

2021-07-09 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Jul  9 20:00:26 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c

Log Message:
Make opts.cmd const char * rather than char * -- nothing ever modifies
the string it points to, it is never passed to a function not taking a
const char * arg, and this allows "" (or other literal strings if ever
needed) to be assigned to it - which should fix the build.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/stdio/h_intr.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/stdio/h_intr.c
diff -u src/tests/lib/libc/stdio/h_intr.c:1.3 src/tests/lib/libc/stdio/h_intr.c:1.4
--- src/tests/lib/libc/stdio/h_intr.c:1.3	Fri Jul  9 15:26:59 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Fri Jul  9 20:00:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $	*/
+/*	$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $	*/
 
 /**
  * Test of interrupted I/O to popen()ed commands.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $");
+__RCSID("$NetBSD: h_intr.c,v 1.4 2021/07/09 20:00:26 kre Exp $");
 
 #include 
 #include 
@@ -53,7 +53,7 @@ static void usage(FILE *fp);
 
 /* Globals */
 static struct options {
-	char* cmd;		/* cmd to run (which must read from stdin) */
+	const char* cmd;	/* cmd to run (which must read from stdin) */
 	size_t bsize;		/* block size to use */
 	size_t asize;		/* alt. stdio buffer size */
 	int btype;		/* buffering type: _IONBF, ... */



CVS commit: src/tests/lib/libc/stdio

2021-07-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Jul  9 15:26:59 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c t_intr.sh

Log Message:
fixes from RVP


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdio/h_intr.c
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/t_intr.sh

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/stdio/h_intr.c
diff -u src/tests/lib/libc/stdio/h_intr.c:1.2 src/tests/lib/libc/stdio/h_intr.c:1.3
--- src/tests/lib/libc/stdio/h_intr.c:1.2	Thu Jul  8 11:21:40 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Fri Jul  9 11:26:59 2021
@@ -1,20 +1,20 @@
-/*	$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $	*/
+/*	$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $	*/
 
 /**
- * Test of interrupted writes to popen()'ed commands.
+ * Test of interrupted I/O to popen()ed commands.
  *
  * Example 1:
- * ./h_fwrite -c "gzip -t" *.gz
+ * ./h_intr -c "gzip -t" *.gz
  *
  * Example 2:
- * while :; do ./h_fwrite -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done
+ * while :; do ./h_intr -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done
  *
  * Example 3:
  * Create checksum file:
  * find /mnt -type f -exec sha512 -n {} + >SHA512
  *
  * Check program:
- * find /mnt -type f -exec ./h_fwrite -b 512 -c run.sh {} +
+ * find /mnt -type f -exec ./h_intr -b 512 -c run.sh {} +
  * 
  * ./run.sh:
 	#!/bin/sh
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $");
+__RCSID("$NetBSD: h_intr.c,v 1.3 2021/07/09 15:26:59 christos Exp $");
 
 #include 
 #include 
@@ -38,25 +38,29 @@ __RCSID("$NetBSD: h_intr.c,v 1.2 2021/07
 #include 
 #include 
 
-static int process(const char *fn);
+static bool process(const char *fn);
 ssize_t maxread(FILE *fp, void *buf, size_t size);
 ssize_t smaxread(FILE *fp, void *buf, size_t size);
 ssize_t maxwrite(FILE *fp, const void *buf, size_t size);
 ssize_t smaxwrite(FILE *fp, const void *buf, size_t size);
+static int rndbuf(void);
+static int rndmode(void);
 static sig_t xsignal(int signo, sig_t handler);
 static void alarmtimer(int wait);
 static void pr_star(int signo);
-static bool isvalid(const char *s);
 static int do_opts(int argc, char* argv[]);
-static void usage(FILE* fp);
+static void usage(FILE *fp);
 
 /* Globals */
 static struct options {
-	size_t bsize;
-	size_t ssize;
-	int btype;
-	int tmout;
-	const char *cmd;
+	char* cmd;		/* cmd to run (which must read from stdin) */
+	size_t bsize;		/* block size to use */
+	size_t asize;		/* alt. stdio buffer size */
+	int btype;		/* buffering type: _IONBF, ... */
+	int tmout;		/* alarm timeout */
+	int flush;		/* call fflush() after write if 1 */
+	int rndbuf;		/* switch buffer randomly if 1 */
+	int rndmod;		/* switch buffering modes randomly if 1 */
 } opts;
 
 static const struct {
@@ -68,15 +72,24 @@ static const struct {
 	{ "IOFBF", _IOFBF },
 };
 
+static void (*alarm_fn)(int);/* real/dummy alarm fn. */
+static int (*sintr_fn)(int, int);			/*  " siginterrupt fn. */
+static ssize_t (*rd_fn)(FILE*, void*, size_t);		/* read fn. */
+static ssize_t (*wr_fn)(FILE*, const void*, size_t);	/* write fn. */
+
 enum {
-	MB = 1024 * 1024,
-	BSIZE = 16 * 1024,
-	DEF_MS = 100,
-	MS = 1000,
+	MB = 1024 * 1024,	/* a megabyte */
+	BSIZE = 16 * 1024,	/* default RW buffer size */
+	DEF_MS = 100,		/* interrupt 10x a second */
+	MS = 1000,		/* msecs. in a second */
 };
 
 
 
+
+/**
+ * M A I N
+ */
 int
 main(int argc, char* argv[])
 {
@@ -100,8 +113,8 @@ main(int argc, char* argv[])
 
 		sig_t osig = xsignal(SIGALRM, pr_star);
 
-		if (process(argv[i]) == 0)
-			printf("ok\n");
+		if (process(argv[i]) == true)
+			printf(" OK\n");
 		else
 			rc = EXIT_FAILURE;
 
@@ -111,46 +124,79 @@ main(int argc, char* argv[])
 	return rc;
 }
 
-static int
+static bool
 process(const char *fn)
 {
 	FILE *ifp, *ofp;
-	char *buf;
+	char *buf, *abuf;
+	int rc = false;
 	size_t nw = 0;
-	int rc = EXIT_FAILURE;
 	ssize_t n;
 
-	if ((buf = malloc(opts.bsize)) == NULL)
-		err(rc, "buffer alloc failed");
+	abuf = NULL;
+
+	if ((buf = malloc(opts.bsize)) == NULL) {
+		warn("buffer alloc failed");
+		return rc;
+	}
+
+	if ((abuf = malloc(opts.asize)) == NULL) {
+		warn("alt. buffer alloc failed");
+		goto fail;
+	}
 
 	if ((ifp = fopen(fn, "r")) == NULL) {
 		warn("fopen failed: %s", fn);
-		return rc;
+		goto fail;
+	}
+
+	if ((ofp = popen(opts.cmd, "w")) == NULL) {
+		warn("popen failed `%s'", opts.cmd);
+		goto fail;
 	}
 
-	if ((ofp = popen(opts.cmd, "w")) == NULL)
-		err(rc, "popen failed `%s'", opts.cmd);
+	setvbuf(ofp, NULL, opts.btype, opts.asize);
+	setvbuf(ifp, NULL, opts.btype, opts.asize);
 
-	setvbuf(ofp, NULL, opts.btype, opts.ssize);
-	setvbuf(ifp, NULL, opts.btype, opts.ssize);
+	alarm_fn(opts.tmout);
 
-	alarmtimer(opts.tmout);
-	while ((n = maxread(ifp, buf, opts.bsize)) > 0) {
+	while 

CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 15:21:40 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: h_intr.c

Log Message:
fix printf format strings


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdio/h_intr.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/stdio/h_intr.c
diff -u src/tests/lib/libc/stdio/h_intr.c:1.1 src/tests/lib/libc/stdio/h_intr.c:1.2
--- src/tests/lib/libc/stdio/h_intr.c:1.1	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Thu Jul  8 11:21:40 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $	*/
+/*	$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $	*/
 
 /**
  * Test of interrupted writes to popen()'ed commands.
@@ -25,7 +25,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $");
+__RCSID("$NetBSD: h_intr.c,v 1.2 2021/07/08 15:21:40 christos Exp $");
 
 #include 
 #include 
@@ -144,7 +144,7 @@ process(const char *fn)
 		nw += i;
 	}
 	alarmtimer(0);
-	// printf("%lu\n", nw);
+	// printf("%zu\n", nw);
 
 	fclose(ifp);
 	if (pclose(ofp) != 0)
@@ -341,11 +341,11 @@ usage(FILE* fp)
 	fprintf(fp, "%s: Test interrupted writes to popen()ed CMD.\n",
 	getprogname());
 	fprintf(fp, "\n");
-	fprintf(fp, "  -b SIZE   Buffer size (%lu)\n", opts.bsize);
+	fprintf(fp, "  -b SIZE   Buffer size (%zu)\n", opts.bsize);
 	fprintf(fp, "  -c CMDCommand to run on each FILE.\n");
 	fprintf(fp, "  -hThis message.\n");
 	fprintf(fp, "  -pBuffering type %s.\n", getbtype(opts.btype));
-	fprintf(fp, "  -s SIZE   stdio buffer size (%lu)\n", opts.ssize);
+	fprintf(fp, "  -s SIZE   stdio buffer size (%zu)\n", opts.ssize);
 	fprintf(fp, "  -t TMOUT  Interrupt writing to CMD every (%d) ms\n",
 	opts.tmout);
 }



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 12:30:20 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile

Log Message:
need to set BINDIR


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/tests/lib/libc/stdio/Makefile

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/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.15 src/tests/lib/libc/stdio/Makefile:1.16
--- src/tests/lib/libc/stdio/Makefile:1.15	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/Makefile	Thu Jul  8 08:30:20 2021
@@ -1,10 +1,12 @@
-# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $
+# $NetBSD: Makefile,v 1.16 2021/07/08 12:30:20 christos Exp $
 
 NOMAN=
 .include 
 
 TESTSDIR=	${TESTSBASE}/lib/libc/stdio
 
+BINDIR= ${TESTSDIR}
+
 TESTS_C+=	t_clearerr
 TESTS_C+=	t_fflush
 TESTS_C+=	t_fmemopen



CVS commit: src/tests/lib/libc/stdio

2021-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Jul  8 09:07:46 UTC 2021

Modified Files:
src/tests/lib/libc/stdio: Makefile
Added Files:
src/tests/lib/libc/stdio: h_intr.c h_makenumbers.c h_testnumbers.c
t_intr.sh

Log Message:
Add interrupted I/O tests (from RVP)


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/stdio/h_intr.c \
src/tests/lib/libc/stdio/h_makenumbers.c \
src/tests/lib/libc/stdio/h_testnumbers.c \
src/tests/lib/libc/stdio/t_intr.sh

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/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.14 src/tests/lib/libc/stdio/Makefile:1.15
--- src/tests/lib/libc/stdio/Makefile:1.14	Mon Jun 29 10:22:11 2020
+++ src/tests/lib/libc/stdio/Makefile	Thu Jul  8 05:07:46 2021
@@ -1,5 +1,6 @@
-# $NetBSD: Makefile,v 1.14 2020/06/29 14:22:11 jruoho Exp $
+# $NetBSD: Makefile,v 1.15 2021/07/08 09:07:46 christos Exp $
 
+NOMAN=
 .include 
 
 TESTSDIR=	${TESTSBASE}/lib/libc/stdio
@@ -13,6 +14,11 @@ TESTS_C+=	t_fputc
 TESTS_C+=	t_popen
 TESTS_C+=	t_printf
 TESTS_C+=	t_scanf
+
+TESTS_SH+=	t_intr
+
 COPTS.t_printf.c += -Wno-format-nonliteral
 
+PROGS+=		h_intr h_makenumbers h_testnumbers
+
 .include 

Added files:

Index: src/tests/lib/libc/stdio/h_intr.c
diff -u /dev/null src/tests/lib/libc/stdio/h_intr.c:1.1
--- /dev/null	Thu Jul  8 05:07:46 2021
+++ src/tests/lib/libc/stdio/h_intr.c	Thu Jul  8 05:07:46 2021
@@ -0,0 +1,421 @@
+/*	$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $	*/
+
+/**
+ * Test of interrupted writes to popen()'ed commands.
+ *
+ * Example 1:
+ * ./h_fwrite -c "gzip -t" *.gz
+ *
+ * Example 2:
+ * while :; do ./h_fwrite -b $((12*1024)) -t 10 -c "bzip2 -t" *.bz2; sleep 2; done
+ *
+ * Example 3:
+ * Create checksum file:
+ * find /mnt -type f -exec sha512 -n {} + >SHA512
+ *
+ * Check program:
+ * find /mnt -type f -exec ./h_fwrite -b 512 -c run.sh {} +
+ * 
+ * ./run.sh:
+	#!/bin/sh
+	set -eu
+	grep -q "^$(sha512 -q)" SHA512
+ *
+ * Author: RVP at sdf.org
+ */
+
+#include 
+__RCSID("$NetBSD: h_intr.c,v 1.1 2021/07/08 09:07:46 christos Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int process(const char *fn);
+ssize_t maxread(FILE *fp, void *buf, size_t size);
+ssize_t smaxread(FILE *fp, void *buf, size_t size);
+ssize_t maxwrite(FILE *fp, const void *buf, size_t size);
+ssize_t smaxwrite(FILE *fp, const void *buf, size_t size);
+static sig_t xsignal(int signo, sig_t handler);
+static void alarmtimer(int wait);
+static void pr_star(int signo);
+static bool isvalid(const char *s);
+static int do_opts(int argc, char* argv[]);
+static void usage(FILE* fp);
+
+/* Globals */
+static struct options {
+	size_t bsize;
+	size_t ssize;
+	int btype;
+	int tmout;
+	const char *cmd;
+} opts;
+
+static const struct {
+	const char *name;
+	int value;
+} btypes[] = {
+	{ "IONBF", _IONBF },
+	{ "IOLBF", _IOLBF },
+	{ "IOFBF", _IOFBF },
+};
+
+enum {
+	MB = 1024 * 1024,
+	BSIZE = 16 * 1024,
+	DEF_MS = 100,
+	MS = 1000,
+};
+
+
+
+int
+main(int argc, char* argv[])
+{
+	int i, rc = EXIT_SUCCESS;
+
+	i = do_opts(argc, argv);
+	argc -= i;
+	argv += i;
+
+	if (argc == 0) {
+		usage(stderr);
+		return rc;
+	}
+
+	xsignal(SIGPIPE, SIG_IGN);
+	for (i = 0; i < argc; i++) {
+		char *s = strdup(argv[i]);
+		printf("%s...", basename(s));
+		fflush(stdout);
+		free(s);
+
+		sig_t osig = xsignal(SIGALRM, pr_star);
+
+		if (process(argv[i]) == 0)
+			printf("ok\n");
+		else
+			rc = EXIT_FAILURE;
+
+		xsignal(SIGALRM, osig);
+	}
+
+	return rc;
+}
+
+static int
+process(const char *fn)
+{
+	FILE *ifp, *ofp;
+	char *buf;
+	size_t nw = 0;
+	int rc = EXIT_FAILURE;
+	ssize_t n;
+
+	if ((buf = malloc(opts.bsize)) == NULL)
+		err(rc, "buffer alloc failed");
+
+	if ((ifp = fopen(fn, "r")) == NULL) {
+		warn("fopen failed: %s", fn);
+		return rc;
+	}
+
+	if ((ofp = popen(opts.cmd, "w")) == NULL)
+		err(rc, "popen failed `%s'", opts.cmd);
+
+	setvbuf(ofp, NULL, opts.btype, opts.ssize);
+	setvbuf(ifp, NULL, opts.btype, opts.ssize);
+
+	alarmtimer(opts.tmout);
+	while ((n = maxread(ifp, buf, opts.bsize)) > 0) {
+		ssize_t i;
+		if ((i = maxwrite(ofp, buf, n)) == -1) {
+			warn("write failed");
+			break;
+		}
+		nw += i;
+	}
+	alarmtimer(0);
+	// printf("%lu\n", nw);
+
+	fclose(ifp);
+	if (pclose(ofp) != 0)
+		warn("command failed `%s'", opts.cmd);
+	else
+		rc = EXIT_SUCCESS;
+
+	return rc;
+}
+
+/**
+ * maxread - syscall version
+ */
+ssize_t
+smaxread(FILE* fp, void* buf, size_t size)
+{
+	char* p = buf;
+	ssize_t nrd = 0;
+	ssize_t n;
+
+	while (size > 0) {
+		n = read(fileno(fp), p, size);
+		if (n < 0) {
+			if (errno == EINTR)
+continue;
+			else
+return -1;
+		} else if (n == 0)
+			break;
+		p += n;
+		nrd += n;
+		size -= n;
+	}
+	

CVS commit: src/tests/lib/libc/regex

2021-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun  9 21:09:20 UTC 2021

Modified Files:
src/tests/lib/libc/regex: t_exhaust.c

Log Message:
remove the kill in the trace code.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/regex/t_exhaust.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/regex/t_exhaust.c
diff -u src/tests/lib/libc/regex/t_exhaust.c:1.13 src/tests/lib/libc/regex/t_exhaust.c:1.14
--- src/tests/lib/libc/regex/t_exhaust.c:1.13	Wed Jun  9 17:08:56 2021
+++ src/tests/lib/libc/regex/t_exhaust.c	Wed Jun  9 17:09:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $	*/
+/*	$NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.14 2021/06/09 21:09:20 christos Exp $");
 
 #include 
 #include 
@@ -74,8 +74,6 @@ malloc(size_t l)
 		return p;
 	q = 1;
 	printf("%p m %zu\n", p, l);
-	if (p == (void *)0x7f7ff7e21ac0)
-		kill(0, SIGSTOP);
 	q = 0;
 	return p;
 }



CVS commit: src/tests/lib/libc/regex

2021-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun  9 21:08:56 UTC 2021

Modified Files:
src/tests/lib/libc/regex: t_exhaust.c

Log Message:
remove not required include files


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/tests/lib/libc/regex/t_exhaust.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/regex/t_exhaust.c
diff -u src/tests/lib/libc/regex/t_exhaust.c:1.12 src/tests/lib/libc/regex/t_exhaust.c:1.13
--- src/tests/lib/libc/regex/t_exhaust.c:1.12	Wed Jun  9 16:48:37 2021
+++ src/tests/lib/libc/regex/t_exhaust.c	Wed Jun  9 17:08:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $	*/
+/*	$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.13 2021/06/09 21:08:56 christos Exp $");
 
 #include 
 #include 
@@ -52,17 +52,17 @@ __RCSID("$NetBSD: t_exhaust.c,v 1.12 202
 #endif
 
 #include 
-#include 
 #include 
 #include 
 #include 
-#include 
 
 #ifndef REGEX_MAXSIZE
 #define REGEX_MAXSIZE	
 #endif
 
 #ifdef TRACE
+
+#include 
 void *
 malloc(size_t l)
 {



CVS commit: src/tests/lib/libc/regex

2021-06-09 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun  9 20:48:37 UTC 2021

Modified Files:
src/tests/lib/libc/regex: t_exhaust.c

Log Message:
1. Preallocate the patterns so that out of memory conditions don't happen
   during their allocation, which the test cannot handle properly.
2. Enable building the test without atf so that we can easily debug with
   atf memory allocations interfering
3. Add memory tracing (disabled)


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/tests/lib/libc/regex/t_exhaust.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/regex/t_exhaust.c
diff -u src/tests/lib/libc/regex/t_exhaust.c:1.11 src/tests/lib/libc/regex/t_exhaust.c:1.12
--- src/tests/lib/libc/regex/t_exhaust.c:1.11	Mon Jun  7 07:45:35 2021
+++ src/tests/lib/libc/regex/t_exhaust.c	Wed Jun  9 16:48:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $	*/
+/*	$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,20 +37,59 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.12 2021/06/09 20:48:37 christos Exp $");
 
 #include 
-#include 
 #include 
+
+#ifdef TEST
+# include 
+# define ATF_REQUIRE(a) assert(a)
+# define ATF_REQUIRE_MSG(a, fmt, ...) \
+if (!(a)) err(EXIT_FAILURE, fmt, __VA_ARGS__)
+#else
+# include 
+#endif
+
 #include 
+#include 
 #include 
 #include 
 #include 
+#include 
 
 #ifndef REGEX_MAXSIZE
 #define REGEX_MAXSIZE	
 #endif
 
+#ifdef TRACE
+void *
+malloc(size_t l)
+{
+	static void *(*m)(size_t);
+	static int q;
+	if (m == NULL) m = dlsym(RTLD_NEXT, "malloc");
+	void *p = (*m)(l);
+	if (q)
+		return p;
+	q = 1;
+	printf("%p m %zu\n", p, l);
+	if (p == (void *)0x7f7ff7e21ac0)
+		kill(0, SIGSTOP);
+	q = 0;
+	return p;
+}
+
+void
+free(void *p)
+{
+	static void (*f)(void *);
+	if (f == NULL) f = dlsym(RTLD_NEXT, "malloc");
+	printf("%p f\n", p);
+	(*f)(p);
+}
+#endif
+
 static char *
 mkstr(const char *str, size_t len)
 {
@@ -168,43 +207,56 @@ static const struct {
 	{ p6, REG_BASIC },
 };
 
-ATF_TC(regcomp_too_big);
-
-ATF_TC_HEAD(regcomp_too_big, tc)
-{
-
-	atf_tc_set_md_var(tc, "descr", "Check that large patterns don't"
-	" crash, but return a proper error code");
-	// libtre needs it.
-	atf_tc_set_md_var(tc, "timeout", "600");
-	atf_tc_set_md_var(tc, "require.memory", "256M");
-}
-
-ATF_TC_BODY(regcomp_too_big, tc)
+static void
+run(void)
 {
 	regex_t re;
 	int e;
 	struct rlimit limit;
+	char *patterns[__arraycount(tests)];
+
+	for (size_t i = 0; i < __arraycount(patterns); i++) {
+		patterns[i] = (*tests[i].pattern)(REGEX_MAXSIZE);
+	}
 
 	limit.rlim_cur = limit.rlim_max = 256 * 1024 * 1024;
 	ATF_REQUIRE(setrlimit(RLIMIT_VMEM, ) != -1);
 
 	for (size_t i = 0; i < __arraycount(tests); i++) {
-		char *d = (*tests[i].pattern)(REGEX_MAXSIZE);
-		e = regcomp(, d, tests[i].type);
+		e = regcomp(, patterns[i], tests[i].type);
 		if (e) {
 			char ebuf[1024];
 			(void)regerror(e, , ebuf, sizeof(ebuf));
 			ATF_REQUIRE_MSG(e == REG_ESPACE,
-			"regcomp returned %d (%s) for pattern %zu [%s]", e, ebuf,
-			i, d);
-			free(d);
+			"regcomp returned %d (%s) for pattern %zu [%s]", e,
+			ebuf, i, patterns[i]);
 			continue;
 		}
-		free(d);
 		(void)regexec(, "aaa", 0, NULL, 0);
 		regfree();
 	}
+	for (size_t i = 0; i < __arraycount(patterns); i++) {
+		free(patterns[i]);
+	}
+}
+
+#ifndef TEST
+
+ATF_TC(regcomp_too_big);
+
+ATF_TC_HEAD(regcomp_too_big, tc)
+{
+
+	atf_tc_set_md_var(tc, "descr", "Check that large patterns don't"
+	" crash, but return a proper error code");
+	// libtre needs it.
+	atf_tc_set_md_var(tc, "timeout", "600");
+	atf_tc_set_md_var(tc, "require.memory", "256M");
+}
+
+ATF_TC_BODY(regcomp_too_big, tc)
+{
+	run();
 }
 
 ATF_TP_ADD_TCS(tp)
@@ -213,3 +265,11 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, regcomp_too_big);
 	return atf_no_error();
 }
+#else
+int
+main(void)
+{
+	run();
+	return 0;
+}
+#endif



CVS commit: src/tests/lib/libc/regex

2021-06-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun  7 11:45:35 UTC 2021

Modified Files:
src/tests/lib/libc/regex: t_exhaust.c

Log Message:
Add more information for the malloc failure.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/t_exhaust.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/regex/t_exhaust.c
diff -u src/tests/lib/libc/regex/t_exhaust.c:1.10 src/tests/lib/libc/regex/t_exhaust.c:1.11
--- src/tests/lib/libc/regex/t_exhaust.c:1.10	Tue Jul  9 09:59:25 2019
+++ src/tests/lib/libc/regex/t_exhaust.c	Mon Jun  7 07:45:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $	*/
+/*	$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_exhaust.c,v 1.10 2019/07/09 13:59:25 gson Exp $");
+__RCSID("$NetBSD: t_exhaust.c,v 1.11 2021/06/07 11:45:35 christos Exp $");
 
 #include 
 #include 
@@ -69,7 +69,7 @@ concat(const char *d, const char *s)
 	size_t slen = strlen(s);
 	char *p = malloc(dlen + slen + 1);
 
-	ATF_REQUIRE(p != NULL);
+	ATF_REQUIRE_MSG(p != NULL, "slen=%zu, dlen=%zu", slen, dlen);
 	strcpy(p, d);
 	strcpy(p + dlen, s);
 	return p;



CVS commit: src/tests/lib/libc/sys

2021-05-24 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon May 24 10:44:06 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
On mips, avoid deliberately executing an illegal instruction for now
because it causes GXemul to exit rather than generating a trap.  A bug
report has been sent to the GXemul author.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.32 src/tests/lib/libc/sys/t_ptrace_wait.h:1.33
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.32	Mon Jun 22 12:21:02 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Mon May 24 10:44:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.32 2020/06/22 12:21:02 rin Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.33 2021/05/24 10:44:06 gson Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -648,7 +648,9 @@ trigger_ill(void)
 
 	/* Illegal instruction causes CPU trap, translated to SIGILL */
 #ifdef PTRACE_ILLEGAL_ASM
+#ifndef __mips__ /* To avoid GXemul crash */
 	PTRACE_ILLEGAL_ASM;
+#endif
 #else
 	/* port me */
 #endif



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

2021-05-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun May  2 11:18:11 UTC 2021

Modified Files:
src/tests/lib/libc/gen/posix_spawn: h_spawn.c t_spawnattr.c

Log Message:
Add test for POSIX_SPAWN_RESETIDS flag


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/posix_spawn/h_spawn.c
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.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/posix_spawn/h_spawn.c
diff -u src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.1 src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.2
--- src/tests/lib/libc/gen/posix_spawn/h_spawn.c:1.1	Mon Feb 13 21:03:08 2012
+++ src/tests/lib/libc/gen/posix_spawn/h_spawn.c	Sun May  2 11:18:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: h_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: h_spawn.c,v 1.2 2021/05/02 11:18:11 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -32,6 +32,8 @@
 
 #include 
 #include 
+#include 
+#include 
 
 int
 main(int argc, char **argv)
@@ -39,11 +41,25 @@ main(int argc, char **argv)
 	unsigned long ret;
 	char *endp;
 
-	if (argc < 2) {
+	if (argc == 2 && strcmp(argv[1], "--resetids") == 0) {
+		if (getuid() != geteuid() || getgid() != getegid()) {
+			fprintf(stderr, "uid/gid do not match effective ids, "
+			"uid: %d euid: %d gid: %d egid: %d\n",
+			getuid(), geteuid(), getgid(), getegid());
+			exit(255);
+		}
+		return 0;
+	} else if (argc != 2) {
 		fprintf(stderr, "usage:\n\t%s (retcode)\n", getprogname());
 		exit(255);
 	}
 	ret = strtoul(argv[1], , 10);
+	if (*endp != 0) {
+		fprintf(stderr,
+		"invalid arg: %s\n"
+		"usage:\n\t%s (retcode)\n", endp, getprogname());
+		exit(255);
+	}
 
 	fprintf(stderr, "%s exiting with status %lu\n", getprogname(), ret);
 	return ret;

Index: src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c
diff -u src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.3 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.4
--- src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.3	Thu Dec 21 03:31:43 2017
+++ src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c	Sun May  2 11:18:11 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawnattr.c,v 1.3 2017/12/21 03:31:43 christos Exp $ */
+/* $NetBSD: t_spawnattr.c,v 1.4 2021/05/02 11:18:11 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -165,9 +165,43 @@ ATF_TC_BODY(t_spawnattr, tc)
 	posix_spawnattr_destroy();
 }
 
+ATF_TC(t_spawn_resetids);
+
+ATF_TC_HEAD(t_spawn_resetids, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"posix_spawn a child and with POSIX_SPAWN_RESETIDS flag");
+}
+
+ATF_TC_BODY(t_spawn_resetids, tc)
+{
+	char buf[FILENAME_MAX];
+	char * const args[] = {
+	 __UNCONST("h_spawn"), __UNCONST("--resetids"), NULL
+	};
+	posix_spawnattr_t attr;
+	int err, status;
+	pid_t pid;
+
+	posix_spawnattr_init();
+	posix_spawnattr_setflags(, POSIX_SPAWN_RESETIDS);
+
+	snprintf(buf, sizeof buf, "%s/h_spawn",
+	atf_tc_get_config_var(tc, "srcdir"));
+
+	err = posix_spawn(, buf, NULL, , args, NULL);
+	ATF_REQUIRE(err == 0);
+	ATF_REQUIRE(pid > 0);
+	waitpid(pid, , 0);
+	ATF_REQUIRE(WIFEXITED(status) && WEXITSTATUS(status) == 0);
+
+	posix_spawnattr_destroy();
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, t_spawnattr);
+	ATF_TP_ADD_TC(tp, t_spawn_resetids);
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/sys

2021-03-28 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 28 17:30:01 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_sendrecv.c

Log Message:
yield so we can lose packets


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/sys/t_sendrecv.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/sys/t_sendrecv.c
diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.7 src/tests/lib/libc/sys/t_sendrecv.c:1.8
--- src/tests/lib/libc/sys/t_sendrecv.c:1.7	Sun Mar 21 12:58:07 2021
+++ src/tests/lib/libc/sys/t_sendrecv.c	Sun Mar 28 13:30:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $	*/
+/*	$NetBSD: t_sendrecv.c,v 1.8 2021/03/28 17:30:01 christos Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $");
+__RCSID("$NetBSD: t_sendrecv.c,v 1.8 2021/03/28 17:30:01 christos Exp $");
 
 #include 
 #include 
@@ -40,6 +40,7 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.7 202
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 
@@ -94,6 +95,8 @@ receiver(int sd)
 return;
 			if (p.seq != seq)
 printf("%ju != %ju\n", p.seq, seq);
+			if (seq % 10 == 0)
+sched_yield();
 			seq = p.seq + 1;
 		}
 //		printf("<<%zd %d %ju\n", n, errno, seq);



CVS commit: src/tests/lib/libc/sys

2021-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 21 16:58:07 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_sendrecv.c

Log Message:
use a pipe instead of sched_yield()


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_sendrecv.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/sys/t_sendrecv.c
diff -u src/tests/lib/libc/sys/t_sendrecv.c:1.6 src/tests/lib/libc/sys/t_sendrecv.c:1.7
--- src/tests/lib/libc/sys/t_sendrecv.c:1.6	Sat Feb  2 22:19:28 2019
+++ src/tests/lib/libc/sys/t_sendrecv.c	Sun Mar 21 12:58:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $	*/
+/*	$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_sendrecv.c,v 1.6 2019/02/03 03:19:28 mrg Exp $");
+__RCSID("$NetBSD: t_sendrecv.c,v 1.7 2021/03/21 16:58:07 christos Exp $");
 
 #include 
 #include 
@@ -41,7 +41,6 @@ __RCSID("$NetBSD: t_sendrecv.c,v 1.6 201
 #include 
 #include 
 #include 
-#include 
 #include 
 
 
@@ -62,33 +61,33 @@ handle_sigchld(__unused int pid)
 }
 
 static void
-sender(int fd)
+sender(int sd)
 {
 	union packet p;
 	ssize_t n;
 	p.seq = 0;
 	for (size_t i = 0; i < COUNT; i++) {
-		for (; (n = send(fd, , sizeof(p), 0)) == sizeof(p);
+		for (; (n = send(sd, , sizeof(p), 0)) == sizeof(p);
 		p.seq++)
 			continue;
-		printf(">>%zd %d %ju\n", n, errno, p.seq);
+//		printf(">>%zd %d %ju\n", n, errno, p.seq);
 		ATF_REQUIRE_MSG(errno == ENOBUFS, "send %s", strerror(errno));
-//		sched_yield();
 	}
-	printf("sender done\n");
+	close(sd);
+//	printf("sender done\n");
 }
 
 static void
-receiver(int fd)
+receiver(int sd)
 {
 	union packet p;
 	ssize_t n;
 	uintmax_t seq = 0;
 
-	do {
+	for (size_t i = 0; i < COUNT; i++) {
 		if (rdied)
 			return;
-		while ((n = recv(fd, , sizeof(p), 0), sizeof(p))
+		while ((n = recv(sd, , sizeof(p), 0), sizeof(p))
 		== sizeof(p))
 		{
 			if (rdied)
@@ -97,26 +96,29 @@ receiver(int fd)
 printf("%ju != %ju\n", p.seq, seq);
 			seq = p.seq + 1;
 		}
-		printf("<<%zd %d %ju\n", n, errno, seq);
+//		printf("<<%zd %d %ju\n", n, errno, seq);
 		if (n == 0)
 			return;
 		ATF_REQUIRE_EQ(n, -1);
 		ATF_REQUIRE_MSG(errno == ENOBUFS, "recv %s", strerror(errno));
-	} while (p.seq < COUNT);
+	}
+	close(sd);
 }
 
 static void
 sendrecv(int rerror)
 {
-	int fd[2], error;
+	int fd[2], sd[2], error;
+	char c = 0;
 	struct sigaction sa;
 
-	error = socketpair(AF_UNIX, SOCK_DGRAM, 0, fd);
-//	error = pipe(fd);
+	error = socketpair(AF_UNIX, SOCK_DGRAM, 0, sd);
 	ATF_REQUIRE_MSG(error != -1, "socketpair failed (%s)", strerror(errno));
+	error = pipe(fd);
+	ATF_REQUIRE_MSG(error != -1, "pipe failed (%s)", strerror(errno));
 
-	for (size_t i = 0; i < __arraycount(fd); i++) {
-		error = setsockopt(fd[i], SOL_SOCKET, SO_RERROR, ,
+	for (size_t i = 0; i < __arraycount(sd); i++) {
+		error = setsockopt(sd[i], SOL_SOCKET, SO_RERROR, ,
 		sizeof(rerror));
 		ATF_REQUIRE_MSG(error != -1,
 		"setsockopt(SO_RERROR) failed (%s)", strerror(errno));
@@ -133,17 +135,18 @@ sendrecv(int rerror)
 	switch (fork()) {
 	case -1:
 		ATF_REQUIRE_MSG(errno == 0,
-		"socketpair failed (%s)", strerror(errno));
+		"fork failed (%s)", strerror(errno));
 		__unreachable();
 		/*NOTREACHED*/
 	case 0:
-		sched_yield();
-		sender(fd[0]);
-		close(fd[0]);
+		read(fd[1], , sizeof(c));
+		sender(sd[0]);
+		close(sd[0]);
 		exit(EXIT_SUCCESS);
 		/*NOTREACHED*/
 	default:
-		receiver(fd[1]);
+		write(fd[0], , sizeof(c));
+		receiver(sd[1]);
 		return;
 	}
 }



CVS commit: src/tests/lib/libc/setjmp

2021-03-21 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Mar 21 16:36:32 UTC 2021

Modified Files:
src/tests/lib/libc/setjmp: t_setjmp.c

Log Message:
PR/56066: Jessica Clarke: Add tests for calling {_,}longjmp with a zero value.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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/tests/lib/libc/setjmp/t_setjmp.c
diff -u src/tests/lib/libc/setjmp/t_setjmp.c:1.2 src/tests/lib/libc/setjmp/t_setjmp.c:1.3
--- src/tests/lib/libc/setjmp/t_setjmp.c:1.2	Sat Jan 14 16:08:17 2017
+++ src/tests/lib/libc/setjmp/t_setjmp.c	Sun Mar 21 12:36:32 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $ */
+/* $NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -63,13 +63,14 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/01/14 21:08:17 christos Exp $");
+__RCSID("$NetBSD: t_setjmp.c,v 1.3 2021/03/21 16:36:32 christos Exp $");
 
 #include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -83,6 +84,8 @@ __RCSID("$NetBSD: t_setjmp.c,v 1.2 2017/
 #define TEST_U_SETJMP 1
 #define TEST_SIGSETJMP_SAVE 2
 #define TEST_SIGSETJMP_NOSAVE 3
+#define TEST_LONGJMP_ZERO 4
+#define TEST_U_LONGJMP_ZERO 5
 
 static int expectsignal;
 
@@ -101,12 +104,16 @@ h_check(int test)
 	sigjmp_buf sjb;
 	sigset_t ss;
 	int i, x;
+	volatile bool did_longjmp;
 
 	i = getpid();
+	did_longjmp = false;
 
-	if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE)
+	if (test == TEST_SETJMP || test == TEST_SIGSETJMP_SAVE ||
+	test == TEST_LONGJMP_ZERO)
 		expectsignal = 0;
-	else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE)
+	else if (test == TEST_U_SETJMP || test == TEST_SIGSETJMP_NOSAVE ||
+	test == TEST_U_LONGJMP_ZERO)
 		expectsignal = 1;
 	else
 		atf_tc_fail("unknown test");
@@ -119,26 +126,37 @@ h_check(int test)
 	REQUIRE_ERRNO(sigaddset(, SIGABRT) != -1);
 	REQUIRE_ERRNO(sigprocmask(SIG_BLOCK, , NULL) != -1);
 
-	if (test == TEST_SETJMP)
+	if (test == TEST_SETJMP || test == TEST_LONGJMP_ZERO)
 		x = setjmp(jb);
-	else if (test == TEST_U_SETJMP)
+	else if (test == TEST_U_SETJMP || test == TEST_U_LONGJMP_ZERO)
 		x = _setjmp(jb);
 	else 
 		x = sigsetjmp(sjb, !expectsignal);
 
 	if (x != 0) {
-		ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value");
+		if (test == TEST_LONGJMP_ZERO || test == TEST_U_LONGJMP_ZERO)
+			ATF_REQUIRE_MSG(x == 1, "setjmp returned wrong value");
+		else
+			ATF_REQUIRE_MSG(x == i, "setjmp returned wrong value");
+
 		kill(i, SIGABRT);
 		ATF_REQUIRE_MSG(!expectsignal, "kill(SIGABRT) failed");
 		atf_tc_pass();
+	} else if (did_longjmp) {
+		atf_tc_fail("setjmp returned zero after longjmp");
 	}
 
 	REQUIRE_ERRNO(sigprocmask(SIG_UNBLOCK, , NULL) != -1);
 
+	did_longjmp = true;
 	if (test == TEST_SETJMP)
 		longjmp(jb, i);
+	else if (test == TEST_LONGJMP_ZERO)
+		longjmp(jb, 0);
 	else if (test == TEST_U_SETJMP)
 		_longjmp(jb, i);
+	else if (test == TEST_U_LONGJMP_ZERO)
+		_longjmp(jb, 0);
 	else 
 		siglongjmp(sjb, i);
 
@@ -185,12 +203,34 @@ ATF_TC_BODY(sigsetjmp_nosave, tc)
 	h_check(TEST_SIGSETJMP_NOSAVE);
 }
 
+ATF_TC(longjmp_zero);
+ATF_TC_HEAD(longjmp_zero, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks longjmp(3) with a zero value");
+}
+ATF_TC_BODY(longjmp_zero, tc)
+{
+	h_check(TEST_LONGJMP_ZERO);
+}
+
+ATF_TC(_longjmp_zero);
+ATF_TC_HEAD(_longjmp_zero, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Checks _longjmp(3) with a zero value");
+}
+ATF_TC_BODY(_longjmp_zero, tc)
+{
+	h_check(TEST_U_LONGJMP_ZERO);
+}
+
 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);
+	ATF_TP_ADD_TC(tp, longjmp_zero);
+	ATF_TP_ADD_TC(tp, _longjmp_zero);
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/sys

2021-03-18 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Fri Mar 19 00:44:09 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_ptrace_signal_wait.h

Log Message:
Sprinkle a few more \n's and the end of some debug printfs.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_ptrace_signal_wait.h

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/sys/t_ptrace_signal_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.4 src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.5
--- src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.4	Mon Jun 22 12:21:02 2020
+++ src/tests/lib/libc/sys/t_ptrace_signal_wait.h	Fri Mar 19 00:44:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_signal_wait.h,v 1.4 2020/06/22 12:21:02 rin Exp $	*/
+/*	$NetBSD: t_ptrace_signal_wait.h,v 1.5 2021/03/19 00:44:09 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -90,7 +90,7 @@ traceme_raise(int sigval)
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
 
-		DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error");
+		DPRINTF("Assert that PT_GET_PROCESS_STATE returns non-error\n");
 		SYSCALL_REQUIRE(
 		ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
 		ATF_REQUIRE(memcmp(, _state, slen) == 0);
@@ -401,7 +401,7 @@ traceme_crash(int sig)
 
 	validate_status_stopped(status, sig);
 
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
 
@@ -567,7 +567,7 @@ traceme_signalmasked_crash(int sig)
 
 	validate_status_stopped(status, sig);
 
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
 
@@ -750,7 +750,7 @@ traceme_signalignored_crash(int sig)
 
 	validate_status_stopped(status, sig);
 
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
+	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
 	SYSCALL_REQUIRE(
 	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
 



CVS commit: src/tests/lib/libc/regex

2021-02-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Feb 25 22:37:37 UTC 2021

Modified Files:
src/tests/lib/libc/regex: Makefile debug.c

Log Message:
Adjust for conditional NLS


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/regex/Makefile
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/regex/debug.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/regex/Makefile
diff -u src/tests/lib/libc/regex/Makefile:1.10 src/tests/lib/libc/regex/Makefile:1.11
--- src/tests/lib/libc/regex/Makefile:1.10	Thu Aug 25 21:31:43 2016
+++ src/tests/lib/libc/regex/Makefile	Thu Feb 25 17:37:36 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2016/08/26 01:31:43 darcy Exp $
+# $NetBSD: Makefile,v 1.11 2021/02/25 22:37:36 christos Exp $
 
 NOMAN=
 
@@ -10,7 +10,7 @@ IMPLEMENTATION?=	-DREGEX_SPENCER -DSKIP_
 BINDIR=		${TESTSDIR}
 PROGS?=		h_regex
 SRCS.h_regex=	main.c split.c debug.c
-CPPFLAGS+=	-I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION}
+CPPFLAGS+=	-I${NETBSDSRCDIR}/lib/libc/regex ${IMPLEMENTATION} -DNLS
 
 TESTS_SH?=	t_regex
 TESTS_C=	t_regex_att

Index: src/tests/lib/libc/regex/debug.c
diff -u src/tests/lib/libc/regex/debug.c:1.6 src/tests/lib/libc/regex/debug.c:1.7
--- src/tests/lib/libc/regex/debug.c:1.6	Wed Feb 24 13:18:53 2021
+++ src/tests/lib/libc/regex/debug.c	Thu Feb 25 17:37:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $	*/
+/*	$NetBSD: debug.c,v 1.7 2021/02/25 22:37:36 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -33,8 +33,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #ifndef __linux__
 /* Don't sort these! */



CVS commit: src/tests/lib/libc/regex

2021-02-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 24 18:18:53 UTC 2021

Modified Files:
src/tests/lib/libc/regex: debug.c

Log Message:
remove casts


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/regex/debug.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/regex/debug.c
diff -u src/tests/lib/libc/regex/debug.c:1.5 src/tests/lib/libc/regex/debug.c:1.6
--- src/tests/lib/libc/regex/debug.c:1.5	Tue Feb 23 21:33:56 2021
+++ src/tests/lib/libc/regex/debug.c	Wed Feb 24 13:18:53 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $	*/
+/*	$NetBSD: debug.c,v 1.6 2021/02/24 18:18:53 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -64,9 +64,7 @@ regprint(regex_t *r, FILE *d)
 #ifndef REGEX_NODEBUG
 	struct re_guts *g = r->re_g;
 
-	fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets);
-	fprintf(d, ", first %ld last %ld", (long)g->firststate,
-		(long)g->laststate);
+	fprintf(d, ", first %u last %u", g->firststate, g->laststate);
 	if (g->iflags)
 		fprintf(d, ", USEBOL");
 	if (g->iflags)
@@ -74,14 +72,13 @@ regprint(regex_t *r, FILE *d)
 	if (g->iflags)
 		fprintf(d, ", BAD");
 	if (g->nsub > 0)
-		fprintf(d, ", nsub=%ld", (long)g->nsub);
+		fprintf(d, ", nsub=%zu", g->nsub);
 	if (g->must != NULL)
-		fprintf(d, ", must(%ld) `%*s'", (long)g->mlen, (int)g->mlen,
-g->must);
+		fprintf(d, ", must(%zu) `%*s'", g->mlen, (int)g->mlen, g->must);
 	if (g->backrefs)
 		fprintf(d, ", backrefs");
 	if (g->nplus > 0)
-		fprintf(d, ", nplus %ld", (long)g->nplus);
+		fprintf(d, ", nplus %u", g->nplus);
 	fprintf(d, "\n");
 	s_print(g, d);
 	fprintf(d, "\n");
@@ -144,63 +141,63 @@ s_print(struct re_guts *g, FILE *d)
 			fprintf(d, ".");
 			break;
 		case OANYOF:
-			fprintf(d, "[(%ld)", (long)opnd);
+			fprintf(d, "[(%u)", opnd);
 			fprintf(d, "]");
 			break;
 		case OBACK_:
-			fprintf(d, "(\\<%ld>", (long)opnd);
+			fprintf(d, "(\\<%u>", opnd);
 			break;
 		case O_BACK:
-			fprintf(d, "<%ld>\\)", (long)opnd);
+			fprintf(d, "<%u>\\)", opnd);
 			break;
 		case OPLUS_:
 			fprintf(d, "(+");
 			if (OP(*(s+opnd)) != O_PLUS)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_PLUS:
 			if (OP(*(s-opnd)) != OPLUS_)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "+)");
 			break;
 		case OQUEST_:
 			fprintf(d, "(?");
 			if (OP(*(s+opnd)) != O_QUEST)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_QUEST:
 			if (OP(*(s-opnd)) != OQUEST_)
-fprintf(d, "<%ld>", (long)opnd);
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "?)");
 			break;
 		case OLPAREN:
-			fprintf(d, "((<%ld>", (long)opnd);
+			fprintf(d, "((<%u>", opnd);
 			break;
 		case ORPAREN:
-			fprintf(d, "<%ld>))", (long)opnd);
+			fprintf(d, "<%u>))", opnd);
 			break;
 		case OCH_:
 			fprintf(d, "<");
-			if (OP(*(s+opnd)) != (sop)OOR2)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s+opnd)) != OOR2)
+fprintf(d, "<%u>", opnd);
 			break;
 		case OOR1:
-			if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
+fprintf(d, "<%u>", opnd);
 			fprintf(d, "|");
 			break;
 		case OOR2:
 			fprintf(d, "|");
-			if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
+fprintf(d, "<%u>", opnd);
 			break;
 		case O_CH:
-			if (OP(*(s-opnd)) != (sop)OOR1)
-fprintf(d, "<%ld>", (long)opnd);
+			if (OP(*(s-opnd)) != OOR1)
+fprintf(d, "<%u>", opnd);
 			fprintf(d, ">");
 			break;
 		default:
-			fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd);
+			fprintf(d, "!%u(%u)!", OP(*s), opnd);
 			break;
 		}
 		if (!done)



CVS commit: src/tests/lib/libc/regex

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 24 02:33:56 UTC 2021

Modified Files:
src/tests/lib/libc/regex: debug.c

Log Message:
minimal fix to match the library code (really make the constants unsigned
instead)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/regex/debug.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/regex/debug.c
diff -u src/tests/lib/libc/regex/debug.c:1.4 src/tests/lib/libc/regex/debug.c:1.5
--- src/tests/lib/libc/regex/debug.c:1.4	Tue Feb 23 09:59:09 2021
+++ src/tests/lib/libc/regex/debug.c	Tue Feb 23 21:33:56 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $	*/
+/*	$NetBSD: debug.c,v 1.5 2021/02/24 02:33:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -181,21 +181,21 @@ s_print(struct re_guts *g, FILE *d)
 			break;
 		case OCH_:
 			fprintf(d, "<");
-			if (OP(*(s+opnd)) != OOR2)
+			if (OP(*(s+opnd)) != (sop)OOR2)
 fprintf(d, "<%ld>", (long)opnd);
 			break;
 		case OOR1:
-			if (OP(*(s-opnd)) != OOR1 && OP(*(s-opnd)) != OCH_)
+			if (OP(*(s-opnd)) != (sop)OOR1 && OP(*(s-opnd)) != (sop)OCH_)
 fprintf(d, "<%ld>", (long)opnd);
 			fprintf(d, "|");
 			break;
 		case OOR2:
 			fprintf(d, "|");
-			if (OP(*(s+opnd)) != OOR2 && OP(*(s+opnd)) != O_CH)
+			if (OP(*(s+opnd)) != (sop)OOR2 && OP(*(s+opnd)) != (sop)O_CH)
 fprintf(d, "<%ld>", (long)opnd);
 			break;
 		case O_CH:
-			if (OP(*(s-opnd)) != OOR1)
+			if (OP(*(s-opnd)) != (sop)OOR1)
 fprintf(d, "<%ld>", (long)opnd);
 			fprintf(d, ">");
 			break;



CVS commit: src/tests/lib/libc/regex

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 23 17:13:44 UTC 2021

Modified Files:
src/tests/lib/libc/regex: main.c

Log Message:
Add REG_GNU


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/main.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/regex/main.c
diff -u src/tests/lib/libc/regex/main.c:1.3 src/tests/lib/libc/regex/main.c:1.4
--- src/tests/lib/libc/regex/main.c:1.3	Tue Feb 23 10:00:01 2021
+++ src/tests/lib/libc/regex/main.c	Tue Feb 23 12:13:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $	*/
+/*	$NetBSD: main.c,v 1.4 2021/02/23 17:13:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -352,7 +352,7 @@ options(int type, char *s)
 {
 	char *p;
 	int o = (type == 'c') ? copts : eopts;
-	const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl";
+	const char *legal = (type == 'c') ? "bisnmpg" : "^$#tl";
 
 	for (p = s; *p != '\0'; p++)
 		if (strchr(legal, *p) != NULL)
@@ -376,8 +376,8 @@ options(int type, char *s)
 			case 'p':
 o |= REG_PEND;
 break;
-			case 'P':
-o |= REG_POSIX;
+			case 'g':
+o |= REG_GNU;
 break;
 			case '^':
 o |= REG_NOTBOL;



CVS commit: src/tests/lib/libc/regex

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 23 16:00:37 UTC 2021

Modified Files:
src/tests/lib/libc/regex: t_regex_att.c

Log Message:
Add support for ENOSYS (was never set)


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/t_regex_att.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/regex/t_regex_att.c
diff -u src/tests/lib/libc/regex/t_regex_att.c:1.3 src/tests/lib/libc/regex/t_regex_att.c:1.4
--- src/tests/lib/libc/regex/t_regex_att.c:1.3	Sat Jan 14 15:59:23 2017
+++ src/tests/lib/libc/regex/t_regex_att.c	Tue Feb 23 11:00:37 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $	*/
+/*	$NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_regex_att.c,v 1.3 2017/01/14 20:59:23 christos Exp $");
+__RCSID("$NetBSD: t_regex_att.c,v 1.4 2021/02/23 16:00:37 christos Exp $");
 
 #include 
 
@@ -284,7 +284,12 @@ geterror(const char *s, int *comp, int *
 		_DO(EMPTY, COMP)
 		_DO(ASSERT, COMP)
 		_DO(INVARG, COMP)
+#ifdef REG_ENOSYS
 		_DO(ENOSYS, COMP)
+#endif
+#ifdef REG_ILLSEQ
+		_DO(ILLSEQ, COMP)
+#endif
 #undef _DO
 	};
 	*comp = 0;



CVS commit: src/tests/lib/libc/regex

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 23 15:00:01 UTC 2021

Modified Files:
src/tests/lib/libc/regex: main.c

Log Message:
Add REG_POSIX, and make compile on linux where we don't have a lot of the
internal flags.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/regex/main.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/regex/main.c
diff -u src/tests/lib/libc/regex/main.c:1.2 src/tests/lib/libc/regex/main.c:1.3
--- src/tests/lib/libc/regex/main.c:1.2	Fri Sep 16 12:13:18 2011
+++ src/tests/lib/libc/regex/main.c	Tue Feb 23 10:00:01 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: main.c,v 1.2 2011/09/16 16:13:18 plunky Exp $	*/
+/*	$NetBSD: main.c,v 1.3 2021/02/23 15:00:01 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -52,6 +52,16 @@ static char empty = '\0';
 static char *eprint(int);
 static int efind(char *);
 
+#ifndef REG_ATOI
+#define REG_ATOI 0
+#define REG_ITOA 0
+#define REG_PEND 0
+#define REG_TRACE 0
+#define REG_BACKR 0
+#define REG_NOSPEC 0
+#define REG_LARGE 0
+#endif
+
 /*
  * main - do the simple case, hand off to regress() for regression
  */
@@ -72,7 +82,7 @@ main(int argc, char *argv[])
 
 	progname = argv[0];
 
-	while ((c = getopt(argc, argv, "c:e:S:E:x")) != -1)
+	while ((c = getopt(argc, argv, "c:E:e:S:x")) != -1)
 		switch (c) {
 		case 'c':	/* compile options */
 			copts = options('c', optarg);
@@ -80,12 +90,12 @@ main(int argc, char *argv[])
 		case 'e':	/* execute options */
 			eopts = options('e', optarg);
 			break;
-		case 'S':	/* start offset */
-			startoff = (regoff_t)atoi(optarg);
-			break;
 		case 'E':	/* end offset */
 			endoff = (regoff_t)atoi(optarg);
 			break;
+		case 'S':	/* start offset */
+			startoff = (regoff_t)atoi(optarg);
+			break;
 		case 'x':	/* Debugging. */
 			debug++;
 			break;
@@ -211,7 +221,9 @@ regress(FILE *in)
 		erbuf, bpname);
 		status = 1;
 	}
+#if REG_ATOI
 	re.re_endp = bpname;
+#endif
 	ne = regerror(REG_ATOI, , erbuf, sizeof(erbuf));
 	if (atoi(erbuf) != (int)REG_BADPAT) {
 		fprintf(stderr, "end: regerror() ATOI test gave `%s' not `%ld'\n",
@@ -247,7 +259,9 @@ try(char *f0, char *f1, char *f2, char *
 	char f2copy[1000];
 
 	strcpy(f0copy, f0);
+#if REG_ATOI
 	re.re_endp = (opts_PEND) ? f0copy + strlen(f0copy) : NULL;
+#endif
 	fixstr(f0copy);
 	err = regcomp(, f0copy, opts);
 	if (err != 0 && (!opt('C', f1) || err != efind(f2))) {
@@ -338,7 +352,7 @@ options(int type, char *s)
 {
 	char *p;
 	int o = (type == 'c') ? copts : eopts;
-	const char *legal = (type == 'c') ? "bisnmp" : "^$#tl";
+	const char *legal = (type == 'c') ? "bisnmpP" : "^$#tl";
 
 	for (p = s; *p != '\0'; p++)
 		if (strchr(legal, *p) != NULL)
@@ -362,6 +376,9 @@ options(int type, char *s)
 			case 'p':
 o |= REG_PEND;
 break;
+			case 'P':
+o |= REG_POSIX;
+break;
 			case '^':
 o |= REG_NOTBOL;
 break;
@@ -517,7 +534,9 @@ efind(char *name)
 
 	sprintf(efbuf, "REG_%s", name);
 	assert(strlen(efbuf) < sizeof(efbuf));
+#if REG_ATOI
 	re.re_endp = efbuf;
+#endif
 	(void) regerror(REG_ATOI, , efbuf, sizeof(efbuf));
 	return(atoi(efbuf));
 }



CVS commit: src/tests/lib/libc/regex

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 23 14:59:09 UTC 2021

Modified Files:
src/tests/lib/libc/regex: debug.c

Log Message:
Delete category stuff that has changed with the new regex; make compile
on linux and with TRE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/regex/debug.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/regex/debug.c
diff -u src/tests/lib/libc/regex/debug.c:1.3 src/tests/lib/libc/regex/debug.c:1.4
--- src/tests/lib/libc/regex/debug.c:1.3	Fri Jan 13 19:50:56 2017
+++ src/tests/lib/libc/regex/debug.c	Tue Feb 23 09:59:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: debug.c,v 1.3 2017/01/14 00:50:56 christos Exp $	*/
+/*	$NetBSD: debug.c,v 1.4 2021/02/23 14:59:09 christos Exp $	*/
 
 /*-
  * Copyright (c) 1993 The NetBSD Foundation, Inc.
@@ -36,14 +36,24 @@
 #include 
 #include 
 
+#ifndef __linux__
 /* Don't sort these! */
 #include "utils.h"
 #include "regex2.h"
+#else
+#define REGEX_NODEBUG
+#endif
+
+#ifdef REGEX_TRE
+#define REGEX_NODEBUG
+#endif
 
 #include "test_regex.h"
 
+#ifndef REGEX_NODEBUG
 static void s_print(struct re_guts *, FILE *);
 static char *regchar(int);
+#endif
 
 /*
  * regprint - print a regexp for debugging
@@ -51,13 +61,10 @@ static char *regchar(int);
 void
 regprint(regex_t *r, FILE *d)
 {
+#ifndef REGEX_NODEBUG
 	struct re_guts *g = r->re_g;
-	int c;
-	int last;
-	int nincat[NC];
 
-	fprintf(d, "%ld states, %zu categories", (long)g->nstates,
-			g->ncategories);
+	fprintf(d, "%ld states, %zu ncsets", (long)g->nstates, g->ncsets);
 	fprintf(d, ", first %ld last %ld", (long)g->firststate,
 		(long)g->laststate);
 	if (g->iflags)
@@ -77,43 +84,11 @@ regprint(regex_t *r, FILE *d)
 		fprintf(d, ", nplus %ld", (long)g->nplus);
 	fprintf(d, "\n");
 	s_print(g, d);
-	for (size_t i = 0; i < g->ncategories; i++) {
-		nincat[i] = 0;
-		for (c = CHAR_MIN; c <= CHAR_MAX; c++)
-			if (g->categories[c] == i)
-nincat[i]++;
-	}
-	fprintf(d, "cc0#%d", nincat[0]);
-	for (size_t i = 1; i < g->ncategories; i++)
-		if (nincat[i] == 1) {
-			for (c = CHAR_MIN; c <= CHAR_MAX; c++)
-if (g->categories[c] == i)
-	break;
-			fprintf(d, ", %zu=%s", i, regchar(c));
-		}
 	fprintf(d, "\n");
-	for (size_t i = 1; i < g->ncategories; i++)
-		if (nincat[i] != 1) {
-			fprintf(d, "cc%zu\t", i);
-			last = -1;
-			for (c = CHAR_MIN; c <= CHAR_MAX+1; c++)	/* +1 does flush */
-if (c <= CHAR_MAX && g->categories[c] == i) {
-	if (last < 0) {
-		fprintf(d, "%s", regchar(c));
-		last = c;
-	}
-} else {
-	if (last >= 0) {
-		if (last != c-1)
-			fprintf(d, "-%s",
-regchar(c-1));
-		last = -1;
-	}
-}
-			fprintf(d, "\n");
-		}
+#endif
 }
 
+#ifndef REGEX_NODEBUG
 /*
  * s_print - print the strip for debugging
  */
@@ -121,11 +96,9 @@ static void
 s_print(struct re_guts *g, FILE *d)
 {
 	sop *s;
-	cset *cs;
 	int done = 0;
 	sop opnd;
 	int col = 0;
-	ssize_t last;
 	sopno offset = 2;
 #	define	GAP()	{	if (offset % 5 == 0) { \
 	if (col > 40) { \
@@ -172,22 +145,6 @@ s_print(struct re_guts *g, FILE *d)
 			break;
 		case OANYOF:
 			fprintf(d, "[(%ld)", (long)opnd);
-			cs = >sets[opnd];
-			last = -1;
-			for (size_t i = 0; i < g->csetsize+1; i++)	/* +1 flushes */
-if (CHIN(cs, i) && i < g->csetsize) {
-	if (last < 0) {
-		fprintf(d, "%s", regchar(i));
-		last = i;
-	}
-} else {
-	if (last >= 0) {
-		if (last != (ssize_t)i - 1)
-			fprintf(d, "-%s",
-			regchar(i - 1));
-		last = -1;
-	}
-}
 			fprintf(d, "]");
 			break;
 		case OBACK_:
@@ -243,7 +200,7 @@ s_print(struct re_guts *g, FILE *d)
 			fprintf(d, ">");
 			break;
 		default:
-			fprintf(d, "!%d(%d)!", OP(*s), opnd);
+			fprintf(d, "!%ld(%ld)!", (long)OP(*s), (long)opnd);
 			break;
 		}
 		if (!done)
@@ -265,3 +222,4 @@ regchar(int ch)
 		sprintf(buf, "\\%o", ch);
 	return(buf);
 }
+#endif



CVS commit: src/tests/lib/libc/regex/data

2021-02-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Feb 23 14:57:16 UTC 2021

Modified Files:
src/tests/lib/libc/regex/data: meta.in repet_bounded.in repet_multi.in

Log Message:
Comment out tests that the new stricter regex does not like


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/regex/data/meta.in \
src/tests/lib/libc/regex/data/repet_bounded.in \
src/tests/lib/libc/regex/data/repet_multi.in

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/regex/data/meta.in
diff -u src/tests/lib/libc/regex/data/meta.in:1.1 src/tests/lib/libc/regex/data/meta.in:1.2
--- src/tests/lib/libc/regex/data/meta.in:1.1	Sat Jan  8 13:10:32 2011
+++ src/tests/lib/libc/regex/data/meta.in	Tue Feb 23 09:57:16 2021
@@ -4,7 +4,8 @@ a[bc]d		&	abd	abd
 a\*c		&	a*c	a*c
 a\\b		&	a\b	a\b
 a\\\*b		&	a\*b	a\*b
-a\bc		&	abc	abc
+# legacy escape
+#a\bc		&	abc	abc
 a\			EESCAPE
 a\\bc		&	a\bc	a\bc
 \{		bC	BADRPT
Index: src/tests/lib/libc/regex/data/repet_bounded.in
diff -u src/tests/lib/libc/regex/data/repet_bounded.in:1.1 src/tests/lib/libc/regex/data/repet_bounded.in:1.2
--- src/tests/lib/libc/regex/data/repet_bounded.in:1.1	Sat Jan  8 13:10:32 2011
+++ src/tests/lib/libc/regex/data/repet_bounded.in	Tue Feb 23 09:57:16 2021
@@ -1,9 +1,10 @@
 # the dreaded bounded repetitions
-{		&	{	{
-{abc		&	{abc	{abc
+# unclosed and with missing values are now errors
+#{		&	{	{
+#{abc		&	{abc	{abc
 {1		C	BADRPT
 {1}		C	BADRPT
-a{b		&	a{b	a{b
+#a{b		&	a{b	a{b
 a{1}b		-	ab	ab
 a\{1\}b		b	ab	ab
 a{1,}b		-	ab	ab
@@ -16,9 +17,9 @@ a{1a		C	EBRACE
 a\{1a		bC	EBRACE
 a{1a}		C	BADBR
 a\{1a\}		bC	BADBR
-a{,2}		-	a{,2}	a{,2}
+#a{,2}		-	a{,2}	a{,2}
 a\{,2\}		bC	BADBR
-a{,}		-	a{,}	a{,}
+#a{,}		-	a{,}	a{,}
 a\{,\}		bC	BADBR
 a{1,x}		C	BADBR
 a\{1,x\}	bC	BADBR
Index: src/tests/lib/libc/regex/data/repet_multi.in
diff -u src/tests/lib/libc/regex/data/repet_multi.in:1.1 src/tests/lib/libc/regex/data/repet_multi.in:1.2
--- src/tests/lib/libc/regex/data/repet_multi.in:1.1	Sat Jan  8 13:10:32 2011
+++ src/tests/lib/libc/regex/data/repet_multi.in	Tue Feb 23 09:57:16 2021
@@ -15,7 +15,8 @@ a?{1}		C	BADRPT
 a{1}*		C	BADRPT
 a{1}+		C	BADRPT
 a{1}?		C	BADRPT
-a*{b}		-	a{b}	a{b}
+# repetition needs to be a number
+#a*{b}		-	a{b}	a{b}
 a\{1\}\{1\}	bC	BADRPT
 a*\{1\}		bC	BADRPT
 a\{1\}*		bC	BADRPT



CVS commit: src/tests/lib/libc/arch/sparc64

2021-02-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Mon Feb  8 23:50:25 UTC 2021

Modified Files:
src/tests/lib/libc/arch/sparc64: return_one.S

Log Message:
Don't define a label twice.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/arch/sparc64/return_one.S

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/arch/sparc64/return_one.S
diff -u src/tests/lib/libc/arch/sparc64/return_one.S:1.2 src/tests/lib/libc/arch/sparc64/return_one.S:1.3
--- src/tests/lib/libc/arch/sparc64/return_one.S:1.2	Sat Dec 31 11:51:20 2016
+++ src/tests/lib/libc/arch/sparc64/return_one.S	Mon Feb  8 23:50:25 2021
@@ -1,11 +1,10 @@
-/*	$NetBSD: return_one.S,v 1.2 2016/12/31 11:51:20 martin Exp $ */
+/*	$NetBSD: return_one.S,v 1.3 2021/02/08 23:50:25 joerg Exp $ */
 
 #include 
 
 .global	return_one_end
 
 ENTRY(return_one)
-return_one:
 	retl
 	 mov 1, %o0
 return_one_end:



CVS commit: src/tests/lib/libc/arch/mips

2021-01-20 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Thu Jan 21 00:56:41 UTC 2021

Modified Files:
src/tests/lib/libc/arch/mips: return_one.S

Log Message:
Use .set noreorder and use reg names.

atf- lib/libc/sys/t_mprotect mprotect_mremap_exec is a bit happier now.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/arch/mips/return_one.S

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/arch/mips/return_one.S
diff -u src/tests/lib/libc/arch/mips/return_one.S:1.2 src/tests/lib/libc/arch/mips/return_one.S:1.3
--- src/tests/lib/libc/arch/mips/return_one.S:1.2	Thu Feb 14 10:36:33 2019
+++ src/tests/lib/libc/arch/mips/return_one.S	Thu Jan 21 00:56:41 2021
@@ -1,11 +1,13 @@
-/*	$NetBSD: return_one.S,v 1.2 2019/02/14 10:36:33 mrg Exp $ */
+/*	$NetBSD: return_one.S,v 1.3 2021/01/21 00:56:41 simonb Exp $ */
 
 #include 
 
+.set noreorder
+
 .globl	return_one, return_one_end;
 
 return_one:
-	jr	$31
-	li	$2,1
+	jr	ra
+	 li	v0,1
 
 return_one_end:



CVS commit: src/tests/lib/libc/sys

2021-01-17 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Jan 18 05:44:21 UTC 2021

Modified Files:
src/tests/lib/libc/sys: t_syscall.c

Log Message:
Check for MAP_FAILED instead of NULL when looking for an error from mmap(2).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_syscall.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/sys/t_syscall.c
diff -u src/tests/lib/libc/sys/t_syscall.c:1.3 src/tests/lib/libc/sys/t_syscall.c:1.4
--- src/tests/lib/libc/sys/t_syscall.c:1.3	Mon May 28 07:55:56 2018
+++ src/tests/lib/libc/sys/t_syscall.c	Mon Jan 18 05:44:20 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_syscall.c,v 1.3 2018/05/28 07:55:56 martin Exp $	*/
+/*	$NetBSD: t_syscall.c,v 1.4 2021/01/18 05:44:20 simonb Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_syscall.c,v 1.3 2018/05/28 07:55:56 martin Exp $");
+__RCSID("$NetBSD: t_syscall.c,v 1.4 2021/01/18 05:44:20 simonb Exp $");
 
 
 #include 
@@ -75,7 +75,7 @@ ATF_TC_BODY(mmap_syscall, tc)
 
 	p = (const char *)syscall(SYS_mmap,
 		0, sizeof(secrect_data), PROT_READ, MAP_PRIVATE, fd, 0, 0, 0);
-	ATF_REQUIRE(p != NULL);
+	ATF_REQUIRE(p != MAP_FAILED);
 
  	ATF_REQUIRE(strcmp(p, secrect_data) == 0);
 }
@@ -101,7 +101,7 @@ ATF_TC_BODY(mmap___syscall, tc)
 	p = (const char *)__SYSCALL_TO_UINTPTR_T(__syscall(SYS_mmap,
 		0, sizeof(secrect_data), PROT_READ, MAP_PRIVATE, fd,
 		/* pad*/ 0, (off_t)0));
-	ATF_REQUIRE(p != NULL);
+	ATF_REQUIRE(p != MAP_FAILED);
 
 	ATF_REQUIRE(strcmp(p, secrect_data) == 0);
 }



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

2021-01-12 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jan 13 06:44:55 UTC 2021

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
skip sigbus_adraln on MIPS


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.44 src/tests/lib/libc/gen/t_siginfo.c:1.45
--- src/tests/lib/libc/gen/t_siginfo.c:1.44	Mon Jan 11 07:17:49 2021
+++ src/tests/lib/libc/gen/t_siginfo.c	Wed Jan 13 06:44:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.44 2021/01/11 07:17:49 skrll Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.45 2021/01/13 06:44:55 skrll Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -483,7 +483,7 @@ ATF_TC_BODY(sigbus_adraln, tc)
 
 #if defined(__mips__)
 	/* no way of detecting if on GXemul, so disable everywhere for now */
-	atf_tc_expect_fail("GXemul fails to trap unaligned accesses with "
+	atf_tc_skip("GXemul fails to trap unaligned accesses with "
 	"correct ENTRYHI");
 #endif
 



CVS commit: src/tests/lib/libc/stdlib

2021-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jan 11 20:31:34 UTC 2021

Modified Files:
src/tests/lib/libc/stdlib: t_mktemp.c

Log Message:
Only try to create up-to NAME_MAX filenames.
XXX: this should be moved to stdio/t_mktemp.c where the rest of the tests
are and the code lives.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/stdlib/t_mktemp.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/stdlib/t_mktemp.c
diff -u src/tests/lib/libc/stdlib/t_mktemp.c:1.3 src/tests/lib/libc/stdlib/t_mktemp.c:1.4
--- src/tests/lib/libc/stdlib/t_mktemp.c:1.3	Sun Nov  1 13:19:54 2020
+++ src/tests/lib/libc/stdlib/t_mktemp.c	Mon Jan 11 15:31:34 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $ */
+/* $NetBSD: t_mktemp.c,v 1.4 2021/01/11 20:31:34 christos Exp $ */
 
 /*-
  * Copyright (c) 2013, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $");
+__RCSID("$NetBSD: t_mktemp.c,v 1.4 2021/01/11 20:31:34 christos Exp $");
 
 #include 
 
@@ -79,10 +79,17 @@ ATF_TC_HEAD(mktemp_large_template, tc)
 ATF_TC_BODY(mktemp_large_template, tc)
 {
 	const char *path = "/tmp/mktemp.XX";
-	char template[PATH_MAX] = { 0 };
+	char *template;
 	size_t i;
+	long name_max;
+	size_t tlen;
 
-	atf_tc_expect_fail("PR lib/55441");
+	name_max = pathconf("/tmp/", _PC_NAME_MAX);
+	ATF_REQUIRE(name_max > 0);
+
+	tlen = (size_t)name_max + sizeof("/tmp/");
+	template = malloc(tlen);
+	ATF_REQUIRE(template != NULL);
 
 	ATF_REQUIRE(strcpy(template, path) != NULL);
 	ATF_REQUIRE(mktemp(template) != NULL);
@@ -90,16 +97,17 @@ ATF_TC_BODY(mktemp_large_template, tc)
 	ATF_REQUIRE(strcmp(template, path) != 0);
 	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
 
-	(void)memset(template, '\0', sizeof(template));
+	(void)memset(template, '\0', tlen);
 	(void)strcpy(template, "/tmp/mktemp.");
 
-	for (i = 12; i < sizeof(template) - 1; i++)
+	for (i = 12; i < tlen - 1; i++)
 		template[i] = 'X';
 
 	ATF_REQUIRE(mktemp(template) != NULL);
-	ATF_REQUIRE(strlen(template) == sizeof(template) - 1);
+	ATF_REQUIRE(strlen(template) == tlen - 1);
 	ATF_REQUIRE(strcmp(template, path) != 0);
 	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+	free(template);
 }
 
 ATF_TC(mkstemp_basic);



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

2021-01-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Jan 11 07:17:49 UTC 2021

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
PR/55715: pmax testbed panics with "assertion "asid == 
curcpu()->ci_pmap_asid_cur" failed"

It's GXemul that has the bug! Unfortunately, there's no way (currently) to
detect if we're running under GXemul emulation, so disable for all mips
for now.  Hopefully, GXemul will get fixed soon.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.43 src/tests/lib/libc/gen/t_siginfo.c:1.44
--- src/tests/lib/libc/gen/t_siginfo.c:1.43	Sun Jan 10 20:46:14 2021
+++ src/tests/lib/libc/gen/t_siginfo.c	Mon Jan 11 07:17:49 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.43 2021/01/10 20:46:14 skrll Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.44 2021/01/11 07:17:49 skrll Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -482,9 +482,9 @@ ATF_TC_BODY(sigbus_adraln, tc)
 #endif
 
 #if defined(__mips__)
-	if (isQEMU())
-		atf_tc_expect_fail("QEMU fails to trap unaligned accesses with "
-		"correct ENTRYHI");
+	/* no way of detecting if on GXemul, so disable everywhere for now */
+	atf_tc_expect_fail("GXemul fails to trap unaligned accesses with "
+	"correct ENTRYHI");
 #endif
 
 	sa.sa_flags = SA_SIGINFO;



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

2021-01-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jan 10 20:46:14 UTC 2021

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
PR/55715: pmax testbed panics with "assertion "asid == 
curcpu()->ci_pmap_asid_cur" failed"

disable the sigbus_adraln test on qemu for now


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.42 src/tests/lib/libc/gen/t_siginfo.c:1.43
--- src/tests/lib/libc/gen/t_siginfo.c:1.42	Tue Oct 13 06:55:25 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Sun Jan 10 20:46:14 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.42 2020/10/13 06:55:25 rin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.43 2021/01/10 20:46:14 skrll Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -481,6 +481,12 @@ ATF_TC_BODY(sigbus_adraln, tc)
 	atf_tc_skip("No SIGBUS signal for unaligned accesses");
 #endif
 
+#if defined(__mips__)
+	if (isQEMU())
+		atf_tc_expect_fail("QEMU fails to trap unaligned accesses with "
+		"correct ENTRYHI");
+#endif
+
 	sa.sa_flags = SA_SIGINFO;
 	sa.sa_sigaction = sigbus_action;
 	sigemptyset(_mask);



CVS commit: src/tests/lib/libc/string

2020-11-27 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Nov 27 16:50:02 UTC 2020

Modified Files:
src/tests/lib/libc/string: t_memmem.c

Log Message:
map enough space for both the page we write and the guard so that we make
sure we own the guard page before we set its protection to none. This fixes
random SEGVs where the page we set protection to none probably belonged to
the dynamic linker. Reported by gson@


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/string/t_memmem.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/string/t_memmem.c
diff -u src/tests/lib/libc/string/t_memmem.c:1.5 src/tests/lib/libc/string/t_memmem.c:1.6
--- src/tests/lib/libc/string/t_memmem.c:1.5	Fri Nov 27 10:37:06 2020
+++ src/tests/lib/libc/string/t_memmem.c	Fri Nov 27 11:50:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */
+/*	$NetBSD: t_memmem.c,v 1.6 2020/11/27 16:50:02 christos Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -105,11 +105,12 @@ ATF_TC_BODY(memmem_oob, tc)
 {
 	static const char str[] = "abcde";
 	size_t pg = getpagesize();
-	char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE,
+	char *src = mmap(NULL, 2 * pg, PROT_READ|PROT_WRITE,
 	MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
 	ATF_CHECK(src != MAP_FAILED);
 	char *guard = mmap(src + pg, pg,
 	PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0);
+printf("%p\n", guard);
 	for (size_t i = 2; i < 5; i++) {
 		char *search = src + pg - i;
 		char match[sizeof(str)];



CVS commit: src/tests/lib/libc/string

2020-11-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Fri Nov 27 15:37:06 UTC 2020

Modified Files:
src/tests/lib/libc/string: t_memmem.c

Log Message:
delete trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/string/t_memmem.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/string/t_memmem.c
diff -u src/tests/lib/libc/string/t_memmem.c:1.4 src/tests/lib/libc/string/t_memmem.c:1.5
--- src/tests/lib/libc/string/t_memmem.c:1.4	Mon Oct 15 17:55:28 2018
+++ src/tests/lib/libc/string/t_memmem.c	Fri Nov 27 15:37:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_memmem.c,v 1.4 2018/10/15 17:55:28 christos Exp $ */
+/*	$NetBSD: t_memmem.c,v 1.5 2020/11/27 15:37:06 gson Exp $ */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -107,7 +107,7 @@ ATF_TC_BODY(memmem_oob, tc)
 	size_t pg = getpagesize();
 	char *src = mmap(NULL, pg, PROT_READ|PROT_WRITE,
 	MAP_ANON|MAP_PRIVATE, -1, (off_t)0);
-	ATF_CHECK(src != MAP_FAILED); 
+	ATF_CHECK(src != MAP_FAILED);
 	char *guard = mmap(src + pg, pg,
 	PROT_NONE, MAP_ANON|MAP_PRIVATE|MAP_FIXED, -1, (off_t)0);
 	for (size_t i = 2; i < 5; i++) {



CVS commit: src/tests/lib/libc/stdlib

2020-11-01 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sun Nov  1 18:19:54 UTC 2020

Modified Files:
src/tests/lib/libc/stdlib: t_mktemp.c

Log Message:
Make the mkstemps_basic and mkostemps_basic test cases not randomly
fail when the replacement string happens to contain the letter "y".


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdlib/t_mktemp.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/stdlib/t_mktemp.c
diff -u src/tests/lib/libc/stdlib/t_mktemp.c:1.2 src/tests/lib/libc/stdlib/t_mktemp.c:1.3
--- src/tests/lib/libc/stdlib/t_mktemp.c:1.2	Wed Jul  1 05:37:25 2020
+++ src/tests/lib/libc/stdlib/t_mktemp.c	Sun Nov  1 18:19:54 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $ */
+/* $NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $ */
 
 /*-
  * Copyright (c) 2013, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $");
+__RCSID("$NetBSD: t_mktemp.c,v 1.3 2020/11/01 18:19:54 gson Exp $");
 
 #include 
 
@@ -136,6 +136,7 @@ ATF_TC_HEAD(mkstemps_basic, tc)
 ATF_TC_BODY(mkstemps_basic, tc)
 {
 	char template[] = "/tmp/mktemp.XXXyyy";
+	char *suffix = strchr(template, 'y');
 	struct stat sa;
 	int fd;
 
@@ -145,10 +146,7 @@ ATF_TC_BODY(mkstemps_basic, tc)
 
 	ATF_REQUIRE(fd != -1);
 	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
-
-	char *str = strchr(template, 'y');
-
-	ATF_REQUIRE(strcmp(str, "yyy") == 0);
+	ATF_REQUIRE(strcmp(suffix, "yyy") == 0);
 	ATF_REQUIRE(write(fd, "X", 1) == 1);
 	ATF_REQUIRE(fstat(fd, ) == 0);
 	ATF_REQUIRE(check_mode(sa, 0600, 0) == 0);
@@ -227,6 +225,7 @@ ATF_TC_BODY(mkostemps_basic, tc)
 	};
 
 	char template[] = "/tmp/mktemp.XXXyyy";
+	char *suffix = strchr(template, 'y');
 	struct stat sa;
 	size_t i;
 	int fd;
@@ -239,10 +238,7 @@ ATF_TC_BODY(mkostemps_basic, tc)
 
 		ATF_REQUIRE(fd != -1);
 		ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
-
-		char *str = strchr(template, 'y');
-
-		ATF_REQUIRE(strcmp(str, "yyy") == 0);
+		ATF_REQUIRE(strcmp(suffix, "yyy") == 0);
 		ATF_REQUIRE(write(fd, "X", 1) == 1);
 		ATF_REQUIRE(fstat(fd, ) == 0);
 		ATF_REQUIRE(check_mode(sa, 0600 | flags[i], 0) == 0);



CVS commit: src/tests/lib/libc/sys

2020-10-27 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Tue Oct 27 08:32:36 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Add tests for AVX-512 registers (zmm0..zmm31, k0..7)

Thanks to David Seifert  for providing a VM
on an AVX-512 capable hardware

Reviewed by kamil


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.30 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.31
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.30	Sat Oct 24 07:14:30 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Tue Oct 27 08:32:36 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.30 2020/10/24 07:14:30 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.31 2020/10/27 08:32:36 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -2177,6 +2177,9 @@ ATF_TC_BODY(x86_cve_2018_8897, tc)
 
 union x86_test_register {
 	struct {
+		uint64_t a, b, c, d, e, f, g, h;
+	} zmm;
+	struct {
 		uint64_t a, b, c, d;
 	} ymm;
 	struct {
@@ -2220,7 +2223,8 @@ enum x86_test_registers {
 	FPREGS_MM,
 	FPREGS_XMM,
 	/* TEST_XSTATE */
-	FPREGS_YMM
+	FPREGS_YMM,
+	FPREGS_ZMM
 };
 
 enum x86_test_regmode {
@@ -2396,14 +2400,14 @@ static __inline void get_gp64_r8_regs(un
 		"\n\t"
 		"int3\n\t"
 		"\n\t"
-		"movq%%r8, 0x00(%0)\n\t"
-		"movq%%r9, 0x20(%0)\n\t"
-		"movq%%r10, 0x40(%0)\n\t"
-		"movq%%r11, 0x60(%0)\n\t"
-		"movq%%r12, 0x80(%0)\n\t"
-		"movq%%r13, 0xA0(%0)\n\t"
-		"movq%%r14, 0xC0(%0)\n\t"
-		"movq%%r15, 0xE0(%0)\n\t"
+		"movq%%r8, 0x000(%0)\n\t"
+		"movq%%r9, 0x040(%0)\n\t"
+		"movq%%r10, 0x080(%0)\n\t"
+		"movq%%r11, 0x0C0(%0)\n\t"
+		"movq%%r12, 0x100(%0)\n\t"
+		"movq%%r13, 0x140(%0)\n\t"
+		"movq%%r14, 0x180(%0)\n\t"
+		"movq%%r15, 0x1C0(%0)\n\t"
 		:
 		: "a"(out), "m"(fill)
 		: "%r8", "%r9", "%r10", "%r11", "%r12", "%r13", "%r14", "%r15"
@@ -2417,14 +2421,14 @@ static __inline void set_gp64_r8_regs(co
 {
 #if defined(__x86_64__)
 	__asm__ __volatile__(
-		"movq0x00(%0), %%r8\n\t"
-		"movq0x20(%0), %%r9\n\t"
-		"movq0x40(%0), %%r10\n\t"
-		"movq0x60(%0), %%r11\n\t"
-		"movq0x80(%0), %%r12\n\t"
-		"movq0xA0(%0), %%r13\n\t"
-		"movq0xC0(%0), %%r14\n\t"
-		"movq0xE0(%0), %%r15\n\t"
+		"movq0x000(%0), %%r8\n\t"
+		"movq0x040(%0), %%r9\n\t"
+		"movq0x080(%0), %%r10\n\t"
+		"movq0x0C0(%0), %%r11\n\t"
+		"movq0x100(%0), %%r12\n\t"
+		"movq0x140(%0), %%r13\n\t"
+		"movq0x180(%0), %%r14\n\t"
+		"movq0x1C0(%0), %%r15\n\t"
 		"int3\n\t"
 		:
 		: "b"(data)
@@ -2526,14 +2530,14 @@ static __inline void get_mm_regs(union x
 		"\n\t"
 		"int3\n\t"
 		"\n\t"
-		"movq%%mm0, 0x00(%0)\n\t"
-		"movq%%mm1, 0x20(%0)\n\t"
-		"movq%%mm2, 0x40(%0)\n\t"
-		"movq%%mm3, 0x60(%0)\n\t"
-		"movq%%mm4, 0x80(%0)\n\t"
-		"movq%%mm5, 0xA0(%0)\n\t"
-		"movq%%mm6, 0xC0(%0)\n\t"
-		"movq%%mm7, 0xE0(%0)\n\t"
+		"movq%%mm0, 0x000(%0)\n\t"
+		"movq%%mm1, 0x040(%0)\n\t"
+		"movq%%mm2, 0x080(%0)\n\t"
+		"movq%%mm3, 0x0C0(%0)\n\t"
+		"movq%%mm4, 0x100(%0)\n\t"
+		"movq%%mm5, 0x140(%0)\n\t"
+		"movq%%mm6, 0x180(%0)\n\t"
+		"movq%%mm7, 0x1C0(%0)\n\t"
 		:
 		: "a"(out), "m"(fill)
 		: "%mm0", "%mm1", "%mm2", "%mm3", "%mm4", "%mm5", "%mm6", "%mm7"
@@ -2544,14 +2548,14 @@ __attribute__((target("mmx")))
 static __inline void set_mm_regs(const union x86_test_register data[])
 {
 	__asm__ __volatile__(
-		"movq0x00(%0), %%mm0\n\t"
-		"movq0x20(%0), %%mm1\n\t"
-		"movq0x40(%0), %%mm2\n\t"
-		"movq0x60(%0), %%mm3\n\t"
-		"movq0x80(%0), %%mm4\n\t"
-		"movq0xA0(%0), %%mm5\n\t"
-		"movq0xC0(%0), %%mm6\n\t"
-		"movq0xE0(%0), %%mm7\n\t"
+		"movq0x000(%0), %%mm0\n\t"
+		"movq0x040(%0), %%mm1\n\t"
+		"movq0x080(%0), %%mm2\n\t"
+		"movq0x0C0(%0), %%mm3\n\t"
+		"movq0x100(%0), %%mm4\n\t"
+		"movq0x140(%0), %%mm5\n\t"
+		"movq0x180(%0), %%mm6\n\t"
+		"movq0x1C0(%0), %%mm7\n\t"
 		"int3\n\t"
 		:
 		: "b"(data)
@@ -2590,22 +2594,22 @@ static __inline void get_xmm_regs(union 
 		"int3\n\t"
 		"\n\t"
 		"movaps  %%xmm0, 0x000(%0)\n\t"
-		"movaps  %%xmm1, 0x020(%0)\n\t"
-		"movaps  %%xmm2, 0x040(%0)\n\t"
-		"movaps  %%xmm3, 0x060(%0)\n\t"
-		"movaps  %%xmm4, 0x080(%0)\n\t"
-		"movaps  %%xmm5, 0x0A0(%0)\n\t"
-		"movaps  %%xmm6, 0x0C0(%0)\n\t"
-		"movaps  %%xmm7, 0x0E0(%0)\n\t"
-#if defined(__x86_64__)
-		"movaps  %%xmm8, 0x100(%0)\n\t"
-		"movaps  %%xmm9, 0x120(%0)\n\t"
-		"movaps  %%xmm10, 0x140(%0)\n\t"
-		"movaps  %%xmm11, 0x160(%0)\n\t"
-		"movaps  %%xmm12, 0x180(%0)\n\t"
-		"movaps  %%xmm13, 0x1A0(%0)\n\t"
-		"movaps  %%xmm14, 0x1C0(%0)\n\t"
-		"movaps  %%xmm15, 

CVS commit: src/tests/lib/libc/sys

2020-10-16 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Fri Oct 16 08:51:12 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Remove leftover commented out #if 0


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.28 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.29
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.28	Thu Oct 15 17:43:09 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Oct 16 08:51:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.28 2020/10/15 17:43:09 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.29 2020/10/16 08:51:12 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -3551,9 +3551,7 @@ x86_register_test(enum x86_test_regset r
 /* SETFPREGS on i386 */
 fpr.fstate.s87_cw = expected_fpu.cw;
 fpr.fstate.s87_sw = expected_fpu.sw;
-//#if 0 /* TODO: translation from FXSAVE is broken */
 fpr.fstate.s87_tw = expected_fpu.tw;
-//#endif
 fpr.fstate.s87_opcode = expected_fpu.opcode;
 fpr.fstate.s87_ip = expected_fpu.ip;
 fpr.fstate.s87_dp = expected_fpu.dp;



CVS commit: src/tests/lib/libc/sys

2020-10-15 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Oct 15 22:59:50 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_core_wait.h

Log Message:
Apply fix in rev 1.2 for core_dump_procinfo to aarch64 and arm:

http://cvsweb.netbsd.org/bsdweb.cgi/src/tests/lib/libc/sys/t_ptrace_core_wait.h#rev1.2

> For powerpc, program counter is not automatically incremented by trap
> instruction. We cannot increment PC in the trap handler, which breaks
> applications depending on this behavior, e.g., GDB.

This statement is true for aarch64 and arm.

Also, use PTRACE_BREAKPOINT_SIZE instead of hard-coded 4 to address
instruction next to PC.

OK ryo


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_core_wait.h

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/sys/t_ptrace_core_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.2	Wed Jun 24 04:47:10 2020
+++ src/tests/lib/libc/sys/t_ptrace_core_wait.h	Thu Oct 15 22:59:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_core_wait.h,v 1.2 2020/06/24 04:47:10 rin Exp $	*/
+/*	$NetBSD: t_ptrace_core_wait.h,v 1.3 2020/10/15 22:59:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -207,21 +207,27 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
-#ifndef __powerpc__
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-#else
+
+#if defined(__aarch64__) || defined(__arm__) || defined(__powerpc__)
 	/*
-	 * For powerpc, program counter is not automatically incremented by
-	 * a trap instruction. We cannot increment PC in the trap handler,
+	 * For these archs, program counter is not automatically incremented
+	 * by a trap instruction. We cannot increment PC in the trap handler,
 	 * which breaks applications depending on this behavior, e.g., GDB.
-	 * Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC)
-	 * to PT_CONTINUE here.
+	 * Therefore, we need to pass PC++ instead of (void *)1 (== PC) to
+	 * PT_CONTINUE here.
 	 */
 	struct reg r;
 
 	SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1);
-	SYSCALL_REQUIRE(
-	ptrace(PT_CONTINUE, child, (void *)(r.pc + 4), 0) != -1);
+	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child,
+#  if defined(__aarch64__) || defined(__arm__)
+	(void *)(r.r_pc + PTRACE_BREAKPOINT_SIZE),
+#  elif defined(__powerpc__)
+	(void *)(r.pc + PTRACE_BREAKPOINT_SIZE),
+#  endif
+	0) != -1);
+#else
+	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
 #endif
 
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);



CVS commit: src/tests/lib/libc/sys

2020-10-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Oct 13 06:58:57 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_setrlimit.c

Log Message:
Bump soft/hard limits for stack to 6MB for aarch64{,eb}, where old value
(~4MB) is too small to be accepted.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_setrlimit.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/sys/t_setrlimit.c
diff -u src/tests/lib/libc/sys/t_setrlimit.c:1.6 src/tests/lib/libc/sys/t_setrlimit.c:1.7
--- src/tests/lib/libc/sys/t_setrlimit.c:1.6	Fri Jan 13 21:16:38 2017
+++ src/tests/lib/libc/sys/t_setrlimit.c	Tue Oct 13 06:58:57 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $ */
+/* $NetBSD: t_setrlimit.c,v 1.7 2020/10/13 06:58:57 rin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_setrlimit.c,v 1.6 2017/01/13 21:16:38 christos Exp $");
+__RCSID("$NetBSD: t_setrlimit.c,v 1.7 2020/10/13 06:58:57 rin Exp $");
 
 #include 
 #include 
@@ -517,7 +517,7 @@ ATF_TC_BODY(setrlimit_stack, tc)
 	struct rlimit res;
 
 	/* Ensure soft limit is not bigger than hard limit */
-	res.rlim_cur = res.rlim_max = 4192256;
+	res.rlim_cur = res.rlim_max = 6 * 1024 * 1024;
 	ATF_REQUIRE(setrlimit(RLIMIT_STACK, ) == 0);
 	ATF_REQUIRE(getrlimit(RLIMIT_STACK, ) == 0);
 	ATF_CHECK(res.rlim_cur <= res.rlim_max);



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

2020-10-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Oct 13 06:55:25 UTC 2020

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
For aarch64eb, no SIGBUS signal for unaligned accesses.
Convert to preprocessor directives.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.41 src/tests/lib/libc/gen/t_siginfo.c:1.42
--- src/tests/lib/libc/gen/t_siginfo.c:1.41	Mon Aug 24 06:55:16 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue Oct 13 06:55:25 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.41 2020/08/24 06:55:16 gson Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.42 2020/10/13 06:55:25 rin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -476,9 +476,10 @@ ATF_TC_BODY(sigbus_adraln, tc)
 
 	/* m68k (except sun2) never issue SIGBUS (PR lib/49653),
 	 * same for armv8 or newer */
-	if (strcmp(MACHINE_ARCH, "m68k") == 0 ||
-	strcmp(MACHINE_ARCH, "aarch64") == 0)
-		atf_tc_skip("No SIGBUS signal for unaligned accesses");
+#if (defined(__m68k__) && !defined(__mc68010__)) || \
+defined(__aarch64__)
+	atf_tc_skip("No SIGBUS signal for unaligned accesses");
+#endif
 
 	sa.sa_flags = SA_SIGINFO;
 	sa.sa_sigaction = sigbus_action;



CVS commit: src/tests/lib/libc/sys

2020-10-09 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Fri Oct  9 17:43:30 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Add tests for x87 FPU registers

Reviewed by kamil


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.27
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26	Fri Oct  9 17:43:07 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Oct  9 17:43:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.26 2020/10/09 17:43:07 mgorny Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.27 2020/10/09 17:43:30 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -2186,6 +2186,21 @@ union x86_test_register {
 	uint32_t u32;
 };
 
+struct x86_test_fpu_registers {
+	struct {
+		uint64_t mantissa;
+		uint16_t sign_exp;
+	} __aligned(16) st[8];
+
+	uint16_t cw;
+	uint16_t sw;
+	uint16_t tw;
+	uint8_t tw_abridged;
+	uint16_t opcode;
+	union fp_addr ip;
+	union fp_addr dp;
+};
+
 enum x86_test_regset {
 	TEST_GPREGS,
 	TEST_FPREGS,
@@ -2201,6 +2216,7 @@ enum x86_test_registers {
 	GPREGS_64,
 	GPREGS_64_R8,
 	/* TEST_FPREGS/TEST_XMMREGS */
+	FPREGS_FPU,
 	FPREGS_MM,
 	FPREGS_XMM,
 	/* TEST_XSTATE */
@@ -2419,6 +2435,79 @@ static __inline void set_gp64_r8_regs(co
 #endif
 }
 
+static __inline void get_fpu_regs(struct x86_test_fpu_registers *out)
+{
+	struct save87 fsave;
+	struct fxsave fxsave;
+
+	__CTASSERT(sizeof(out->st[0]) == 16);
+
+	__asm__ __volatile__(
+		"finit\n\t"
+		"int3\n\t"
+#if defined(__x86_64__)
+		"fxsave64 %2\n\t"
+#else
+		"fxsave %2\n\t"
+#endif
+		"fnstenv %1\n\t"
+		"fnclex\n\t"
+		"fstpt 0x00(%0)\n\t"
+		"fstpt 0x10(%0)\n\t"
+		"fstpt 0x20(%0)\n\t"
+		"fstpt 0x30(%0)\n\t"
+		"fstpt 0x40(%0)\n\t"
+		"fstpt 0x50(%0)\n\t"
+		"fstpt 0x60(%0)\n\t"
+		"fstpt 0x70(%0)\n\t"
+		:
+		: "a"(out->st), "m"(fsave), "m"(fxsave)
+		: "st", "memory"
+	);
+
+	FORKEE_ASSERT(fsave.s87_cw == fxsave.fx_cw);
+	FORKEE_ASSERT(fsave.s87_sw == fxsave.fx_sw);
+
+	/* fsave contains full tw */
+	out->cw = fsave.s87_cw;
+	out->sw = fsave.s87_sw;
+	out->tw = fsave.s87_tw;
+	out->tw_abridged = fxsave.fx_tw;
+	out->opcode = fxsave.fx_opcode;
+	out->ip = fxsave.fx_ip;
+	out->dp = fxsave.fx_dp;
+}
+
+/* used as single-precision float */
+uint32_t x86_test_zero = 0;
+
+static __inline void set_fpu_regs(const struct x86_test_fpu_registers *data)
+{
+	__CTASSERT(sizeof(data->st[0]) == 16);
+
+	__asm__ __volatile__(
+		"finit\n\t"
+		"fldcw %1\n\t"
+		/* load on stack in reverse order to make it easier to read */
+		"fldt 0x70(%0)\n\t"
+		"fldt 0x60(%0)\n\t"
+		"fldt 0x50(%0)\n\t"
+		"fldt 0x40(%0)\n\t"
+		"fldt 0x30(%0)\n\t"
+		"fldt 0x20(%0)\n\t"
+		"fldt 0x10(%0)\n\t"
+		"fldt 0x00(%0)\n\t"
+		/* free st7 */
+		"ffree %%st(7)\n\t"
+		/* this should trigger a divide-by-zero */
+		"fdivs (%2)\n\t"
+		"int3\n\t"
+		:
+		: "a"(>st), "m"(data->cw), "b"(_test_zero)
+		: "st"
+	);
+}
+
 __attribute__((target("mmx")))
 static __inline void get_mm_regs(union x86_test_register out[])
 {
@@ -2712,6 +2801,54 @@ x86_register_test(enum x86_test_regset r
 		   0x262524232221201F, 0x2E2D2C2B2A292827, }},
 	};
 
+	const struct x86_test_fpu_registers expected_fpu = {
+		.st = {
+			{0x8000, 0x4000}, /* +2.0 */
+			{0x3f00, 0x}, /* 1.654785e-4932 */
+			{0x, 0x}, /* +0 */
+			{0x, 0x8000}, /* -0 */
+			{0x8000, 0x7fff}, /* +inf */
+			{0x8000, 0x}, /* -inf */
+			{0xc000, 0x}, /* nan */
+			/* st(7) will be freed to test tag word better */
+			{0x, 0x}, /* +0 */
+		},
+		/*  0011 0111 1011
+		 * PU OZDI -- unmask divide-by-zero exc.
+		 *   RR - reserved
+		 *PC  64-bit precision
+		 *  RC -- round to nearest
+		 *I - allow interrupts (unused)
+		 */
+		.cw = 0x037b,
+		/* 1000  1000 0100
+		 *SPU OZDI -- divide-by-zero exception
+		 *   I -- interrupt (exception handling)
+		 *  CCCC  condition codes
+		 *   TO P --- top register is 0
+		 * B  FPU is busy
+		 */
+		.sw = 0x8084,
+		/* 1110 1010 0101 1000
+		 * R7R6 R5R4 R3R2 R1R0
+		 *  nz -- non-zero (+2.0)
+		 *sp  special (denormal)
+		 *   zrzr --- zeroes
+		 *   sp spsp  specials (NaN + infinities)
+		 * em --- empty register
+		 */
+		.tw = 0xea58,
+		/* 0111  -- registers 0 to 6 are used */
+		.tw_abridged = 0x7f,
+		/* FDIV */
+		.opcode = 0x0033,
+		/* random bits for IP/DP write 

CVS commit: src/tests/lib/libc/sys

2020-10-09 Thread Michał Górny
Module Name:src
Committed By:   mgorny
Date:   Fri Oct  9 17:43:07 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_x86_wait.h

Log Message:
Rename MM_REG macro to ST_MAN, and cover fpr/xstate with it

Rename the MM_REG macro to ST_MAN, to make it clearer that it gets
mantissa of ST registers which overlaps with MM registers but can be
also used to read ST registers (to be used in the next commit).  Extend
it to cover the difference between GETFPREGS and GETXSTATE,
and therefore avoid additional condition on i386.

Reviewed by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.25 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.26
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.25	Fri Apr 24 03:25:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Oct  9 17:43:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.25 2020/04/24 03:25:20 thorpej Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.26 2020/10/09 17:43:07 mgorny Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -3089,9 +3089,13 @@ x86_register_test(enum x86_test_regset r
 	}
 
 #if defined(__x86_64__)
-#define MM_REG(n) fpr.fxstate.fx_87_ac[n].r.f87_mantissa
+#define ST_MAN(n) fxs->fx_87_ac[n].r.f87_mantissa
 #else
-#define MM_REG(n) fpr.fstate.s87_ac[n].f87_mantissa
+#define ST_MAN(n) *(			\
+regset == TEST_FPREGS		\
+? _ac[n].f87_mantissa\
+: >fx_87_ac[n].r.f87_mantissa	\
+)
 #endif
 
 	switch (regmode) {
@@ -3155,33 +3159,14 @@ x86_register_test(enum x86_test_regset r
 #endif
 			break;
 		case FPREGS_MM:
-			if (regset == TEST_FPREGS) {
-ATF_CHECK_EQ(MM_REG(0), expected[0].u64);
-ATF_CHECK_EQ(MM_REG(1), expected[1].u64);
-ATF_CHECK_EQ(MM_REG(2), expected[2].u64);
-ATF_CHECK_EQ(MM_REG(3), expected[3].u64);
-ATF_CHECK_EQ(MM_REG(4), expected[4].u64);
-ATF_CHECK_EQ(MM_REG(5), expected[5].u64);
-ATF_CHECK_EQ(MM_REG(6), expected[6].u64);
-ATF_CHECK_EQ(MM_REG(7), expected[7].u64);
-			} else {
-ATF_CHECK_EQ(fxs->fx_87_ac[0].r.f87_mantissa,
-			expected[0].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[1].r.f87_mantissa,
-			expected[1].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[2].r.f87_mantissa,
-			expected[2].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[3].r.f87_mantissa,
-			expected[3].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[4].r.f87_mantissa,
-			expected[4].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[5].r.f87_mantissa,
-			expected[5].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[6].r.f87_mantissa,
-			expected[6].u64);
-ATF_CHECK_EQ(fxs->fx_87_ac[7].r.f87_mantissa,
-			expected[7].u64);
-			}
+			ATF_CHECK_EQ(ST_MAN(0), expected[0].u64);
+			ATF_CHECK_EQ(ST_MAN(1), expected[1].u64);
+			ATF_CHECK_EQ(ST_MAN(2), expected[2].u64);
+			ATF_CHECK_EQ(ST_MAN(3), expected[3].u64);
+			ATF_CHECK_EQ(ST_MAN(4), expected[4].u64);
+			ATF_CHECK_EQ(ST_MAN(5), expected[5].u64);
+			ATF_CHECK_EQ(ST_MAN(6), expected[6].u64);
+			ATF_CHECK_EQ(ST_MAN(7), expected[7].u64);
 			break;
 		case FPREGS_YMM:
 			ATF_CHECK(!memcmp(_ymm_hi128.xs_ymm[0],
@@ -3300,33 +3285,14 @@ x86_register_test(enum x86_test_regset r
 #endif
 			break;
 		case FPREGS_MM:
-			if (regset == TEST_FPREGS) {
-MM_REG(0) = expected[0].u64;
-MM_REG(1) = expected[1].u64;
-MM_REG(2) = expected[2].u64;
-MM_REG(3) = expected[3].u64;
-MM_REG(4) = expected[4].u64;
-MM_REG(5) = expected[5].u64;
-MM_REG(6) = expected[6].u64;
-MM_REG(7) = expected[7].u64;
-			} else {
-fxs->fx_87_ac[0].r.f87_mantissa =
-expected[0].u64;
-fxs->fx_87_ac[1].r.f87_mantissa =
-expected[1].u64;
-fxs->fx_87_ac[2].r.f87_mantissa =
-expected[2].u64;
-fxs->fx_87_ac[3].r.f87_mantissa =
-expected[3].u64;
-fxs->fx_87_ac[4].r.f87_mantissa =
-expected[4].u64;
-fxs->fx_87_ac[5].r.f87_mantissa =
-expected[5].u64;
-fxs->fx_87_ac[6].r.f87_mantissa =
-expected[6].u64;
-fxs->fx_87_ac[7].r.f87_mantissa =
-expected[7].u64;
-			}
+			ST_MAN(0) = expected[0].u64;
+			ST_MAN(1) = expected[1].u64;
+			ST_MAN(2) = expected[2].u64;
+			ST_MAN(3) = expected[3].u64;
+			ST_MAN(4) = expected[4].u64;
+			ST_MAN(5) = expected[5].u64;
+			ST_MAN(6) = expected[6].u64;
+			ST_MAN(7) = expected[7].u64;
 			break;
 		case FPREGS_YMM:
 			memcpy(_ymm_hi128.xs_ymm[0],
@@ -3431,7 +3397,7 @@ x86_register_test(enum x86_test_regset r
 		break;
 	}
 
-#undef MM_REG
+#undef ST_MAN
 
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");



CVS commit: src/tests/lib/libc/db

2020-09-06 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Mon Sep  7 00:28:44 UTC 2020

Modified Files:
src/tests/lib/libc/db: t_db_hash_seq.c

Log Message:
don't pass NULL to printf(), but use "" to signify this
test is operating on an in-memory only database.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/db/t_db_hash_seq.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/db/t_db_hash_seq.c
diff -u src/tests/lib/libc/db/t_db_hash_seq.c:1.3 src/tests/lib/libc/db/t_db_hash_seq.c:1.4
--- src/tests/lib/libc/db/t_db_hash_seq.c:1.3	Tue Jul  9 16:24:01 2019
+++ src/tests/lib/libc/db/t_db_hash_seq.c	Mon Sep  7 00:28:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_db_hash_seq.c,v 1.3 2019/07/09 16:24:01 maya Exp $	*/
+/*	$NetBSD: t_db_hash_seq.c,v 1.4 2020/09/07 00:28:44 mrg Exp $	*/
 
 /*-
  * Copyright (c) 2015 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_db_hash_seq.c,v 1.3 2019/07/09 16:24:01 maya Exp $");
+__RCSID("$NetBSD: t_db_hash_seq.c,v 1.4 2020/09/07 00:28:44 mrg Exp $");
 
 #include 
 #include 
@@ -107,7 +107,8 @@ state_open(const char *dbname, int flags
 	if (db == NULL) {
 		if (errno == ENOENT && (flags & O_CREAT) == 0)
 			return NULL;
-		DO_ERR("%s: can't open `%s'", __func__, dbname);
+		DO_ERR("%s: can't open `%s'", __func__,
+		dbname ? dbname : "");
 	}
 	return db;
 }



CVS commit: src/tests/lib/libc/sys

2020-08-24 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Aug 25 01:37:39 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_getrandom.c

Log Message:
Fix getrandom() tests.

Use sigaction() without SA_RESTART -- signal() implies SA_RESTART so
we never got the EINTR.

While here, reduce the timeout to something more reasonable so we
don't waste 20min of testbed time if anything goes wrong and the
one-second alarm doesn't fire.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_getrandom.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/sys/t_getrandom.c
diff -u src/tests/lib/libc/sys/t_getrandom.c:1.2 src/tests/lib/libc/sys/t_getrandom.c:1.3
--- src/tests/lib/libc/sys/t_getrandom.c:1.2	Sun Aug 23 17:50:19 2020
+++ src/tests/lib/libc/sys/t_getrandom.c	Tue Aug 25 01:37:38 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_getrandom.c,v 1.2 2020/08/23 17:50:19 riastradh Exp $	*/
+/*	$NetBSD: t_getrandom.c,v 1.3 2020/08/25 01:37:38 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,13 +30,14 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_getrandom.c,v 1.2 2020/08/23 17:50:19 riastradh Exp $");
+__RCSID("$NetBSD: t_getrandom.c,v 1.3 2020/08/25 01:37:38 riastradh Exp $");
 
 #include 
 
 #include 
 #include 
 #include 
+#include 
 #include 
 
 static uint8_t buf[65536];
@@ -45,6 +46,22 @@ static uint8_t zero24[24];
 static void
 alarm_handler(int signo)
 {
+
+	fprintf(stderr, "timeout\n");
+}
+
+static void
+install_alarm_handler(void)
+{
+	struct sigaction sa;
+
+	memset(, 0, sizeof sa);
+	sa.sa_handler = alarm_handler;
+	sigfillset(_mask);
+	sa.sa_flags = 0;	/* no SA_RESTART */
+
+	ATF_CHECK_MSG(sigaction(SIGALRM, , NULL) != -1,
+	"sigaction(SIGALRM): %s", strerror(errno));
 }
 
 /*
@@ -58,14 +75,14 @@ ATF_TC(getrandom_default);
 ATF_TC_HEAD(getrandom_default, tc)
 {
 	atf_tc_set_md_var(tc, "descr", "getrandom(..., 0)");
+	atf_tc_set_md_var(tc, "timeout", "2");
 }
 ATF_TC_BODY(getrandom_default, tc)
 {
 	ssize_t n;
 
-	ATF_REQUIRE(signal(SIGALRM, _handler) != SIG_ERR);
-
 	/* default */
+	install_alarm_handler();
 	alarm(1);
 	memset(buf, 0, sizeof buf);
 	n = getrandom(buf, sizeof buf, 0);
@@ -141,14 +158,14 @@ ATF_TC(getrandom_random);
 ATF_TC_HEAD(getrandom_random, tc)
 {
 	atf_tc_set_md_var(tc, "descr", "getrandom(..., GRND_RANDOM)");
+	atf_tc_set_md_var(tc, "timeout", "2");
 }
 ATF_TC_BODY(getrandom_random, tc)
 {
 	ssize_t n;
 
-	ATF_REQUIRE(signal(SIGALRM, _handler) != SIG_ERR);
-
 	/* `random' (hokey) */
+	install_alarm_handler();
 	alarm(1);
 	memset(buf, 0, sizeof buf);
 	n = getrandom(buf, sizeof buf, GRND_RANDOM);



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

2020-08-24 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Mon Aug 24 06:55:16 UTC 2020

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
Expect a failure to trap unaligned acesses only when running under
qemu's TCG CPU emulation, not when running under hardware virtualization
such as qemu -accel nvmm.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.40 src/tests/lib/libc/gen/t_siginfo.c:1.41
--- src/tests/lib/libc/gen/t_siginfo.c:1.40	Sat Jun 20 07:30:09 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Mon Aug 24 06:55:16 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.40 2020/06/20 07:30:09 rin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.41 2020/08/24 06:55:16 gson Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -495,7 +495,7 @@ ATF_TC_BODY(sigbus_adraln, tc)
 	addr = calloc(2, sizeof(int));
 	ATF_REQUIRE(addr != NULL);
 
-	if (isQEMU())
+	if (isQEMU_TCG())
 		atf_tc_expect_fail("QEMU fails to trap unaligned accesses");
 
 	/* Force an unaligned access */



CVS commit: src/tests/lib/libc/sys

2020-08-23 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 23 17:50:19 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_getrandom.c

Log Message:
Split getrandom tests into several cases to find out which ones hang.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_getrandom.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/sys/t_getrandom.c
diff -u src/tests/lib/libc/sys/t_getrandom.c:1.1 src/tests/lib/libc/sys/t_getrandom.c:1.2
--- src/tests/lib/libc/sys/t_getrandom.c:1.1	Fri Aug 14 00:53:16 2020
+++ src/tests/lib/libc/sys/t_getrandom.c	Sun Aug 23 17:50:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $	*/
+/*	$NetBSD: t_getrandom.c,v 1.2 2020/08/23 17:50:19 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_getrandom.c,v 1.1 2020/08/14 00:53:16 riastradh Exp $");
+__RCSID("$NetBSD: t_getrandom.c,v 1.2 2020/08/23 17:50:19 riastradh Exp $");
 
 #include 
 
@@ -47,13 +47,6 @@ alarm_handler(int signo)
 {
 }
 
-ATF_TC(getrandom);
-ATF_TC_HEAD(getrandom, tc)
-{
-
-	atf_tc_set_md_var(tc, "descr", "getrandom(2)");
-}
-
 /*
  * Probability of spurious failure is 1/2^192 for each of the memcmps.
  * As long as there are fewer than 2^64 of them, the probability of
@@ -61,7 +54,12 @@ ATF_TC_HEAD(getrandom, tc)
  * don't care about it.
  */
 
-ATF_TC_BODY(getrandom, tc)
+ATF_TC(getrandom_default);
+ATF_TC_HEAD(getrandom_default, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "getrandom(..., 0)");
+}
+ATF_TC_BODY(getrandom_default, tc)
 {
 	ssize_t n;
 
@@ -79,6 +77,16 @@ ATF_TC_BODY(getrandom, tc)
 		ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 	}
 	alarm(0);
+}
+
+ATF_TC(getrandom_nonblock);
+ATF_TC_HEAD(getrandom_nonblock, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "getrandom(..., GRND_NONBLOCK)");
+}
+ATF_TC_BODY(getrandom_nonblock, tc)
+{
+	ssize_t n;
 
 	/* default, nonblocking */
 	memset(buf, 0, sizeof buf);
@@ -90,6 +98,16 @@ ATF_TC_BODY(getrandom, tc)
 		ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 		ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
 	}
+}
+
+ATF_TC(getrandom_insecure);
+ATF_TC_HEAD(getrandom_insecure, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "getrandom(..., GRND_INSECURE)");
+}
+ATF_TC_BODY(getrandom_insecure, tc)
+{
+	ssize_t n;
 
 	/* insecure */
 	memset(buf, 0, sizeof buf);
@@ -98,6 +116,17 @@ ATF_TC_BODY(getrandom, tc)
 	ATF_CHECK_EQ((size_t)n, sizeof buf);
 	ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 	ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
+}
+
+ATF_TC(getrandom_insecure_nonblock);
+ATF_TC_HEAD(getrandom_insecure_nonblock, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"getrandom(..., GRND_INSECURE|GRND_NONBLOCK)");
+}
+ATF_TC_BODY(getrandom_insecure_nonblock, tc)
+{
+	ssize_t n;
 
 	/* insecure, nonblocking -- same as mere insecure */
 	memset(buf, 0, sizeof buf);
@@ -106,6 +135,18 @@ ATF_TC_BODY(getrandom, tc)
 	ATF_CHECK_EQ((size_t)n, sizeof buf);
 	ATF_CHECK(memcmp(buf, zero24, 24) != 0);
 	ATF_CHECK(memcmp(buf + sizeof buf - 24, zero24, 24) != 0);
+}
+
+ATF_TC(getrandom_random);
+ATF_TC_HEAD(getrandom_random, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "getrandom(..., GRND_RANDOM)");
+}
+ATF_TC_BODY(getrandom_random, tc)
+{
+	ssize_t n;
+
+	ATF_REQUIRE(signal(SIGALRM, _handler) != SIG_ERR);
 
 	/* `random' (hokey) */
 	alarm(1);
@@ -122,6 +163,17 @@ ATF_TC_BODY(getrandom, tc)
 		}
 	}
 	alarm(0);
+}
+
+ATF_TC(getrandom_random_nonblock);
+ATF_TC_HEAD(getrandom_random_nonblock, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"getrandom(..., GRND_RANDOM|GRND_NONBLOCK)");
+}
+ATF_TC_BODY(getrandom_random_nonblock, tc)
+{
+	ssize_t n;
 
 	/* `random' (hokey), nonblocking */
 	memset(buf, 0, sizeof buf);
@@ -136,17 +188,49 @@ ATF_TC_BODY(getrandom, tc)
 			ATF_CHECK(memcmp(buf + n - 24, zero24, 24) != 0);
 		}
 	}
+}
+
+ATF_TC(getrandom_random_insecure);
+ATF_TC_HEAD(getrandom_random_insecure, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"getrandom(..., GRND_RANDOM|GRND_INSECURE)");
+}
+ATF_TC_BODY(getrandom_random_insecure, tc)
+{
+	ssize_t n;
 
 	/* random and insecure -- nonsensical */
 	n = getrandom(buf, sizeof buf, GRND_RANDOM|GRND_INSECURE);
 	ATF_CHECK_EQ(n, -1);
 	ATF_CHECK_EQ(errno, EINVAL);
+}
+
+ATF_TC(getrandom_random_insecure_nonblock);
+ATF_TC_HEAD(getrandom_random_insecure_nonblock, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"getrandom(..., GRND_RANDOM|GRND_INSECURE|GRND_NONBLOCK)");
+}
+ATF_TC_BODY(getrandom_random_insecure_nonblock, tc)
+{
+	ssize_t n;
 
 	/* random and insecure, nonblocking -- nonsensical */
 	n = getrandom(buf, sizeof buf,
 	GRND_RANDOM|GRND_INSECURE|GRND_NONBLOCK);
 	ATF_CHECK_EQ(n, -1);
 	ATF_CHECK_EQ(errno, EINVAL);
+}
+
+ATF_TC(getrandom_invalid);
+ATF_TC_HEAD(getrandom_invalid, tc)
+{
+	atf_tc_set_md_var(tc, "descr", 

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

2020-08-23 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sun Aug 23 11:04:58 UTC 2020

Modified Files:
src/tests/lib/libc/gen: t_fpsetmask.c

Log Message:
Expect failure only when running under qemu's TCG CPU emulation, not
when running under hardware virtualization such as qemu -accel nvmm.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/tests/lib/libc/gen/t_fpsetmask.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/t_fpsetmask.c
diff -u src/tests/lib/libc/gen/t_fpsetmask.c:1.20 src/tests/lib/libc/gen/t_fpsetmask.c:1.21
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.20	Thu Apr 25 20:48:54 2019
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Sun Aug 23 11:04:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.20 2019/04/25 20:48:54 kamil Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.21 2020/08/23 11:04:58 gson Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -311,7 +311,7 @@ sigfpe(int s, siginfo_t *si, void *c)
 	\
 		FPU_PREREQ();		\
 	\
-		if (isQEMU())		\
+		if (isQEMU_TCG())	\
 			atf_tc_expect_fail("PR misc/44767");		\
 	\
 		m(t##_ops);		\



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

2020-08-23 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sun Aug 23 11:00:18 UTC 2020

Modified Files:
src/tests/lib/libc/gen: isqemu.h

Log Message:
Provide separate functions to check for running under qemu in general
and for running under qemu's built-in TCG CPU emulation (as opposed to
hardware virtualization via NVMM or KVM).


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/isqemu.h

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/isqemu.h
diff -u src/tests/lib/libc/gen/isqemu.h:1.4 src/tests/lib/libc/gen/isqemu.h:1.5
--- src/tests/lib/libc/gen/isqemu.h:1.4	Sat Jan  3 14:21:05 2015
+++ src/tests/lib/libc/gen/isqemu.h	Sun Aug 23 11:00:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: isqemu.h,v 1.4 2015/01/03 14:21:05 gson Exp $	*/
+/*	$NetBSD: isqemu.h,v 1.5 2020/08/23 11:00:18 gson Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -33,14 +33,36 @@
  */
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 
 static __inline bool
 isQEMU(void) {
+   struct devlistargs dla = {
+	   .l_devname = "qemufwcfg0",
+	   .l_childname = NULL,
+	   .l_children = 0,
+   };
+   int fd = open(DRVCTLDEV, O_RDONLY, 0);
+   if (fd == -1)
+	   return false;
+   if (ioctl(fd, DRVLISTDEV, ) == -1) {
+	   close(fd);
+	   return false;
+   }
+   close(fd);
+   return true;
+}
+
+static __inline bool
+isQEMU_TCG(void) {
 #if defined(__i386__) || defined(__x86_64__)
 	char name[1024];
 	size_t len = sizeof(name);



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

2020-07-02 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Fri Jul  3 03:13:10 UTC 2020

Modified Files:
src/tests/lib/libc/gen: t_syslog.c

Log Message:
Verify that PR lib/55041 is no longer an issue.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_syslog.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/t_syslog.c
diff -u src/tests/lib/libc/gen/t_syslog.c:1.2 src/tests/lib/libc/gen/t_syslog.c:1.3
--- src/tests/lib/libc/gen/t_syslog.c:1.2	Sun Mar 18 07:00:51 2012
+++ src/tests/lib/libc/gen/t_syslog.c	Fri Jul  3 03:13:10 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: t_syslog.c,v 1.2 2012/03/18 07:00:51 jruoho Exp $ */
+/*	$NetBSD: t_syslog.c,v 1.3 2020/07/03 03:13:10 jruoho Exp $ */
 
 /*-
- * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * Copyright (c) 2010, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -36,7 +36,6 @@
 ATF_TC(syslog_pthread);
 ATF_TC_HEAD(syslog_pthread, tc)
 {
-
 	atf_tc_set_md_var(tc, "descr", "Test that syslog(3) "
 	"works when linked to pthread(3) (PR lib/44248)");
 	atf_tc_set_md_var(tc, "timeout", "2");
@@ -47,10 +46,23 @@ ATF_TC_BODY(syslog_pthread, tc)
 	syslog(LOG_DEBUG, "from tests/lib/libc/gen/t_syslog");
 }
 
+ATF_TC(syslog_invalid_priority);
+ATF_TC_HEAD(syslog_invalid_priority, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test that syslog(3) does "
+	"not segfault from an invalid priority (PR lib/55041)");
+}
+
+ATF_TC_BODY(syslog_invalid_priority, tc)
+{
+	syslog(-1, "from tests/lib/libc/gen/t_syslog");
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
 	ATF_TP_ADD_TC(tp, syslog_pthread);
+	ATF_TP_ADD_TC(tp, syslog_invalid_priority);
 
 	return atf_no_error();
 }



CVS commit: src/tests/lib/libc/stdlib

2020-06-30 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Wed Jul  1 05:37:25 UTC 2020

Modified Files:
src/tests/lib/libc/stdlib: t_mktemp.c

Log Message:
Add basic tests for the rest of the mktemp(3) family of functions, including
a case for PR lib/55441.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdlib/t_mktemp.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/stdlib/t_mktemp.c
diff -u src/tests/lib/libc/stdlib/t_mktemp.c:1.1 src/tests/lib/libc/stdlib/t_mktemp.c:1.2
--- src/tests/lib/libc/stdlib/t_mktemp.c:1.1	Sat Jun 27 09:45:57 2020
+++ src/tests/lib/libc/stdlib/t_mktemp.c	Wed Jul  1 05:37:25 2020
@@ -1,11 +1,11 @@
-/* $NetBSD: t_mktemp.c,v 1.1 2020/06/27 09:45:57 jruoho Exp $ */
+/* $NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $ */
 
 /*-
- * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * Copyright (c) 2013, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * This code is derived from software contributed to The NetBSD Foundation
- * by Christos Zoulas.
+ * by Christos Zoulas and Jukka Ruohonen.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -29,16 +29,38 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_mktemp.c,v 1.1 2020/06/27 09:45:57 jruoho Exp $");
+__RCSID("$NetBSD: t_mktemp.c,v 1.2 2020/07/01 05:37:25 jruoho Exp $");
+
+#include 
 
 #include 
+#include 
+#include 
+#include 
 #include 
+#include 
+
+static int
+check_mode(struct stat sa, const int mode, const int dir)
+{
+
+	if (dir == 0 && S_ISREG(sa.st_mode) == 0)
+		return -1;
+
+	if (dir != 0 && S_ISDIR(sa.st_mode) == 0)
+		return -1;
+
+	if ((sa.st_mode & mode) == 0)
+		return -1;
+
+	return 0;
+}
 
 ATF_TC(mktemp_not_exist);
 ATF_TC_HEAD(mktemp_not_exist, tc)
 {
-	atf_tc_set_md_var(tc, "descr", "Test that mktemp does not fail on"
-	" a path that does not exist");
+	atf_tc_set_md_var(tc, "descr", "Test that mktemp(3)"
+	" does not fail on a path that does not exist");
 }
 
 ATF_TC_BODY(mktemp_not_exist, tc)
@@ -47,8 +69,198 @@ ATF_TC_BODY(mktemp_not_exist, tc)
 	ATF_REQUIRE(mktemp(template) != NULL);
 }
 
+ATF_TC(mktemp_large_template);
+ATF_TC_HEAD(mktemp_large_template, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "Test that mktemp "
+	"accepts arbitrarily large templates (PR lib/55441)");
+}
+
+ATF_TC_BODY(mktemp_large_template, tc)
+{
+	const char *path = "/tmp/mktemp.XX";
+	char template[PATH_MAX] = { 0 };
+	size_t i;
+
+	atf_tc_expect_fail("PR lib/55441");
+
+	ATF_REQUIRE(strcpy(template, path) != NULL);
+	ATF_REQUIRE(mktemp(template) != NULL);
+	ATF_REQUIRE(strlen(template) == strlen(path));
+	ATF_REQUIRE(strcmp(template, path) != 0);
+	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+
+	(void)memset(template, '\0', sizeof(template));
+	(void)strcpy(template, "/tmp/mktemp.");
+
+	for (i = 12; i < sizeof(template) - 1; i++)
+		template[i] = 'X';
+
+	ATF_REQUIRE(mktemp(template) != NULL);
+	ATF_REQUIRE(strlen(template) == sizeof(template) - 1);
+	ATF_REQUIRE(strcmp(template, path) != 0);
+	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+}
+
+ATF_TC(mkstemp_basic);
+ATF_TC_HEAD(mkstemp_basic, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "A basic test of mkstemp(3)");
+}
+
+ATF_TC_BODY(mkstemp_basic, tc)
+{
+	char template[] = "/tmp/mktemp.XX";
+	struct stat sa;
+	int fd;
+
+	(void)memset(, 0, sizeof(struct stat));
+
+	fd = mkstemp(template);
+
+	ATF_REQUIRE(fd != -1);
+	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+	ATF_REQUIRE(write(fd, "X", 1) == 1);
+	ATF_REQUIRE(fstat(fd, ) == 0);
+	ATF_REQUIRE(check_mode(sa, 0600, 0) == 0);
+	ATF_REQUIRE(close(fd) == 0);
+	ATF_REQUIRE(unlink(template) == 0);
+}
+
+ATF_TC(mkstemps_basic);
+ATF_TC_HEAD(mkstemps_basic, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "A basic test of mkstemps(3)");
+}
+
+ATF_TC_BODY(mkstemps_basic, tc)
+{
+	char template[] = "/tmp/mktemp.XXXyyy";
+	struct stat sa;
+	int fd;
+
+	(void)memset(, 0, sizeof(struct stat));
+
+	fd = mkstemps(template, 3);
+
+	ATF_REQUIRE(fd != -1);
+	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+
+	char *str = strchr(template, 'y');
+
+	ATF_REQUIRE(strcmp(str, "yyy") == 0);
+	ATF_REQUIRE(write(fd, "X", 1) == 1);
+	ATF_REQUIRE(fstat(fd, ) == 0);
+	ATF_REQUIRE(check_mode(sa, 0600, 0) == 0);
+	ATF_REQUIRE(close(fd) == 0);
+	ATF_REQUIRE(unlink(template) == 0);
+}
+
+ATF_TC(mkdtemp_basic);
+ATF_TC_HEAD(mkdtemp_basic, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "A basic test of mkdtemp(3)");
+}
+
+ATF_TC_BODY(mkdtemp_basic, tc)
+{
+	char template[] = "/tmp/mktemp.XX";
+	char *path = mkdtemp(template);
+	struct stat sa;
+
+	(void)memset(, 0, sizeof(struct stat));
+
+	ATF_REQUIRE(path != NULL);
+	ATF_REQUIRE(strncmp(template, "/tmp/mktemp.", 12) == 0);
+	ATF_REQUIRE(stat(path, ) == 0);
+	

CVS commit: src/tests/lib/libc/stdlib

2020-06-29 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Mon Jun 29 20:53:40 UTC 2020

Modified Files:
src/tests/lib/libc/stdlib: t_mbtowc.c

Log Message:
Avoid copyright issues and name the listed author as the copyright holder.

In a private email, Miloslav had agreed that if they had written the
test, then it can be licensed bsd-2-clause. I am going to assume this
is true as the file names Miloslav as the author.

This test was likely sent to tcsh (not netbsd) that had changed bug
report systems since.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/stdlib/t_mbtowc.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/stdlib/t_mbtowc.c
diff -u src/tests/lib/libc/stdlib/t_mbtowc.c:1.2 src/tests/lib/libc/stdlib/t_mbtowc.c:1.3
--- src/tests/lib/libc/stdlib/t_mbtowc.c:1.2	Sat Jun 27 10:19:43 2020
+++ src/tests/lib/libc/stdlib/t_mbtowc.c	Mon Jun 29 20:53:40 2020
@@ -1,22 +1,23 @@
-/*	$NetBSD: t_mbtowc.c,v 1.2 2020/06/27 10:19:43 jruoho Exp $ */
+/*	$NetBSD: t_mbtowc.c,v 1.3 2020/06/29 20:53:40 maya Exp $ */
 
 /*-
- * Copyright (c) 2005 The NetBSD Foundation, Inc.
+ * Copyright (c) 2005 Miloslav Trmac
  * 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
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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



CVS commit: src/tests/lib/libc

2020-06-29 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Mon Jun 29 14:22:11 UTC 2020

Modified Files:
src/tests/lib/libc/stdio: Makefile
src/tests/lib/libc/stdlib: Makefile

Log Message:
Use -Wl,--no-fatal-warnings for the mktemp(3) test.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/stdio/Makefile
cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libc/stdlib/Makefile

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/stdio/Makefile
diff -u src/tests/lib/libc/stdio/Makefile:1.13 src/tests/lib/libc/stdio/Makefile:1.14
--- src/tests/lib/libc/stdio/Makefile:1.13	Sat Jun 27 09:45:57 2020
+++ src/tests/lib/libc/stdio/Makefile	Mon Jun 29 14:22:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2020/06/27 09:45:57 jruoho Exp $
+# $NetBSD: Makefile,v 1.14 2020/06/29 14:22:11 jruoho Exp $
 
 .include 
 
@@ -15,6 +15,4 @@ TESTS_C+=	t_printf
 TESTS_C+=	t_scanf
 COPTS.t_printf.c += -Wno-format-nonliteral
 
-LDADD.t_mktemp+=	-Wl,--no-fatal-warnings
-
 .include 

Index: src/tests/lib/libc/stdlib/Makefile
diff -u src/tests/lib/libc/stdlib/Makefile:1.30 src/tests/lib/libc/stdlib/Makefile:1.31
--- src/tests/lib/libc/stdlib/Makefile:1.30	Sat Jun 27 10:14:10 2020
+++ src/tests/lib/libc/stdlib/Makefile	Mon Jun 29 14:22:11 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.30 2020/06/27 10:14:10 jruoho Exp $
+# $NetBSD: Makefile,v 1.31 2020/06/29 14:22:11 jruoho Exp $
 
 .include 
 
@@ -35,6 +35,7 @@ CPPFLAGS.t_strtod.c+=  -D__TEST_FENV
 LDADD.t_strtod=			-lm
 DPADD.t_strtod+=		${LIBM}
 
-LDADD.t_getenv_thread=		-lpthread
+LDADD.t_getenv_thread=	-lpthread
+LDADD.t_mktemp+=	-Wl,--no-fatal-warnings
 
 .include 



CVS commit: src/tests/lib/libc/stdlib

2020-06-27 Thread Jukka Ruohonen
Module Name:src
Committed By:   jruoho
Date:   Sat Jun 27 10:19:43 UTC 2020

Modified Files:
src/tests/lib/libc/stdlib: t_mbtowc.c

Log Message:
Add the default TNF copyright (2005), cf. PR misc/55419.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/stdlib/t_mbtowc.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/stdlib/t_mbtowc.c
diff -u src/tests/lib/libc/stdlib/t_mbtowc.c:1.1 src/tests/lib/libc/stdlib/t_mbtowc.c:1.2
--- src/tests/lib/libc/stdlib/t_mbtowc.c:1.1	Sat Jun 27 10:14:10 2020
+++ src/tests/lib/libc/stdlib/t_mbtowc.c	Sat Jun 27 10:19:43 2020
@@ -1,3 +1,30 @@
+/*	$NetBSD: t_mbtowc.c,v 1.2 2020/06/27 10:19:43 jruoho Exp $ */
+
+/*-
+ * Copyright (c) 2005 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.
+ */
 
 /* From: Miloslav Trmac  */
 



CVS commit: src/tests/lib/libc/sys

2020-06-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 24 04:47:10 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_core_wait.h

Log Message:
Fix core_dump_procinfo tests for powerpc, for which child process was
stalled indefinitely in trap instruction even after PT_CONTINUE.

For powerpc, program counter is not automatically incremented by trap
instruction. We cannot increment PC in the trap handler, which breaks
applications depending on this behavior, e.g., GDB.

Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC) to
PT_CONTINUE when child process traps itself.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_core_wait.h

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/sys/t_ptrace_core_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.2
--- src/tests/lib/libc/sys/t_ptrace_core_wait.h:1.1	Tue May  5 01:24:29 2020
+++ src/tests/lib/libc/sys/t_ptrace_core_wait.h	Wed Jun 24 04:47:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_core_wait.h,v 1.1 2020/05/05 01:24:29 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_core_wait.h,v 1.2 2020/06/24 04:47:10 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -207,7 +207,22 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
+#ifndef __powerpc__
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
+#else
+	/*
+	 * For powerpc, program counter is not automatically incremented by
+	 * a trap instruction. We cannot increment PC in the trap handler,
+	 * which breaks applications depending on this behavior, e.g., GDB.
+	 * Therefore, we need to pass (PC + 4) instead of (void *)1 (== PC)
+	 * to PT_CONTINUE here.
+	 */
+	struct reg r;
+
+	SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1);
+	SYSCALL_REQUIRE(
+	ptrace(PT_CONTINUE, child, (void *)(r.pc + 4), 0) != -1);
+#endif
 
 	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);



CVS commit: src/tests/lib/libc/sys

2020-06-22 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 22 12:21:03 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_signal_wait.h t_ptrace_wait.h

Log Message:
Work around QEMU bug #1668041 differently, by which floating-point
division by zero is not correctly trapped for i386 and amd64:

https://bugs.launchpad.net/qemu/+bug/1668041

Make trigger_fpe() cause integer division by zero for x86, and
floating-point one for other architectures. Also, assertions for
si_code in *_crash_fpe tests are commented out for now. They
should be cleaned up after the bug is fixed.

Now, *_crash_fpe tests are working also on powerpc.

Suggested by kamil.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_ptrace_signal_wait.h
cvs rdiff -u -r1.31 -r1.32 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_signal_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.3 src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.4
--- src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.3	Mon Jun 22 02:51:06 2020
+++ src/tests/lib/libc/sys/t_ptrace_signal_wait.h	Mon Jun 22 12:21:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_signal_wait.h,v 1.3 2020/06/22 02:51:06 rin Exp $	*/
+/*	$NetBSD: t_ptrace_signal_wait.h,v 1.4 2020/06/22 12:21:02 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -423,7 +423,7 @@ traceme_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -603,7 +603,7 @@ traceme_signalmasked_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -786,7 +786,7 @@ traceme_signalignored_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -1890,7 +1890,7 @@ unrelated_tracer_sees_crash(int sig, boo
 			info.psi_siginfo.si_code <= ILL_BADSTK);
 			break;
 		case SIGFPE:
-			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+// XXXQEMU		FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 			break;
 		case SIGBUS:
 			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.31 src/tests/lib/libc/sys/t_ptrace_wait.h:1.32
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.31	Mon Jun 22 02:51:06 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Mon Jun 22 12:21:02 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.31 2020/06/22 02:51:06 rin Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.32 2020/06/22 12:21:02 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -671,9 +671,6 @@ are_fpu_exceptions_supported(void)
 		return false;
 	return true;
 }
-#elif __powerpc__
-/* Integer division by zero do not trap on powerpc. */
-#define are_fpu_exceptions_supported() 0
 #else
 #define are_fpu_exceptions_supported() 1
 #endif
@@ -681,15 +678,28 @@ are_fpu_exceptions_supported(void)
 static void __used
 trigger_fpe(void)
 {
-	volatile int a = getpid();
-	volatile int b = atoi("0");
+#if __i386__ || __x86_64__
+	/*
+	 * XXX
+	 * Hack for QEMU bug #1668041, by which floating-point division by
+	 * zero is not trapped correctly. Also, assertions for si_code in
+	 * ptrace_signal_wait.h are commented out. Clean them up after the
+	 * bug is fixed.
+	 */
+	volatile int a, b;
+#else
+	volatile double a, b;
+#endif
+
+	a = getpid();
+	b = atoi("0");
 
 #ifdef __HAVE_FENV
 	feenableexcept(FE_ALL_EXCEPT);
 #endif
 
 	/* Division by zero causes CPU trap, translated to SIGFPE */
-	usleep(a / b);
+	usleep((int)(a / b));
 }
 
 static void __used



CVS commit: src/tests/lib/libc/sys

2020-06-21 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 22 02:51:07 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_signal_wait.h t_ptrace_wait.h

Log Message:
Turn trigger_fpe() back to integer division by zero for a while
until QEMU bug #1668041 is fixed:

https://bugs.launchpad.net/qemu/+bug/1668041

by which floating-point division by zero is not trapped correctly
both on amd64 and i386.

Skip *_crash_fpe tests on powerpc, where integer division by zero
is never trapped.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_signal_wait.h
cvs rdiff -u -r1.30 -r1.31 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_signal_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.2	Wed Jun 17 08:42:16 2020
+++ src/tests/lib/libc/sys/t_ptrace_signal_wait.h	Mon Jun 22 02:51:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_signal_wait.h,v 1.2 2020/06/17 08:42:16 rin Exp $	*/
+/*	$NetBSD: t_ptrace_signal_wait.h,v 1.3 2020/06/22 02:51:06 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -423,7 +423,7 @@ traceme_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -603,7 +603,7 @@ traceme_signalmasked_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -786,7 +786,7 @@ traceme_signalignored_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -1890,7 +1890,7 @@ unrelated_tracer_sees_crash(int sig, boo
 			info.psi_siginfo.si_code <= ILL_BADSTK);
 			break;
 		case SIGFPE:
-			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
+			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
 			break;
 		case SIGBUS:
 			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.30 src/tests/lib/libc/sys/t_ptrace_wait.h:1.31
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.30	Wed Jun 17 08:42:16 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Mon Jun 22 02:51:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.30 2020/06/17 08:42:16 rin Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.31 2020/06/22 02:51:06 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -671,6 +671,9 @@ are_fpu_exceptions_supported(void)
 		return false;
 	return true;
 }
+#elif __powerpc__
+/* Integer division by zero do not trap on powerpc. */
+#define are_fpu_exceptions_supported() 0
 #else
 #define are_fpu_exceptions_supported() 1
 #endif
@@ -678,14 +681,15 @@ are_fpu_exceptions_supported(void)
 static void __used
 trigger_fpe(void)
 {
-	volatile double a = getpid();
-	volatile double b = atoi("0");
+	volatile int a = getpid();
+	volatile int b = atoi("0");
 
 #ifdef __HAVE_FENV
 	feenableexcept(FE_ALL_EXCEPT);
 #endif
 
-	usleep((int)(a / b));
+	/* Division by zero causes CPU trap, translated to SIGFPE */
+	usleep(a / b);
 }
 
 static void __used



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

2020-06-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Sat Jun 20 07:30:09 UTC 2020

Modified Files:
src/tests/lib/libc/gen: t_siginfo.c

Log Message:
Skip sigbus_adraln for powerpc.

SIGBUS for unaligned accesses is not mandatory for powerpc;
most processors (not all, e.g., 403) can deal with that.


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/tests/lib/libc/gen/t_siginfo.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/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.39 src/tests/lib/libc/gen/t_siginfo.c:1.40
--- src/tests/lib/libc/gen/t_siginfo.c:1.39	Sat Feb 22 19:09:51 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Sat Jun 20 07:30:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.39 2020/02/22 19:09:51 kamil Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.40 2020/06/20 07:30:09 rin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -465,6 +465,15 @@ ATF_TC_BODY(sigbus_adraln, tc)
 		atf_tc_skip("No SIGBUS signal for unaligned accesses");
 #endif
 
+#ifdef __powerpc__
+	/*
+	 * SIGBUS is not mandatory for powerpc; most processors (not all)
+	 * can deal with unaligned accesses.
+	 */
+	atf_tc_skip("SIGBUS signal for unaligned accesses is "
+	"not mandatory for this architecture");
+#endif
+
 	/* m68k (except sun2) never issue SIGBUS (PR lib/49653),
 	 * same for armv8 or newer */
 	if (strcmp(MACHINE_ARCH, "m68k") == 0 ||



CVS commit: src/tests/lib/libc/sys

2020-06-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 17 22:07:21 UTC 2020

Modified Files:
src/tests/lib/libc/sys: Makefile

Log Message:
Fix build for vax; Compile t_ptrace_sigchld.c with -D__TEST_FENV.


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/tests/lib/libc/sys/Makefile

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/sys/Makefile
diff -u src/tests/lib/libc/sys/Makefile:1.64 src/tests/lib/libc/sys/Makefile:1.65
--- src/tests/lib/libc/sys/Makefile:1.64	Thu Apr 30 11:03:29 2020
+++ src/tests/lib/libc/sys/Makefile	Wed Jun 17 22:07:21 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.64 2020/04/30 11:03:29 ryo Exp $
+# $NetBSD: Makefile,v 1.65 2020/06/17 22:07:21 rin Exp $
 
 MKMAN=	no
 
@@ -111,6 +111,7 @@ CPPFLAGS.t_futex_ops.c		+= -I${.CURDIR}/
 CPPFLAGS.t_futex_robust.c	+= -I${.CURDIR}/../../../../lib
 
 CPPFLAGS.t_lwp_create.c		+= -D_KERNTYPES
+CPPFLAGS.t_ptrace_sigchld.c	+= -D__TEST_FENV
 CPPFLAGS.t_ptrace_wait.c	+= -D_KERNTYPES -D__TEST_FENV
 CPPFLAGS.t_ptrace_wait3.c	+= -D_KERNTYPES -D__TEST_FENV
 CPPFLAGS.t_ptrace_wait4.c	+= -D_KERNTYPES -D__TEST_FENV



CVS commit: src/tests/lib/libc/sys

2020-06-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 17 08:42:16 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_signal_wait.h t_ptrace_wait.h

Log Message:
Let trigger_fpe() cause floating-point divide by zero exception, instead of
integer one, which is not trapped for powerpc and aarch64.

Note that it is checked in lib/libc/gen/t_siginfo whether integer divide by
zero is interpreted as SIGFPE or not.

Now, all *_crash_fpe tests pass for powerpc, and nothing changes for amd64
at least.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_signal_wait.h
cvs rdiff -u -r1.29 -r1.30 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_signal_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.2
--- src/tests/lib/libc/sys/t_ptrace_signal_wait.h:1.1	Mon May  4 23:49:31 2020
+++ src/tests/lib/libc/sys/t_ptrace_signal_wait.h	Wed Jun 17 08:42:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_signal_wait.h,v 1.1 2020/05/04 23:49:31 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_signal_wait.h,v 1.2 2020/06/17 08:42:16 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -423,7 +423,7 @@ traceme_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -603,7 +603,7 @@ traceme_signalmasked_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -786,7 +786,7 @@ traceme_signalignored_crash(int sig)
 		info.psi_siginfo.si_code <= ILL_BADSTK);
 		break;
 	case SIGFPE:
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 		break;
 	case SIGBUS:
 		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, BUS_ADRERR);
@@ -1890,7 +1890,7 @@ unrelated_tracer_sees_crash(int sig, boo
 			info.psi_siginfo.si_code <= ILL_BADSTK);
 			break;
 		case SIGFPE:
-			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_INTDIV);
+			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, FPE_FLTDIV);
 			break;
 		case SIGBUS:
 			FORKEE_ASSERT_EQ(info.psi_siginfo.si_code, BUS_ADRERR);

Index: src/tests/lib/libc/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.29 src/tests/lib/libc/sys/t_ptrace_wait.h:1.30
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.29	Wed Jun 17 08:23:18 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Wed Jun 17 08:42:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.29 2020/06/17 08:23:18 rin Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.30 2020/06/17 08:42:16 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -678,15 +678,14 @@ are_fpu_exceptions_supported(void)
 static void __used
 trigger_fpe(void)
 {
-	volatile int a = getpid();
-	volatile int b = atoi("0");
+	volatile double a = getpid();
+	volatile double b = atoi("0");
 
 #ifdef __HAVE_FENV
 	feenableexcept(FE_ALL_EXCEPT);
 #endif
 
-	/* Division by zero causes CPU trap, translated to SIGFPE */
-	usleep(a / b);
+	usleep((int)(a / b));
 }
 
 static void __used



CVS commit: src/tests/lib/libc/sys

2020-06-17 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 17 08:23:18 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.h

Log Message:
Regardless of __HAVE_FENV, include , which itself defines __HAVE_FENV.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_wait.h:1.28 src/tests/lib/libc/sys/t_ptrace_wait.h:1.29
--- src/tests/lib/libc/sys/t_ptrace_wait.h:1.28	Tue May  5 00:50:39 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.h	Wed Jun 17 08:23:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.h,v 1.28 2020/05/05 00:50:39 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.h,v 1.29 2020/06/17 08:23:18 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -654,9 +654,7 @@ trigger_ill(void)
 #endif
 }
 
-#ifdef __HAVE_FENV
 #include 
-#endif
 
 #if (__arm__ && !__SOFTFP__) || __aarch64__
 #include  /* only need for ARM Cortex/Neon hack */



CVS commit: src/tests/lib/libc/sys

2020-06-15 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 15 13:57:45 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_wait_noproc.c

Log Message:
language sensitivity


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_wait_noproc.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/sys/t_wait_noproc.c
diff -u src/tests/lib/libc/sys/t_wait_noproc.c:1.5 src/tests/lib/libc/sys/t_wait_noproc.c:1.6
--- src/tests/lib/libc/sys/t_wait_noproc.c:1.5	Wed Nov  9 12:50:19 2016
+++ src/tests/lib/libc/sys/t_wait_noproc.c	Mon Jun 15 09:57:45 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $ */
+/* $NetBSD: t_wait_noproc.c,v 1.6 2020/06/15 13:57:45 christos Exp $ */
 
 /*-
  * Copyright (c) 2016 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_wait_noproc.c,v 1.5 2016/11/09 17:50:19 kamil Exp $");
+__RCSID("$NetBSD: t_wait_noproc.c,v 1.6 2020/06/15 13:57:45 christos Exp $");
 
 #include 
 #include 
@@ -141,7 +141,7 @@ get_options6(size_t pos)
 	 */
 
 	const int matrix[] = {
-		WNOWAIT,	/* First in order to blacklist it easily */
+		WNOWAIT,	/* First in order to exclude it easily */
 		WEXITED,
 		WUNTRACED,
 		WSTOPPED,	/* SUS compatibility, equal to WUNTRACED */



CVS commit: src/tests/lib/libc/sys

2020-06-08 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue Jun  9 00:28:57 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Add fork/vfork/posix_spawn tests for processes within pgrp

New tests:
 - fork_setpgid
 - vfork_setpgid
 - posix_spawn_setpgid
 - unrelated_tracer_fork_setpgid
 - unrelated_tracer_vfork_setpgid
 - unrelated_tracer_posix_spawn_setpgid

These tests trigger a kernel assert for pg_jobc going negative.

The tests are temporarily skipped.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.6 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.7
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.6	Sat May 16 23:10:26 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Tue Jun  9 00:28:57 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.6 2020/05/16 23:10:26 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.7 2020/06/09 00:28:57 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 
 static void
 fork_body(const char *fn, bool trackspawn, bool trackfork, bool trackvfork,
-bool trackvforkdone)
+bool trackvforkdone, bool newpgrp)
 {
 	const int exitval = 5;
 	const int exitval2 = 0; /* This matched exit status from /bin/echo */
@@ -46,9 +46,17 @@ fork_body(const char *fn, bool trackspaw
 
 	char * const arg[] = { __UNCONST("/bin/echo"), NULL };
 
+	if (newpgrp)
+		atf_tc_skip("kernel panic (pg_jobc going negative)");
+
 	DPRINTF("Before forking process PID=%d\n", getpid());
 	SYSCALL_REQUIRE((child = fork()) != -1);
 	if (child == 0) {
+		if (newpgrp) {
+			DPRINTF("Before entering new process group");
+			setpgid(0, 0);
+		}
+
 		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
 		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
 
@@ -232,24 +240,28 @@ fork_body(const char *fn, bool trackspaw
 	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
 }
 
-#define FORK_TEST(name,fun,tspawn,tfork,tvfork,tvforkdone)		\
+#define FORK_TEST2(name,fun,tspawn,tfork,tvfork,tvforkdone,newpgrp)	\
 ATF_TC(name);\
 ATF_TC_HEAD(name, tc)			\
 {	\
 	atf_tc_set_md_var(tc, "descr", "Verify " fun "() "		\
-	"called with 0%s%s%s%s in EVENT_MASK",			\
+	"called with 0%s%s%s%s in EVENT_MASK%s",			\
 	tspawn ? "|PTRACE_POSIX_SPAWN" : "",			\
 	tfork ? "|PTRACE_FORK" : "",\
 	tvfork ? "|PTRACE_VFORK" : "",\
-	tvforkdone ? "|PTRACE_VFORK_DONE" : "");			\
+	tvforkdone ? "|PTRACE_VFORK_DONE" : "",			\
+	newpgrp ? " and the traced processes call setpgrp(0,0)":"");\
 }	\
 	\
 ATF_TC_BODY(name, tc)			\
 {	\
 	\
-	fork_body(fun, tspawn, tfork, tvfork, tvforkdone);		\
+	fork_body(fun, tspawn, tfork, tvfork, tvforkdone, newpgrp);	\
 }
 
+#define FORK_TEST(name,fun,tspawn,tfork,tvfork,tvforkdone)		\
+	FORK_TEST2(name,fun,tspawn,tfork,tvfork,tvforkdone,false)
+
 FORK_TEST(fork1, "fork", false, false, false, false)
 #if defined(TWAIT_HAVE_PID)
 FORK_TEST(fork2, "fork", false, true, false, false)
@@ -275,6 +287,10 @@ FORK_TEST(fork15, "fork", true, false, t
 FORK_TEST(fork16, "fork", true, true, true, true)
 #endif
 
+#if defined(TWAIT_HAVE_PID)
+FORK_TEST2(fork_setpgid, "fork", true, true, true, true, true)
+#endif
+
 FORK_TEST(vfork1, "vfork", false, false, false, false)
 #if defined(TWAIT_HAVE_PID)
 FORK_TEST(vfork2, "vfork", false, true, false, false)
@@ -300,6 +316,10 @@ FORK_TEST(vfork15, "vfork", true, false,
 FORK_TEST(vfork16, "vfork", true, true, true, true)
 #endif
 
+#if defined(TWAIT_HAVE_PID)
+FORK_TEST2(vfork_setpgid, "vfork", true, true, true, true, true)
+#endif
+
 FORK_TEST(posix_spawn1, "spawn", false, false, false, false)
 FORK_TEST(posix_spawn2, "spawn", false, true, false, false)
 FORK_TEST(posix_spawn3, "spawn", false, false, true, false)
@@ -319,12 +339,16 @@ FORK_TEST(posix_spawn15, "spawn", true, 
 FORK_TEST(posix_spawn16, "spawn", true, true, true, true)
 #endif
 
+#if defined(TWAIT_HAVE_PID)
+FORK_TEST2(posix_spawn_setpgid, "spawn", true, true, true, true, true)
+#endif
+
 /// 
 
 #if defined(TWAIT_HAVE_PID)
 static void
 unrelated_tracer_fork_body(const char *fn, bool trackspawn, bool trackfork,
-bool trackvfork, bool trackvforkdone)
+bool trackvfork, bool trackvforkdone, bool newpgrp)
 {
 	const int sigval = SIGSTOP;
 	struct msg_fds parent_tracee, parent_tracer;
@@ -346,10 +370,18 @@ unrelated_tracer_fork_body(const char *f
 
 	char * const arg[] = { __UNCONST("/bin/echo"), NULL };
 
+	if (newpgrp)
+		atf_tc_skip("kernel panic (pg_jobc going negative)");
+
 	DPRINTF("Spawn tracee\n");
 	

CVS commit: src/tests/lib/libc/sys

2020-06-06 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Sat Jun  6 18:11:21 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_lwp_create.c

Log Message:
Add a test case to ensure that _lwp_create() fails with the
expected error code when a bad new-lwp-id pointer is passed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_lwp_create.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/sys/t_lwp_create.c
diff -u src/tests/lib/libc/sys/t_lwp_create.c:1.2 src/tests/lib/libc/sys/t_lwp_create.c:1.3
--- src/tests/lib/libc/sys/t_lwp_create.c:1.2	Tue May 22 09:23:39 2012
+++ src/tests/lib/libc/sys/t_lwp_create.c	Sat Jun  6 18:11:21 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_lwp_create.c,v 1.2 2012/05/22 09:23:39 martin Exp $ */
+/* $NetBSD: t_lwp_create.c,v 1.3 2020/06/06 18:11:21 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -119,6 +119,30 @@ ATF_TC_BODY(lwp_create_works, tc)
 	ATF_REQUIRE(lid == the_lwp_id);
 }
 
+ATF_TC(lwp_create_bad_lid_ptr);
+ATF_TC_HEAD(lwp_create_bad_lid_ptr, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Verify _lwp_create() fails as expected with bad lid pointer");
+}
+
+ATF_TC_BODY(lwp_create_bad_lid_ptr, tc)
+{
+	ucontext_t uc;
+	int error;
+	int serrno;
+	void *stack;
+	static const size_t ssize = 16*1024;
+
+	stack = malloc(ssize);
+	_lwp_makecontext(, lwp_main_func, NULL, NULL, stack, ssize);
+
+	error = _lwp_create(, 0, NULL);
+	serrno = errno;
+	ATF_REQUIRE(error == -1);
+	ATF_REQUIRE(serrno == EFAULT);
+}
+
 INVALID_UCONTEXT(generic, no_uc_cpu, "not setting cpu registers")
 	uc->uc_flags &= ~_UC_CPU;
 }
@@ -206,6 +230,7 @@ INVALID_UCONTEXT(vax, psl_cm, "setting C
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, lwp_create_works);
+	ATF_TP_ADD_TC(tp, lwp_create_bad_lid_ptr);
 	ATF_TP_ADD_TC(tp, lwp_create_generic_fail_no_uc_cpu);
 #ifdef __alpha__
 	ATF_TP_ADD_TC(tp, lwp_create_alpha_fail_pslset);



CVS commit: src/tests/lib/libc/net

2020-05-31 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon Jun  1 01:03:21 UTC 2020

Modified Files:
src/tests/lib/libc/net: Makefile h_nsd_recurse.c

Log Message:
Avoid redefining _REENTRANT under sanitizers

Switch away from -Wno-macro-redefined which was Clang specific.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/tests/lib/libc/net/Makefile
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/net/h_nsd_recurse.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/net/Makefile
diff -u src/tests/lib/libc/net/Makefile:1.13 src/tests/lib/libc/net/Makefile:1.14
--- src/tests/lib/libc/net/Makefile:1.13	Sat Feb  8 00:11:18 2020
+++ src/tests/lib/libc/net/Makefile	Mon Jun  1 01:03:21 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.13 2020/02/08 00:11:18 kamil Exp $
+# $NetBSD: Makefile,v 1.14 2020/06/01 01:03:21 kamil Exp $
 
 .include 
 
@@ -41,8 +41,4 @@ LDADD.h_nsd_recurse+=	-lpthread
 
 CLEANFILES+=	aton_ether_subr.c
 
-.if ${MKSANITIZER:Uno} == "yes" || ${MKLIBCSANITIZER:Uno} == "yes"
-COPTS.h_nsd_recurse.c+=	-Wno-macro-redefined # _REENTRANT redefined
-.endif
-
 .include 

Index: src/tests/lib/libc/net/h_nsd_recurse.c
diff -u src/tests/lib/libc/net/h_nsd_recurse.c:1.2 src/tests/lib/libc/net/h_nsd_recurse.c:1.3
--- src/tests/lib/libc/net/h_nsd_recurse.c:1.2	Thu Jan 13 02:24:51 2011
+++ src/tests/lib/libc/net/h_nsd_recurse.c	Mon Jun  1 01:03:21 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: h_nsd_recurse.c,v 1.2 2011/01/13 02:24:51 pgoyette Exp $ */
+/*	$NetBSD: h_nsd_recurse.c,v 1.3 2020/06/01 01:03:21 kamil Exp $ */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -32,9 +32,11 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: h_nsd_recurse.c,v 1.2 2011/01/13 02:24:51 pgoyette Exp $");
+__RCSID("$NetBSD: h_nsd_recurse.c,v 1.3 2020/06/01 01:03:21 kamil Exp $");
 
+#ifndef	_REENTRANT
 #define	_REENTRANT
+#endif
 
 #include 
 #include 



CVS commit: src/tests/lib/libc/sys

2020-05-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 16 23:10:26 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Ignore interception of SIGCHLD signals in the debugger

Set SIGPASS for SIGCHLD for the traced child in the following tests:
 - unrelated_tracer_fork*
 - unrelated_tracer_vfork*
 - unrelated_tracer_posix_spawn*

There is a race that SIGCHLD might be blocked during forking and dropped.

PR/55241 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.5 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.6
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.5	Sat May 16 22:07:06 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Sat May 16 23:10:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.5 2020/05/16 22:07:06 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.6 2020/05/16 23:10:26 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -337,6 +337,7 @@ unrelated_tracer_fork_body(const char *f
 	int status;
 #endif
 
+	sigset_t set;
 	struct ptrace_siginfo info;
 	ptrace_state_t state;
 	const int slen = sizeof(state);
@@ -453,6 +454,21 @@ unrelated_tracer_fork_body(const char *f
 		SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, tracee, , elen)
 		!= -1);
 
+		/*
+		 * Ignore interception of the SIGCHLD signals.
+		 *
+		 * SIGCHLD once blocked is discarded by the kernel as it has the
+		 * SA_IGNORE property. During the fork(2) operation all signals
+		 * can be shortly blocked and missed (unless there is a
+		 * registered signal handler in the traced child). This leads to
+		 * a race in this test if there would be an intention to catch
+		 * SIGCHLD.
+		 */
+		sigemptyset();
+		sigaddset(, SIGCHLD);
+		SYSCALL_REQUIRE(ptrace(PT_SET_SIGPASS, tracee, ,
+		sizeof(set)) != -1);
+
 		DPRINTF("Before resuming the child process where it left off "
 		"and without signal to be sent\n");
 		SYSCALL_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
@@ -559,16 +575,6 @@ unrelated_tracer_fork_body(const char *f
 			wpid = TWAIT_GENERIC(tracee2, , 0));
 		}
 
-		DPRINTF("Before calling %s() for the tracee - expected stopped "
-		"SIGCHLD\n", TWAIT_FNAME);
-		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, , 0), tracee);
-
-		validate_status_stopped(status, SIGCHLD);
-
-		DPRINTF("Before resuming the tracee process where it left off and "
-		"without signal to be sent\n");
-		SYSCALL_REQUIRE(ptrace(PT_CONTINUE, tracee, (void *)1, 0) != -1);
-
 		DPRINTF("Before calling %s() for the tracee - expected exited\n",
 		TWAIT_FNAME);
 		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(tracee, , 0), tracee);



CVS commit: src/tests/lib/libc/sys

2020-05-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 16 22:07:06 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Fix typo in test names

Noted by 


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.4 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.5
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.4	Sat May 16 19:08:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Sat May 16 22:07:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.4 2020/05/16 19:08:20 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.5 2020/05/16 22:07:06 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -1600,14 +1600,14 @@ ATF_TC_BODY(name, tc)			\
 	fork2_body(fn, masked, ignored);\
 }
 
-FORK2_TEST(posix_spawn_singalmasked, "spawn", true, false)
-FORK2_TEST(posix_spawn_singalignored, "spawn", false, true)
-FORK2_TEST(fork_singalmasked, "fork", true, false)
-FORK2_TEST(fork_singalignored, "fork", false, true)
-FORK2_TEST(vfork_singalmasked, "vfork", true, false)
-FORK2_TEST(vfork_singalignored, "vfork", false, true)
-FORK2_TEST(vforkdone_singalmasked, "vforkdone", true, false)
-FORK2_TEST(vforkdone_singalignored, "vforkdone", false, true)
+FORK2_TEST(posix_spawn_signalmasked, "spawn", true, false)
+FORK2_TEST(posix_spawn_signalignored, "spawn", false, true)
+FORK2_TEST(fork_signalmasked, "fork", true, false)
+FORK2_TEST(fork_signalignored, "fork", false, true)
+FORK2_TEST(vfork_signalmasked, "vfork", true, false)
+FORK2_TEST(vfork_signalignored, "vfork", false, true)
+FORK2_TEST(vforkdone_signalmasked, "vforkdone", true, false)
+FORK2_TEST(vforkdone_signalignored, "vforkdone", false, true)
 #endif
 
 #define ATF_TP_ADD_TCS_PTRACE_WAIT_FORK() \
@@ -1725,11 +1725,11 @@ FORK2_TEST(vforkdone_singalignored, "vfo
 	ATF_TP_ADD_TC_HAVE_PID(tp, unrelated_tracer_vfork_kill_vforkerdone); \
 	ATF_TP_ADD_TC(tp, traceme_vfork_fork); \
 	ATF_TP_ADD_TC(tp, traceme_vfork_vfork); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, posix_spawn_singalmasked); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, posix_spawn_singalignored); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, fork_singalmasked); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, fork_singalignored); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, vfork_singalmasked); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, vfork_singalignored); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, vforkdone_singalmasked); \
-	ATF_TP_ADD_TC_HAVE_PID(tp, vforkdone_singalignored);
+	ATF_TP_ADD_TC_HAVE_PID(tp, posix_spawn_signalmasked); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, posix_spawn_signalignored); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, fork_signalmasked); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, fork_signalignored); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, vfork_signalmasked); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, vfork_signalignored); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, vforkdone_signalmasked); \
+	ATF_TP_ADD_TC_HAVE_PID(tp, vforkdone_signalignored);



CVS commit: src/tests/lib/libc/sys

2020-05-16 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat May 16 19:08:20 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Ignore interception of SIGCHLD signals in the debugger

Set SIGPASS for SIGCHLD for the traced child in the following tests:

 - posix_spawn_singalmasked
 - posix_spawn_singalignored
 - fork_singalmasked
 - fork_singalignored
 - vfork_singalmasked
 - vfork_singalignored
 - vforkdone_singalmasked
 - vforkdone_singalignored

There is a race that SIGCHLD might be blocked during forking and dropped.

PR/55241 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.3 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.4
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.3	Thu May 14 19:21:35 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Sat May 16 19:08:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.3 2020/05/14 19:21:35 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.4 2020/05/16 19:08:20 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -1250,6 +1250,7 @@ fork2_body(const char *fn, bool masked, 
 
 	int name[6];
 	const size_t namelen = __arraycount(name);
+	sigset_t set;
 	ki_sigset_t kp_sigmask;
 	ki_sigset_t kp_sigignore;
 
@@ -1341,6 +1342,19 @@ fork2_body(const char *fn, bool masked, 
 		event.pe_set_event |= PTRACE_VFORK_DONE;
 	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
 
+	/*
+	 * Ignore interception of the SIGCHLD signals.
+	 *
+	 * SIGCHLD once blocked is discarded by the kernel as it has the
+	 * SA_IGNORE property. During the fork(2) operation all signals can be
+	 * shortly blocked and missed (unless there is a registered signal
+	 * handler in the traced child). This leads to a race in this test if
+	 * there would be an intention to catch SIGCHLD.
+	 */
+	sigemptyset();
+	sigaddset(, SIGCHLD);
+	SYSCALL_REQUIRE(ptrace(PT_SET_SIGPASS, child, , sizeof(set)) != -1);
+
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -1560,16 +1574,6 @@ fork2_body(const char *fn, bool masked, 
 		wpid = TWAIT_GENERIC(child2, , 0));
 	}
 
-	DPRINTF("Before calling %s() for the child - expected stopped "
-	"SIGCHLD\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGCHLD);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
 	DPRINTF("Before calling %s() for the child - expected exited\n",
 	TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);



CVS commit: src/tests/lib/libc/sys

2020-05-14 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Thu May 14 19:21:35 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Ignore interception of the SIGCHLD signals.

SIGCHLD once blocked is discarded by the kernel as it has the
SA_IGNORE property. During the fork(2) operation all signals can be
shortly blocked and missed (unless there is a registered signal
handler in the traced child). This leads to a race in this test if
there would be an intention to catch SIGCHLD.

Fixes PR lib/55241 by Andreas Gustafsson


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2	Mon May 11 20:58:48 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Thu May 14 19:21:35 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.2 2020/05/11 20:58:48 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.3 2020/05/14 19:21:35 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -38,6 +38,7 @@ fork_body(const char *fn, bool trackspaw
 #if defined(TWAIT_HAVE_STATUS)
 	int status;
 #endif
+	sigset_t set;
 	ptrace_state_t state;
 	const int slen = sizeof(state);
 	ptrace_event_t event;
@@ -98,6 +99,19 @@ fork_body(const char *fn, bool trackspaw
 		event.pe_set_event |= PTRACE_VFORK_DONE;
 	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
 
+	/*
+	 * Ignore interception of the SIGCHLD signals.
+	 *
+	 * SIGCHLD once blocked is discarded by the kernel as it has the
+	 * SA_IGNORE property. During the fork(2) operation all signals can be
+	 * shortly blocked and missed (unless there is a registered signal
+	 * handler in the traced child). This leads to a race in this test if
+	 * there would be an intention to catch SIGCHLD.
+	 */
+	sigemptyset();
+	sigaddset(, SIGCHLD);
+	SYSCALL_REQUIRE(ptrace(PT_SET_SIGPASS, child, , sizeof(set)) != -1);
+
 	DPRINTF("Before resuming the child process where it left off and "
 	"without signal to be sent\n");
 	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
@@ -207,16 +221,6 @@ fork_body(const char *fn, bool trackspaw
 	}
 #endif
 
-	DPRINTF("Before calling %s() for the child - expected stopped "
-	"SIGCHLD\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGCHLD);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
 	DPRINTF("Before calling %s() for the child - expected exited\n",
 	TWAIT_FNAME);
 	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);



CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 21:18:11 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_clone_wait.h

Log Message:
Fix potential race in ptrace(2) clone(2) tests

Instead of comparing old and new signal mask, just after the cloning
operation, check whether the expected signal is still masked and in
another test whether it is still ignored.

Catch up after t_ptrace_fork_wait.h r. 1.2.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_clone_wait.h

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/sys/t_ptrace_clone_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2	Mon May  4 22:24:31 2020
+++ src/tests/lib/libc/sys/t_ptrace_clone_wait.h	Mon May 11 21:18:11 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_clone_wait.h,v 1.2 2020/05/04 22:24:31 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_clone_wait.h,v 1.3 2020/05/11 21:18:11 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -414,11 +414,8 @@ clone_body2(int flags, bool masked, bool
 
 	FORKEE_ASSERT_EQ(sysctl(name, namelen, , , NULL, 0), 0);
 
-	if (masked)
-		kp_sigmask = kp.p_sigmask;
-
-	if (ignored)
-		kp_sigignore = kp.p_sigignore;
+	kp_sigmask = kp.p_sigmask;
+	kp_sigignore = kp.p_sigignore;
 
 	DPRINTF("Set PTRACE_FORK | PTRACE_VFORK | PTRACE_VFORK_DONE in "
 	"EVENT_MASK for the child %d\n", child);
@@ -451,8 +448,8 @@ clone_body2(int flags, bool masked, bool
 		kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
 		kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
 
-		ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-		sizeof(kp_sigmask)));
+		ATF_REQUIRE(sigismember((sigset_t *)_sigmask,
+			SIGTRAP));
 	}
 
 	if (ignored) {
@@ -468,8 +465,8 @@ clone_body2(int flags, bool masked, bool
 		kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
 		kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
 
-		ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-		sizeof(kp_sigignore)));
+		ATF_REQUIRE(sigismember((sigset_t *)_sigignore,
+			SIGTRAP));
 	}
 
 	SYSCALL_REQUIRE(
@@ -510,8 +507,8 @@ clone_body2(int flags, bool masked, bool
 		kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
 		kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
 
-		ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-		sizeof(kp_sigmask)));
+		ATF_REQUIRE(sigismember((sigset_t *)_sigmask,
+			SIGTRAP));
 	}
 
 	if (ignored) {
@@ -527,8 +524,8 @@ clone_body2(int flags, bool masked, bool
 		kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
 		kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
 
-		ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-		sizeof(kp_sigignore)));
+		ATF_REQUIRE(sigismember((sigset_t *)_sigignore,
+			SIGTRAP));
 	}
 
 	SYSCALL_REQUIRE(



CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 20:58:48 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_fork_wait.h

Log Message:
Fix race in fork_singalmasked

ELF RTLD after rtld.c r. 1.204 introduced locking that wraps the fork
syscall. This locking changes signal mask of the calling process during
the forking process.

Instead of comparing old and new signal mask, just after the forking
operation, check whether the expected signal is still masked and in
another test whether it is still ignored.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_fork_wait.h

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/sys/t_ptrace_fork_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.2
--- src/tests/lib/libc/sys/t_ptrace_fork_wait.h:1.1	Mon May  4 22:34:22 2020
+++ src/tests/lib/libc/sys/t_ptrace_fork_wait.h	Mon May 11 20:58:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_fork_wait.h,v 1.1 2020/05/04 22:34:22 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_fork_wait.h,v 1.2 2020/05/11 20:58:48 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2020 The NetBSD Foundation, Inc.
@@ -1318,11 +1318,8 @@ fork2_body(const char *fn, bool masked, 
 
 	FORKEE_ASSERT_EQ(sysctl(name, namelen, , , NULL, 0), 0);
 
-	if (masked)
-		kp_sigmask = kp.p_sigmask;
-
-	if (ignored)
-		kp_sigignore = kp.p_sigignore;
+	kp_sigmask = kp.p_sigmask;
+	kp_sigignore = kp.p_sigignore;
 
 	DPRINTF("Set 0%s%s%s%s in EVENT_MASK for the child %d\n",
 	strcmp(fn, "spawn") == 0 ? "|PTRACE_POSIX_SPAWN" : "",
@@ -1368,8 +1365,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
 			kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-			sizeof(kp_sigmask)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigmask,
+			SIGTRAP));
 		}
 
 		if (ignored) {
@@ -1385,8 +1382,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
 			kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-			sizeof(kp_sigignore)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigignore,
+			SIGTRAP));
 		}
 
 		SYSCALL_REQUIRE(
@@ -1431,8 +1428,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
 			kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-			sizeof(kp_sigmask)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigmask,
+			SIGTRAP));
 		}
 
 		if (ignored) {
@@ -1448,8 +1445,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
 			kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-			sizeof(kp_sigignore)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigignore,
+			SIGTRAP));
 		}
 
 		SYSCALL_REQUIRE(
@@ -1510,8 +1507,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
 			kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-			sizeof(kp_sigmask)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigmask,
+			SIGTRAP));
 		}
 
 		if (ignored) {
@@ -1527,8 +1524,8 @@ fork2_body(const char *fn, bool masked, 
 			kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
 			kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
 
-			ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-			sizeof(kp_sigignore)));
+			ATF_REQUIRE(sigismember((sigset_t *)_sigignore,
+			SIGTRAP));
 		}
 
 		SYSCALL_REQUIRE(



CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 12:17:57 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_register_wait.h

Log Message:
Simplify previous

Emit SIGKILL without a loop and without checking for exact process status
once it is collected.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_register_wait.h

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/sys/t_ptrace_register_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2 src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.3
--- src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2	Mon May 11 11:03:15 2020
+++ src/tests/lib/libc/sys/t_ptrace_register_wait.h	Mon May 11 12:17:57 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: t_ptrace_register_wait.h,v 1.2 2020/05/11 11:03:15 kamil Exp $   */
+/*  $NetBSD: t_ptrace_register_wait.h,v 1.3 2020/05/11 12:17:57 kamil Exp $   */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -136,19 +136,13 @@ access_regs(const char *regset, const ch
 	if (strstr(aux, "unaligned") != NULL) {
 		DPRINTF("Before resuming the child process where it left off "
 		"and without signal to be sent\n");
-		for (;;) {
-			errno = 0;
-			if (ptrace(PT_KILL, child, NULL, 0) == 0)
-break;
-			ATF_REQUIRE_EQ(errno, ESRCH);
-		}
+
+		ptrace(PT_KILL, child, NULL, 0);
 
 		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),
 		child);
 
-		validate_status_signaled(status, SIGKILL, 0);
-
 		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 		TWAIT_REQUIRE_FAILURE(ECHILD,
 		wpid = TWAIT_GENERIC(child, , 0));



CVS commit: src/tests/lib/libc/sys

2020-05-11 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May 11 11:03:15 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_register_wait.h

Log Message:
Do not fail when trying to kill a dying process

A dying process can disappear for a while. Rather than aborting, retry
sending SIGKILL to it.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_register_wait.h

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/sys/t_ptrace_register_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.2
--- src/tests/lib/libc/sys/t_ptrace_register_wait.h:1.1	Mon May  4 20:55:48 2020
+++ src/tests/lib/libc/sys/t_ptrace_register_wait.h	Mon May 11 11:03:15 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: t_ptrace_register_wait.h,v 1.1 2020/05/04 20:55:48 kamil Exp $   */
+/*  $NetBSD: t_ptrace_register_wait.h,v 1.2 2020/05/11 11:03:15 kamil Exp $   */
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -136,7 +136,12 @@ access_regs(const char *regset, const ch
 	if (strstr(aux, "unaligned") != NULL) {
 		DPRINTF("Before resuming the child process where it left off "
 		"and without signal to be sent\n");
-		SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
+		for (;;) {
+			errno = 0;
+			if (ptrace(PT_KILL, child, NULL, 0) == 0)
+break;
+			ATF_REQUIRE_EQ(errno, ESRCH);
+		}
 
 		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
 		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),



CVS commit: src/tests/lib/libc/sys

2020-05-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed May  6 05:14:27 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_futex_ops.c

Log Message:
Fix a bug in the futex_wake_highest_pri test case.  Still fails as
expected.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/sys/t_futex_ops.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/sys/t_futex_ops.c
diff -u src/tests/lib/libc/sys/t_futex_ops.c:1.4 src/tests/lib/libc/sys/t_futex_ops.c:1.5
--- src/tests/lib/libc/sys/t_futex_ops.c:1.4	Mon May  4 15:09:34 2020
+++ src/tests/lib/libc/sys/t_futex_ops.c	Wed May  6 05:14:27 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_futex_ops.c,v 1.4 2020/05/04 15:09:34 thorpej Exp $ */
+/* $NetBSD: t_futex_ops.c,v 1.5 2020/05/06 05:14:27 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2019, 2020\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_futex_ops.c,v 1.4 2020/05/04 15:09:34 thorpej Exp $");
+__RCSID("$NetBSD: t_futex_ops.c,v 1.5 2020/05/06 05:14:27 thorpej Exp $");
 
 #include 
 #include 
@@ -1416,8 +1416,8 @@ do_test_wake_highest_pri(void)
 	lwp_data[1].block_val = 0;
 	lwp_data[1].bitset = 0;
 	lwp_data[1].wait_op = FUTEX_WAIT;
-	ATF_REQUIRE(_lwp_create(_data[0].context, 0,
-_data[0].lwpid) == 0);
+	ATF_REQUIRE(_lwp_create(_data[1].context, 0,
+_data[1].lwpid) == 0);
 
 	for (tries = 0; tries < 5; tries++) {
 		membar_sync();



CVS commit: src/tests/lib/libc/sys

2020-05-05 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 18:12:20 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_sigchld.c

Log Message:
Skip traceme_raise* tests rather than failing upfront

This avoid reporting the tests as unexpected failure.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/sys/t_ptrace_sigchld.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/sys/t_ptrace_sigchld.c
diff -u src/tests/lib/libc/sys/t_ptrace_sigchld.c:1.2 src/tests/lib/libc/sys/t_ptrace_sigchld.c:1.3
--- src/tests/lib/libc/sys/t_ptrace_sigchld.c:1.2	Fri Mar  6 19:10:27 2020
+++ src/tests/lib/libc/sys/t_ptrace_sigchld.c	Tue May  5 18:12:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_sigchld.c,v 1.2 2020/03/06 19:10:27 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_sigchld.c,v 1.3 2020/05/05 18:12:20 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_sigchld.c,v 1.2 2020/03/06 19:10:27 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_sigchld.c,v 1.3 2020/05/05 18:12:20 kamil Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ traceme_raise(int sigval)
 	sa.sa_flags = SA_SIGINFO | SA_NOCLDWAIT;
 	sigemptyset(_mask);
 
-	atf_tc_fail("XXX: zombie is not collected before tracer's death");
+	atf_tc_skip("XXX: zombie is not collected before tracer's death");
 
 	SYSCALL_REQUIRE(sigaction(SIGCHLD, , NULL) == 0);
 



CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 02:06:08 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_misc_wait.h

Log Message:
Move misc tests out of t_ptrace_wait.c to t_ptrace_misc_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_misc_wait.h
cvs rdiff -u -r1.190 -r1.191 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.190 src/tests/lib/libc/sys/t_ptrace_wait.c:1.191
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.190	Tue May  5 01:24:29 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 02:06:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.190 2020/05/05 01:24:29 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.191 2020/05/05 02:06:08 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.190 2020/05/05 01:24:29 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.191 2020/05/05 02:06:08 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -103,94 +103,6 @@ static int debug = 0;
 
 /// 
 
-static void
-user_va0_disable(int operation)
-{
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	const int sigval = SIGSTOP;
-	int rv;
-
-	struct ptrace_siginfo info;
-
-	if (get_user_va0_disable() == 0)
-		atf_tc_skip("vm.user_va0_disable is set to 0");
-
-	memset(, 0, sizeof(info));
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		/* NOTREACHED */
-		FORKEE_ASSERTX(0 && "This shall not be reached");
-		__unreachable();
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
-		"child\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, ,
-		sizeof(info)) != -1);
-
-	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
-	DPRINTF("Signal properties: si_signo=%#x si_code=%#x "
-		"si_errno=%#x\n",
-		info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
-		info.psi_siginfo.si_errno);
-
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
-
-	DPRINTF("Before resuming the child process in PC=0x0 "
-	"and without signal to be sent\n");
-	errno = 0;
-	rv = ptrace(operation, child, (void *)0, 0);
-	ATF_REQUIRE_EQ(errno, EINVAL);
-	ATF_REQUIRE_EQ(rv, -1);
-
-	SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-	validate_status_signaled(status, SIGKILL, 0);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
-}
-
-#define USER_VA0_DISABLE(test, operation)\
-ATF_TC(test);\
-ATF_TC_HEAD(test, tc)			\
-{	\
-	atf_tc_set_md_var(tc, "descr",	\
-	"Verify behavior of " #operation " with PC set to 0x0");	\
-}	\
-	\
-ATF_TC_BODY(test, tc)			\
-{	\
-	\
-	user_va0_disable(operation);	\
-}
-
-USER_VA0_DISABLE(user_va0_disable_pt_continue, PT_CONTINUE)
-USER_VA0_DISABLE(user_va0_disable_pt_syscall, PT_SYSCALL)
-USER_VA0_DISABLE(user_va0_disable_pt_detach, PT_DETACH)
-
-/// 
-
 #include "t_ptrace_register_wait.h"
 #include "t_ptrace_syscall_wait.h"
 #include "t_ptrace_step_wait.h"
@@ -206,6 +118,7 @@ USER_VA0_DISABLE(user_va0_disable_pt_det
 #include "t_ptrace_threads_wait.h"
 #include "t_ptrace_siginfo_wait.h"
 #include "t_ptrace_core_wait.h"
+#include "t_ptrace_misc_wait.h"
 
 /// 
 
@@ -236,10 +149,6 @@ ATF_TP_ADD_TCS(tp)
 	setvbuf(stderr, NULL, _IONBF, 0);
 
 #ifdef ENABLE_TESTS
-	ATF_TP_ADD_TC(tp, user_va0_disable_pt_continue);
-	ATF_TP_ADD_TC(tp, user_va0_disable_pt_syscall);
-	ATF_TP_ADD_TC(tp, user_va0_disable_pt_detach);
-
 	ATF_TP_ADD_TCS_PTRACE_WAIT_REGISTER();
 	

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 01:24:29 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_core_wait.h

Log Message:
Move core tests out of t_ptrace_wait.c to t_ptrace_core_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_core_wait.h
cvs rdiff -u -r1.189 -r1.190 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.189 src/tests/lib/libc/sys/t_ptrace_wait.c:1.190
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.189	Tue May  5 00:57:34 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 01:24:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.189 2020/05/05 00:57:34 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.190 2020/05/05 01:24:29 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.189 2020/05/05 00:57:34 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.190 2020/05/05 01:24:29 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -191,199 +191,6 @@ USER_VA0_DISABLE(user_va0_disable_pt_det
 
 /// 
 
-/*
- * Parse the core file and find the requested note.  If the reading or parsing
- * fails, the test is failed.  If the note is found, it is read onto buf, up to
- * buf_len.  The actual length of the note is returned (which can be greater
- * than buf_len, indicating that it has been truncated).  If the note is not
- * found, -1 is returned.
- *
- * If the note_name ends in '*', then we find the first note that matches
- * the note_name prefix up to the '*' character, e.g.:
- *
- *	NetBSD-CORE@*
- *
- * finds the first note whose name prefix matches "NetBSD-CORE@".
- */
-static ssize_t core_find_note(const char *core_path,
-const char *note_name, uint64_t note_type, void *buf, size_t buf_len)
-{
-	int core_fd;
-	Elf *core_elf;
-	size_t core_numhdr, i;
-	ssize_t ret = -1;
-	size_t name_len = strlen(note_name);
-	bool prefix_match = false;
-
-	if (note_name[name_len - 1] == '*') {
-		prefix_match = true;
-		name_len--;
-	} else {
-		/* note: we assume note name will be null-terminated */
-		name_len++;
-	}
-
-	SYSCALL_REQUIRE((core_fd = open(core_path, O_RDONLY)) != -1);
-	SYSCALL_REQUIRE(elf_version(EV_CURRENT) != EV_NONE);
-	SYSCALL_REQUIRE((core_elf = elf_begin(core_fd, ELF_C_READ, NULL)));
-
-	SYSCALL_REQUIRE(elf_getphnum(core_elf, _numhdr) != 0);
-	for (i = 0; i < core_numhdr && ret == -1; i++) {
-		GElf_Phdr core_hdr;
-		size_t offset;
-		SYSCALL_REQUIRE(gelf_getphdr(core_elf, i, _hdr));
-		if (core_hdr.p_type != PT_NOTE)
-		continue;
-
-		for (offset = core_hdr.p_offset;
-		offset < core_hdr.p_offset + core_hdr.p_filesz;) {
-			Elf64_Nhdr note_hdr;
-			char name_buf[64];
-
-			switch (gelf_getclass(core_elf)) {
-			case ELFCLASS64:
-SYSCALL_REQUIRE(pread(core_fd, _hdr,
-sizeof(note_hdr), offset)
-== sizeof(note_hdr));
-offset += sizeof(note_hdr);
-break;
-			case ELFCLASS32:
-{
-Elf32_Nhdr tmp_hdr;
-SYSCALL_REQUIRE(pread(core_fd, _hdr,
-sizeof(tmp_hdr), offset)
-== sizeof(tmp_hdr));
-offset += sizeof(tmp_hdr);
-note_hdr.n_namesz = tmp_hdr.n_namesz;
-note_hdr.n_descsz = tmp_hdr.n_descsz;
-note_hdr.n_type = tmp_hdr.n_type;
-}
-break;
-			}
-
-			/* indicates end of notes */
-			if (note_hdr.n_namesz == 0 || note_hdr.n_descsz == 0)
-break;
-			if (((prefix_match &&
-			  note_hdr.n_namesz > name_len) ||
-			 (!prefix_match &&
-			  note_hdr.n_namesz == name_len)) &&
-			note_hdr.n_namesz <= sizeof(name_buf)) {
-SYSCALL_REQUIRE(pread(core_fd, name_buf,
-note_hdr.n_namesz, offset)
-== (ssize_t)(size_t)note_hdr.n_namesz);
-
-if (!strncmp(note_name, name_buf, name_len) &&
-note_hdr.n_type == note_type)
-	ret = note_hdr.n_descsz;
-			}
-
-			offset += note_hdr.n_namesz;
-			/* fix to alignment */
-			offset = roundup(offset, core_hdr.p_align);
-
-			/* if name & type matched above */
-			if (ret != -1) {
-ssize_t read_len = MIN(buf_len,
-note_hdr.n_descsz);
-SYSCALL_REQUIRE(pread(core_fd, buf,
-read_len, offset) == read_len);
-break;
-			}
-
-			offset += note_hdr.n_descsz;
-			/* fix to alignment */
-			offset = roundup(offset, core_hdr.p_align);
-		}
-	}
-
-	elf_end(core_elf);
-	close(core_fd);
-
-	return ret;
-}
-
-ATF_TC(core_dump_procinfo);
-ATF_TC_HEAD(core_dump_procinfo, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-		"Trigger a core dump and verify its 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:57:34 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_siginfo_wait.h

Log Message:
Move siginfo tests out of t_ptrace_wait.c to t_ptrace_siginfo_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_siginfo_wait.h
cvs rdiff -u -r1.188 -r1.189 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.188 src/tests/lib/libc/sys/t_ptrace_wait.c:1.189
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.188	Tue May  5 00:50:39 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:57:34 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.188 2020/05/05 00:50:39 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.189 2020/05/05 00:57:34 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.188 2020/05/05 00:50:39 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.189 2020/05/05 00:57:34 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -104,132 +104,6 @@ static int debug = 0;
 /// 
 
 static void
-ptrace_siginfo(bool faked, void (*sah)(int a, siginfo_t *b, void *c), int *signal_caught)
-{
-	const int exitval = 5;
-	const int sigval = SIGINT;
-	const int sigfaked = SIGTRAP;
-	const int sicodefaked = TRAP_BRKPT;
-	pid_t child, wpid;
-	struct sigaction sa;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	struct ptrace_siginfo info;
-	memset(, 0, sizeof(info));
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		sa.sa_sigaction = sah;
-		sa.sa_flags = SA_SIGINFO;
-		sigemptyset(_mask);
-
-		FORKEE_ASSERT(sigaction(faked ? sigfaked : sigval, , NULL)
-		!= -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		FORKEE_ASSERT_EQ(*signal_caught, 1);
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
-	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
-	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
-	info.psi_siginfo.si_errno);
-
-	if (faked) {
-		DPRINTF("Before setting new faked signal to signo=%d "
-		"si_code=%d\n", sigfaked, sicodefaked);
-		info.psi_siginfo.si_signo = sigfaked;
-		info.psi_siginfo.si_code = sicodefaked;
-	}
-
-	DPRINTF("Before calling ptrace(2) with PT_SET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(
-	ptrace(PT_SET_SIGINFO, child, , sizeof(info)) != -1);
-
-	if (faked) {
-		DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for "
-		"child\n");
-		SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, ,
-		sizeof(info)) != -1);
-
-		DPRINTF("Before checking siginfo_t\n");
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigfaked);
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, sicodefaked);
-	}
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1,
-	faked ? sigfaked : sigval) != -1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_exited(status, exitval);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
-}
-
-#define PTRACE_SIGINFO(test, faked)	\
-ATF_TC(test);\
-ATF_TC_HEAD(test, tc)			\
-{	\
-	atf_tc_set_md_var(tc, "descr",	\
-	"Verify basic PT_GET_SIGINFO and PT_SET_SIGINFO calls"	\
-	"with%s setting signal to new value", faked ? "" : "out");	\
-}	\
-	\
-static int test##_caught = 0;		\
-	\
-static void\
-test##_sighandler(int sig, siginfo_t *info, void *ctx)			\
-{	\
-	if (faked) {			\
-		FORKEE_ASSERT_EQ(sig, SIGTRAP);\
-		

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:50:39 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_wait.h
Added Files:
src/tests/lib/libc/sys: t_ptrace_threads_wait.h

Log Message:
Move threads tests out of t_ptrace_wait.c to t_ptrace_threads_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_threads_wait.h
cvs rdiff -u -r1.187 -r1.188 src/tests/lib/libc/sys/t_ptrace_wait.c
cvs rdiff -u -r1.27 -r1.28 src/tests/lib/libc/sys/t_ptrace_wait.h

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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.187 src/tests/lib/libc/sys/t_ptrace_wait.c:1.188
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.187	Tue May  5 00:33:37 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:50:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.187 2020/05/05 00:33:37 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.188 2020/05/05 00:50:39 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.187 2020/05/05 00:33:37 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.188 2020/05/05 00:50:39 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -229,631 +229,6 @@ PTRACE_SIGINFO(siginfo_set_faked, true)
 
 /// 
 
-#define TRACE_THREADS_NUM 100
-
-static volatile int done;
-pthread_mutex_t trace_threads_mtx = PTHREAD_MUTEX_INITIALIZER;
-
-static void *
-trace_threads_cb(void *arg __unused)
-{
-
-	pthread_mutex_lock(_threads_mtx);
-	done++;
-	pthread_mutex_unlock(_threads_mtx);
-
-	while (done < TRACE_THREADS_NUM)
-		sched_yield();
-
-	return NULL;
-}
-
-static void
-trace_threads(bool trace_create, bool trace_exit, bool masked)
-{
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	ptrace_state_t state;
-	const int slen = sizeof(state);
-	ptrace_event_t event;
-	const int elen = sizeof(event);
-	struct ptrace_siginfo info;
-
-	sigset_t intmask;
-
-	pthread_t t[TRACE_THREADS_NUM];
-	int rv;
-	size_t n;
-	lwpid_t lid;
-
-	/* Track created and exited threads */
-	struct lwp_event_count traced_lwps[__arraycount(t)] = {{0, 0}};
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		if (masked) {
-			sigemptyset();
-			sigaddset(, SIGTRAP);
-			sigprocmask(SIG_BLOCK, , NULL);
-		}
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		for (n = 0; n < __arraycount(t); n++) {
-			rv = pthread_create([n], NULL, trace_threads_cb,
-			NULL);
-			FORKEE_ASSERT(rv == 0);
-		}
-
-		for (n = 0; n < __arraycount(t); n++) {
-			rv = pthread_join(t[n], NULL);
-			FORKEE_ASSERT(rv == 0);
-		}
-
-		/*
-		 * There is race between _exit() and pthread_join() detaching
-		 * a thread. For simplicity kill the process after detecting
-		 * LWP events.
-		 */
-		while (true)
-			continue;
-
-		FORKEE_ASSERT(0 && "Not reached");
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
-	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
-	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
-	info.psi_siginfo.si_errno);
-
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
-
-	DPRINTF("Set LWP event mask for the child %d\n", child);
-	memset(, 0, sizeof(event));
-	if (trace_create)
-		event.pe_set_event |= PTRACE_LWP_CREATE;
-	if (trace_exit)
-		event.pe_set_event |= PTRACE_LWP_EXIT;
-	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-	for (n = 0; n < (trace_create ? __arraycount(t) : 0); n++) {
-		DPRINTF("Before calling %s() for the child - expected stopped "
-		"SIGTRAP\n", TWAIT_FNAME);
-		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),
-		child);
-
-		validate_status_stopped(status, 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:33:37 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_topology_wait.h

Log Message:
Move topology tests out of t_ptrace_wait.c to t_ptrace_topology_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_topology_wait.h
cvs rdiff -u -r1.186 -r1.187 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.186 src/tests/lib/libc/sys/t_ptrace_wait.c:1.187
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.186	Tue May  5 00:23:12 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:33:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.186 2020/05/05 00:23:12 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.187 2020/05/05 00:33:37 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.186 2020/05/05 00:23:12 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.187 2020/05/05 00:33:37 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -103,683 +103,6 @@ static int debug = 0;
 
 /// 
 
-ATF_TC(traceme_pid1_parent);
-ATF_TC_HEAD(traceme_pid1_parent, tc)
-{
-	atf_tc_set_md_var(tc, "descr",
-	"Verify that PT_TRACE_ME is not allowed when our parent is PID1");
-}
-
-ATF_TC_BODY(traceme_pid1_parent, tc)
-{
-	struct msg_fds parent_child;
-	int exitval_child1 = 1, exitval_child2 = 2;
-	pid_t child1, child2, wpid;
-	uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-
-	SYSCALL_REQUIRE(msg_open(_child) == 0);
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child1 = fork()) != -1);
-	if (child1 == 0) {
-		DPRINTF("Before forking process PID=%d\n", getpid());
-		SYSCALL_REQUIRE((child2 = fork()) != -1);
-		if (child2 != 0) {
-			DPRINTF("Parent process PID=%d, child2's PID=%d\n",
-			getpid(), child2);
-			_exit(exitval_child1);
-		}
-		CHILD_FROM_PARENT("exit child1", parent_child, msg);
-
-		DPRINTF("Assert that our parent is PID1 (initproc)\n");
-		FORKEE_ASSERT_EQ(getppid(), 1);
-
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) == -1);
-		SYSCALL_REQUIRE_ERRNO(errno, EPERM);
-
-		CHILD_TO_PARENT("child2 exiting", parent_child, msg);
-
-		_exit(exitval_child2);
-	}
-	DPRINTF("Parent process PID=%d, child1's PID=%d\n", getpid(), child1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(
-	wpid = TWAIT_GENERIC(child1, , WEXITED), child1);
-
-	validate_status_exited(status, exitval_child1);
-
-	DPRINTF("Notify that child1 is dead\n");
-	PARENT_TO_CHILD("exit child1", parent_child, msg);
-
-	DPRINTF("Wait for exiting of child2\n");
-	PARENT_FROM_CHILD("child2 exiting", parent_child, msg);
-}
-
-/// 
-
-#if defined(TWAIT_HAVE_PID)
-static void
-tracer_sees_terminaton_before_the_parent_raw(bool notimeout, bool unrelated,
- bool stopped)
-{
-	/*
-	 * notimeout - disable timeout in await zombie function
-	 * unrelated - attach from unrelated tracer reparented to initproc
-	 * stopped - attach to a stopped process
-	 */
-
-	struct msg_fds parent_tracee, parent_tracer;
-	const int exitval_tracee = 5;
-	const int exitval_tracer = 10;
-	pid_t tracee, tracer, wpid;
-	uint8_t msg = 0xde; /* dummy message for IPC based on pipe(2) */
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-
-	/*
-	 * Only a subset of options are supported.
-	 */
-	ATF_REQUIRE((!notimeout && !unrelated && !stopped) ||
-	(!notimeout && unrelated && !stopped) ||
-	(notimeout && !unrelated && !stopped) ||
-	(!notimeout && unrelated && stopped));
-
-	DPRINTF("Spawn tracee\n");
-	SYSCALL_REQUIRE(msg_open(_tracee) == 0);
-	tracee = atf_utils_fork();
-	if (tracee == 0) {
-		if (stopped) {
-			DPRINTF("Stop self PID %d\n", getpid());
-			raise(SIGSTOP);
-		}
-
-		// Wait for parent to let us exit
-		CHILD_FROM_PARENT("exit tracee", parent_tracee, msg);
-		_exit(exitval_tracee);
-	}
-
-	DPRINTF("Spawn debugger\n");
-	SYSCALL_REQUIRE(msg_open(_tracer) == 0);
-	tracer = atf_utils_fork();
-	if (tracer == 0) {
-		if(unrelated) {
-			/* Fork again and drop parent to reattach to PID 1 */
-			tracer = atf_utils_fork();
-			if (tracer != 0)
-_exit(exitval_tracer);
-		}
-
-		if (stopped) {
-			

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:23:13 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_exec_wait.h

Log Message:
Move exec() tests out of t_ptrace_wait.c to t_ptrace_exec_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_exec_wait.h
cvs rdiff -u -r1.185 -r1.186 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.185 src/tests/lib/libc/sys/t_ptrace_wait.c:1.186
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.185	Tue May  5 00:15:45 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:23:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.185 2020/05/05 00:15:45 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.186 2020/05/05 00:23:12 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.185 2020/05/05 00:15:45 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.186 2020/05/05 00:23:12 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -162,153 +162,6 @@ ATF_TC_BODY(traceme_pid1_parent, tc)
 
 /// 
 
-static void
-traceme_vfork_exec(bool masked, bool ignored)
-{
-	const int sigval = SIGTRAP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	struct sigaction sa;
-	struct ptrace_siginfo info;
-	sigset_t intmask;
-	struct kinfo_proc2 kp;
-	size_t len = sizeof(kp);
-
-	int name[6];
-	const size_t namelen = __arraycount(name);
-	ki_sigset_t kp_sigmask;
-	ki_sigset_t kp_sigignore;
-
-	memset(, 0, sizeof(info));
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = vfork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		if (masked) {
-			sigemptyset();
-			sigaddset(, sigval);
-			sigprocmask(SIG_BLOCK, , NULL);
-		}
-
-		if (ignored) {
-			memset(, 0, sizeof(sa));
-			sa.sa_handler = SIG_IGN;
-			sigemptyset(_mask);
-			FORKEE_ASSERT(sigaction(sigval, , NULL) != -1);
-		}
-
-		DPRINTF("Before calling execve(2) from child\n");
-		execlp("/bin/echo", "/bin/echo", NULL);
-
-		/* NOTREACHED */
-		FORKEE_ASSERTX(0 && "Not reached");
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	name[0] = CTL_KERN,
-	name[1] = KERN_PROC2,
-	name[2] = KERN_PROC_PID;
-	name[3] = getpid();
-	name[4] = sizeof(kp);
-	name[5] = 1;
-
-	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
-
-	if (masked)
-		kp_sigmask = kp.p_sigmask;
-
-	if (ignored)
-		kp_sigignore = kp.p_sigignore;
-
-	name[3] = getpid();
-
-	ATF_REQUIRE_EQ(sysctl(name, namelen, , , NULL, 0), 0);
-
-	if (masked) {
-		DPRINTF("kp_sigmask="
-		"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
-		kp_sigmask.__bits[0], kp_sigmask.__bits[1],
-		kp_sigmask.__bits[2], kp_sigmask.__bits[3]);
-
-	DPRINTF("kp.p_sigmask="
-	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
-	kp.p_sigmask.__bits[0], kp.p_sigmask.__bits[1],
-	kp.p_sigmask.__bits[2], kp.p_sigmask.__bits[3]);
-
-		ATF_REQUIRE(!memcmp(_sigmask, _sigmask,
-		sizeof(kp_sigmask)));
-	}
-
-	if (ignored) {
-		DPRINTF("kp_sigignore="
-		"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
-		kp_sigignore.__bits[0], kp_sigignore.__bits[1],
-		kp_sigignore.__bits[2], kp_sigignore.__bits[3]);
-
-	DPRINTF("kp.p_sigignore="
-	"%#02" PRIx32 "%02" PRIx32 "%02" PRIx32 "%02" PRIx32"\n",
-	kp.p_sigignore.__bits[0], kp.p_sigignore.__bits[1],
-	kp.p_sigignore.__bits[2], kp.p_sigignore.__bits[3]);
-
-		ATF_REQUIRE(!memcmp(_sigignore, _sigignore,
-		sizeof(kp_sigignore)));
-	}
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
-	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
-	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
-	info.psi_siginfo.si_errno);
-
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_EXEC);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:15:45 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_lwp_wait.h

Log Message:
Move LWP tests out of t_ptrace_wait.c to t_ptrace_lwp_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_lwp_wait.h
cvs rdiff -u -r1.184 -r1.185 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.184 src/tests/lib/libc/sys/t_ptrace_wait.c:1.185
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.184	Tue May  5 00:03:49 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:15:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.184 2020/05/05 00:03:49 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.185 2020/05/05 00:15:45 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.184 2020/05/05 00:03:49 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.185 2020/05/05 00:15:45 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -927,618 +927,6 @@ TRACEE_SEES_ITS_ORIGINAL_PARENT(
 
 /// 
 
-static int lwpinfo_thread_sigmask[] = {SIGXCPU, SIGPIPE, SIGALRM, SIGURG};
-
-static pthread_mutex_t lwpinfo_thread_mtx = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t lwpinfo_thread_cnd = PTHREAD_COND_INITIALIZER;
-static volatile size_t lwpinfo_thread_done;
-
-static void *
-lwpinfo_thread(void *arg)
-{
-	sigset_t s;
-	volatile void **tcb;
-
-	tcb = (volatile void **)arg;
-
-	*tcb = _lwp_getprivate();
-	DPRINTF("Storing tcb[] = %p from thread %d\n", *tcb, _lwp_self());
-
-	pthread_setname_np(pthread_self(), "thread %d",
-	(void *)(intptr_t)_lwp_self());
-
-	sigemptyset();
-	pthread_mutex_lock(_thread_mtx);
-	sigaddset(, lwpinfo_thread_sigmask[lwpinfo_thread_done]);
-	lwpinfo_thread_done++;
-	pthread_sigmask(SIG_BLOCK, , NULL);
-	pthread_cond_signal(_thread_cnd);
-	pthread_mutex_unlock(_thread_mtx);
-
-	return infinite_thread(NULL);
-}
-
-static void
-traceme_lwpinfo(const size_t threads, const char *iter)
-{
-	const int sigval = SIGSTOP;
-	const int sigval2 = SIGINT;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	struct ptrace_lwpinfo lwp = {0, 0};
-	struct ptrace_lwpstatus lwpstatus = {0};
-	struct ptrace_siginfo info;
-	void *private;
-	char *name;
-	char namebuf[PL_LNAMELEN];
-	volatile void *tcb[4];
-	bool found;
-	sigset_t s;
-
-	/* Maximum number of supported threads in this test */
-	pthread_t t[__arraycount(tcb) - 1];
-	size_t n, m;
-	int rv;
-	size_t bytes_read;
-
-	struct ptrace_io_desc io;
-	sigset_t sigmask;
-
-	ATF_REQUIRE(__arraycount(t) >= threads);
-	memset(tcb, 0, sizeof(tcb));
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		tcb[0] = _lwp_getprivate();
-		DPRINTF("Storing tcb[0] = %p\n", tcb[0]);
-
-		pthread_setname_np(pthread_self(), "thread %d",
-		(void *)(intptr_t)_lwp_self());
-
-		sigemptyset();
-		sigaddset(, lwpinfo_thread_sigmask[lwpinfo_thread_done]);
-		pthread_sigmask(SIG_BLOCK, , NULL);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		for (n = 0; n < threads; n++) {
-			rv = pthread_create([n], NULL, lwpinfo_thread,
-			[n + 1]);
-			FORKEE_ASSERT(rv == 0);
-		}
-
-		pthread_mutex_lock(_thread_mtx);
-		while (lwpinfo_thread_done < threads) {
-			pthread_cond_wait(_thread_cnd,
-			_thread_mtx);
-		}
-		pthread_mutex_unlock(_thread_mtx);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval2));
-		FORKEE_ASSERT(raise(sigval2) == 0);
-
-		/* NOTREACHED */
-		FORKEE_ASSERTX(0 && "Not reached");
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child");
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Signal traced to lwpid=%d\n", info.psi_lwpid);
-	DPRINTF("Signal properties: si_signo=%#x si_code=%#x si_errno=%#x\n",
-	info.psi_siginfo.si_signo, info.psi_siginfo.si_code,
-	info.psi_siginfo.si_errno);
-
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
-	

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:03:49 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove the duplicate ATF_TP_ADD_TC() entries

Event mask tests are already defined in
ATF_TP_ADD_TCS_PTRACE_WAIT_EVENTMASK().


To generate a diff of this commit:
cvs rdiff -u -r1.183 -r1.184 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.183 src/tests/lib/libc/sys/t_ptrace_wait.c:1.184
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.183	Tue May  5 00:01:14 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:03:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.183 2020/05/05 00:01:14 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.184 2020/05/05 00:03:49 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.183 2020/05/05 00:01:14 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.184 2020/05/05 00:03:49 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -3172,14 +3172,6 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC_HAVE_PID(tp,
 		tracee_sees_its_original_parent_procfs_status);
 
-	ATF_TP_ADD_TC(tp, eventmask_preserved_empty);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_fork);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_vfork);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_vfork_done);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_lwp_create);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_lwp_exit);
-	ATF_TP_ADD_TC(tp, eventmask_preserved_posix_spawn);
-
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo0);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo1);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo2);



CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Tue May  5 00:01:15 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_eventmask_wait.h

Log Message:
Move eventmask tests out of t_ptrace_wait.c to t_ptrace_eventmask_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_eventmask_wait.h
cvs rdiff -u -r1.182 -r1.183 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.182 src/tests/lib/libc/sys/t_ptrace_wait.c:1.183
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.182	Mon May  4 23:53:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Tue May  5 00:01:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.182 2020/05/04 23:53:20 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.183 2020/05/05 00:01:14 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.182 2020/05/04 23:53:20 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.183 2020/05/05 00:01:14 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -927,83 +927,6 @@ TRACEE_SEES_ITS_ORIGINAL_PARENT(
 
 /// 
 
-static void
-eventmask_preserved(int event)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	ptrace_event_t set_event, get_event;
-	const int len = sizeof(ptrace_event_t);
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	set_event.pe_set_event = event;
-	SYSCALL_REQUIRE(
-	ptrace(PT_SET_EVENT_MASK, child, _event, len) != -1);
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_EVENT_MASK, child, _event, len) != -1);
-	DPRINTF("set_event=%#x get_event=%#x\n", set_event.pe_set_event,
-	get_event.pe_set_event);
-	ATF_REQUIRE(memcmp(_event, _event, len) == 0);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_exited(status, exitval);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
-}
-
-#define EVENTMASK_PRESERVED(test, event)\
-ATF_TC(test);\
-ATF_TC_HEAD(test, tc)			\
-{	\
-	atf_tc_set_md_var(tc, "descr",	\
-	"Verify that eventmask " #event " is preserved");		\
-}	\
-	\
-ATF_TC_BODY(test, tc)			\
-{	\
-	\
-	eventmask_preserved(event);	\
-}
-
-EVENTMASK_PRESERVED(eventmask_preserved_empty, 0)
-EVENTMASK_PRESERVED(eventmask_preserved_fork, PTRACE_FORK)
-EVENTMASK_PRESERVED(eventmask_preserved_vfork, PTRACE_VFORK)
-EVENTMASK_PRESERVED(eventmask_preserved_vfork_done, PTRACE_VFORK_DONE)
-EVENTMASK_PRESERVED(eventmask_preserved_lwp_create, PTRACE_LWP_CREATE)
-EVENTMASK_PRESERVED(eventmask_preserved_lwp_exit, PTRACE_LWP_EXIT)
-EVENTMASK_PRESERVED(eventmask_preserved_posix_spawn, PTRACE_POSIX_SPAWN)
-
-/// 
-
 static int lwpinfo_thread_sigmask[] = {SIGXCPU, SIGPIPE, SIGALRM, SIGURG};
 
 static pthread_mutex_t lwpinfo_thread_mtx = PTHREAD_MUTEX_INITIALIZER;
@@ -3193,6 +3116,7 @@ THREAD_CONCURRENT_TEST(thread_concurrent
 #include "t_ptrace_clone_wait.h"
 #include "t_ptrace_fork_wait.h"
 #include "t_ptrace_signal_wait.h"
+#include "t_ptrace_eventmask_wait.h"
 
 /// 
 
@@ -3362,6 +3286,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TCS_PTRACE_WAIT_CLONE();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_FORK();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_SIGNAL();
+	ATF_TP_ADD_TCS_PTRACE_WAIT_EVENTMASK();
 
 	ATF_TP_ADD_TCS_PTRACE_WAIT_AMD64();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_I386();

Added files:

Index: 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 23:53:20 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Remove the duplicate ATF_TP_ADD_TC() entries

Byte transfer tests are already defined in
ATF_TP_ADD_TCS_PTRACE_WAIT_BYTETRANSFER().


To generate a diff of this commit:
cvs rdiff -u -r1.181 -r1.182 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.181 src/tests/lib/libc/sys/t_ptrace_wait.c:1.182
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.181	Mon May  4 23:49:31 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 23:53:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.181 2020/05/04 23:49:31 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.182 2020/05/04 23:53:20 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.181 2020/05/04 23:49:31 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.182 2020/05/04 23:53:20 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -3256,80 +3256,6 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, eventmask_preserved_lwp_exit);
 	ATF_TP_ADD_TC(tp, eventmask_preserved_posix_spawn);
 
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_8);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_16);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_32);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_64);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_8);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_16);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_32);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_64);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_8);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_16);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_32);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_64);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_8);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_16);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_32);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_64);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_read_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_read_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_write_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_write_i);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_8_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_16_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_32_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_d_64_text);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_8_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_16_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_32_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_i_64_text);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_8_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_16_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_32_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_d_64_text);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_8_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_16_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_32_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_write_i_64_text);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_read_d_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_read_i_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_write_d_text);
-	ATF_TP_ADD_TC(tp, bytes_transfer_write_i_text);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_piod_read_auxv);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_pt_read_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_pt_read_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_pt_write_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_pt_write_d);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_piod_read_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_piod_read_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_piod_write_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_piod_write_d);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_alignment_piod_read_auxv);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_pt_read_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_pt_read_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_pt_write_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_pt_write_d);
-
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_read_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_read_d);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_write_i);
-	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_write_d);
-
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo0);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo1);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo2);



CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 22:24:31 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_clone_wait.h

Log Message:
Bump (c) year


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_ptrace_clone_wait.h

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/sys/t_ptrace_clone_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.1 src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.2
--- src/tests/lib/libc/sys/t_ptrace_clone_wait.h:1.1	Mon May  4 22:15:23 2020
+++ src/tests/lib/libc/sys/t_ptrace_clone_wait.h	Mon May  4 22:24:31 2020
@@ -1,7 +1,7 @@
-/*	$NetBSD: t_ptrace_clone_wait.h,v 1.1 2020/05/04 22:15:23 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_clone_wait.h,v 1.2 2020/05/04 22:24:31 kamil Exp $	*/
 
 /*-
- * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
+ * Copyright (c) 2016, 2017, 2018, 2019, 2020 The NetBSD Foundation, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without



CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 22:15:23 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_clone_wait.h

Log Message:
Move clone() tests out of t_ptrace_wait.c to t_ptrace_clone_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_clone_wait.h
cvs rdiff -u -r1.178 -r1.179 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.178 src/tests/lib/libc/sys/t_ptrace_wait.c:1.179
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.178	Mon May  4 22:05:28 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 22:15:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.178 2020/05/04 22:05:28 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.179 2020/05/04 22:15:23 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.178 2020/05/04 22:05:28 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.179 2020/05/04 22:15:23 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -6159,742 +6159,6 @@ ATF_TC_BODY(resume, tc)
 /// 
 
 static void
-clone_body(int flags, bool trackfork, bool trackvfork,
-bool trackvforkdone)
-{
-	const int exitval = 5;
-	const int exitval2 = 15;
-	const int sigval = SIGSTOP;
-	pid_t child, child2 = 0, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	ptrace_state_t state;
-	const int slen = sizeof(state);
-	ptrace_event_t event;
-	const int elen = sizeof(event);
-
-	const size_t stack_size = 1024 * 1024;
-	void *stack, *stack_base;
-
-	stack = malloc(stack_size);
-	ATF_REQUIRE(stack != NULL);
-
-#ifdef __MACHINE_STACK_GROWS_UP
-	stack_base = stack;
-#else
-	stack_base = (char *)stack + stack_size;
-#endif
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		SYSCALL_REQUIRE((child2 = __clone(clone_func, stack_base,
-		flags|SIGCHLD, (void *)(intptr_t)exitval2)) != -1);
-
-		DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(),
-		child2);
-
-		// XXX WALLSIG?
-		FORKEE_REQUIRE_SUCCESS
-		(wpid = TWAIT_GENERIC(child2, , WALLSIG), child2);
-
-		forkee_status_exited(status, exitval2);
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Set 0%s%s%s in EVENT_MASK for the child %d\n",
-	trackfork ? "|PTRACE_FORK" : "",
-	trackvfork ? "|PTRACE_VFORK" : "",
-	trackvforkdone ? "|PTRACE_VFORK_DONE" : "", child);
-	event.pe_set_event = 0;
-	if (trackfork)
-		event.pe_set_event |= PTRACE_FORK;
-	if (trackvfork)
-		event.pe_set_event |= PTRACE_VFORK;
-	if (trackvforkdone)
-		event.pe_set_event |= PTRACE_VFORK_DONE;
-	SYSCALL_REQUIRE(ptrace(PT_SET_EVENT_MASK, child, , elen) != -1);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-#if defined(TWAIT_HAVE_PID)
-	if ((trackfork && !(flags & CLONE_VFORK)) ||
-	(trackvfork && (flags & CLONE_VFORK))) {
-		DPRINTF("Before calling %s() for the child %d\n", TWAIT_FNAME,
-		child);
-		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),
-		child);
-
-		validate_status_stopped(status, SIGTRAP);
-
-		SYSCALL_REQUIRE(
-		ptrace(PT_GET_PROCESS_STATE, child, , slen) != -1);
-		if (trackfork && !(flags & CLONE_VFORK)) {
-			ATF_REQUIRE_EQ(state.pe_report_event & PTRACE_FORK,
-			   PTRACE_FORK);
-		}
-		if (trackvfork && (flags & CLONE_VFORK)) {
-			ATF_REQUIRE_EQ(state.pe_report_event & PTRACE_VFORK,
-			   PTRACE_VFORK);
-		}
-
-		child2 = state.pe_other_pid;
-		DPRINTF("Reported ptrace event with forkee %d\n", child2);
-
-		DPRINTF("Before calling %s() for the forkee %d of the child "
-		"%d\n", TWAIT_FNAME, child2, child);
-		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child2, , 0),
-		child2);
-
-		validate_status_stopped(status, SIGTRAP);
-
-		SYSCALL_REQUIRE(
-		ptrace(PT_GET_PROCESS_STATE, child2, , slen) != -1);
-		if (trackfork 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 22:05:29 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_bytetransfer_wait.h

Log Message:
Move byte transfer tests out of t_ptrace_wait.c to t_ptrace_bytetransfer_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_bytetransfer_wait.h
cvs rdiff -u -r1.177 -r1.178 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.177 src/tests/lib/libc/sys/t_ptrace_wait.c:1.178
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.177	Mon May  4 21:55:12 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 22:05:28 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.177 2020/05/04 21:55:12 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.178 2020/05/04 22:05:28 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.177 2020/05/04 21:55:12 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.178 2020/05/04 22:05:28 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -4194,826 +4194,6 @@ TRACEME_VFORK_FORK_TEST(traceme_vfork_vf
 
 /// 
 
-enum bytes_transfer_type {
-	BYTES_TRANSFER_DATA,
-	BYTES_TRANSFER_DATAIO,
-	BYTES_TRANSFER_TEXT,
-	BYTES_TRANSFER_TEXTIO,
-	BYTES_TRANSFER_AUXV
-};
-
-static int __used
-bytes_transfer_dummy(int a, int b, int c, int d)
-{
-	int e, f, g, h;
-
-	a *= 4;
-	b += 3;
-	c -= 2;
-	d /= 1;
-
-	e = strtol("10", NULL, 10);
-	f = strtol("20", NULL, 10);
-	g = strtol("30", NULL, 10);
-	h = strtol("40", NULL, 10);
-
-	return (a + b * c - d) + (e * f - g / h);
-}
-
-static void
-bytes_transfer(int operation, size_t size, enum bytes_transfer_type type)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-	bool skip = false;
-
-	int lookup_me = 0;
-	uint8_t lookup_me8 = 0;
-	uint16_t lookup_me16 = 0;
-	uint32_t lookup_me32 = 0;
-	uint64_t lookup_me64 = 0;
-
-	int magic = 0x13579246;
-	uint8_t magic8 = 0xab;
-	uint16_t magic16 = 0x1234;
-	uint32_t magic32 = 0x98765432;
-	uint64_t magic64 = 0xabcdef0123456789;
-
-	struct ptrace_io_desc io;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	/* 513 is just enough, for the purposes of ATF it's good enough */
-	AuxInfo ai[513], *aip;
-
-	ATF_REQUIRE(size < sizeof(ai));
-
-	/* Prepare variables for .TEXT transfers */
-	switch (type) {
-	case BYTES_TRANSFER_TEXT:
-		memcpy(, bytes_transfer_dummy, sizeof(magic));
-		break;
-	case BYTES_TRANSFER_TEXTIO:
-		switch (size) {
-		case 8:
-			memcpy(, bytes_transfer_dummy, sizeof(magic8));
-			break;
-		case 16:
-			memcpy(, bytes_transfer_dummy, sizeof(magic16));
-			break;
-		case 32:
-			memcpy(, bytes_transfer_dummy, sizeof(magic32));
-			break;
-		case 64:
-			memcpy(, bytes_transfer_dummy, sizeof(magic64));
-			break;
-		}
-		break;
-	default:
-		break;
-	}
-
-	/* Prepare variables for PIOD and AUXV transfers */
-	switch (type) {
-	case BYTES_TRANSFER_TEXTIO:
-	case BYTES_TRANSFER_DATAIO:
-		io.piod_op = operation;
-		switch (size) {
-		case 8:
-			io.piod_offs = (type == BYTES_TRANSFER_TEXTIO) ?
-			   (void *)bytes_transfer_dummy :
-			   _me8;
-			io.piod_addr = _me8;
-			io.piod_len = sizeof(lookup_me8);
-			break;
-		case 16:
-			io.piod_offs = (type == BYTES_TRANSFER_TEXTIO) ?
-			   (void *)bytes_transfer_dummy :
-			   _me16;
-			io.piod_addr = _me16;
-			io.piod_len = sizeof(lookup_me16);
-			break;
-		case 32:
-			io.piod_offs = (type == BYTES_TRANSFER_TEXTIO) ?
-			   (void *)bytes_transfer_dummy :
-			   _me32;
-			io.piod_addr = _me32;
-			io.piod_len = sizeof(lookup_me32);
-			break;
-		case 64:
-			io.piod_offs = (type == BYTES_TRANSFER_TEXTIO) ?
-			   (void *)bytes_transfer_dummy :
-			   _me64;
-			io.piod_addr = _me64;
-			io.piod_len = sizeof(lookup_me64);
-			break;
-		default:
-			break;
-		}
-		break;
-	case BYTES_TRANSFER_AUXV:
-		io.piod_op = operation;
-		io.piod_offs = 0;
-		io.piod_addr = ai;
-		io.piod_len = size;
-		break;
-	default:
-		break;
-	}
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		switch (type) {
-		case BYTES_TRANSFER_DATA:
-			switch (operation) {
-			case PT_READ_D:
-			case PT_READ_I:
-lookup_me = magic;
-break;
-			default:
-break;
-			}
-			

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 21:55:12 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_kill_wait.h

Log Message:
Move kill()-like tests out of t_ptrace_wait.c to t_ptrace_kill_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_kill_wait.h
cvs rdiff -u -r1.176 -r1.177 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.176 src/tests/lib/libc/sys/t_ptrace_wait.c:1.177
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.176	Mon May  4 21:33:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 21:55:12 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.176 2020/05/04 21:33:20 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.177 2020/05/04 21:55:12 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.176 2020/05/04 21:33:20 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.177 2020/05/04 21:55:12 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -5014,75 +5014,6 @@ BYTES_TRANSFER_EOF(bytes_transfer_eof_pi
 
 /// 
 
-static void
-ptrace_kill(const char *type)
-{
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		/* NOTREACHED */
-		FORKEE_ASSERTX(0 &&
-		"Child should be terminated by a signal from its parent");
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before killing the child process with %s\n", type);
-	if (strcmp(type, "ptrace(PT_KILL)") == 0) {
-		SYSCALL_REQUIRE(ptrace(PT_KILL, child, (void*)1, 0) != -1);
-	} else if (strcmp(type, "kill(SIGKILL)") == 0) {
-		kill(child, SIGKILL);
-	} else if (strcmp(type, "killpg(SIGKILL)") == 0) {
-		setpgid(child, 0);
-		killpg(getpgid(child), SIGKILL);
-	}
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_signaled(status, SIGKILL, 0);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_FAILURE(ECHILD, wpid = TWAIT_GENERIC(child, , 0));
-}
-
-#define PTRACE_KILL(test, type)		\
-ATF_TC(test);\
-ATF_TC_HEAD(test, tc)			\
-{	\
-atf_tc_set_md_var(tc, "descr",	\
-"Verify killing the child with " type);			\
-}	\
-	\
-ATF_TC_BODY(test, tc)			\
-{	\
-	\
-ptrace_kill(type);		\
-}
-
-// PT_CONTINUE with SIGKILL is covered by traceme_sendsignal_simple1
-PTRACE_KILL(kill1, "ptrace(PT_KILL)")
-PTRACE_KILL(kill2, "kill(SIGKILL)")
-PTRACE_KILL(kill3, "killpg(SIGKILL)")
-
-/// 
-
 static int lwpinfo_thread_sigmask[] = {SIGXCPU, SIGPIPE, SIGALRM, SIGURG};
 
 static pthread_mutex_t lwpinfo_thread_mtx = PTHREAD_MUTEX_INITIALIZER;
@@ -8458,6 +8389,7 @@ THREAD_CONCURRENT_TEST(thread_concurrent
 #include "t_ptrace_register_wait.h"
 #include "t_ptrace_syscall_wait.h"
 #include "t_ptrace_step_wait.h"
+#include "t_ptrace_kill_wait.h"
 
 /// 
 
@@ -8865,10 +8797,6 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_write_i);
 	ATF_TP_ADD_TC(tp, bytes_transfer_eof_piod_write_d);
 
-	ATF_TP_ADD_TC(tp, kill1);
-	ATF_TP_ADD_TC(tp, kill2);
-	ATF_TP_ADD_TC(tp, kill3);
-
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo0);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo1);
 	ATF_TP_ADD_TC(tp, traceme_lwpinfo2);
@@ -9055,6 +8983,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TCS_PTRACE_WAIT_REGISTER();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_SYSCALL();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_STEP();
+	ATF_TP_ADD_TCS_PTRACE_WAIT_KILL();
 
 	ATF_TP_ADD_TCS_PTRACE_WAIT_AMD64();
 	ATF_TP_ADD_TCS_PTRACE_WAIT_I386();

Added files:

Index: src/tests/lib/libc/sys/t_ptrace_kill_wait.h
diff -u /dev/null src/tests/lib/libc/sys/t_ptrace_kill_wait.h:1.1
--- /dev/null	Mon May  4 21:55:12 2020

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 21:33:20 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_step_wait.h

Log Message:
Move PT_STEP tests out of t_ptrace_wait.c to t_ptrace_step_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_step_wait.h
cvs rdiff -u -r1.175 -r1.176 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.175 src/tests/lib/libc/sys/t_ptrace_wait.c:1.176
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.175	Mon May  4 21:21:30 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 21:33:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.175 2020/05/04 21:21:30 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.176 2020/05/04 21:33:20 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.175 2020/05/04 21:21:30 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.176 2020/05/04 21:33:20 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -5014,226 +5014,6 @@ BYTES_TRANSFER_EOF(bytes_transfer_eof_pi
 
 /// 
 
-#if defined(PT_STEP)
-static void
-ptrace_step(int N, int setstep, bool masked, bool ignored)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	int happy;
-	struct sigaction sa;
-	struct ptrace_siginfo info;
-	sigset_t intmask;
-	struct kinfo_proc2 kp;
-	size_t len = sizeof(kp);
-
-	int name[6];
-	const size_t namelen = __arraycount(name);
-	ki_sigset_t kp_sigmask;
-	ki_sigset_t kp_sigignore;
-
-#if defined(__arm__)
-	/* PT_STEP not supported on arm 32-bit */
-	atf_tc_expect_fail("PR kern/52119");
-#endif
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		if (masked) {
-			sigemptyset();
-			sigaddset(, SIGTRAP);
-			sigprocmask(SIG_BLOCK, , NULL);
-		}
-
-		if (ignored) {
-			memset(, 0, sizeof(sa));
-			sa.sa_handler = SIG_IGN;
-			sigemptyset(_mask);
-			FORKEE_ASSERT(sigaction(SIGTRAP, , NULL) != -1);
-		}
-
-		happy = check_happy(999);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		FORKEE_ASSERT_EQ(happy, check_happy(999));
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(
-	ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Before checking siginfo_t\n");
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, sigval);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, SI_LWP);
-
-	name[0] = CTL_KERN,
-	name[1] = KERN_PROC2,
-	name[2] = KERN_PROC_PID;
-	name[3] = child;
-	name[4] = sizeof(kp);
-	name[5] = 1;
-
-	FORKEE_ASSERT_EQ(sysctl(name, namelen, , , NULL, 0), 0);
-
-	if (masked)
-		kp_sigmask = kp.p_sigmask;
-
-	if (ignored)
-		kp_sigignore = kp.p_sigignore;
-
-	while (N --> 0) {
-		if (setstep) {
-			DPRINTF("Before resuming the child process where it "
-			"left off and without signal to be sent (use "
-			"PT_SETSTEP and PT_CONTINUE)\n");
-			SYSCALL_REQUIRE(ptrace(PT_SETSTEP, child, 0, 0) != -1);
-			SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0)
-			!= -1);
-		} else {
-			DPRINTF("Before resuming the child process where it "
-			"left off and without signal to be sent (use "
-			"PT_STEP)\n");
-			SYSCALL_REQUIRE(ptrace(PT_STEP, child, (void *)1, 0)
-			!= -1);
-		}
-
-		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-		TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0),
-		child);
-
-		validate_status_stopped(status, SIGTRAP);
-
-		DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-		SYSCALL_REQUIRE(
-		ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-		DPRINTF("Before checking siginfo_t\n");
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
-		ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_TRACE);
-
-		if (setstep) {
-			SYSCALL_REQUIRE(ptrace(PT_CLEARSTEP, child, 0, 0) != -1);
-		}
-
-		ATF_REQUIRE_EQ(sysctl(name, 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 21:21:30 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_syscall_wait.h

Log Message:
Move syscall tests out of t_ptrace_wait.c to t_ptrace_syscall_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_syscall_wait.h
cvs rdiff -u -r1.174 -r1.175 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.174 src/tests/lib/libc/sys/t_ptrace_wait.c:1.175
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.174	Mon May  4 20:55:48 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 21:21:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.174 2020/05/04 20:55:48 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.175 2020/05/04 21:21:30 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.174 2020/05/04 20:55:48 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.175 2020/05/04 21:21:30 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -7267,245 +7267,6 @@ ATF_TC_BODY(resume, tc)
 
 /// 
 
-static int test_syscall_caught;
-
-static void
-syscall_sighand(int arg)
-{
-
-	DPRINTF("Caught a signal %d in process %d\n", arg, getpid());
-
-	FORKEE_ASSERT_EQ(arg, SIGINFO);
-
-	++test_syscall_caught;
-
-	FORKEE_ASSERT_EQ(test_syscall_caught, 1);
-}
-
-static void
-syscall_body(const char *op)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-	struct ptrace_siginfo info;
-
-	memset(, 0, sizeof(info));
-
-#if defined(TWAIT_HAVE_STATUS)
-	if (strstr(op, "signal") != NULL) {
-		atf_tc_expect_fail("XXX: behavior under investigation");
-	}
-#endif
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		signal(SIGINFO, syscall_sighand);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		syscall(SYS_getpid);
-
-		if (strstr(op, "signal") != NULL) {
-			FORKEE_ASSERT_EQ(test_syscall_caught, 1);
-		}
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_SYSCALL, child, (void *)1, 0) != -1);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, SIGTRAP);
-
-	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
-	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
-
-	DPRINTF("Before checking siginfo_t and lwpid\n");
-	ATF_REQUIRE(info.psi_lwpid > 0);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
-	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_SCE);
-
-	if (strstr(op, "killed") != NULL) {
-		SYSCALL_REQUIRE(ptrace(PT_KILL, child, NULL, 0) != -1);
-
-		DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-		TWAIT_REQUIRE_SUCCESS(
-		wpid = TWAIT_GENERIC(child, , 0), child);
-
-		validate_status_signaled(status, SIGKILL, 0);
-	} else {
-		if (strstr(op, "signal") != NULL) {
-			DPRINTF("Before resuming the child %d and sending a "
-			"signal SIGINFO\n", child);
-			SYSCALL_REQUIRE(
-			ptrace(PT_CONTINUE, child, (void *)1, SIGINFO)
-			!= -1);
-		} else if (strstr(op, "detach") != NULL) {
-			DPRINTF("Before detaching the child %d\n", child);
-			SYSCALL_REQUIRE(
-			ptrace(PT_DETACH, child, (void *)1, 0) != -1);
-		} else {
-			DPRINTF("Before resuming the child process where it "
-			"left off and without signal to be sent\n");
-			SYSCALL_REQUIRE(
-			ptrace(PT_SYSCALL, child, (void *)1, 0) != -1);
-
-			DPRINTF("Before calling %s() for the child\n",
-			TWAIT_FNAME);
-			TWAIT_REQUIRE_SUCCESS(
-			wpid = TWAIT_GENERIC(child, , 0), child);
-
-			validate_status_stopped(status, SIGTRAP);
-
-			DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO "
-			"for child\n");
-			SYSCALL_REQUIRE(
-			

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Mon May  4 20:55:48 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c
Added Files:
src/tests/lib/libc/sys: t_ptrace_register_wait.h

Log Message:
Move register tests out of t_ptrace_wait.c to t_ptrace_register_wait.h

The same tests are now included with the preprocessor in t_ptrace_wait.c.

No functional change intended.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/sys/t_ptrace_register_wait.h
cvs rdiff -u -r1.173 -r1.174 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.173 src/tests/lib/libc/sys/t_ptrace_wait.c:1.174
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.173	Fri Apr 24 12:17:45 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Mon May  4 20:55:48 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.173 2020/04/24 12:17:45 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.174 2020/05/04 20:55:48 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.173 2020/04/24 12:17:45 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.174 2020/05/04 20:55:48 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -5014,172 +5014,6 @@ BYTES_TRANSFER_EOF(bytes_transfer_eof_pi
 
 /// 
 
-#if defined(HAVE_GPREGS) || defined(HAVE_FPREGS)
-static void
-access_regs(const char *regset, const char *aux)
-{
-	const int exitval = 5;
-	const int sigval = SIGSTOP;
-	pid_t child, wpid;
-#if defined(TWAIT_HAVE_STATUS)
-	int status;
-#endif
-#if defined(HAVE_GPREGS)
-	struct reg gpr;
-	register_t rgstr;
-#endif
-#if defined(HAVE_FPREGS)
-	struct fpreg fpr;
-#endif
-	
-#if !defined(HAVE_GPREGS)
-	if (strcmp(regset, "regs") == 0)
-		atf_tc_fail("Impossible test scenario!");
-#endif
-
-#if !defined(HAVE_FPREGS)
-	if (strcmp(regset, "fpregs") == 0)
-		atf_tc_fail("Impossible test scenario!");
-#endif
-
-	DPRINTF("Before forking process PID=%d\n", getpid());
-	SYSCALL_REQUIRE((child = fork()) != -1);
-	if (child == 0) {
-		DPRINTF("Before calling PT_TRACE_ME from child %d\n", getpid());
-		FORKEE_ASSERT(ptrace(PT_TRACE_ME, 0, NULL, 0) != -1);
-
-		DPRINTF("Before raising %s from child\n", strsignal(sigval));
-		FORKEE_ASSERT(raise(sigval) == 0);
-
-		DPRINTF("Before exiting of the child process\n");
-		_exit(exitval);
-	}
-	DPRINTF("Parent process PID=%d, child's PID=%d\n", getpid(), child);
-
-	DPRINTF("Before calling %s() for the child\n", TWAIT_FNAME);
-	TWAIT_REQUIRE_SUCCESS(wpid = TWAIT_GENERIC(child, , 0), child);
-
-	validate_status_stopped(status, sigval);
-
-#if defined(HAVE_GPREGS)
-	if (strcmp(regset, "regs") == 0) {
-		DPRINTF("Call GETREGS for the child process\n");
-		SYSCALL_REQUIRE(ptrace(PT_GETREGS, child, , 0) != -1);
-
-		if (strcmp(aux, "none") == 0) {
-			DPRINTF("Retrieved registers\n");
-		} else if (strcmp(aux, "pc") == 0) {
-			rgstr = PTRACE_REG_PC();
-			DPRINTF("Retrieved %" PRIxREGISTER "\n", rgstr);
-		} else if (strstr(aux, "set_pc") != NULL) {
-			rgstr = PTRACE_REG_PC();
-			DPRINTF("Retrieved PC %" PRIxREGISTER "\n", rgstr);
-			if (strstr(aux, "0x1") != NULL) {
-rgstr |= 0x1;
-			} else if (strstr(aux, "0x3") != NULL) {
-rgstr |= 0x3;
-			} else if (strstr(aux, "0x7") != NULL) {
-rgstr |= 0x7;
-			}
-			DPRINTF("Set PC %" PRIxREGISTER "\n", rgstr);
-			PTRACE_REG_SET_PC(, rgstr);
-			if (strcmp(aux, "set_pc") != 0) {
-/* This call can fail with EINVAL or similar. */
-ptrace(PT_SETREGS, child, , 0);
-			}
-		} else if (strcmp(aux, "sp") == 0) {
-			rgstr = PTRACE_REG_SP();
-			DPRINTF("Retrieved %" PRIxREGISTER "\n", rgstr);
-		} else if (strcmp(aux, "intrv") == 0) {
-			rgstr = PTRACE_REG_INTRV();
-			DPRINTF("Retrieved %" PRIxREGISTER "\n", rgstr);
-		} else if (strcmp(aux, "setregs") == 0) {
-			DPRINTF("Call SETREGS for the child process\n");
-			SYSCALL_REQUIRE(
-			ptrace(PT_SETREGS, child, , 0) != -1);
-		}
-	}
-#endif
-
-#if defined(HAVE_FPREGS)
-	if (strcmp(regset, "fpregs") == 0) {
-		DPRINTF("Call GETFPREGS for the child process\n");
-		SYSCALL_REQUIRE(ptrace(PT_GETFPREGS, child, , 0) != -1);
-
-		if (strcmp(aux, "getfpregs") == 0) {
-			DPRINTF("Retrieved FP registers\n");
-		} else if (strcmp(aux, "setfpregs") == 0) {
-			DPRINTF("Call SETFPREGS for the child\n");
-			SYSCALL_REQUIRE(
-			ptrace(PT_SETFPREGS, child, , 0) != -1);
-		}
-	}
-#endif
-
-	DPRINTF("Before resuming the child process where it left off and "
-	"without signal to be sent\n");
-	SYSCALL_REQUIRE(ptrace(PT_CONTINUE, child, (void *)1, 0) != -1);
-
-	if (strstr(aux, "unaligned") != NULL) {
-		DPRINTF("Before resuming the child process where it left off "
-		"and without 

CVS commit: src/tests/lib/libc/sys

2020-05-04 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Mon May  4 15:09:34 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_futex_ops.c

Log Message:
Add a test case for PR kern/55230.  It is currently marked as expect-fail.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/sys/t_futex_ops.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/sys/t_futex_ops.c
diff -u src/tests/lib/libc/sys/t_futex_ops.c:1.3 src/tests/lib/libc/sys/t_futex_ops.c:1.4
--- src/tests/lib/libc/sys/t_futex_ops.c:1.3	Thu Apr 30 04:18:07 2020
+++ src/tests/lib/libc/sys/t_futex_ops.c	Mon May  4 15:09:34 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_futex_ops.c,v 1.3 2020/04/30 04:18:07 thorpej Exp $ */
+/* $NetBSD: t_futex_ops.c,v 1.4 2020/05/04 15:09:34 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2019, 2020\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_futex_ops.c,v 1.3 2020/04/30 04:18:07 thorpej Exp $");
+__RCSID("$NetBSD: t_futex_ops.c,v 1.4 2020/05/04 15:09:34 thorpej Exp $");
 
 #include 
 #include 
@@ -42,6 +42,7 @@ __RCSID("$NetBSD: t_futex_ops.c,v 1.3 20
 #include 
 #include 
 #include 
+#include 
 #include 
 
 #include 
@@ -1334,6 +1335,152 @@ ATF_TC_CLEANUP(futex_wait_evil_unmapped_
 
 /*/
 
+static int pri_min;
+static int pri_max;
+
+static void
+lowpri_simple_test_waiter_lwp(void *arg)
+{
+	struct lwp_data *d = arg;
+	struct sched_param sp;
+	int policy;
+
+	d->threadid = _lwp_self();
+
+	ATF_REQUIRE(_sched_getparam(getpid(), d->threadid, , ) == 0);
+	policy = SCHED_RR;
+	sp.sched_priority = pri_min;
+	ATF_REQUIRE(_sched_setparam(getpid(), d->threadid, policy, ) == 0);
+
+	simple_test_waiter_lwp(arg);
+}
+
+static void
+highpri_simple_test_waiter_lwp(void *arg)
+{
+	struct lwp_data *d = arg;
+	struct sched_param sp;
+	int policy;
+
+	d->threadid = _lwp_self();
+
+	ATF_REQUIRE(_sched_getparam(getpid(), d->threadid, , ) == 0);
+	policy = SCHED_RR;
+	sp.sched_priority = pri_max;
+	ATF_REQUIRE(_sched_setparam(getpid(), d->threadid, policy, ) == 0);
+
+	simple_test_waiter_lwp(arg);
+}
+
+static void
+do_test_wake_highest_pri(void)
+{
+	lwpid_t waiter;
+	int tries;
+	long pri;
+
+	ATF_REQUIRE((pri = sysconf(_SC_SCHED_PRI_MIN)) != -1);
+	pri_min = (int)pri;
+	ATF_REQUIRE((pri = sysconf(_SC_SCHED_PRI_MAX)) != -1);
+	pri_max = (int)pri;
+
+	futex_word = 0;
+	membar_sync();
+
+	setup_lwp_context(_data[0], lowpri_simple_test_waiter_lwp);
+	lwp_data[0].op_flags = FUTEX_PRIVATE_FLAG;
+	lwp_data[0].futex_error = -1;
+	lwp_data[0].futex_ptr = _word;
+	lwp_data[0].block_val = 0;
+	lwp_data[0].bitset = 0;
+	lwp_data[0].wait_op = FUTEX_WAIT;
+	ATF_REQUIRE(_lwp_create(_data[0].context, 0,
+_data[0].lwpid) == 0);
+
+	for (tries = 0; tries < 5; tries++) {
+		membar_sync();
+		if (nlwps_running == 1)
+			break;
+		sleep(1);
+	}
+	membar_sync();
+	ATF_REQUIRE_EQ_MSG(nlwps_running, 1, "lowpri waiter failed to start");
+
+	/* Ensure it's blocked. */
+	ATF_REQUIRE(lwp_data[0].futex_error == -1);
+
+	setup_lwp_context(_data[1], highpri_simple_test_waiter_lwp);
+	lwp_data[1].op_flags = FUTEX_PRIVATE_FLAG;
+	lwp_data[1].futex_error = -1;
+	lwp_data[1].futex_ptr = _word;
+	lwp_data[1].block_val = 0;
+	lwp_data[1].bitset = 0;
+	lwp_data[1].wait_op = FUTEX_WAIT;
+	ATF_REQUIRE(_lwp_create(_data[0].context, 0,
+_data[0].lwpid) == 0);
+
+	for (tries = 0; tries < 5; tries++) {
+		membar_sync();
+		if (nlwps_running == 2)
+			break;
+		sleep(1);
+	}
+	membar_sync();
+	ATF_REQUIRE_EQ_MSG(nlwps_running, 2, "highpri waiter failed to start");
+
+	/* Ensure it's blocked. */
+	ATF_REQUIRE(lwp_data[1].futex_error == -1);
+
+	/* Wake the first LWP.  We should get the highpri thread. */
+	ATF_REQUIRE(__futex(_word, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
+			1, NULL, NULL, 0, 0) == 1);
+	sleep(1);
+	for (tries = 0; tries < 5; tries++) {
+		membar_sync();
+		if (nlwps_running == 1)
+			break;
+		sleep(1);
+	}
+	membar_sync();
+	ATF_REQUIRE(nlwps_running == 1);
+	ATF_REQUIRE(_lwp_wait(0, ) == 0);
+	ATF_REQUIRE(waiter == lwp_data[1].threadid);
+
+	/* Wake the second LWP.  We should get the lowpri thread. */
+	ATF_REQUIRE(__futex(_word, FUTEX_WAKE | FUTEX_PRIVATE_FLAG,
+			1, NULL, NULL, 0, 0) == 1);
+	sleep(1);
+	for (tries = 0; tries < 5; tries++) {
+		membar_sync();
+		if (nlwps_running == 0)
+			break;
+		sleep(1);
+	}
+	membar_sync();
+	ATF_REQUIRE(nlwps_running == 0);
+	ATF_REQUIRE(_lwp_wait(0, ) == 0);
+	ATF_REQUIRE(waiter == lwp_data[0].threadid);
+}
+
+ATF_TC_WITH_CLEANUP(futex_wake_highest_pri);
+ATF_TC_HEAD(futex_wake_highest_pri, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"tests that futex WAKE wakes the highest priority waiter");
+	atf_tc_set_md_var(tc, "require.user", "root");
+}

CVS commit: src/tests/lib/libc/sys

2020-05-01 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri May  1 21:35:30 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_sigaltstack.c

Log Message:
no need for alloca() (breaks SSP)


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_sigaltstack.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/sys/t_sigaltstack.c
diff -u src/tests/lib/libc/sys/t_sigaltstack.c:1.1 src/tests/lib/libc/sys/t_sigaltstack.c:1.2
--- src/tests/lib/libc/sys/t_sigaltstack.c:1.1	Thu Apr 30 07:03:29 2020
+++ src/tests/lib/libc/sys/t_sigaltstack.c	Fri May  1 17:35:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sigaltstack.c,v 1.1 2020/04/30 11:03:29 ryo Exp $ */
+/* $NetBSD: t_sigaltstack.c,v 1.2 2020/05/01 21:35:30 christos Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_sigaltstack.c,v 1.1 2020/04/30 11:03:29 ryo Exp $");
+__RCSID("$NetBSD: t_sigaltstack.c,v 1.2 2020/05/01 21:35:30 christos Exp $");
 
 #include 
 #include 
@@ -43,7 +43,7 @@ static bool handler_use_altstack;
 static void
 handler(int signo __unused)
 {
-	char *sp = alloca(128);
+	char sp[128];
 
 	handler_called = true;
 



CVS commit: src/tests/lib/libc/sys

2020-04-30 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri May  1 01:44:30 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_futex_robust.c

Log Message:
Oops, accidentally #if 0'd some tests, probably while debugging
something else.  Correct this silly mistake.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/sys/t_futex_robust.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/sys/t_futex_robust.c
diff -u src/tests/lib/libc/sys/t_futex_robust.c:1.1 src/tests/lib/libc/sys/t_futex_robust.c:1.2
--- src/tests/lib/libc/sys/t_futex_robust.c:1.1	Sun Apr 26 18:53:33 2020
+++ src/tests/lib/libc/sys/t_futex_robust.c	Fri May  1 01:44:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_futex_robust.c,v 1.1 2020/04/26 18:53:33 thorpej Exp $ */
+/* $NetBSD: t_futex_robust.c,v 1.2 2020/05/01 01:44:30 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2019\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: t_futex_robust.c,v 1.1 2020/04/26 18:53:33 thorpej Exp $");
+__RCSID("$NetBSD: t_futex_robust.c,v 1.2 2020/05/01 01:44:30 thorpej Exp $");
 
 #include 
 #include 
@@ -396,12 +396,10 @@ ATF_TC_CLEANUP(futex_robust_bad_pending,
 
 ATF_TP_ADD_TCS(tp)
 {
-#if 0
 	ATF_TP_ADD_TC(tp, futex_robust_positive);
 	ATF_TP_ADD_TC(tp, futex_robust_negative);
 	ATF_TP_ADD_TC(tp, futex_robust_unmapped);
 	ATF_TP_ADD_TC(tp, futex_robust_evil_circular);
-#endif
 	ATF_TP_ADD_TC(tp, futex_robust_bad_pending);
 
 	return atf_no_error();



CVS commit: src/tests/lib/libc/sys

2020-04-24 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Apr 24 12:17:45 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c

Log Message:
Reduce assumptions about LWP numbers


To generate a diff of this commit:
cvs rdiff -u -r1.172 -r1.173 src/tests/lib/libc/sys/t_ptrace_wait.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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.172 src/tests/lib/libc/sys/t_ptrace_wait.c:1.173
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.172	Fri Apr 24 03:25:20 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Fri Apr 24 12:17:45 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.172 2020/04/24 03:25:20 thorpej Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.173 2020/04/24 12:17:45 kamil Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.172 2020/04/24 03:25:20 thorpej Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.173 2020/04/24 12:17:45 kamil Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -7506,11 +7506,8 @@ syscall_body(const char *op)
 	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
 	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
 
-	/*
-	 * N.B. 9.99.59 and later - single-LWP processes lwpid==pid.
-	 */
 	DPRINTF("Before checking siginfo_t and lwpid\n");
-	ATF_REQUIRE(info.psi_lwpid == 1 || info.psi_lwpid == child);
+	ATF_REQUIRE(info.psi_lwpid > 0);
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_SCE);
 
@@ -7552,13 +7549,8 @@ syscall_body(const char *op)
 			ptrace(PT_GET_SIGINFO, child, , sizeof(info))
 			!= -1);
 
-			/*
-			 * N.B. 9.99.59 and later - single-LWP processes
-			 * lwpid==pid.
-			 */
 			DPRINTF("Before checking siginfo_t and lwpid\n");
-			ATF_REQUIRE(info.psi_lwpid == 1 ||
-info.psi_lwpid == child);
+			ATF_REQUIRE(info.psi_lwpid > 0);
 			ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
 			ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_SCX);
 
@@ -8678,10 +8670,7 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 	ATF_CHECK_EQ(procinfo.cpi_rgid, getgid());
 	ATF_CHECK_EQ(procinfo.cpi_egid, getegid());
 	ATF_CHECK_EQ(procinfo.cpi_nlwps, 1);
-	/*
-	 * N.B. 9.99.59 and later - single-LWP processes lwpid==pid.
-	 */
-	ATF_CHECK(procinfo.cpi_siglwp == 1 || procinfo.cpi_siglwp == child);
+	ATF_CHECK(procinfo.cpi_siglwp > 0);
 
 	unlink(core_path);
 



CVS commit: src/tests/lib/libc/sys

2020-04-23 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Apr 24 03:25:20 UTC 2020

Modified Files:
src/tests/lib/libc/sys: t_ptrace_wait.c t_ptrace_x86_wait.h

Log Message:
Update for new LWP behavior -- as of 9.99.59, the LWP ID of a single-LWP
process is the PID, not 1.


To generate a diff of this commit:
cvs rdiff -u -r1.171 -r1.172 src/tests/lib/libc/sys/t_ptrace_wait.c
cvs rdiff -u -r1.24 -r1.25 src/tests/lib/libc/sys/t_ptrace_x86_wait.h

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/sys/t_ptrace_wait.c
diff -u src/tests/lib/libc/sys/t_ptrace_wait.c:1.171 src/tests/lib/libc/sys/t_ptrace_wait.c:1.172
--- src/tests/lib/libc/sys/t_ptrace_wait.c:1.171	Fri Apr 17 22:53:52 2020
+++ src/tests/lib/libc/sys/t_ptrace_wait.c	Fri Apr 24 03:25:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_wait.c,v 1.171 2020/04/17 22:53:52 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_wait.c,v 1.172 2020/04/24 03:25:20 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_ptrace_wait.c,v 1.171 2020/04/17 22:53:52 kamil Exp $");
+__RCSID("$NetBSD: t_ptrace_wait.c,v 1.172 2020/04/24 03:25:20 thorpej Exp $");
 
 #define __LEGACY_PT_LWPINFO
 
@@ -7506,8 +7506,11 @@ syscall_body(const char *op)
 	DPRINTF("Before calling ptrace(2) with PT_GET_SIGINFO for child\n");
 	SYSCALL_REQUIRE(ptrace(PT_GET_SIGINFO, child, , sizeof(info)) != -1);
 
+	/*
+	 * N.B. 9.99.59 and later - single-LWP processes lwpid==pid.
+	 */
 	DPRINTF("Before checking siginfo_t and lwpid\n");
-	ATF_REQUIRE_EQ(info.psi_lwpid, 1);
+	ATF_REQUIRE(info.psi_lwpid == 1 || info.psi_lwpid == child);
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
 	ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_SCE);
 
@@ -7549,8 +7552,13 @@ syscall_body(const char *op)
 			ptrace(PT_GET_SIGINFO, child, , sizeof(info))
 			!= -1);
 
+			/*
+			 * N.B. 9.99.59 and later - single-LWP processes
+			 * lwpid==pid.
+			 */
 			DPRINTF("Before checking siginfo_t and lwpid\n");
-			ATF_REQUIRE_EQ(info.psi_lwpid, 1);
+			ATF_REQUIRE(info.psi_lwpid == 1 ||
+info.psi_lwpid == child);
 			ATF_REQUIRE_EQ(info.psi_siginfo.si_signo, SIGTRAP);
 			ATF_REQUIRE_EQ(info.psi_siginfo.si_code, TRAP_SCX);
 
@@ -8502,6 +8510,13 @@ USER_VA0_DISABLE(user_va0_disable_pt_det
  * buf_len.  The actual length of the note is returned (which can be greater
  * than buf_len, indicating that it has been truncated).  If the note is not
  * found, -1 is returned.
+ *
+ * If the note_name ends in '*', then we find the first note that matches
+ * the note_name prefix up to the '*' character, e.g.:
+ *
+ *	NetBSD-CORE@*
+ *
+ * finds the first note whose name prefix matches "NetBSD-CORE@".
  */
 static ssize_t core_find_note(const char *core_path,
 const char *note_name, uint64_t note_type, void *buf, size_t buf_len)
@@ -8510,8 +8525,16 @@ static ssize_t core_find_note(const char
 	Elf *core_elf;
 	size_t core_numhdr, i;
 	ssize_t ret = -1;
-	/* note: we assume note name will be null-terminated */
-	size_t name_len = strlen(note_name) + 1;
+	size_t name_len = strlen(note_name);
+	bool prefix_match = false;
+
+	if (note_name[name_len - 1] == '*') {
+		prefix_match = true;
+		name_len--;
+	} else {
+		/* note: we assume note name will be null-terminated */
+		name_len++;
+	}
 
 	SYSCALL_REQUIRE((core_fd = open(core_path, O_RDONLY)) != -1);
 	SYSCALL_REQUIRE(elf_version(EV_CURRENT) != EV_NONE);
@@ -8554,7 +8577,10 @@ static ssize_t core_find_note(const char
 			/* indicates end of notes */
 			if (note_hdr.n_namesz == 0 || note_hdr.n_descsz == 0)
 break;
-			if (note_hdr.n_namesz == name_len &&
+			if (((prefix_match &&
+			  note_hdr.n_namesz > name_len) ||
+			 (!prefix_match &&
+			  note_hdr.n_namesz == name_len)) &&
 			note_hdr.n_namesz <= sizeof(name_buf)) {
 SYSCALL_REQUIRE(pread(core_fd, name_buf,
 note_hdr.n_namesz, offset)
@@ -8652,7 +8678,10 @@ ATF_TC_BODY(core_dump_procinfo, tc)
 	ATF_CHECK_EQ(procinfo.cpi_rgid, getgid());
 	ATF_CHECK_EQ(procinfo.cpi_egid, getegid());
 	ATF_CHECK_EQ(procinfo.cpi_nlwps, 1);
-	ATF_CHECK_EQ(procinfo.cpi_siglwp, 1);
+	/*
+	 * N.B. 9.99.59 and later - single-LWP processes lwpid==pid.
+	 */
+	ATF_CHECK(procinfo.cpi_siglwp == 1 || procinfo.cpi_siglwp == child);
 
 	unlink(core_path);
 

Index: src/tests/lib/libc/sys/t_ptrace_x86_wait.h
diff -u src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.24 src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.25
--- src/tests/lib/libc/sys/t_ptrace_x86_wait.h:1.24	Thu Feb 20 23:57:16 2020
+++ src/tests/lib/libc/sys/t_ptrace_x86_wait.h	Fri Apr 24 03:25:20 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ptrace_x86_wait.h,v 1.24 2020/02/20 23:57:16 kamil Exp $	*/
+/*	$NetBSD: t_ptrace_x86_wait.h,v 1.25 2020/04/24 03:25:20 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2016, 2017, 2018, 2019 The NetBSD Foundation, Inc.
@@ 

  1   2   3   4   5   6   7   8   9   10   >