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/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/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/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/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/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/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/gen

2020-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 13 23:27:55 UTC 2020

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

Log Message:
t_glob.c: clean up test code

In struct vfs_file, using an int as a boolean is an anachronism and has
been replaced with a single-character file type, like in ls(1).

Some other redundant test code has been removed as well since it was
either unreachable or existed only for performance reasons.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.9 src/tests/lib/libc/gen/t_glob.c:1.10
--- src/tests/lib/libc/gen/t_glob.c:1.9	Fri Mar 13 22:58:31 2020
+++ src/tests/lib/libc/gen/t_glob.c	Fri Mar 13 23:27:54 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.9 2020/03/13 22:58:31 rillig Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.10 2020/03/13 23:27:54 rillig Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.9 2020/03/13 22:58:31 rillig Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.10 2020/03/13 23:27:54 rillig Exp $");
 
 #include 
 
@@ -57,38 +57,39 @@ __RCSID("$NetBSD: t_glob.c,v 1.9 2020/03
 #endif
 
 struct vfs_file {
+	char type;		/* 'd' or '-', like in ls(1) */
 	const char *name;
-	int dir;
 };
 
 static struct vfs_file a[] = {
-	{ "1", 0 },
-	{ "b", 1 },
-	{ "3", 0 },
-	{ "4", 0 },
+	{ '-', "1" },
+	{ 'd', "b" },
+	{ '-', "3" },
+	{ '-', "4" },
 };
 
 static struct vfs_file b[] = {
-	{ "x", 0 },
-	{ "y", 0 },
-	{ "z", 0 },
-	{ "w", 0 },
+	{ '-', "x" },
+	{ '-', "y" },
+	{ '-', "z" },
+	{ '-', "w" },
 };
 
 static struct vfs_file hidden_dir[] = {
-	{ "visible-file", 0 },
-	{ ".hidden-file", 0 },
+	{ '-', "visible-file" },
+	{ '-', ".hidden-file" },
 };
 
 static struct vfs_file dot[] = {
-	{ "a", 1 },
-	{ ".hidden-dir", 1 },
+	{ 'd', "a" },
+	{ 'd', ".hidden-dir" },
 };
 
 struct vfs_dir {
-	const char *name;	/* directory name */
-	const struct vfs_file *dir;
-	size_t len, pos;
+	const char *name;	/* full directory name */
+	const struct vfs_file *entries;
+	size_t entries_len;
+	size_t pos;		/* only between opendir/closedir */
 };
 
 #define VFS_DIR_INIT(name, entries) \
@@ -134,12 +135,12 @@ vfs_readdir(void *v)
 {
 	static struct dirent dir;
 	struct vfs_dir *dd = v;
-	if (dd->pos < dd->len) {
-		const struct vfs_file *f = >dir[dd->pos++];
+	if (dd->pos < dd->entries_len) {
+		const struct vfs_file *f = >entries[dd->pos++];
 		strcpy(dir.d_name, f->name);
 		dir.d_namlen = strlen(f->name);
 		dir.d_ino = dd->pos;
-		dir.d_type = f->dir ? DT_DIR : DT_REG;
+		dir.d_type = f->type == 'd' ? DT_DIR : DT_REG;
 		DPRINTF(("readdir %s %d\n", dir.d_name, dir.d_type));
 		dir.d_reclen = _DIRENT_RECLEN(, dir.d_namlen);
 		return 
@@ -167,16 +168,15 @@ vfs_stat(const char *name , __gl_stat_t 
 		if (buf[dir_len] != '/')
 			continue;
 		const char *base = buf + dir_len + 1;
-		if (strcspn(base, "/") != strlen(base))
-			continue;
 
-		for (size_t j = 0; j < d[i].len; j++)
-			if (strcmp(d[i].dir[j].name, base) == 0) {
-st->st_mode = d[i].dir[j].dir
-? S_IFDIR | 0755
-: S_IFREG | 0644;
-goto out;
-			}
+		for (size_t j = 0; j < d[i].entries_len; j++) {
+			const struct vfs_file *f = [i].entries[j];
+			if (strcmp(f->name, base) != 0)
+continue;
+			ATF_CHECK(f->type != 'd'); // handled above
+			st->st_mode = S_IFREG | 0644;
+			goto out;
+		}
 	}
 	DPRINTF(("stat %s ENOENT\n", buf));
 	errno = ENOENT;



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

2020-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 13 22:58:31 UTC 2020

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

Log Message:
t_glob.c: add test cases for hidden directory and file

The existing test code was geared towards every little bit of
performance. It even duplicated the file definitions in vfs_stat in order
to avoid a few strcmp calls. This made the test code fragile. Therefore,
vfs_stat has been rewritten completely to not duplicate any information
from the vfs.

In vfs_stat, the returned st_mode is now more realistic. It had been 0
before. The file mode is only logged when it makes sense. In the ENOENT
case it is not logged anymore.

The debug logging for opendir/closedir now logs the same pointer, so that
the corresponding calls can be matched easily. Failed vfs_opendir calls
are logged as well, to get a more complete picture of which callbacks are
called.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.8 src/tests/lib/libc/gen/t_glob.c:1.9
--- src/tests/lib/libc/gen/t_glob.c:1.8	Fri Mar 13 21:44:25 2020
+++ src/tests/lib/libc/gen/t_glob.c	Fri Mar 13 22:58:31 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.8 2020/03/13 21:44:25 rillig Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.9 2020/03/13 22:58:31 rillig Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.8 2020/03/13 21:44:25 rillig Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.9 2020/03/13 22:58:31 rillig Exp $");
 
 #include 
 
@@ -75,15 +75,30 @@ static struct vfs_file b[] = {
 	{ "w", 0 },
 };
 
+static struct vfs_file hidden_dir[] = {
+	{ "visible-file", 0 },
+	{ ".hidden-file", 0 },
+};
+
+static struct vfs_file dot[] = {
+	{ "a", 1 },
+	{ ".hidden-dir", 1 },
+};
+
 struct vfs_dir {
 	const char *name;	/* directory name */
 	const struct vfs_file *dir;
 	size_t len, pos;
 };
 
+#define VFS_DIR_INIT(name, entries) \
+{ name, entries, __arraycount(entries), 0 }
+
 static struct vfs_dir d[] = {
-	{ "a", a, __arraycount(a), 0 },
-	{ "a/b", b, __arraycount(b), 0 },
+	VFS_DIR_INIT("a", a),
+	VFS_DIR_INIT("a/b", b),
+	VFS_DIR_INIT(".", dot),
+	VFS_DIR_INIT(".hidden-dir", hidden_dir),
 };
 
 static void
@@ -106,9 +121,10 @@ vfs_opendir(const char *dir)
 
 	for (i = 0; i < __arraycount(d); i++)
 		if (strcmp(buf, d[i].name) == 0) {
-			DPRINTF(("opendir %s %zu\n", buf, i));
+			DPRINTF(("opendir %s %p\n", buf, [i]));
 			return [i];
 		}
+	DPRINTF(("opendir %s ENOENT\n", buf));
 	errno = ENOENT;
 	return NULL;
 }
@@ -138,32 +154,36 @@ vfs_stat(const char *name , __gl_stat_t 
 	trim(buf, sizeof(buf), name);
 	memset(st, 0, sizeof(*st));
 
-	if (strcmp(buf, "a") == 0 || strcmp(buf, "a/b") == 0) {
-		st->st_mode |= S_IFDIR;
-		return 0;
-	}
-
-	if (buf[0] == 'a' && buf[1] == '/') {
-		struct vfs_file *f;
-		size_t offs, count;
-
-		if (buf[2] == 'b' && buf[3] == '/') {
-			offs = 4;
-			count = __arraycount(b);
-			f = b;
-		} else {
-			offs = 2;
-			count = __arraycount(a);
-			f = a;
+	for (size_t i = 0; i < __arraycount(d); i++)
+		if (strcmp(buf, d[i].name) == 0) {
+			st->st_mode = S_IFDIR | 0755;
+			goto out;
 		}
 
-		for (size_t i = 0; i < count; i++)
-			if (strcmp(f[i].name, buf + offs) == 0)
-return 0;
+	for (size_t i = 0; i < __arraycount(d); i++) {
+		size_t dir_len = strlen(d[i].name);
+		if (strncmp(buf, d[i].name, dir_len) != 0)
+			continue;
+		if (buf[dir_len] != '/')
+			continue;
+		const char *base = buf + dir_len + 1;
+		if (strcspn(base, "/") != strlen(base))
+			continue;
+
+		for (size_t j = 0; j < d[i].len; j++)
+			if (strcmp(d[i].dir[j].name, base) == 0) {
+st->st_mode = d[i].dir[j].dir
+? S_IFDIR | 0755
+: S_IFREG | 0644;
+goto out;
+			}
 	}
-	DPRINTF(("stat %s %d\n", buf, st->st_mode));
+	DPRINTF(("stat %s ENOENT\n", buf));
 	errno = ENOENT;
 	return -1;
+out:
+	DPRINTF(("stat %s %06o\n", buf, st->st_mode));
+	return 0;
 }
 
 static int
@@ -216,16 +236,21 @@ run(const char *p, int flags, /* const c
 	}
 
 	for (i = 0; i < gl.gl_pathc; i++)
-		DPRINTF(("%s\n", gl.gl_pathv[i]));
+		DPRINTF(("glob result %zu: %s\n", i, gl.gl_pathv[i]));
 
 	va_list res;
 	va_start(res, flags);
-	const char *expected = NULL;
-	for (i = 0; (expected = va_arg(res, const char *)) != NULL && i < gl.gl_pathc; i++)
-		ATF_CHECK_STREQ(gl.gl_pathv[i], expected);
+	i = 0;
+	const char *name;
+	while ((name = va_arg(res, const char *)) != NULL && i < gl.gl_pathc) {
+		ATF_CHECK_STREQ(gl.gl_pathv[i], name);
+		i++;
+	}
 	va_end(res);
-	ATF_CHECK_EQ(i, gl.gl_pathc);
-	ATF_CHECK_MSG(expected == NULL, "expected \"%s\" to be matched", expected);
+	ATF_CHECK_EQ_MSG(i, gl.gl_pathc,
+	"expected %zu results, got %zu", i, gl.gl_pathc);
+	

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

2020-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 13 21:44:25 UTC 2020

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

Log Message:
t_glob.c: use distinct names for test structures

Before, the structures and functions defined by the test used the same
prefix as the code to be tested. This made it difficult to draw a line
between these parts.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.7 src/tests/lib/libc/gen/t_glob.c:1.8
--- src/tests/lib/libc/gen/t_glob.c:1.7	Fri Mar 13 20:48:33 2020
+++ src/tests/lib/libc/gen/t_glob.c	Fri Mar 13 21:44:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.7 2020/03/13 20:48:33 rillig Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.8 2020/03/13 21:44:25 rillig Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.7 2020/03/13 20:48:33 rillig Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.8 2020/03/13 21:44:25 rillig Exp $");
 
 #include 
 
@@ -56,32 +56,32 @@ __RCSID("$NetBSD: t_glob.c,v 1.7 2020/03
 #define DPRINTF(a)
 #endif
 
-struct gl_file {
+struct vfs_file {
 	const char *name;
 	int dir;
 };
 
-static struct gl_file a[] = {
+static struct vfs_file a[] = {
 	{ "1", 0 },
 	{ "b", 1 },
 	{ "3", 0 },
 	{ "4", 0 },
 };
 
-static struct gl_file b[] = {
+static struct vfs_file b[] = {
 	{ "x", 0 },
 	{ "y", 0 },
 	{ "z", 0 },
 	{ "w", 0 },
 };
 
-struct gl_dir {
+struct vfs_dir {
 	const char *name;	/* directory name */
-	const struct gl_file *dir;
+	const struct vfs_file *dir;
 	size_t len, pos;
 };
 
-static struct gl_dir d[] = {
+static struct vfs_dir d[] = {
 	{ "a", a, __arraycount(a), 0 },
 	{ "a/b", b, __arraycount(b), 0 },
 };
@@ -98,7 +98,7 @@ trim(char *buf, size_t len, const char *
 }
 
 static void *
-gl_opendir(const char *dir)
+vfs_opendir(const char *dir)
 {
 	size_t i;
 	char buf[MAXPATHLEN];
@@ -114,12 +114,12 @@ gl_opendir(const char *dir)
 }
 
 static struct dirent *
-gl_readdir(void *v)
+vfs_readdir(void *v)
 {
 	static struct dirent dir;
-	struct gl_dir *dd = v;
+	struct vfs_dir *dd = v;
 	if (dd->pos < dd->len) {
-		const struct gl_file *f = >dir[dd->pos++];
+		const struct vfs_file *f = >dir[dd->pos++];
 		strcpy(dir.d_name, f->name);
 		dir.d_namlen = strlen(f->name);
 		dir.d_ino = dd->pos;
@@ -132,7 +132,7 @@ gl_readdir(void *v)
 }
 
 static int
-gl_stat(const char *name , __gl_stat_t *st)
+vfs_stat(const char *name , __gl_stat_t *st)
 {
 	char buf[MAXPATHLEN];
 	trim(buf, sizeof(buf), name);
@@ -144,7 +144,7 @@ gl_stat(const char *name , __gl_stat_t *
 	}
 
 	if (buf[0] == 'a' && buf[1] == '/') {
-		struct gl_file *f;
+		struct vfs_file *f;
 		size_t offs, count;
 
 		if (buf[2] == 'b' && buf[3] == '/') {
@@ -167,15 +167,15 @@ gl_stat(const char *name , __gl_stat_t *
 }
 
 static int
-gl_lstat(const char *name , __gl_stat_t *st)
+vfs_lstat(const char *name , __gl_stat_t *st)
 {
-	return gl_stat(name, st);
+	return vfs_stat(name, st);
 }
 
 static void
-gl_closedir(void *v)
+vfs_closedir(void *v)
 {
-	struct gl_dir *dd = v;
+	struct vfs_dir *dd = v;
 	dd->pos = 0;
 	DPRINTF(("closedir %p\n", dd));
 }
@@ -189,11 +189,11 @@ run(const char *p, int flags, /* const c
 
 	DPRINTF(("pattern %s\n", p));
 	memset(, 0, sizeof(gl));
-	gl.gl_opendir = gl_opendir;
-	gl.gl_readdir = gl_readdir;
-	gl.gl_closedir = gl_closedir;
-	gl.gl_stat = gl_stat;
-	gl.gl_lstat = gl_lstat;
+	gl.gl_opendir = vfs_opendir;
+	gl.gl_readdir = vfs_readdir;
+	gl.gl_closedir = vfs_closedir;
+	gl.gl_stat = vfs_stat;
+	gl.gl_lstat = vfs_lstat;
 
 	switch ((e = glob(p, GLOB_ALTDIRFUNC | flags, NULL, ))) {
 	case 0:



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

2020-03-13 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Fri Mar 13 20:48:33 UTC 2020

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

Log Message:
t_glob.c: move expected globbing result directly into the test cases

This makes the tests more self-contained. The example directory tree that
is common to all the tests is still defined elsewhere, but in the same
file. Setting up the example directory structure in each test would make
the tests even more independent and read.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.6 src/tests/lib/libc/gen/t_glob.c:1.7
--- src/tests/lib/libc/gen/t_glob.c:1.6	Wed Apr 26 14:52:57 2017
+++ src/tests/lib/libc/gen/t_glob.c	Fri Mar 13 20:48:33 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.6 2017/04/26 14:52:57 christos Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.7 2020/03/13 20:48:33 rillig Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.6 2017/04/26 14:52:57 christos Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.7 2020/03/13 20:48:33 rillig Exp $");
 
 #include 
 
@@ -41,6 +41,7 @@ __RCSID("$NetBSD: t_glob.c,v 1.6 2017/04
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -85,22 +86,6 @@ static struct gl_dir d[] = {
 	{ "a/b", b, __arraycount(b), 0 },
 };
 
-static const char *glob_range[] = {
-	"a/b/x", "a/b/y", "a/b/z",
-};
-
-static const char *glob_range_not[] = {
-	"a/b/w",
-};
-
-static const char *glob_star[] = {
-	"a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z",
-};
-
-static const char *glob_star_not[] = {
-	"a/1", "a/3", "a/4", "a/b",
-};
-
 static void
 trim(char *buf, size_t len, const char *name)
 {
@@ -171,7 +156,7 @@ gl_stat(const char *name , __gl_stat_t *
 			count = __arraycount(a);
 			f = a;
 		}
-		
+
 		for (size_t i = 0; i < count; i++)
 			if (strcmp(f[i].name, buf + offs) == 0)
 return 0;
@@ -196,7 +181,7 @@ gl_closedir(void *v)
 }
 
 static void
-run(const char *p, int flags, const char **res, size_t len)
+run(const char *p, int flags, /* const char *res */ ...)
 {
 	glob_t gl;
 	size_t i;
@@ -233,9 +218,14 @@ run(const char *p, int flags, const char
 	for (i = 0; i < gl.gl_pathc; i++)
 		DPRINTF(("%s\n", gl.gl_pathv[i]));
 
-	ATF_CHECK(len == gl.gl_pathc);
-	for (i = 0; i < gl.gl_pathc && i < len; i++)
-		ATF_CHECK_STREQ(gl.gl_pathv[i], res[i]);
+	va_list res;
+	va_start(res, flags);
+	const char *expected = NULL;
+	for (i = 0; (expected = va_arg(res, const char *)) != NULL && i < gl.gl_pathc; i++)
+		ATF_CHECK_STREQ(gl.gl_pathv[i], expected);
+	va_end(res);
+	ATF_CHECK_EQ(i, gl.gl_pathc);
+	ATF_CHECK_MSG(expected == NULL, "expected \"%s\" to be matched", expected);
 
 	globfree();
 	return;
@@ -243,6 +233,7 @@ bad:
 	ATF_REQUIRE_MSG(e == 0, "No match for `%s'", p);
 }
 
+#define run(p, flags, ...) (run)(p, flags, __VA_ARGS__, (const char *) 0)
 
 ATF_TC(glob_range);
 ATF_TC_HEAD(glob_range, tc)
@@ -253,7 +244,8 @@ ATF_TC_HEAD(glob_range, tc)
 
 ATF_TC_BODY(glob_range, tc)
 {
-	run("a/b/[x-z]", 0, glob_range, __arraycount(glob_range));
+	run("a/b/[x-z]", 0,
+	"a/b/x", "a/b/y", "a/b/z");
 }
 
 ATF_TC(glob_range_not);
@@ -265,7 +257,8 @@ ATF_TC_HEAD(glob_range_not, tc)
 
 ATF_TC_BODY(glob_range_not, tc)
 {
-	run("a/b/[!x-z]", 0, glob_range_not, __arraycount(glob_range_not));
+	run("a/b/[!x-z]", 0,
+	"a/b/w");
 }
 
 ATF_TC(glob_star);
@@ -277,7 +270,8 @@ ATF_TC_HEAD(glob_star, tc)
 
 ATF_TC_BODY(glob_star, tc)
 {
-	run("a/**", GLOB_STAR, glob_star, __arraycount(glob_star));
+	run("a/**", GLOB_STAR,
+	"a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z");
 }
 
 ATF_TC(glob_star_not);
@@ -287,10 +281,10 @@ ATF_TC_HEAD(glob_star_not, tc)
 	"Test glob(3) ** without GLOB_STAR");
 }
 
-
 ATF_TC_BODY(glob_star_not, tc)
 {
-	run("a/**", 0, glob_star_not, __arraycount(glob_star_not));
+	run("a/**", 0,
+	"a/1", "a/3", "a/4", "a/b");
 }
 
 #if 0



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

2020-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 19:14:57 UTC 2020

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

Log Message:
Update t_siginfo.c build rules

Add logic for MKSANITIZER/MKLIBCSANITIZER checks.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.53 src/tests/lib/libc/gen/Makefile:1.54
--- src/tests/lib/libc/gen/Makefile:1.53	Fri Apr 26 19:17:05 2019
+++ src/tests/lib/libc/gen/Makefile	Sat Feb 22 19:14:57 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.53 2019/04/26 19:17:05 maya Exp $
+# $NetBSD: Makefile,v 1.54 2020/02/22 19:14:57 kamil Exp $
 
 .include 
 
@@ -39,6 +39,10 @@ TESTS_C+=	t_time
 TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
+.if ${MKSANITIZER:Uno} != "yes" && ${MKLIBCSANITIZER:Uno} != "yes"
+COPTS.t_siginfo.c+=	-DENABLE_TESTS
+.endif
+
 CPPFLAGS.t_siginfo.c+=-D__TEST_FENV
 COPTS.t_fpsetround.c+=${${ACTIVE_CC} == "gcc":? -frounding-math :}
 



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

2020-02-22 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Sat Feb 22 19:09:51 UTC 2020

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

Log Message:
Disable the t_siginfo test under MKSANITIZER / MKLIBCSANITIZER

Signal crash events are incompatible with sanitizers.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/tests/lib/libc/gen/t_siginfo.c:1.39
--- src/tests/lib/libc/gen/t_siginfo.c:1.38	Fri Feb 21 22:25:50 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Sat Feb 22 19:09:51 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.38 2020/02/21 22:25:50 kamil Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.39 2020/02/22 19:09:51 kamil Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -53,6 +53,7 @@
 
 #include "isqemu.h"
 
+#ifdef ENABLE_TESTS
 /* for sigbus */
 volatile char *addr;
 
@@ -361,18 +362,6 @@ ATF_TC_HEAD(sigfpe_int, tc)
 	"for integer div-by-zero (PR port-i386/43655)");
 }
 
-#if defined(__clang__)
-__attribute__((no_sanitize("undefined")))
-#else   
-__attribute__((no_sanitize_undefined))
-#endif
-static long int
-sigfpe_int_division(long int a, long int b)
-{
-
-	return a / b;
-}
-
 ATF_TC_BODY(sigfpe_int, tc)
 {
 	struct sigaction sa;
@@ -391,7 +380,7 @@ ATF_TC_BODY(sigfpe_int, tc)
 #elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
-		printf("%ld\n", sigfpe_int_division(1, l));
+		printf("%ld\n", 1 / l);
 	}
 	if (intdiv_signalled == 0)
 		atf_tc_fail("FPE signal handler was not invoked");
@@ -508,9 +497,25 @@ ATF_TC_BODY(sigbus_adraln, tc)
 	atf_tc_fail("Test did not fault as expected");
 }
 
+#else
+ATF_TC(dummy);
+ATF_TC_HEAD(dummy, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "A dummy test");
+}
+
+ATF_TC_BODY(dummy, tc)
+{
+
+	// Dummy, skipped
+	// The ATF framework requires at least a single defined test.
+}
+#endif
+
 ATF_TP_ADD_TCS(tp)
 {
 
+#ifdef ENABLE_TESTS
 	ATF_TP_ADD_TC(tp, sigalarm);
 	ATF_TP_ADD_TC(tp, sigchild_normal);
 	ATF_TP_ADD_TC(tp, sigchild_dump);
@@ -519,6 +524,9 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, sigfpe_int);
 	ATF_TP_ADD_TC(tp, sigsegv);
 	ATF_TP_ADD_TC(tp, sigbus_adraln);
+#else
+	ATF_TP_ADD_TC(tp, dummy);
+#endif
 
 	return atf_no_error();
 }



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

2020-02-21 Thread Kamil Rytarowski
Module Name:src
Committed By:   kamil
Date:   Fri Feb 21 22:25:50 UTC 2020

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

Log Message:
Mark division by 0 as expected in sigfpe_int

Disable ubsan instrumentation on the operation.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 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.37 src/tests/lib/libc/gen/t_siginfo.c:1.38
--- src/tests/lib/libc/gen/t_siginfo.c:1.37	Tue Feb 11 03:11:42 2020
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Feb 21 22:25:50 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.37 2020/02/11 03:11:42 riastradh Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.38 2020/02/21 22:25:50 kamil Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -361,6 +361,18 @@ ATF_TC_HEAD(sigfpe_int, tc)
 	"for integer div-by-zero (PR port-i386/43655)");
 }
 
+#if defined(__clang__)
+__attribute__((no_sanitize("undefined")))
+#else   
+__attribute__((no_sanitize_undefined))
+#endif
+static long int
+sigfpe_int_division(long int a, long int b)
+{
+
+	return a / b;
+}
+
 ATF_TC_BODY(sigfpe_int, tc)
 {
 	struct sigaction sa;
@@ -379,7 +391,7 @@ ATF_TC_BODY(sigfpe_int, tc)
 #elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
-		printf("%ld\n", 1 / l);
+		printf("%ld\n", sigfpe_int_division(1, l));
 	}
 	if (intdiv_signalled == 0)
 		atf_tc_fail("FPE signal handler was not invoked");



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

2020-02-10 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue Feb 11 03:11:43 UTC 2020

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

Log Message:
aarch64 doesn't trap integer division by zero either.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/tests/lib/libc/gen/t_siginfo.c:1.37
--- src/tests/lib/libc/gen/t_siginfo.c:1.36	Thu Apr 25 20:48:54 2019
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue Feb 11 03:11:42 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.36 2019/04/25 20:48:54 kamil Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.37 2020/02/11 03:11:42 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -366,8 +366,8 @@ ATF_TC_BODY(sigfpe_int, tc)
 	struct sigaction sa;
 	long l = strtol("0", NULL, 10);
 
-#if defined(__powerpc__)
-	atf_tc_skip("Test not valid on powerpc");
+#if defined(__powerpc__) || defined(__aarch64__)
+	atf_tc_skip("Integer division by zero doesn't trap");
 #endif
 	if (sigsetjmp(sigfpe_int_env, 0) == 0) {
 		sa.sa_flags = SA_SIGINFO;



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

2019-04-26 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Fri Apr 26 19:17:05 UTC 2019

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

Log Message:
-frounding-math is gcc specific, help clang builds


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.52 src/tests/lib/libc/gen/Makefile:1.53
--- src/tests/lib/libc/gen/Makefile:1.52	Wed Apr 24 15:12:09 2019
+++ src/tests/lib/libc/gen/Makefile	Fri Apr 26 19:17:05 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.52 2019/04/24 15:12:09 christos Exp $
+# $NetBSD: Makefile,v 1.53 2019/04/26 19:17:05 maya Exp $
 
 .include 
 
@@ -40,7 +40,7 @@ TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
 CPPFLAGS.t_siginfo.c+=-D__TEST_FENV
-COPTS.t_fpsetround.c+=-frounding-math
+COPTS.t_fpsetround.c+=${${ACTIVE_CC} == "gcc":? -frounding-math :}
 
 LDADD.t_siginfo+=	-lm
 DPADD.t_siginfo+=	${LIBM}



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

2019-04-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 24 15:12:09 UTC 2019

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

Log Message:
PR/54000: Andreag Gustafsson: Compile the rounding test with
-fround-math since with gcc-7, the default mode ignores fenv settings
(the same effect can be achieved with -O0 :-)

https://gcc.gnu.org/wiki/FloatingPointMath


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.51 src/tests/lib/libc/gen/Makefile:1.52
--- src/tests/lib/libc/gen/Makefile:1.51	Wed Feb  8 22:27:07 2017
+++ src/tests/lib/libc/gen/Makefile	Wed Apr 24 11:12:09 2019
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.51 2017/02/09 03:27:07 christos Exp $
+# $NetBSD: Makefile,v 1.52 2019/04/24 15:12:09 christos Exp $
 
 .include 
 
@@ -40,6 +40,7 @@ TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
 CPPFLAGS.t_siginfo.c+=-D__TEST_FENV
+COPTS.t_fpsetround.c+=-frounding-math
 
 LDADD.t_siginfo+=	-lm
 DPADD.t_siginfo+=	${LIBM}



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

2019-03-11 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Mon Mar 11 17:45:12 UTC 2019

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

Log Message:
Explicitly test for PR lib/54053

A suitable test was actually there already - but the results
were not verified.   So just add a test that the result string
is what is expected.  (Previously for len==128 and bytes==1
it would  have returned "0E" now it returns 1 as it should.)


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/gen/t_humanize_number.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_humanize_number.c
diff -u src/tests/lib/libc/gen/t_humanize_number.c:1.9 src/tests/lib/libc/gen/t_humanize_number.c:1.10
--- src/tests/lib/libc/gen/t_humanize_number.c:1.9	Tue Jan 10 15:20:44 2017
+++ src/tests/lib/libc/gen/t_humanize_number.c	Mon Mar 11 17:45:12 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_humanize_number.c,v 1.9 2017/01/10 15:20:44 christos Exp $	*/
+/*	$NetBSD: t_humanize_number.c,v 1.10 2019/03/11 17:45:12 kre Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -287,6 +287,11 @@ ATF_TC_BODY(humanize_number_big, tc)
 
 	ATF_REQUIRE(rv != -1);
 	ATF_REQUIRE(strcmp(buf, "0%d%s%d%s%s%s") != 0);
+	/*
+	 * PR lib/54053: before version 1.18 the output was nonsense
+	 * with HN_AUTOSCALE and a buffer big enough to not need scaling
+	 */
+	ATF_REQUIRE(strcmp(buf, "1") == 0);
 
 	/*
 	 * Tight buffer.



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

2019-01-26 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Jan 26 15:46:27 UTC 2019

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

Log Message:
aarch64 does not trap on unaligned acces


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/tests/lib/libc/gen/t_siginfo.c:1.34
--- src/tests/lib/libc/gen/t_siginfo.c:1.33	Wed Jan 23 17:36:01 2019
+++ src/tests/lib/libc/gen/t_siginfo.c	Sat Jan 26 15:46:27 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.33 2019/01/23 17:36:01 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.34 2019/01/26 15:46:27 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -464,8 +464,10 @@ ATF_TC_BODY(sigbus_adraln, tc)
 		atf_tc_skip("No SIGBUS signal for unaligned accesses");
 #endif
 
-	/* m68k (except sun2) never issue SIGBUS (PR lib/49653) */
-	if (strcmp(MACHINE_ARCH, "m68k") == 0)
+	/* 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");
 
 	sa.sa_flags = SA_SIGINFO;



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

2018-12-15 Thread Sevan Janiyan
Module Name:src
Committed By:   sevan
Date:   Sun Dec 16 02:18:01 UTC 2018

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

Log Message:
port-macppc/46319 is marked as resolved now.
Test on 8.99.26 build of NetBSD/macppc


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/tests/lib/libc/gen/t_fpsetmask.c:1.17
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.16	Sat Mar 12 11:55:14 2016
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Sun Dec 16 02:18:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.16 2016/03/12 11:55:14 martin Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.17 2018/12/16 02:18:01 sevan Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -311,9 +311,6 @@ sigfpe(int s, siginfo_t *si, void *c)
 	\
 		FPU_PREREQ();		\
 	\
-		if (strcmp(MACHINE, "macppc") == 0)			\
-			atf_tc_expect_fail("PR port-macppc/46319");	\
-	\
 		if (isQEMU())		\
 			atf_tc_expect_fail("PR misc/44767");		\
 	\



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

2018-01-16 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Wed Jan 17 00:16:43 UTC 2018

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

Log Message:
Improve portability of headers and sort them.

>From Ngie Cooper in PR bin/51833


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 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.31 src/tests/lib/libc/gen/t_siginfo.c:1.32
--- src/tests/lib/libc/gen/t_siginfo.c:1.31	Sun Mar  5 16:07:38 2017
+++ src/tests/lib/libc/gen/t_siginfo.c	Wed Jan 17 00:16:43 2018
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.31 2017/03/05 16:07:38 chs Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.32 2018/01/17 00:16:43 maya Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -28,7 +28,6 @@
 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -36,13 +35,14 @@
 #include 
 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
 
 #include 
 #ifdef __HAVE_FENV



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

2017-12-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Dec 21 03:31:43 UTC 2017

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

Log Message:
Fix broken test: we can't assume that the current schedule priority range
will overlap with the requested scheduler range, so get the new scheduler
range, and then try to find a different priority. If that fails (to find
a different scheduling range), give up here.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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/t_spawnattr.c
diff -u src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.2 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.3
--- src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.2	Mon Dec 18 08:18:23 2017
+++ src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c	Wed Dec 20 22:31:43 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawnattr.c,v 1.2 2017/12/18 13:18:23 christos Exp $ */
+/* $NetBSD: t_spawnattr.c,v 1.3 2017/12/21 03:31:43 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -45,11 +45,8 @@
 #define MAX(a, b)	(a) > (b) ? (a) : (b)
 #define MIN(a, b)	(a) > (b) ? (b) : (a)
 
-static int get_different_scheduler(void);
-static int get_different_priority(void);
-
 static int
-get_different_scheduler()
+get_different_scheduler(void)
 {
 	/*
 	 * We don't want to use SCHED_OTHER because it does not have
@@ -69,14 +66,12 @@ get_different_scheduler()
 }
 
 static int
-get_different_priority()
+get_different_priority(int scheduler)
 {
-	int scheduler, max, min, new, priority;
+	int min, max, new, priority;
 	struct sched_param param;
 
-	/* get current schedule policy */
-	scheduler = sched_getscheduler(0);
-
+	/* Get the priority range for the new scheduler */
 	max = sched_get_priority_max(scheduler);
 	min = sched_get_priority_min(scheduler);
 
@@ -84,10 +79,13 @@ get_different_priority()
 	priority = param.sched_priority;
 	
 	/* new schedule policy */
-	new = (priority + 1);
-	if (new > max)
-		new = min;
+	for (new = min; new <= max; new++)
+		if (priority != new)
+			break;
 	
+	ATF_REQUIRE_MSG(priority != new, "could not find different priority");
+	printf("min %d max %d for scheduler %d, returning %d\n",
+	min, max, scheduler, new);
 	return new;
 }
 
@@ -120,8 +118,9 @@ ATF_TC_BODY(t_spawnattr, tc)
 	posix_spawnattr_init();
 
 	scheduler = get_different_scheduler();
-	priority = get_different_priority();
+	priority = get_different_priority(scheduler);
 	sp.sched_priority = priority;
+	printf("using scheduler %d, priority %d\n", scheduler, priority);
 	
 	sigemptyset();
 	sigaddset(, SIGUSR1);



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

2017-12-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 18 13:18:23 UTC 2017

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

Log Message:
Don't use SCHED_OTHER.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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/t_spawnattr.c
diff -u src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.1 src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.2
--- src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c:1.1	Mon Feb 13 16:03:08 2012
+++ src/tests/lib/libc/gen/posix_spawn/t_spawnattr.c	Mon Dec 18 08:18:23 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawnattr.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: t_spawnattr.c,v 1.2 2017/12/18 13:18:23 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -51,20 +51,21 @@ static int get_different_priority(void);
 static int
 get_different_scheduler()
 {
-	int scheduler, max, min, new;
-
-	max = MAX(MAX(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
-	min = MIN(MIN(SCHED_FIFO, SCHED_OTHER), SCHED_RR);
+	/*
+	 * We don't want to use SCHED_OTHER because it does not have
+	 * different priorities.
+	 */
 
 	/* get current schedule policy */
-	scheduler = sched_getscheduler(0);
-	
-	/* new scheduler */
-	new = (scheduler + 1);
-	if (new > max)
-		new = min;
-
-	return new;
+	switch (sched_getscheduler(0)) {
+	case SCHED_RR:
+		return SCHED_FIFO;
+	case SCHED_FIFO:
+	case SCHED_OTHER:
+		return SCHED_RR;
+	default:
+		abort();
+	}
 }
 
 static int



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

2017-12-12 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 13 06:47:04 UTC 2017

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

Log Message:
Revert rev 1.4: fmtcheck(3) neglect unused trailing arguments as before.
"%d" is a valid format string with default format string "%d %s", etc.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_fmtcheck.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_fmtcheck.c
diff -u src/tests/lib/libc/gen/t_fmtcheck.c:1.4 src/tests/lib/libc/gen/t_fmtcheck.c:1.5
--- src/tests/lib/libc/gen/t_fmtcheck.c:1.4	Thu Dec  7 09:37:33 2017
+++ src/tests/lib/libc/gen/t_fmtcheck.c	Wed Dec 13 06:47:04 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fmtcheck.c,v 1.4 2017/12/07 09:37:33 kre Exp $	*/
+/*	$NetBSD: t_fmtcheck.c,v 1.5 2017/12/13 06:47:04 rin Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,13 +65,13 @@ struct test_fmt {
 	{ "%-3", "%d", 2 },
 	{ "%d %s", "%d", 2 },
 	{ "%*.*.*d", "%*.*.*d", 2 },
-	{ "%d", "%d %s", 2 },
+	{ "%d", "%d %s", 1 },
 	{ "%40s", "%20s", 1 },
 	{ "%x %x %x", "%o %u %d", 1 },
 	{ "%o %u %d", "%x %x %X", 1 },
 	{ "%#o %u %#-d", "%x %#x %X", 1 },
 	{ "%qd", "%llx", 1 },
-	{ "%%", "%llx", 2 },
+	{ "%%", "%llx", 1 },
 	{ "%ld %30s %#llx %-10.*e", "This number %lu%% and string %s has %qd numbers and %.*g floats", 1 },
 	{ "%o", "%lx", 2 },
 	{ "%p", "%lu", 2 },



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

2017-12-07 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Dec  7 09:37:33 UTC 2017

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

Log Message:
Correct a couple of broken test cases:
"%d"  does not take the same args as "%d %s"
"%%"  does not take the same args as "%llx"
How did these ever survive any kind of even basic sanity check?


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_fmtcheck.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_fmtcheck.c
diff -u src/tests/lib/libc/gen/t_fmtcheck.c:1.3 src/tests/lib/libc/gen/t_fmtcheck.c:1.4
--- src/tests/lib/libc/gen/t_fmtcheck.c:1.3	Sat Jun 14 08:19:02 2014
+++ src/tests/lib/libc/gen/t_fmtcheck.c	Thu Dec  7 09:37:33 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fmtcheck.c,v 1.3 2014/06/14 08:19:02 apb Exp $	*/
+/*	$NetBSD: t_fmtcheck.c,v 1.4 2017/12/07 09:37:33 kre Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -65,13 +65,13 @@ struct test_fmt {
 	{ "%-3", "%d", 2 },
 	{ "%d %s", "%d", 2 },
 	{ "%*.*.*d", "%*.*.*d", 2 },
-	{ "%d", "%d %s", 1 },
+	{ "%d", "%d %s", 2 },
 	{ "%40s", "%20s", 1 },
 	{ "%x %x %x", "%o %u %d", 1 },
 	{ "%o %u %d", "%x %x %X", 1 },
 	{ "%#o %u %#-d", "%x %#x %X", 1 },
 	{ "%qd", "%llx", 1 },
-	{ "%%", "%llx", 1 },
+	{ "%%", "%llx", 2 },
 	{ "%ld %30s %#llx %-10.*e", "This number %lu%% and string %s has %qd numbers and %.*g floats", 1 },
 	{ "%o", "%lx", 2 },
 	{ "%p", "%lu", 2 },



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

2017-04-26 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Apr 26 14:52:57 UTC 2017

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

Log Message:
- add range tests
- be more descriptive about errors


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.5 src/tests/lib/libc/gen/t_glob.c:1.6
--- src/tests/lib/libc/gen/t_glob.c:1.5	Sat Jan 14 15:47:41 2017
+++ src/tests/lib/libc/gen/t_glob.c	Wed Apr 26 10:52:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.6 2017/04/26 14:52:57 christos Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.6 2017/04/26 14:52:57 christos Exp $");
 
 #include 
 
@@ -85,8 +85,16 @@ static struct gl_dir d[] = {
 	{ "a/b", b, __arraycount(b), 0 },
 };
 
+static const char *glob_range[] = {
+	"a/b/x", "a/b/y", "a/b/z",
+};
+
+static const char *glob_range_not[] = {
+	"a/b/w",
+};
+
 static const char *glob_star[] = {
-"a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z",
+	"a/1", "a/3", "a/4", "a/b", "a/b/w", "a/b/x", "a/b/y", "a/b/z",
 };
 
 static const char *glob_star_not[] = {
@@ -192,7 +200,9 @@ run(const char *p, int flags, const char
 {
 	glob_t gl;
 	size_t i;
+	int e;
 
+	DPRINTF(("pattern %s\n", p));
 	memset(, 0, sizeof(gl));
 	gl.gl_opendir = gl_opendir;
 	gl.gl_readdir = gl_readdir;
@@ -200,18 +210,63 @@ run(const char *p, int flags, const char
 	gl.gl_stat = gl_stat;
 	gl.gl_lstat = gl_lstat;
 
-	RZ(glob(p, GLOB_ALTDIRFUNC | flags, NULL, ));
+	switch ((e = glob(p, GLOB_ALTDIRFUNC | flags, NULL, ))) {
+	case 0:
+		break;
+	case GLOB_NOSPACE:
+		fprintf(stderr, "Malloc call failed.\n");
+		goto bad;
+	case GLOB_ABORTED:
+		fprintf(stderr, "Unignored error.\n");
+		goto bad;
+	case GLOB_NOMATCH:
+		fprintf(stderr, "No match, and GLOB_NOCHECK was not set.\n");
+		goto bad;
+	case GLOB_NOSYS:
+		fprintf(stderr, "Implementation does not support function.\n");
+		goto bad;
+	default:
+		fprintf(stderr, "Unknown error %d.\n", e);
+		goto bad;
+	}
 
 	for (i = 0; i < gl.gl_pathc; i++)
 		DPRINTF(("%s\n", gl.gl_pathv[i]));
 
 	ATF_CHECK(len == gl.gl_pathc);
-	for (i = 0; i < gl.gl_pathc; i++)
+	for (i = 0; i < gl.gl_pathc && i < len; i++)
 		ATF_CHECK_STREQ(gl.gl_pathv[i], res[i]);
 
 	globfree();
+	return;
+bad:
+	ATF_REQUIRE_MSG(e == 0, "No match for `%s'", p);
+}
+
+
+ATF_TC(glob_range);
+ATF_TC_HEAD(glob_range, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Test glob(3) range");
+}
+
+ATF_TC_BODY(glob_range, tc)
+{
+	run("a/b/[x-z]", 0, glob_range, __arraycount(glob_range));
+}
+
+ATF_TC(glob_range_not);
+ATF_TC_HEAD(glob_range_not, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Test glob(3) ! range");
 }
 
+ATF_TC_BODY(glob_range_not, tc)
+{
+	run("a/b/[!x-z]", 0, glob_range_not, __arraycount(glob_range_not));
+}
 
 ATF_TC(glob_star);
 ATF_TC_HEAD(glob_star, tc)
@@ -262,6 +317,8 @@ ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, glob_star);
 	ATF_TP_ADD_TC(tp, glob_star_not);
+	ATF_TP_ADD_TC(tp, glob_range);
+	ATF_TP_ADD_TC(tp, glob_range_not);
 /*
  * Remove this test for now - the GLOB_NOCHECK return value has been
  * re-defined to return a modified pattern in revision 1.33 of glob.c



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

2017-03-05 Thread Chuck Silvers
Module Name:src
Committed By:   chs
Date:   Sun Mar  5 16:07:38 UTC 2017

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

Log Message:
reenable sigfpe_flt on powerpc now that FPU exceptions work.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 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.30 src/tests/lib/libc/gen/t_siginfo.c:1.31
--- src/tests/lib/libc/gen/t_siginfo.c:1.30	Tue Dec 22 14:25:58 2015
+++ src/tests/lib/libc/gen/t_siginfo.c	Sun Mar  5 16:07:38 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.30 2015/12/22 14:25:58 christos Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.31 2017/03/05 16:07:38 chs Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -309,9 +309,7 @@ ATF_TC_BODY(sigfpe_flt, tc)
 
 	if (isQEMU())
 		atf_tc_skip("Test does not run correctly under QEMU");
-#if defined(__powerpc__)
-	atf_tc_skip("Test not valid on powerpc");
-#elif defined(__arm__) && !__SOFTFP__
+#if defined(__arm__) && !__SOFTFP__
 	/*
 	 * Some NEON fpus do not implement IEEE exception handling,
 	 * skip these tests if running on them and compiled for



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

2017-01-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Jan 14 20:47:41 UTC 2017

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

Log Message:
PR/51825: Ngie Cooper: use the non _ version of the macro


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.4 src/tests/lib/libc/gen/t_glob.c:1.5
--- src/tests/lib/libc/gen/t_glob.c:1.4	Fri Jan 13 16:30:41 2017
+++ src/tests/lib/libc/gen/t_glob.c	Sat Jan 14 15:47:41 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: t_glob.c,v 1.4 2017/01/13 21:30:41 christos Exp $");
+__RCSID("$NetBSD: t_glob.c,v 1.5 2017/01/14 20:47:41 christos Exp $");
 
 #include 
 
@@ -146,7 +146,7 @@ gl_stat(const char *name , __gl_stat_t *
 	memset(st, 0, sizeof(*st));
 
 	if (strcmp(buf, "a") == 0 || strcmp(buf, "a/b") == 0) {
-		st->st_mode |= _S_IFDIR;
+		st->st_mode |= S_IFDIR;
 		return 0;
 	}
 



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

2017-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 11 18:15:03 UTC 2017

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

Log Message:
more error checks


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/gen/t_dir.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_dir.c
diff -u src/tests/lib/libc/gen/t_dir.c:1.9 src/tests/lib/libc/gen/t_dir.c:1.10
--- src/tests/lib/libc/gen/t_dir.c:1.9	Wed Jan 11 13:09:40 2017
+++ src/tests/lib/libc/gen/t_dir.c	Wed Jan 11 13:15:02 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.9 2017/01/11 18:09:40 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.10 2017/01/11 18:15:02 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -75,29 +75,40 @@ ATF_TC_BODY(seekdir_basic, tc)
 
 	/* skip two for . and .. */
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	".", strerror(errno));
+
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"..", strerror(errno));
 
 	/* get first entry */
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"first", strerror(errno));
+
 	here = telldir(dp);
-	ATF_REQUIRE_MSG(here != -1,
-	"telldir failed: %s", strerror(errno));
+	ATF_REQUIRE_MSG(here != -1, "telldir failed: %s", strerror(errno));
 
 	/* get second entry */
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"second", strerror(errno));
+
 	wasname = strdup(entry->d_name);
 	if (wasname == NULL)
 		atf_tc_fail("cannot allocate memory");
 
 	/* get third entry */
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"third", strerror(errno));
 
 	/* try to return to the position after the first entry */
 	seekdir(dp, here);
 	entry = readdir(dp);
-
-	if (entry == NULL)
-		atf_tc_fail("entry 1 not found");
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"first[1]", strerror(errno));
 	if (strcmp(entry->d_name, wasname) != 0)
 		atf_tc_fail("1st seekdir found wrong name");
 
@@ -105,18 +116,17 @@ ATF_TC_BODY(seekdir_basic, tc)
 	seekdir(dp, here);
 	here = telldir(dp);
 	entry = readdir(dp);
-
-	if (entry == NULL)
-		atf_tc_fail("entry 2 not found");
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"second[1]", strerror(errno));
 	if (strcmp(entry->d_name, wasname) != 0)
 		atf_tc_fail("2nd seekdir found wrong name");
 
 	/* One more time, to make sure that telldir() doesn't affect result */
 	seekdir(dp, here);
 	entry = readdir(dp);
+	ATF_REQUIRE_MSG(entry != NULL, "readdir[%s] failed: %s",
+	"third[1]", strerror(errno));
 
-	if (entry == NULL)
-		atf_tc_fail("entry 3 not found");
 	if (strcmp(entry->d_name, wasname) != 0)
 		atf_tc_fail("3rd seekdir found wrong name");
 



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

2017-01-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 11 18:09:40 UTC 2017

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

Log Message:
fix mismatched paren, also the previous commit should say and check error
for -1.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_dir.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_dir.c
diff -u src/tests/lib/libc/gen/t_dir.c:1.8 src/tests/lib/libc/gen/t_dir.c:1.9
--- src/tests/lib/libc/gen/t_dir.c:1.8	Wed Jan 11 02:26:17 2017
+++ src/tests/lib/libc/gen/t_dir.c	Wed Jan 11 13:09:40 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.8 2017/01/11 07:26:17 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.9 2017/01/11 18:09:40 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@ ATF_TC_BODY(seekdir_basic, tc)
 
 #define	CREAT(x, m)	do {		\
 		int _creat_fd;		\
-		ATF_REQUIRE_MSG((_creat_fd = creat((x), (m)) != -1),	\
+		ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))) != -1,	\
 		"creat(%s, %x) failed: %s", (x), (m),		\
 		strerror(errno));	\
 		(void)close(_creat_fd);	\



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 11 07:26:17 UTC 2017

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

Log Message:
wrap the macro in do/while.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/gen/t_dir.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_dir.c
diff -u src/tests/lib/libc/gen/t_dir.c:1.7 src/tests/lib/libc/gen/t_dir.c:1.8
--- src/tests/lib/libc/gen/t_dir.c:1.7	Tue Jan 10 10:19:00 2017
+++ src/tests/lib/libc/gen/t_dir.c	Wed Jan 11 02:26:17 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.7 2017/01/10 15:19:00 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.8 2017/01/11 07:26:17 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -55,12 +55,12 @@ ATF_TC_BODY(seekdir_basic, tc)
 	struct dirent *entry;
 	long here;
 
-#define	CREAT(x, m)	do {	\
-		int _creat_fd;	\
-		ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))),	\
-		"creat(%s, %x) failed: %s", (x), (m),	\
-		strerror(errno));\
-		(void)close(_creat_fd);			\
+#define	CREAT(x, m)	do {		\
+		int _creat_fd;		\
+		ATF_REQUIRE_MSG((_creat_fd = creat((x), (m)) != -1),	\
+		"creat(%s, %x) failed: %s", (x), (m),		\
+		strerror(errno));	\
+		(void)close(_creat_fd);	\
 	} while(0);
 
 	ATF_REQUIRE_MSG(mkdir("t", 0755) == 0,



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

2017-01-10 Thread Maya Rashish
Module Name:src
Committed By:   maya
Date:   Tue Jan 10 15:43:59 UTC 2017

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

Log Message:
remove duplicate include.

(also move so it is alphabetical, hence the weird diff)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.10 src/tests/lib/libc/gen/t_sleep.c:1.11
--- src/tests/lib/libc/gen/t_sleep.c:1.10	Tue Jan 10 15:31:11 2017
+++ src/tests/lib/libc/gen/t_sleep.c	Tue Jan 10 15:43:59 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.10 2017/01/10 15:31:11 christos Exp $ */
+/* $NetBSD: t_sleep.c,v 1.11 2017/01/10 15:43:59 maya Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -33,12 +33,11 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 #include 
 



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:32:46 UTC 2017

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

Log Message:
PR/51812: Ngie Cooper: According to ToG gettimeofday() needs 


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_time.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_time.c
diff -u src/tests/lib/libc/gen/t_time.c:1.3 src/tests/lib/libc/gen/t_time.c:1.4
--- src/tests/lib/libc/gen/t_time.c:1.3	Fri Oct 31 08:22:38 2014
+++ src/tests/lib/libc/gen/t_time.c	Tue Jan 10 10:32:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $ */
+/*	$NetBSD: t_time.c,v 1.4 2017/01/10 15:32:46 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $");
+__RCSID("$NetBSD: t_time.c,v 1.4 2017/01/10 15:32:46 christos Exp $");
 
 #include 
 #include 
@@ -38,6 +38,7 @@ __RCSID("$NetBSD: t_time.c,v 1.3 2014/10
 #include 
 #include 
 #include 
+#include 
 #include 
 
 ATF_TC(time_copy);



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:31:11 UTC 2017

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

Log Message:
PR/51811: Ngie Cooper: Fix include file portability.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.9 src/tests/lib/libc/gen/t_sleep.c:1.10
--- src/tests/lib/libc/gen/t_sleep.c:1.9	Thu Aug 11 17:34:11 2016
+++ src/tests/lib/libc/gen/t_sleep.c	Tue Jan 10 10:31:11 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.9 2016/08/11 21:34:11 kre Exp $ */
+/* $NetBSD: t_sleep.c,v 1.10 2017/01/10 15:31:11 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -26,19 +26,22 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
+#include 
+#include 
+#include 		/* for TIMESPEC_TO_TIMEVAL on FreeBSD */
+
 #include 
 #include 
 #include 
 #include 
 #include 
+#include 
 #include 
+#include 
 #include 
 #include 
 
-#include 
-#include 
-#include 
-
 #include "isqemu.h"
 
 #define BILLION		10LL	/* nano-seconds per second */



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:33:40 UTC 2017

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

Log Message:
PR/51813: Ngie Cooper: don't leak fd :ttyname_err


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_ttyname.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_ttyname.c
diff -u src/tests/lib/libc/gen/t_ttyname.c:1.3 src/tests/lib/libc/gen/t_ttyname.c:1.4
--- src/tests/lib/libc/gen/t_ttyname.c:1.3	Sun May  1 14:14:01 2011
+++ src/tests/lib/libc/gen/t_ttyname.c	Tue Jan 10 10:33:40 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ttyname.c,v 1.3 2011/05/01 18:14:01 jruoho Exp $ */
+/*	$NetBSD: t_ttyname.c,v 1.4 2017/01/10 15:33:40 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_ttyname.c,v 1.3 2011/05/01 18:14:01 jruoho Exp $");
+__RCSID("$NetBSD: t_ttyname.c,v 1.4 2017/01/10 15:33:40 christos Exp $");
 
 #include 
 #include 
@@ -78,6 +78,7 @@ ATF_TC_BODY(ttyname_err, tc)
 
 		ATF_REQUIRE(ttyname(fd) == NULL);
 		ATF_REQUIRE(errno == ENOTTY);
+		(void)close(fd);
 	}
 }
 



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:20:44 UTC 2017

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

Log Message:
PR/51810: Ngie Cooper: don't leak buf


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_humanize_number.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_humanize_number.c
diff -u src/tests/lib/libc/gen/t_humanize_number.c:1.8 src/tests/lib/libc/gen/t_humanize_number.c:1.9
--- src/tests/lib/libc/gen/t_humanize_number.c:1.8	Sun Mar 18 03:14:08 2012
+++ src/tests/lib/libc/gen/t_humanize_number.c	Tue Jan 10 10:20:44 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_humanize_number.c,v 1.8 2012/03/18 07:14:08 jruoho Exp $	*/
+/*	$NetBSD: t_humanize_number.c,v 1.9 2017/01/10 15:20:44 christos Exp $	*/
 
 /*-
  * Copyright (c) 2010, 2011 The NetBSD Foundation, Inc.
@@ -241,6 +241,7 @@ ATF_TC_BODY(humanize_number_basic, tc)
 		newline();
 		atf_tc_fail_nonfatal("Failed for table entry %d", i);
 	}
+	free(buf);
 }
 
 ATF_TC(humanize_number_big);



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:19:52 UTC 2017

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

Log Message:
PR/51809: Ngie Cooper: fix file descriptor leak


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/t_ftok.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_ftok.c
diff -u src/tests/lib/libc/gen/t_ftok.c:1.1 src/tests/lib/libc/gen/t_ftok.c:1.2
--- src/tests/lib/libc/gen/t_ftok.c:1.1	Tue Nov  8 00:47:00 2011
+++ src/tests/lib/libc/gen/t_ftok.c	Tue Jan 10 10:19:52 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_ftok.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $ */
+/*	$NetBSD: t_ftok.c,v 1.2 2017/01/10 15:19:52 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_ftok.c,v 1.1 2011/11/08 05:47:00 jruoho Exp $");
+__RCSID("$NetBSD: t_ftok.c,v 1.2 2017/01/10 15:19:52 christos Exp $");
 
 #include 
 #include 
@@ -68,6 +68,7 @@ ATF_TC_BODY(ftok_link, tc)
 	fd = open(path, O_RDONLY | O_CREAT);
 
 	ATF_REQUIRE(fd >= 0);
+	(void)close(fd);
 	ATF_REQUIRE(link(path, hlnk) == 0);
 	ATF_REQUIRE(symlink(path, slnk) == 0);
 



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:19:00 UTC 2017

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

Log Message:
PR/51808: Ngie Cooper: fix leaks, sort includes, check returns


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_dir.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_dir.c
diff -u src/tests/lib/libc/gen/t_dir.c:1.6 src/tests/lib/libc/gen/t_dir.c:1.7
--- src/tests/lib/libc/gen/t_dir.c:1.6	Sat Oct 19 13:45:00 2013
+++ src/tests/lib/libc/gen/t_dir.c	Tue Jan 10 10:19:00 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_dir.c,v 1.6 2013/10/19 17:45:00 christos Exp $ */
+/* $NetBSD: t_dir.c,v 1.7 2017/01/10 15:19:00 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -26,18 +26,19 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include 
-
+#include 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
 #include 
 #include 
 
-#include 
+
 
 ATF_TC(seekdir_basic);
 ATF_TC_HEAD(seekdir_basic, tc)
@@ -54,10 +55,19 @@ ATF_TC_BODY(seekdir_basic, tc)
 	struct dirent *entry;
 	long here;
 
-	mkdir("t", 0755);
-	creat("t/a", 0600);
-	creat("t/b", 0600);
-	creat("t/c", 0600);
+#define	CREAT(x, m)	do {	\
+		int _creat_fd;	\
+		ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))),	\
+		"creat(%s, %x) failed: %s", (x), (m),	\
+		strerror(errno));\
+		(void)close(_creat_fd);			\
+	} while(0);
+
+	ATF_REQUIRE_MSG(mkdir("t", 0755) == 0,
+	"mkdir failed: %s", strerror(errno));
+	CREAT("t/a", 0600);
+	CREAT("t/b", 0600);
+	CREAT("t/c", 0600);
 
 	dp = opendir("t");
 	if ( dp == NULL)
@@ -70,6 +80,8 @@ ATF_TC_BODY(seekdir_basic, tc)
 	/* get first entry */
 	entry = readdir(dp);
 	here = telldir(dp);
+	ATF_REQUIRE_MSG(here != -1,
+	"telldir failed: %s", strerror(errno));
 
 	/* get second entry */
 	entry = readdir(dp);
@@ -109,6 +121,7 @@ ATF_TC_BODY(seekdir_basic, tc)
 		atf_tc_fail("3rd seekdir found wrong name");
 
 	closedir(dp);
+	free(wasname);
 }
 
 ATF_TC(telldir_leak);



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:17:57 UTC 2017

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

Log Message:
PR/51807: Ngie Cooper: disable core file generation in :assert_false,
:assert_true


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_assert.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_assert.c
diff -u src/tests/lib/libc/gen/t_assert.c:1.2 src/tests/lib/libc/gen/t_assert.c:1.3
--- src/tests/lib/libc/gen/t_assert.c:1.2	Tue Jun 14 01:28:00 2011
+++ src/tests/lib/libc/gen/t_assert.c	Tue Jan 10 10:17:57 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $ */
+/* $NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,8 +29,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $");
+__RCSID("$NetBSD: t_assert.c,v 1.3 2017/01/10 15:17:57 christos Exp $");
 
+#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -40,6 +43,17 @@ __RCSID("$NetBSD: t_assert.c,v 1.2 2011/
 #include 
 #include 
 
+static void
+disable_corefile(void)
+{
+	struct rlimit limits;
+
+	limits.rlim_cur = 0;
+	limits.rlim_max = 0;
+
+	ATF_REQUIRE(setrlimit(RLIMIT_CORE, ) == 0);
+}
+
 static void		handler(int);
 
 static void
@@ -65,6 +79,7 @@ ATF_TC_BODY(assert_false, tc)
 
 	if (pid == 0) {
 
+		disable_corefile();
 		(void)closefrom(0);
 		(void)memset(, 0, sizeof(struct sigaction));
 
@@ -102,6 +117,7 @@ ATF_TC_BODY(assert_true, tc)
 
 	if (pid == 0) {
 
+		disable_corefile();
 		(void)closefrom(0);
 		(void)memset(, 0, sizeof(struct sigaction));
 



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

2017-01-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Jan 10 15:16:57 UTC 2017

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

Log Message:
PR/51806: Ngie Cooper: Only run the vis locale test if VIS_NOLOCALE is defined


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_vis.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_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.8 src/tests/lib/libc/gen/t_vis.c:1.9
--- src/tests/lib/libc/gen/t_vis.c:1.8	Sat May 23 10:02:11 2015
+++ src/tests/lib/libc/gen/t_vis.c	Tue Jan 10 10:16:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vis.c,v 1.8 2015/05/23 14:02:11 christos Exp $	*/
+/*	$NetBSD: t_vis.c,v 1.9 2017/01/10 15:16:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -144,6 +144,7 @@ ATF_TC_BODY(strunvis_hex, tc)
 	}
 }
 
+#ifdef VIS_NOLOCALE
 ATF_TC(strvis_locale);
 ATF_TC_HEAD(strvis_locale, tc)
 {
@@ -172,6 +173,7 @@ ATF_TC_BODY(strvis_locale, tc)
 	setlocale(LC_CTYPE, ol);
 	free(ol);
 }
+#endif /* VIS_NOLOCALE */
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -180,7 +182,9 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, strvis_null);
 	ATF_TP_ADD_TC(tp, strvis_empty);
 	ATF_TP_ADD_TC(tp, strunvis_hex);
+#ifdef VIS_NOLOCALE
 	ATF_TP_ADD_TC(tp, strvis_locale);
+#endif /* VIS_NOLOCALE */
 
 	return atf_no_error();
 }



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

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

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

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


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/exect/t_exect.c

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

Modified files:

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



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

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

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

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

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

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

Sponsored by 


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

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

Modified files:

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



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

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

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

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

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

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

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/exect/t_exect.c

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

Modified files:

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



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

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

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

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

Currently this test fails on amd64.

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

On FreeBSD/amd64 this tests passes correctly.

Sponsored by 


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/exect/t_exect.c

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

Modified files:

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



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

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

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

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

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

t_exect_null:
Tests an empty exect(2) executing

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

This test will be attached to build afterwards.

Sponsored by 


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

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

Added files:

Index: src/tests/lib/libc/gen/exect/Makefile
diff -u /dev/null src/tests/lib/libc/gen/exect/Makefile:1.1
--- /dev/null	Fri Dec  9 04:00:36 2016
+++ src/tests/lib/libc/gen/exect/Makefile	Fri Dec  9 04:00:36 2016
@@ -0,0 +1,15 @@
+# $NetBSD: Makefile,v 1.1 2016/12/09 04:00:36 kamil Exp $
+
+NOMAN=		# defined
+WARNS=4
+
+.include 
+
+TESTSDIR=	${TESTSBASE}/lib/libc/gen/exect
+
+TESTS_C=	t_exect
+
+BINDIR=		${TESTSDIR}
+SCRIPTSDIR=	${TESTSDIR}
+
+.include 
Index: src/tests/lib/libc/gen/exect/t_exect.c
diff -u /dev/null src/tests/lib/libc/gen/exect/t_exect.c:1.1
--- /dev/null	Fri Dec  9 04:00:36 2016
+++ src/tests/lib/libc/gen/exect/t_exect.c	Fri Dec  9 04:00:36 2016
@@ -0,0 +1,59 @@
+/*	$NetBSD: t_exect.c,v 1.1 2016/12/09 04:00:36 kamil Exp $	*/
+
+/*-
+ * Copyright (c) 2014 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+ATF_TC(t_exect_null);
+
+ATF_TC_HEAD(t_exect_null, tc)
+{
+	atf_tc_set_md_var(tc, "descr",
+	"Tests an empty exect(2) executing");
+}
+
+ATF_TC_BODY(t_exect_null, tc)
+{
+	int err;
+
+	err = exect(NULL, NULL, NULL);
+	ATF_REQUIRE(err == -1);
+	ATF_REQUIRE_MSG(errno == EFAULT,
+	"wrong error returned %d instead of %d", errno, EFAULT);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+	ATF_TP_ADD_TC(tp, t_exect_null);
+
+	return atf_no_error();
+}



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

2016-10-30 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Oct 31 05:08:53 UTC 2016

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

Log Message:
Add another case related to the ones from PR 49278: [A-\\].


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_fnmatch.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_fnmatch.c
diff -u src/tests/lib/libc/gen/t_fnmatch.c:1.6 src/tests/lib/libc/gen/t_fnmatch.c:1.7
--- src/tests/lib/libc/gen/t_fnmatch.c:1.6	Sun Oct 12 22:33:41 2014
+++ src/tests/lib/libc/gen/t_fnmatch.c	Mon Oct 31 05:08:53 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include 
-__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $");
+__RCSID("$NetBSD: t_fnmatch.c,v 1.7 2016/10/31 05:08:53 dholland Exp $");
 
 #include 
 #include 
@@ -166,6 +166,7 @@ ATF_TC_BODY(fnmatch_initialbracket, tc)
 	ATF_CHECK(fnmatch("[!]a-]", "b", 0) == 0);
 	ATF_CHECK(fnmatch("[]-_]", "^", 0) == 0); /* range: ']', '^', '_' */
 	ATF_CHECK(fnmatch("[!]-_]", "X", 0) == 0);
+	ATF_CHECK(fnmatch("[A-]", "[", 0) == 0);
 	ATF_CHECK(fnmatch("[a-z]/[a-z]", "a/b", 0) == 0);
 	ATF_CHECK(fnmatch("[*]/b", "*/b", 0) == 0);
 	ATF_CHECK(fnmatch("[?]/b", "?/b", 0) == 0);



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

2016-08-11 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Thu Aug 11 21:34:11 UTC 2016

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

Log Message:
Correct use of incorrect errno - should have no real practical effect.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.8 src/tests/lib/libc/gen/t_sleep.c:1.9
--- src/tests/lib/libc/gen/t_sleep.c:1.8	Tue Jul 15 14:56:34 2014
+++ src/tests/lib/libc/gen/t_sleep.c	Thu Aug 11 21:34:11 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.8 2014/07/15 14:56:34 gson Exp $ */
+/* $NetBSD: t_sleep.c,v 1.9 2016/08/11 21:34:11 kre Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -171,7 +171,8 @@ do_kevent(struct timespec *delay, struct
 	(void)close(kq);
 
 	if (rtc == -1) {
-		ATF_REQUIRE_MSG(kerrno == EINTR, "kevent: %s", strerror(errno));
+		ATF_REQUIRE_MSG(kerrno == EINTR, "kevent: %s",
+		strerror(kerrno));
 		return 0;
 	}
 



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

2016-03-12 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Mar 12 11:55:14 UTC 2016

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

Log Message:
Fix masking for the fpsetmask_basic test, pointed out by Timo Buhrmester


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/tests/lib/libc/gen/t_fpsetmask.c:1.16
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.15	Tue Nov 18 08:58:08 2014
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Sat Mar 12 11:55:14 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.15 2014/11/18 08:58:08 martin Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.16 2016/03/12 11:55:14 martin Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -344,7 +344,7 @@ ATF_TC_BODY(fpsetmask_basic, tc)
 	for (i = 0; i < __arraycount(lst); i++) {
 		fpsetmask(msk | lst[i]);
 		ATF_CHECK((fpgetmask() & lst[i]) != 0);
-		fpsetmask(msk & lst[i]);
+		fpsetmask(msk & ~lst[i]);
 		ATF_CHECK((fpgetmask() & lst[i]) == 0);
 	}
 



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

2015-12-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 22 14:18:35 UTC 2015

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

Log Message:
Put have fenv elsewhere.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.47 src/tests/lib/libc/gen/Makefile:1.48
--- src/tests/lib/libc/gen/Makefile:1.47	Tue Dec 22 03:26:16 2015
+++ src/tests/lib/libc/gen/Makefile	Tue Dec 22 09:18:35 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.47 2015/12/22 08:26:16 martin Exp $
+# $NetBSD: Makefile,v 1.48 2015/12/22 14:18:35 christos Exp $
 
 .include 
 
@@ -39,16 +39,8 @@ TESTS_C+=	t_time
 TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
-.if ${MACHINE_CPU} == "aarch64" || ${MACHINE_CPU} == "arm" \
-|| ${MACHINE_ARCH} == "hppa" ||  ${MACHINE_ARCH} == "powerpc" \
-|| ${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64" \
-|| ${MACHINE_ARCH} == "i386" || ${MACHINE_ARCH} == "x86_64" \
-|| ${MACHINE_ARCH} == "mips"
-CPPFLAGS.t_siginfo.c+=	-DHAVE_FENV
 LDADD.t_siginfo+=	-lm
 DPADD.t_siginfo+=	${LIBM}
-.endif
-
 LDADD.t_fpclassify+=	-lm
 DPADD.t_fpclassify+=	${LIBM}
 LDADD.t_fpsetround+=	-lm



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

2015-12-22 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Dec 22 14:25:58 UTC 2015

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

Log Message:
Add __TEST_FENV


To generate a diff of this commit:
cvs rdiff -u -r1.48 -r1.49 src/tests/lib/libc/gen/Makefile
cvs rdiff -u -r1.29 -r1.30 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/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.48 src/tests/lib/libc/gen/Makefile:1.49
--- src/tests/lib/libc/gen/Makefile:1.48	Tue Dec 22 09:18:35 2015
+++ src/tests/lib/libc/gen/Makefile	Tue Dec 22 09:25:58 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.48 2015/12/22 14:18:35 christos Exp $
+# $NetBSD: Makefile,v 1.49 2015/12/22 14:25:58 christos Exp $
 
 .include 
 
@@ -39,6 +39,8 @@ TESTS_C+=	t_time
 TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
+CPPFLAGS.t_siginfo.c+=-D__TEST_FENV
+
 LDADD.t_siginfo+=	-lm
 DPADD.t_siginfo+=	${LIBM}
 LDADD.t_fpclassify+=	-lm

Index: src/tests/lib/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.29 src/tests/lib/libc/gen/t_siginfo.c:1.30
--- src/tests/lib/libc/gen/t_siginfo.c:1.29	Tue Feb 17 04:47:08 2015
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue Dec 22 09:25:58 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.29 2015/02/17 09:47:08 isaki Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.30 2015/12/22 14:25:58 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -44,8 +44,8 @@
 #include 
 #include 
 
-#ifdef HAVE_FENV
 #include 
+#ifdef __HAVE_FENV
 #include 	/* only need for ARM Cortex/Neon hack */
 #elif defined(_FLOAT_IEEE754)
 #include 
@@ -325,7 +325,7 @@ ATF_TC_BODY(sigfpe_flt, tc)
 		sa.sa_sigaction = sigfpe_flt_action;
 		sigemptyset(_mask);
 		sigaction(SIGFPE, , NULL);
-#ifdef HAVE_FENV
+#ifdef __HAVE_FENV
 		feenableexcept(FE_ALL_EXCEPT);
 #elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
@@ -376,7 +376,7 @@ ATF_TC_BODY(sigfpe_int, tc)
 		sa.sa_sigaction = sigfpe_int_action;
 		sigemptyset(_mask);
 		sigaction(SIGFPE, , NULL);
-#ifdef HAVE_FENV
+#ifdef __HAVE_FENV
 		feenableexcept(FE_ALL_EXCEPT);
 #elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);



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

2015-09-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Sep 12 15:21:33 UTC 2015

Modified Files:
src/tests/lib/libc/gen/execve: t_execve.c

Log Message:
make error more informative.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/execve/t_execve.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/execve/t_execve.c
diff -u src/tests/lib/libc/gen/execve/t_execve.c:1.1 src/tests/lib/libc/gen/execve/t_execve.c:1.2
--- src/tests/lib/libc/gen/execve/t_execve.c:1.1	Tue Apr 29 02:29:02 2014
+++ src/tests/lib/libc/gen/execve/t_execve.c	Sat Sep 12 11:21:33 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_execve.c,v 1.1 2014/04/29 06:29:02 uebayasi Exp $	*/
+/*	$NetBSD: t_execve.c,v 1.2 2015/09/12 15:21:33 christos Exp $	*/
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -47,7 +47,8 @@ ATF_TC_BODY(t_execve_null, tc)
 
 	err = execve(NULL, NULL, NULL);
 	ATF_REQUIRE(err == -1);
-	ATF_REQUIRE(errno == EFAULT);
+	ATF_REQUIRE_MSG(errno == EFAULT,
+	"wrong error returned %d instead of %d", errno, EFAULT);
 }
 
 ATF_TP_ADD_TCS(tp)



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

2015-07-07 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Wed Jul  8 01:09:25 UTC 2015

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

Log Message:
Build t_fpgetmask/t_fpgetround for aarch64 since they are now in libc


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.44 src/tests/lib/libc/gen/Makefile:1.45
--- src/tests/lib/libc/gen/Makefile:1.44	Sat Dec 27 18:00:13 2014
+++ src/tests/lib/libc/gen/Makefile	Wed Jul  8 01:09:25 2015
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.44 2014/12/27 18:00:13 martin Exp $
+# $NetBSD: Makefile,v 1.45 2015/07/08 01:09:25 matt Exp $
 
 .include bsd.own.mk
 
@@ -17,10 +17,8 @@ TESTS_C+=	t_floatunditf
 TESTS_C+=	t_fmtcheck
 TESTS_C+=	t_fnmatch
 TESTS_C+=	t_fpclassify
-.if ${MACHINE_CPU} != aarch64
 TESTS_C+=	t_fpsetmask
 TESTS_C+=	t_fpsetround
-.endif
 TESTS_C+=	t_ftok
 TESTS_C+=	t_getcwd
 TESTS_C+=	t_getgrent



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

2015-05-23 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat May 23 14:02:11 UTC 2015

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

Log Message:
Add a VIS_NOLOCALE test


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/gen/t_vis.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_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.7 src/tests/lib/libc/gen/t_vis.c:1.8
--- src/tests/lib/libc/gen/t_vis.c:1.7	Mon Sep  8 15:01:03 2014
+++ src/tests/lib/libc/gen/t_vis.c	Sat May 23 10:02:11 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vis.c,v 1.7 2014/09/08 19:01:03 christos Exp $	*/
+/*	$NetBSD: t_vis.c,v 1.8 2015/05/23 14:02:11 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -32,6 +32,7 @@
 
 #include string.h
 #include stdlib.h
+#include locale.h
 #include err.h
 #include vis.h
 
@@ -143,6 +144,35 @@ ATF_TC_BODY(strunvis_hex, tc)
 	}
 }
 
+ATF_TC(strvis_locale);
+ATF_TC_HEAD(strvis_locale, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test strvis(3) with locale);
+}
+
+ATF_TC_BODY(strvis_locale, tc)
+{
+	char s[256], cd[sizeof(s) * 4 + 1], jd[sizeof(cd)], *ol;
+	int jr, cr;
+
+	for (size_t i = 0; i  sizeof(s) - 1; i++)
+		s[i] = i + 1;
+	s[sizeof(s) - 1] = '\0';
+
+	ol = setlocale(LC_CTYPE, ja_JP.UTF-8);
+	ATF_REQUIRE(ol != NULL);
+	jr = strvisx(jd, s, sizeof(s), VIS_WHITE | VIS_NOLOCALE);
+	ATF_REQUIRE(jr != -1);
+	ol = strdup(ol);
+	ATF_REQUIRE(ol != NULL);
+	ATF_REQUIRE(setlocale(LC_CTYPE, C) != NULL);
+	cr = strvisx(cd, s, sizeof(s), VIS_WHITE);
+	ATF_REQUIRE(jr == cr);
+	ATF_REQUIRE(memcmp(jd, cd, jr) == 0);
+	setlocale(LC_CTYPE, ol);
+	free(ol);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -150,6 +180,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, strvis_null);
 	ATF_TP_ADD_TC(tp, strvis_empty);
 	ATF_TP_ADD_TC(tp, strunvis_hex);
+	ATF_TP_ADD_TC(tp, strvis_locale);
 
 	return atf_no_error();
 }



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

2015-03-07 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Mar  7 09:59:15 UTC 2015

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

Log Message:
Reduce the number of loops.
It avoids timeout on slow machines, and I think that 100,000
times loop also satisfies the evaluation.
PR lib/49664 (no comments)


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_randomid.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_randomid.c
diff -u src/tests/lib/libc/gen/t_randomid.c:1.4 src/tests/lib/libc/gen/t_randomid.c:1.5
--- src/tests/lib/libc/gen/t_randomid.c:1.4	Sat Feb 14 08:46:02 2015
+++ src/tests/lib/libc/gen/t_randomid.c	Sat Mar  7 09:59:15 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_randomid.c,v 1.4 2015/02/14 08:46:02 isaki Exp $ */
+/* $NetBSD: t_randomid.c,v 1.5 2015/03/07 09:59:15 isaki Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -58,7 +58,7 @@ ATF_TC_BODY(randomid_basic, tc)
 
 	lowest = UINT32_MAX;
 
-	for (n = 0; n  100; n++) {
+	for (n = 0; n  10; n++) {
 		id = randomid(ctx);
 
 		if (last[id]  0) {



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

2015-02-17 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Tue Feb 17 09:47:08 UTC 2015

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

Log Message:
m68k (except sun2) never issue SIGBUS on unaligned accesses.
PR lib/49653.  Thanks martin@.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 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.28 src/tests/lib/libc/gen/t_siginfo.c:1.29
--- src/tests/lib/libc/gen/t_siginfo.c:1.28	Fri Feb 13 16:56:57 2015
+++ src/tests/lib/libc/gen/t_siginfo.c	Tue Feb 17 09:47:08 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.28 2015/02/13 16:56:57 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.29 2015/02/17 09:47:08 isaki Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -466,6 +466,10 @@ ATF_TC_BODY(sigbus_adraln, tc)
 		atf_tc_skip(No SIGBUS signal for unaligned accesses);
 #endif
 
+	/* m68k (except sun2) never issue SIGBUS (PR lib/49653) */
+	if (strcmp(MACHINE_ARCH, m68k) == 0)
+		atf_tc_skip(No SIGBUS signal for unaligned accesses);
+
 	sa.sa_flags = SA_SIGINFO;
 	sa.sa_sigaction = sigbus_action;
 	sigemptyset(sa.sa_mask);



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

2015-02-14 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Sat Feb 14 08:46:02 UTC 2015

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

Log Message:
uint64_t - uint32_t.  32bit is sufficient in this case
and it improved the performance approx 7% on my 68030.
see also PR lib/49664.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_randomid.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_randomid.c
diff -u src/tests/lib/libc/gen/t_randomid.c:1.3 src/tests/lib/libc/gen/t_randomid.c:1.4
--- src/tests/lib/libc/gen/t_randomid.c:1.3	Thu Jul  7 09:49:59 2011
+++ src/tests/lib/libc/gen/t_randomid.c	Sat Feb 14 08:46:02 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_randomid.c,v 1.3 2011/07/07 09:49:59 jruoho Exp $ */
+/* $NetBSD: t_randomid.c,v 1.4 2015/02/14 08:46:02 isaki Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 
 #define	PERIOD		3
 
-uint64_t last[65536];
+uint32_t last[65536];
 
 ATF_TC(randomid_basic);
 ATF_TC_HEAD(randomid_basic, tc)
@@ -50,13 +50,13 @@ ATF_TC_HEAD(randomid_basic, tc)
 ATF_TC_BODY(randomid_basic, tc)
 {
 	static randomid_t ctx = NULL;
-	uint64_t lowest, n, diff;
+	uint32_t lowest, n, diff;
 	uint16_t id;
 
 	memset(last, 0, sizeof(last));
 	ctx = randomid_new(16, (long)3600);
 
-	lowest = UINT64_MAX;
+	lowest = UINT32_MAX;
 
 	for (n = 0; n  100; n++) {
 		id = randomid(ctx);
@@ -65,15 +65,15 @@ ATF_TC_BODY(randomid_basic, tc)
 			diff = n - last[id];
 
 			if (diff = lowest) {
-if (lowest != UINT64_MAX)
-	printf(id %5d: last call at %9PRIu64
-	, current call %9PRIu64
-	 (diff %5PRIu64), 
-	lowest %PRIu64\n,
+if (lowest != UINT32_MAX)
+	printf(id %5d: last call at %9PRIu32
+	, current call %9PRIu32
+	 (diff %5PRIu32), 
+	lowest %PRIu32\n,
 	id, last[id], n, diff, lowest);
 
 ATF_REQUIRE_MSG(diff = PERIOD,
-diff (%PRIu64) less than minimum 
+diff (%PRIu32) less than minimum 
 period (%d), diff, PERIOD);
 
 lowest = diff;



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

2015-02-13 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Fri Feb 13 16:56:57 UTC 2015

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

Log Message:
Fix strange editor mishap and start block comment on its own line.


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 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.27 src/tests/lib/libc/gen/t_siginfo.c:1.28
--- src/tests/lib/libc/gen/t_siginfo.c:1.27	Mon Dec 29 18:36:27 2014
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Feb 13 16:56:57 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.27 2014/12/29 18:36:27 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.28 2015/02/13 16:56:57 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -311,7 +311,8 @@ ATF_TC_BODY(sigfpe_flt, tc)
 		atf_tc_skip(Test does not run correctly under QEMU);
 #if defined(__powerpc__)
 	atf_tc_skip(Test not valid on powerpc);
-#elif defined(__arm__)  !__SOFTFP__	/*
+#elif defined(__arm__)  !__SOFTFP__
+	/*
 	 * Some NEON fpus do not implement IEEE exception handling,
 	 * skip these tests if running on them and compiled for
 	 * hard float.



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

2015-01-03 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Sat Jan  3 14:21:05 UTC 2015

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

Log Message:
Need stdlib.h for EXIT_FAILURE


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 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.3 src/tests/lib/libc/gen/isqemu.h:1.4
--- src/tests/lib/libc/gen/isqemu.h:1.3	Sun Apr 14 12:46:29 2013
+++ src/tests/lib/libc/gen/isqemu.h	Sat Jan  3 14:21:05 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: isqemu.h,v 1.3 2013/04/14 12:46:29 martin Exp $	*/
+/*	$NetBSD: isqemu.h,v 1.4 2015/01/03 14:21:05 gson Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -34,6 +34,7 @@
 #include sys/param.h
 #include sys/sysctl.h
 #include stdbool.h
+#include stdlib.h
 #include string.h
 #include errno.h
 #include err.h



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

2014-12-29 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Dec 29 18:36:27 UTC 2014

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

Log Message:
Include ieeefp.h even for the fenv.h case since we use fpsetmask()
to detect ARM Cortex NEON fpus.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 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.26 src/tests/lib/libc/gen/t_siginfo.c:1.27
--- src/tests/lib/libc/gen/t_siginfo.c:1.26	Wed Nov 19 10:09:45 2014
+++ src/tests/lib/libc/gen/t_siginfo.c	Mon Dec 29 18:36:27 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.26 2014/11/19 10:09:45 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.27 2014/12/29 18:36:27 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -46,6 +46,7 @@
 
 #ifdef HAVE_FENV
 #include fenv.h
+#include ieeefp.h	/* only need for ARM Cortex/Neon hack */
 #elif defined(_FLOAT_IEEE754)
 #include ieeefp.h
 #endif



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

2014-12-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Dec 27 18:00:13 UTC 2014

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

Log Message:
Enable fenv for arm


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.43 src/tests/lib/libc/gen/Makefile:1.44
--- src/tests/lib/libc/gen/Makefile:1.43	Sun Aug 10 12:01:57 2014
+++ src/tests/lib/libc/gen/Makefile	Sat Dec 27 18:00:13 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.43 2014/08/10 12:01:57 martin Exp $
+# $NetBSD: Makefile,v 1.44 2014/12/27 18:00:13 martin Exp $
 
 .include bsd.own.mk
 
@@ -41,8 +41,7 @@ TESTS_C+=	t_time
 TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
-# add back || ${MACHINE_CPU} == arm once feenableexcept() is implemented
-.if ${MACHINE_CPU} == aarch64 \
+.if ${MACHINE_CPU} == aarch64 || ${MACHINE_CPU} == arm \
 || ${MACHINE_ARCH} == sparc || ${MACHINE_ARCH} == sparc64 \
 || ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64
 CPPFLAGS.t_siginfo.c+=	-DHAVE_FENV



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

2014-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 19 10:03:51 UTC 2014

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

Log Message:
Use machdep.unaligned_sigbus to skip the unaligned access test on arm
as well.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 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.24 src/tests/lib/libc/gen/t_siginfo.c:1.25
--- src/tests/lib/libc/gen/t_siginfo.c:1.24	Tue Nov  4 00:20:19 2014
+++ src/tests/lib/libc/gen/t_siginfo.c	Wed Nov 19 10:03:51 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.24 2014/11/04 00:20:19 justin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.25 2014/11/19 10:03:51 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -448,13 +448,13 @@ ATF_TC_BODY(sigbus_adraln, tc)
 {
 	struct sigaction sa;
 
-#if defined(__alpha__)
+#if defined(__alpha__) || defined(__arm__)
 	int rv, val;
 	size_t len = sizeof(val);
 	rv = sysctlbyname(machdep.unaligned_sigbus, val, len, NULL, 0);
 	ATF_REQUIRE(rv == 0);
 	if (val == 0)
-		atf_tc_skip(SIGBUS signal not enabled for unaligned accesses);
+		atf_tc_skip(No SIGBUS signal for unaligned accesses);
 #endif
 
 	sa.sa_flags = SA_SIGINFO;



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

2014-11-19 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Nov 19 10:09:45 UTC 2014

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

Log Message:
Skip the SIGFPE test on arm when the FPU does not provide exception handling.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 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.25 src/tests/lib/libc/gen/t_siginfo.c:1.26
--- src/tests/lib/libc/gen/t_siginfo.c:1.25	Wed Nov 19 10:03:51 2014
+++ src/tests/lib/libc/gen/t_siginfo.c	Wed Nov 19 10:09:45 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.25 2014/11/19 10:03:51 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.26 2014/11/19 10:09:45 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -310,6 +310,13 @@ ATF_TC_BODY(sigfpe_flt, tc)
 		atf_tc_skip(Test does not run correctly under QEMU);
 #if defined(__powerpc__)
 	atf_tc_skip(Test not valid on powerpc);
+#elif defined(__arm__)  !__SOFTFP__	/*
+	 * Some NEON fpus do not implement IEEE exception handling,
+	 * skip these tests if running on them and compiled for
+	 * hard float.
+	 */
+	if (0 == fpsetmask(fpsetmask(FP_X_INV)))
+		atf_tc_skip(FPU does not implement exception handling);
 #endif
 	if (sigsetjmp(sigfpe_flt_env, 0) == 0) {
 		sa.sa_flags = SA_SIGINFO;



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

2014-11-18 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Tue Nov 18 08:58:08 UTC 2014

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

Log Message:
Skip the tests on ARM if the NEON fpu does not support exceptions (Cortex).


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/tests/lib/libc/gen/t_fpsetmask.c:1.15
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.14	Tue Nov  4 00:20:19 2014
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Tue Nov 18 08:58:08 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.15 2014/11/18 08:58:08 martin Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -58,8 +58,20 @@ ATF_TC_BODY(no_test, tc)
 
 #include ieeefp.h
 
-const char *skip_mesg;
-const char *skip_arch;
+#if __arm__  !__SOFTFP__
+	/*
+	 * Some NEON fpus do not implement IEEE exception handling,
+	 * skip these tests if running on them and compiled for
+	 * hard float.
+	 */
+#define	FPU_PREREQ()			\
+	if (0 == fpsetmask(fpsetmask(FP_X_INV)))			\
+		atf_tc_skip(FPU does not implement exception handling);
+#endif
+
+#ifndef FPU_PREREQ
+#define	FPU_PREREQ()	/* nothing */
+#endif
 
 void		sigfpe(int, siginfo_t *, void *);
 
@@ -296,6 +308,9 @@ sigfpe(int s, siginfo_t *si, void *c)
 	\
 	ATF_TC_BODY(m##_##t, tc)	\
 	{\
+	\
+		FPU_PREREQ();		\
+	\
 		if (strcmp(MACHINE, macppc) == 0)			\
 			atf_tc_expect_fail(PR port-macppc/46319);	\
 	\
@@ -323,6 +338,8 @@ ATF_TC_BODY(fpsetmask_basic, tc)
 	size_t i;
 	fp_except_t msk, lst[] = { FP_X_INV, FP_X_DZ, FP_X_OFL, FP_X_UFL };
 
+	FPU_PREREQ();
+
 	msk = fpgetmask();
 	for (i = 0; i  __arraycount(lst); i++) {
 		fpsetmask(msk | lst[i]);



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

2014-10-31 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Fri Oct 31 12:22:38 UTC 2014

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

Log Message:
PR misc/49342 fix issue where time can tick during tests

Note there are still potential issues as the clock being tested is not
monotonic but it should now not fail unless time is being adjusted.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_time.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_time.c
diff -u src/tests/lib/libc/gen/t_time.c:1.2 src/tests/lib/libc/gen/t_time.c:1.3
--- src/tests/lib/libc/gen/t_time.c:1.2	Fri Nov 11 05:03:38 2011
+++ src/tests/lib/libc/gen/t_time.c	Fri Oct 31 12:22:38 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $ */
+/*	$NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $ */
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $);
+__RCSID($NetBSD: t_time.c,v 1.3 2014/10/31 12:22:38 justin Exp $);
 
 #include atf-c.h
 #include errno.h
@@ -91,15 +91,16 @@ ATF_TC_HEAD(time_timeofday, tc)
 ATF_TC_BODY(time_timeofday, tc)
 {
 	struct timeval tv = { 0, 0 };
-	time_t t;
+	time_t t1, t2;
 
-	t = time(NULL);
+	t1 = time(NULL);
 	ATF_REQUIRE(gettimeofday(tv, NULL) == 0);
+	t2 = time(NULL);
 
 	(void)fprintf(stderr, %PRId64 vs. %PRId64\n,
-	(int64_t)t, (int64_t)tv.tv_sec);
+	(int64_t)t1, (int64_t)tv.tv_sec);
 
-	if (t != tv.tv_sec)
+	if (t1  tv.tv_sec || t2  tv.tv_sec)
 		atf_tc_fail(time(3) and gettimeofday(2) differ);
 }
 



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

2014-10-12 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sun Oct 12 18:59:35 UTC 2014

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

Log Message:
Add some fnmatch test cases from other C library test suites


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_fnmatch.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_fnmatch.c
diff -u src/tests/lib/libc/gen/t_fnmatch.c:1.3 src/tests/lib/libc/gen/t_fnmatch.c:1.4
--- src/tests/lib/libc/gen/t_fnmatch.c:1.3	Sun Apr  8 09:58:59 2012
+++ src/tests/lib/libc/gen/t_fnmatch.c	Sun Oct 12 18:59:35 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.3 2012/04/08 09:58:59 jruoho Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.4 2014/10/12 18:59:35 justin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_fnmatch.c,v 1.3 2012/04/08 09:58:59 jruoho Exp $);
+__RCSID($NetBSD: t_fnmatch.c,v 1.4 2014/10/12 18:59:35 justin Exp $);
 
 #include atf-c.h
 #include fnmatch.h
@@ -153,6 +153,30 @@ ATF_TC_BODY(fnmatch_period, tc)
 	ATF_CHECK(fnmatch(x/*y, x/.y, FNM_PATHNAME | FNM_PERIOD) != 0);
 }
 
+ATF_TC(fnmatch_initialbracket);
+ATF_TC_HEAD(fnmatch_initialbracket, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test fnmatch with initial [);
+}
+
+ATF_TC_BODY(fnmatch_initialbracket, tc)
+{
+	ATF_CHECK(fnmatch([[?*\\], \\, 0) == 0);
+	ATF_CHECK(fnmatch([]?*\\], ], 0) == 0);
+	ATF_CHECK(fnmatch([!]a-], b, 0) == 0);
+	ATF_CHECK(fnmatch([]-_], ^, 0) == 0); /* range: ']', '^', '_' */
+	ATF_CHECK(fnmatch([!]-_], X, 0) == 0);
+	ATF_CHECK(fnmatch([a-z]/[a-z], a/b, 0) == 0);
+	ATF_CHECK(fnmatch([*]/b, */b, 0) == 0);
+	ATF_CHECK(fnmatch([?]/b, ?/b, 0) == 0);
+	ATF_CHECK(fnmatch([[a]/b, a/b, 0) == 0);
+	ATF_CHECK(fnmatch([[a]/b, [/b, 0) == 0);
+	ATF_CHECK(fnmatch([/b, [/b, 0) == 0);
+
+	ATF_CHECK(fnmatch([*]/b, a/b, 0) != 0);
+	ATF_CHECK(fnmatch([?]/b, a/b, 0) != 0);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -162,6 +186,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, fnmatch_noescape);
 	ATF_TP_ADD_TC(tp, fnmatch_pathname);
 	ATF_TP_ADD_TC(tp, fnmatch_period);
+	ATF_TP_ADD_TC(tp, fnmatch_initialbracket);
 
 	return atf_no_error();
 }



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

2014-10-12 Thread Justin Cormack
Module Name:src
Committed By:   justin
Date:   Sun Oct 12 19:08:08 UTC 2014

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

Log Message:
Add expect fail for PR lib/49278


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_fnmatch.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_fnmatch.c
diff -u src/tests/lib/libc/gen/t_fnmatch.c:1.4 src/tests/lib/libc/gen/t_fnmatch.c:1.5
--- src/tests/lib/libc/gen/t_fnmatch.c:1.4	Sun Oct 12 18:59:35 2014
+++ src/tests/lib/libc/gen/t_fnmatch.c	Sun Oct 12 19:08:08 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.4 2014/10/12 18:59:35 justin Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.5 2014/10/12 19:08:08 justin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_fnmatch.c,v 1.4 2014/10/12 18:59:35 justin Exp $);
+__RCSID($NetBSD: t_fnmatch.c,v 1.5 2014/10/12 19:08:08 justin Exp $);
 
 #include atf-c.h
 #include fnmatch.h
@@ -175,6 +175,8 @@ ATF_TC_BODY(fnmatch_initialbracket, tc)
 
 	ATF_CHECK(fnmatch([*]/b, a/b, 0) != 0);
 	ATF_CHECK(fnmatch([?]/b, a/b, 0) != 0);
+
+	atf_tc_expect_fail(PR lib/49278);
 }
 
 ATF_TP_ADD_TCS(tp)



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

2014-10-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 12 22:33:41 UTC 2014

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

Log Message:
You need double the number of backslashes in a pattern, since \\ - '\' in
the string which means escape. Now the tests don't fail.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_fnmatch.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_fnmatch.c
diff -u src/tests/lib/libc/gen/t_fnmatch.c:1.5 src/tests/lib/libc/gen/t_fnmatch.c:1.6
--- src/tests/lib/libc/gen/t_fnmatch.c:1.5	Sun Oct 12 15:08:08 2014
+++ src/tests/lib/libc/gen/t_fnmatch.c	Sun Oct 12 18:33:41 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fnmatch.c,v 1.5 2014/10/12 19:08:08 justin Exp $ */
+/* $NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include sys/cdefs.h
-__RCSID($NetBSD: t_fnmatch.c,v 1.5 2014/10/12 19:08:08 justin Exp $);
+__RCSID($NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos Exp $);
 
 #include atf-c.h
 #include fnmatch.h
@@ -161,8 +161,8 @@ ATF_TC_HEAD(fnmatch_initialbracket, tc)
 
 ATF_TC_BODY(fnmatch_initialbracket, tc)
 {
-	ATF_CHECK(fnmatch([[?*\\], \\, 0) == 0);
-	ATF_CHECK(fnmatch([]?*\\], ], 0) == 0);
+	ATF_CHECK(fnmatch([[?*], \\, 0) == 0);
+	ATF_CHECK(fnmatch([]?*], ], 0) == 0);
 	ATF_CHECK(fnmatch([!]a-], b, 0) == 0);
 	ATF_CHECK(fnmatch([]-_], ^, 0) == 0); /* range: ']', '^', '_' */
 	ATF_CHECK(fnmatch([!]-_], X, 0) == 0);
@@ -175,8 +175,6 @@ ATF_TC_BODY(fnmatch_initialbracket, tc)
 
 	ATF_CHECK(fnmatch([*]/b, a/b, 0) != 0);
 	ATF_CHECK(fnmatch([?]/b, a/b, 0) != 0);
-
-	atf_tc_expect_fail(PR lib/49278);
 }
 
 ATF_TP_ADD_TCS(tp)



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

2014-09-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Sep  8 19:01:03 UTC 2014

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

Log Message:
add null and empty tests.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_vis.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_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.6 src/tests/lib/libc/gen/t_vis.c:1.7
--- src/tests/lib/libc/gen/t_vis.c:1.6	Tue Feb 12 23:51:56 2013
+++ src/tests/lib/libc/gen/t_vis.c	Mon Sep  8 15:01:03 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vis.c,v 1.6 2013/02/13 04:51:56 christos Exp $	*/
+/*	$NetBSD: t_vis.c,v 1.7 2014/09/08 19:01:03 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -89,6 +89,32 @@ ATF_TC_BODY(strvis_basic, tc)
 	free(visbuf);
 }
 
+ATF_TC(strvis_null);
+ATF_TC_HEAD(strvis_null, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test strvis(3) NULL);
+}
+
+ATF_TC_BODY(strvis_null, tc)
+{
+	char dst[] = fail;
+	strvis(dst, NULL, VIS_SAFE);
+	ATF_REQUIRE(dst[0] == '\0'  dst[1] == 'a');
+}
+
+ATF_TC(strvis_empty);
+ATF_TC_HEAD(strvis_empty, tc)
+{
+	atf_tc_set_md_var(tc, descr, Test strvis(3) empty);
+}
+
+ATF_TC_BODY(strvis_empty, tc)
+{
+	char dst[] = fail;
+	strvis(dst, , VIS_SAFE);
+	ATF_REQUIRE(dst[0] == '\0'  dst[1] == 'a');
+}
+
 ATF_TC(strunvis_hex);
 ATF_TC_HEAD(strunvis_hex, tc)
 {
@@ -121,6 +147,8 @@ ATF_TP_ADD_TCS(tp)
 {
 
 	ATF_TP_ADD_TC(tp, strvis_basic);
+	ATF_TP_ADD_TC(tp, strvis_null);
+	ATF_TP_ADD_TC(tp, strvis_empty);
 	ATF_TP_ADD_TC(tp, strunvis_hex);
 
 	return atf_no_error();



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

2014-08-10 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Aug 10 12:01:57 UTC 2014

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

Log Message:
Do not set HAVE_FENV for arm as long as it misses feenableexcept().


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/tests/lib/libc/gen/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/gen/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.42 src/tests/lib/libc/gen/Makefile:1.43
--- src/tests/lib/libc/gen/Makefile:1.42	Sun Aug 10 11:30:51 2014
+++ src/tests/lib/libc/gen/Makefile	Sun Aug 10 12:01:57 2014
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.42 2014/08/10 11:30:51 martin Exp $
+# $NetBSD: Makefile,v 1.43 2014/08/10 12:01:57 martin Exp $
 
 .include bsd.own.mk
 
@@ -41,7 +41,8 @@ TESTS_C+=	t_time
 TESTS_C+=	t_ttyname
 TESTS_C+=	t_vis
 
-.if ${MACHINE_CPU} == aarch64 || ${MACHINE_CPU} == arm \
+# add back || ${MACHINE_CPU} == arm once feenableexcept() is implemented
+.if ${MACHINE_CPU} == aarch64 \
 || ${MACHINE_ARCH} == sparc || ${MACHINE_ARCH} == sparc64 \
 || ${MACHINE_ARCH} == i386 || ${MACHINE_ARCH} == x86_64
 CPPFLAGS.t_siginfo.c+=	-DHAVE_FENV



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

2014-07-15 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Jul 15 14:56:35 UTC 2014

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

Log Message:
space after comma


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.7 src/tests/lib/libc/gen/t_sleep.c:1.8
--- src/tests/lib/libc/gen/t_sleep.c:1.7	Fri Apr 12 17:13:55 2013
+++ src/tests/lib/libc/gen/t_sleep.c	Tue Jul 15 14:56:34 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.7 2013/04/12 17:13:55 christos Exp $ */
+/* $NetBSD: t_sleep.c,v 1.8 2014/07/15 14:56:34 gson Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -69,7 +69,7 @@
  * penultimate pass, and the KEVNT_TIMEOUT on the final pass.  We
  * set KEVNT_TIMEOUT just barely long enough to put it into the
  * last test pass, and set MAXSLEEP a couple seconds longer than
- * necessary,in order to avoid a QEMU bug which nearly doubles
+ * necessary, in order to avoid a QEMU bug which nearly doubles
  * some timers.
  */
 



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

2014-06-14 Thread Alan Barrett
Module Name:src
Committed By:   apb
Date:   Sat Jun 14 08:19:02 UTC 2014

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

Log Message:
Update fmtcheck(3) test now that pointers and longs are differentiated.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_fmtcheck.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_fmtcheck.c
diff -u src/tests/lib/libc/gen/t_fmtcheck.c:1.2 src/tests/lib/libc/gen/t_fmtcheck.c:1.3
--- src/tests/lib/libc/gen/t_fmtcheck.c:1.2	Thu Jul  7 09:49:59 2011
+++ src/tests/lib/libc/gen/t_fmtcheck.c	Sat Jun 14 08:19:02 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fmtcheck.c,v 1.2 2011/07/07 09:49:59 jruoho Exp $	*/
+/*	$NetBSD: t_fmtcheck.c,v 1.3 2014/06/14 08:19:02 apb Exp $	*/
 
 /*-
  * Copyright (c) 2000 The NetBSD Foundation, Inc.
@@ -72,7 +72,9 @@ struct test_fmt {
 	{ %#o %u %#-d, %x %#x %X, 1 },
 	{ %qd, %llx, 1 },
 	{ %%, %llx, 1 },
-	{ %p %30s %#llx %-10.*e, This number %lu%% and string %s has %qd numbers and %.*g floats, 1 },
+	{ %ld %30s %#llx %-10.*e, This number %lu%% and string %s has %qd numbers and %.*g floats, 1 },
+	{ %o, %lx, 2 },
+	{ %p, %lu, 2 },
 };
 
 ATF_TC(fmtcheck_basic);



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

2014-02-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Feb  2 08:16:22 UTC 2014

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

Log Message:
Add a few more test values from the range that sparc64 previously would
have got wrong.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_floatunditf.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_floatunditf.c
diff -u src/tests/lib/libc/gen/t_floatunditf.c:1.4 src/tests/lib/libc/gen/t_floatunditf.c:1.5
--- src/tests/lib/libc/gen/t_floatunditf.c:1.4	Sat Feb  1 13:53:16 2014
+++ src/tests/lib/libc/gen/t_floatunditf.c	Sun Feb  2 08:16:22 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floatunditf.c,v 1.4 2014/02/01 13:53:16 martin Exp $ */
+/* $NetBSD: t_floatunditf.c,v 1.5 2014/02/02 08:16:22 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -37,6 +37,9 @@ static const struct {
 	long double ld;
 } testcases[] = {
 	{ 0xULL, 0xf.fffp+60L },
+	{ 0xfffeULL, 0xf.ffep+60L },
+	{ 0xfffdULL, 0xf.ffdp+60L },
+	{ 0xfffcULL, 0xf.ffcp+60L },
 	{ 0x7fffULL, 0xf.ffep+59L },
 	{ 0x3fffULL, 0xf.ffcp+58L },
 	{ 0x1fffULL, 0xf.ff8p+57L },



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

2014-02-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb  1 10:00:04 UTC 2014

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

Log Message:
Print a slightly more helpfull message in case of test failure


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_floatunditf.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_floatunditf.c
diff -u src/tests/lib/libc/gen/t_floatunditf.c:1.2 src/tests/lib/libc/gen/t_floatunditf.c:1.3
--- src/tests/lib/libc/gen/t_floatunditf.c:1.2	Thu Jan 30 22:15:55 2014
+++ src/tests/lib/libc/gen/t_floatunditf.c	Sat Feb  1 10:00:04 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floatunditf.c,v 1.2 2014/01/30 22:15:55 joerg Exp $ */
+/* $NetBSD: t_floatunditf.c,v 1.3 2014/02/01 10:00:04 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -114,7 +114,11 @@ ATF_TC_BODY(floatunditf, tc)
 	size_t i;
 
 	for (i = 0; i  __arraycount(testcases); ++i)
-		ATF_CHECK(testcases[i].ld == (long double)testcases[i].u64);
+		ATF_CHECK_MSG(
+		testcases[i].ld == (long double)testcases[i].u64,
+		#%zu: expected %.20Lf, got %.20Lf\n, i,
+		testcases[i].ld,
+		(long double)testcases[i].u64);
 }
 #endif
 



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

2014-02-01 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sat Feb  1 13:53:16 UTC 2014

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

Log Message:
Skip testcase inside its body for architectures w/o long double support


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_floatunditf.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_floatunditf.c
diff -u src/tests/lib/libc/gen/t_floatunditf.c:1.3 src/tests/lib/libc/gen/t_floatunditf.c:1.4
--- src/tests/lib/libc/gen/t_floatunditf.c:1.3	Sat Feb  1 10:00:04 2014
+++ src/tests/lib/libc/gen/t_floatunditf.c	Sat Feb  1 13:53:16 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floatunditf.c,v 1.3 2014/02/01 10:00:04 martin Exp $ */
+/* $NetBSD: t_floatunditf.c,v 1.4 2014/02/01 13:53:16 martin Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -101,6 +101,7 @@ static const struct {
 	{ 0x3ULL, 0xcp-2L },
 	{ 0x1ULL, 0x8p-3L },
 };
+#endif
 
 ATF_TC(floatunditf);
 ATF_TC_HEAD(floatunditf, tc)
@@ -111,6 +112,9 @@ ATF_TC_HEAD(floatunditf, tc)
 
 ATF_TC_BODY(floatunditf, tc)
 {
+#ifndef __HAVE_LONG_DOUBLE
+	atf_tc_skip(Requires long double support);
+#else
 	size_t i;
 
 	for (i = 0; i  __arraycount(testcases); ++i)
@@ -119,16 +123,11 @@ ATF_TC_BODY(floatunditf, tc)
 		#%zu: expected %.20Lf, got %.20Lf\n, i,
 		testcases[i].ld,
 		(long double)testcases[i].u64);
-}
 #endif
+}
 
 ATF_TP_ADD_TCS(tp)
 {
-#ifdef __HAVE_LONG_DOUBLE
 	ATF_TP_ADD_TC(tp, floatunditf);
-#else
-	atf_tc_skip(No real long double);
-#endif
-
 	return atf_no_error();
 }



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

2014-01-30 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Thu Jan 30 22:15:55 UTC 2014

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

Log Message:
No unused functions if there is no long double support.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/t_floatunditf.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_floatunditf.c
diff -u src/tests/lib/libc/gen/t_floatunditf.c:1.1 src/tests/lib/libc/gen/t_floatunditf.c:1.2
--- src/tests/lib/libc/gen/t_floatunditf.c:1.1	Thu Jan 30 15:04:04 2014
+++ src/tests/lib/libc/gen/t_floatunditf.c	Thu Jan 30 22:15:55 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_floatunditf.c,v 1.1 2014/01/30 15:04:04 joerg Exp $ */
+/* $NetBSD: t_floatunditf.c,v 1.2 2014/01/30 22:15:55 joerg Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -31,6 +31,7 @@
 #include inttypes.h
 #include math.h
 
+#ifdef __HAVE_LONG_DOUBLE
 static const struct {
 	uint64_t u64;
 	long double ld;
@@ -101,8 +102,6 @@ static const struct {
 	{ 0x1ULL, 0x8p-3L },
 };
 
-long double floatunditf(uint64_t);
-
 ATF_TC(floatunditf);
 ATF_TC_HEAD(floatunditf, tc)
 {
@@ -117,6 +116,7 @@ ATF_TC_BODY(floatunditf, tc)
 	for (i = 0; i  __arraycount(testcases); ++i)
 		ATF_CHECK(testcases[i].ld == (long double)testcases[i].u64);
 }
+#endif
 
 ATF_TP_ADD_TCS(tp)
 {



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

2014-01-26 Thread Matt Thomas
Module Name:src
Committed By:   matt
Date:   Sun Jan 26 21:04:46 UTC 2014

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

Log Message:
Support using fenv instead of fpsetmask if HAVE_FENV is defined.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 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.21 src/tests/lib/libc/gen/t_siginfo.c:1.22
--- src/tests/lib/libc/gen/t_siginfo.c:1.21	Sat Jan 25 10:09:47 2014
+++ src/tests/lib/libc/gen/t_siginfo.c	Sun Jan 26 21:04:46 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.21 2014/01/25 10:09:47 skrll Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.22 2014/01/26 21:04:46 matt Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -45,7 +45,9 @@
 #include setjmp.h
 #include float.h
 
-#ifdef _FLOAT_IEEE754
+#ifdef HAVE_FENV
+#include fenv.h
+#elif defined(_FLOAT_IEEE754)
 #include ieeefp.h
 #endif
 
@@ -314,7 +316,9 @@ ATF_TC_BODY(sigfpe_flt, tc)
 		sa.sa_sigaction = sigfpe_flt_action;
 		sigemptyset(sa.sa_mask);
 		sigaction(SIGFPE, sa, NULL);
-#ifdef _FLOAT_IEEE754
+#ifdef HAVE_FENV
+		feenableexcept(FE_ALL_EXCEPT);
+#elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
 		printf(%g\n, 1 / d);
@@ -362,7 +366,9 @@ ATF_TC_BODY(sigfpe_int, tc)
 		sa.sa_sigaction = sigfpe_int_action;
 		sigemptyset(sa.sa_mask);
 		sigaction(SIGFPE, sa, NULL);
-#ifdef _FLOAT_IEEE754
+#ifdef HAVE_FENV
+		feenableexcept(FE_ALL_EXCEPT);
+#elif defined(_FLOAT_IEEE754)
 		fpsetmask(FP_X_INV|FP_X_DZ|FP_X_OFL|FP_X_UFL|FP_X_IMP);
 #endif
 		printf(%ld\n, 1 / l);



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

2013-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 16 15:22:52 UTC 2013

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

Log Message:
Make it compile on archs where NAN is not defined - previously it only
compiled by chance (and details of the __isnan macro) on vax.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/t_isnan.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_isnan.c
diff -u src/tests/lib/libc/gen/t_isnan.c:1.1 src/tests/lib/libc/gen/t_isnan.c:1.2
--- src/tests/lib/libc/gen/t_isnan.c:1.1	Mon Sep 19 05:25:50 2011
+++ src/tests/lib/libc/gen/t_isnan.c	Mon Sep 16 15:22:51 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_isnan.c,v 1.1 2011/09/19 05:25:50 jruoho Exp $ */
+/* $NetBSD: t_isnan.c,v 1.2 2013/09/16 15:22:51 martin Exp $ */
 
 /*
  * This file is in the Public Domain.
@@ -21,9 +21,11 @@ ATF_TC_HEAD(isnan_basic, tc)
 
 ATF_TC_BODY(isnan_basic, tc)
 {
+#ifdef NAN
 	/* NAN is meant to be a (float)NaN. */
 	ATF_CHECK(isnan(NAN) != 0);
 	ATF_CHECK(isnan((double)NAN) != 0);
+#endif
 }
 
 ATF_TC(isinf_basic);
@@ -51,10 +53,12 @@ ATF_TP_ADD_TCS(tp)
 
 	arch = atf_config_get(atf_arch);
 
-	if (strcmp(vax, arch) == 0 || strcmp(m68000, arch) == 0)
+	if (strcmp(m68000, arch) == 0)
 		atf_tc_skip(Test not applicable on %s, arch);
 	else {
+#ifdef NAN
 		ATF_TP_ADD_TC(tp, isnan_basic);
+#endif
 		ATF_TP_ADD_TC(tp, isinf_basic);
 	}
 



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

2013-09-16 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Sep 16 15:33:24 UTC 2013

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

Log Message:
Retry previous


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_isnan.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_isnan.c
diff -u src/tests/lib/libc/gen/t_isnan.c:1.2 src/tests/lib/libc/gen/t_isnan.c:1.3
--- src/tests/lib/libc/gen/t_isnan.c:1.2	Mon Sep 16 15:22:51 2013
+++ src/tests/lib/libc/gen/t_isnan.c	Mon Sep 16 15:33:24 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_isnan.c,v 1.2 2013/09/16 15:22:51 martin Exp $ */
+/* $NetBSD: t_isnan.c,v 1.3 2013/09/16 15:33:24 martin Exp $ */
 
 /*
  * This file is in the Public Domain.
@@ -25,6 +25,8 @@ ATF_TC_BODY(isnan_basic, tc)
 	/* NAN is meant to be a (float)NaN. */
 	ATF_CHECK(isnan(NAN) != 0);
 	ATF_CHECK(isnan((double)NAN) != 0);
+#else
+	atf_tc_skip(Test not applicable);
 #endif
 }
 
@@ -56,9 +58,7 @@ ATF_TP_ADD_TCS(tp)
 	if (strcmp(m68000, arch) == 0)
 		atf_tc_skip(Test not applicable on %s, arch);
 	else {
-#ifdef NAN
 		ATF_TP_ADD_TC(tp, isnan_basic);
-#endif
 		ATF_TP_ADD_TC(tp, isinf_basic);
 	}
 



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

2013-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 14 12:45:50 UTC 2013

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

Log Message:
Do not include isqemu.h if we are not going to use the test


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/tests/lib/libc/gen/t_fpsetmask.c:1.11
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.10	Fri Apr 12 17:13:54 2013
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Sun Apr 14 12:45:50 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.10 2013/04/12 17:13:54 christos Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.11 2013/04/14 12:45:50 martin Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 
 #ifndef _FLOAT_IEEE754
 
+
 ATF_TC(no_test);
 ATF_TC_HEAD(no_test, tc)
 {



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

2013-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 14 12:46:29 UTC 2013

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

Log Message:
Mark the test function as inline, so we don't get warnings if it is not
actually used.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 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.2 src/tests/lib/libc/gen/isqemu.h:1.3
--- src/tests/lib/libc/gen/isqemu.h:1.2	Fri Apr 12 17:21:04 2013
+++ src/tests/lib/libc/gen/isqemu.h	Sun Apr 14 12:46:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: isqemu.h,v 1.2 2013/04/12 17:21:04 christos Exp $	*/
+/*	$NetBSD: isqemu.h,v 1.3 2013/04/14 12:46:29 martin Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
 #include errno.h
 #include err.h
 
-static bool
+static __inline bool
 isQEMU(void) {
 #if defined(__i386__) || defined(__x86_64__)
 	char name[1024];



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

2013-04-14 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 14 16:03:06 UTC 2013

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

Log Message:
Backout previous - which did not include the change described in the log
message anyway but pure accidental white space changes. The whole change
was not needed any more after fixing isqemu.h.
Thanks to agc for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/tests/lib/libc/gen/t_fpsetmask.c:1.12
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.11	Sun Apr 14 12:45:50 2013
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Sun Apr 14 16:03:06 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.11 2013/04/14 12:45:50 martin Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.12 2013/04/14 16:03:06 martin Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -40,7 +40,6 @@
 
 #ifndef _FLOAT_IEEE754
 
-
 ATF_TC(no_test);
 ATF_TC_HEAD(no_test, tc)
 {



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

2013-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 12 17:13:55 UTC 2013

Modified Files:
src/tests/lib/libc/gen: t_fpsetmask.c t_siginfo.c t_sleep.c
Added Files:
src/tests/lib/libc/gen: isqemu.h

Log Message:
easier way to find if we are on qemu.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/gen/isqemu.h
cvs rdiff -u -r1.9 -r1.10 src/tests/lib/libc/gen/t_fpsetmask.c
cvs rdiff -u -r1.18 -r1.19 src/tests/lib/libc/gen/t_siginfo.c
cvs rdiff -u -r1.6 -r1.7 src/tests/lib/libc/gen/t_sleep.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.9 src/tests/lib/libc/gen/t_fpsetmask.c:1.10
--- src/tests/lib/libc/gen/t_fpsetmask.c:1.9	Fri Apr 13 02:10:55 2012
+++ src/tests/lib/libc/gen/t_fpsetmask.c	Fri Apr 12 13:13:54 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_fpsetmask.c,v 1.9 2012/04/13 06:10:55 jruoho Exp $ */
+/*	$NetBSD: t_fpsetmask.c,v 1.10 2013/04/12 17:13:54 christos Exp $ */
 
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
@@ -36,6 +36,8 @@
 #include stdlib.h
 #include string.h
 
+#include isqemu.h
+
 #ifndef _FLOAT_IEEE754
 
 ATF_TC(no_test);
@@ -296,7 +298,7 @@ sigfpe(int s, siginfo_t *si, void *c)
 		if (strcmp(atf_config_get(atf_arch), macppc) == 0)	\
 			atf_tc_expect_fail(PR port-macppc/46319);	\
 	\
-		if (system(cpuctl identify 0 | grep -q QEMU) == 0)	\
+		if (isQEMU())		\
 			atf_tc_expect_fail(PR misc/44767);		\
 	\
 		m(t##_ops);		\

Index: src/tests/lib/libc/gen/t_siginfo.c
diff -u src/tests/lib/libc/gen/t_siginfo.c:1.18 src/tests/lib/libc/gen/t_siginfo.c:1.19
--- src/tests/lib/libc/gen/t_siginfo.c:1.18	Wed Jun 13 07:45:17 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Apr 12 13:13:55 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.18 2012/06/13 11:45:17 njoly Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.19 2013/04/12 17:13:55 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -49,6 +49,8 @@
 #include ieeefp.h
 #endif
 
+#include isqemu.h
+
 /* for sigbus */
 volatile char *addr;
 
@@ -303,7 +305,7 @@ ATF_TC_BODY(sigfpe_flt, tc)
 	struct sigaction sa;
 	double d = strtod(0, NULL);
 
-	if (system(cpuctl identify 0 | grep -q QEMU) == 0)
+	if (isQEMU())
 		atf_tc_skip(Test does not run correctly under qemu);
 	if (system(cpuctl identify 0 | grep -q 
 	'cpu0: Intel Pentium II (Klamath) (686-class), id 0x633') == 0)
@@ -472,12 +474,8 @@ ATF_TC_BODY(sigbus_adraln, tc)
 	addr = calloc(2, sizeof(int));
 	ATF_REQUIRE(addr != NULL);
 
-	if (strcmp(arch, i386) == 0 || strcmp(arch, x86_64) == 0) {
-		if (system(cpuctl identify 0 | grep -q QEMU) == 0) {
-			atf_tc_expect_fail(QEMU fails to trap unaligned 
-			accesses);
-		}
-	}
+	if (isQEMU())
+		atf_tc_expect_fail(QEMU fails to trap unaligned accesses);
 
 	/* Force an unaligned access */
 	addr++;

Index: src/tests/lib/libc/gen/t_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.6 src/tests/lib/libc/gen/t_sleep.c:1.7
--- src/tests/lib/libc/gen/t_sleep.c:1.6	Sun Mar 17 01:47:48 2013
+++ src/tests/lib/libc/gen/t_sleep.c	Fri Apr 12 13:13:55 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.6 2013/03/17 05:47:48 jmmv Exp $ */
+/* $NetBSD: t_sleep.c,v 1.7 2013/04/12 17:13:55 christos Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -39,6 +39,8 @@
 #include sys/event.h
 #include sys/signal.h
 
+#include isqemu.h
+
 #define BILLION		10LL	/* nano-seconds per second */
 #define MILLION		100LL	/* nano-seconds per milli-second */
 
@@ -157,7 +159,7 @@ do_kevent(struct timespec *delay, struct
 	 * under QEMU, make sure the delay is long enough to account
 	 * for the effects of PR kern/43997 !
 	 */
-	if (system(cpuctl identify 0 | grep -q QEMU) == 0 
+	if (isQEMU() 
 	tmo/1000  delay-tv_sec  tmo/500  delay-tv_sec)
 		delay-tv_sec = MAXSLEEP;
 

Added files:

Index: src/tests/lib/libc/gen/isqemu.h
diff -u /dev/null src/tests/lib/libc/gen/isqemu.h:1.1
--- /dev/null	Fri Apr 12 13:13:55 2013
+++ src/tests/lib/libc/gen/isqemu.h	Fri Apr 12 13:13:54 2013
@@ -0,0 +1,59 @@
+/*	$NetBSD: isqemu.h,v 1.1 2013/04/12 17:13:54 christos Exp $	*/
+
+/*-
+ * Copyright (c) 2013 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of The 

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

2013-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 12 17:21:04 UTC 2013

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

Log Message:
don't pay for sysctl if we don't have to.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 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.1 src/tests/lib/libc/gen/isqemu.h:1.2
--- src/tests/lib/libc/gen/isqemu.h:1.1	Fri Apr 12 13:13:54 2013
+++ src/tests/lib/libc/gen/isqemu.h	Fri Apr 12 13:21:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: isqemu.h,v 1.1 2013/04/12 17:13:54 christos Exp $	*/
+/*	$NetBSD: isqemu.h,v 1.2 2013/04/12 17:21:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 
 static bool
 isQEMU(void) {
+#if defined(__i386__) || defined(__x86_64__)
 	char name[1024];
 	size_t len = sizeof(name);
 
@@ -49,6 +50,9 @@ isQEMU(void) {
 		err(EXIT_FAILURE, sysctl);
 	}
 	return strstr(name, QEMU) != NULL;
+#else
+	return false;
+#endif
 }
 
 #ifdef TEST



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

2013-04-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Fri Apr 12 17:30:50 UTC 2013

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

Log Message:
use one qemu test


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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.19 src/tests/lib/libc/gen/t_siginfo.c:1.20
--- src/tests/lib/libc/gen/t_siginfo.c:1.19	Fri Apr 12 13:13:55 2013
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Apr 12 13:30:50 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.19 2013/04/12 17:13:55 christos Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.20 2013/04/12 17:30:50 christos Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -306,11 +306,7 @@ ATF_TC_BODY(sigfpe_flt, tc)
 	double d = strtod(0, NULL);
 
 	if (isQEMU())
-		atf_tc_skip(Test does not run correctly under qemu);
-	if (system(cpuctl identify 0 | grep -q 
-	'cpu0: Intel Pentium II (Klamath) (686-class), id 0x633') == 0)
-		atf_tc_skip(Test does not run correctly under qemu 
-		(heuristic match));
+		atf_tc_skip(Test does not run correctly under QEMU);
 	if (strcmp(atf_config_get(atf_arch),powerpc) == 0)
 		atf_tc_skip(Test not valid on powerpc);
 	if (sigsetjmp(sigfpe_flt_env, 0) == 0) {



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

2013-03-16 Thread Julio Merino
Module Name:src
Committed By:   jmmv
Date:   Sun Mar 17 05:47:48 UTC 2013

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

Log Message:
Do not special-case qemu when expecting the failure due to PR kern/43997.

I am sporadically observing this in my real machine as well.  It's harder
to trigger, but it happens.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.5 src/tests/lib/libc/gen/t_sleep.c:1.6
--- src/tests/lib/libc/gen/t_sleep.c:1.5	Fri Nov  9 20:13:24 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Sun Mar 17 05:47:48 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.5 2012/11/09 20:13:24 pgoyette Exp $ */
+/* $NetBSD: t_sleep.c,v 1.6 2013/03/17 05:47:48 jmmv Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -301,8 +301,7 @@ sleeptest(int (*test)(struct timespec *,
 		delta3 *= round;
 
 		if (delta3  FUZZ || delta3  -FUZZ) {
-			if (!sim_remain 
-			system(cpuctl identify 0 | grep -q QEMU) == 0) 
+			if (!sim_remain)
 atf_tc_expect_fail(Long reschedule latency 
 due to PR kern/43997);
 



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

2013-02-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Feb 13 04:51:56 UTC 2013

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

Log Message:
- check the results of the vis functions
- zero output to make sure things work
- don't use encodings that don't work
- fix the style on decoding


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/tests/lib/libc/gen/t_vis.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_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.5 src/tests/lib/libc/gen/t_vis.c:1.6
--- src/tests/lib/libc/gen/t_vis.c:1.5	Sun Feb 10 23:12:48 2013
+++ src/tests/lib/libc/gen/t_vis.c	Tue Feb 12 23:51:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vis.c,v 1.5 2013/02/11 04:12:48 christos Exp $	*/
+/*	$NetBSD: t_vis.c,v 1.6 2013/02/13 04:51:56 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -76,7 +76,9 @@ ATF_TC_BODY(strvis_basic, tc)
 
 	for (i = 0; i  __arraycount(styles); i++) {
 		ATF_REQUIRE(strsvisx(visbuf, srcbuf, SIZE, styles[i], )  0);
-		ATF_REQUIRE(strunvisx(dstbuf, visbuf, styles[i])  0);
+		memset(dstbuf, 0, SIZE);
+		ATF_REQUIRE(strunvisx(dstbuf, visbuf, 
+		styles[i]  (VIS_HTTP1808|VIS_MIMESTYLE))  0);
 		for (j = 0; j  SIZE; j++)
 			if (dstbuf[j] != (char)j)
 atf_tc_fail_nonfatal(Failed for style %x, 



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

2013-02-10 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Feb 11 04:12:49 UTC 2013

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

Log Message:
check the results of encoding and decoding


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_vis.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_vis.c
diff -u src/tests/lib/libc/gen/t_vis.c:1.4 src/tests/lib/libc/gen/t_vis.c:1.5
--- src/tests/lib/libc/gen/t_vis.c:1.4	Sat Nov  5 23:38:16 2011
+++ src/tests/lib/libc/gen/t_vis.c	Sun Feb 10 23:12:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_vis.c,v 1.4 2011/11/06 03:38:16 christos Exp $	*/
+/*	$NetBSD: t_vis.c,v 1.5 2013/02/11 04:12:48 christos Exp $	*/
 
 /*-
  * Copyright (c) 2002 The NetBSD Foundation, Inc.
@@ -48,7 +48,9 @@ static int styles[] = {
 #endif
 	VIS_HTTP1808,
 	VIS_MIMESTYLE,
+#if 0	/* Not supported by vis(3) */
 	VIS_HTTP1866,
+#endif
 };
 
 #define SIZE	256
@@ -73,8 +75,8 @@ ATF_TC_BODY(strvis_basic, tc)
 		srcbuf[i] = (char)i;
 
 	for (i = 0; i  __arraycount(styles); i++) {
-		strsvisx(visbuf, srcbuf, SIZE, styles[i], );
-		strunvisx(dstbuf, visbuf, styles[i]);
+		ATF_REQUIRE(strsvisx(visbuf, srcbuf, SIZE, styles[i], )  0);
+		ATF_REQUIRE(strunvisx(dstbuf, visbuf, styles[i])  0);
 		for (j = 0; j  SIZE; j++)
 			if (dstbuf[j] != (char)j)
 atf_tc_fail_nonfatal(Failed for style %x, 



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

2013-01-02 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Jan  2 11:28:49 UTC 2013

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

Log Message:
Remove check for GLOB_NOCHECK - the behaviour has been changed again, so it
will return a modified pattern.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_glob.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_glob.c
diff -u src/tests/lib/libc/gen/t_glob.c:1.2 src/tests/lib/libc/gen/t_glob.c:1.3
--- src/tests/lib/libc/gen/t_glob.c:1.2	Tue Dec 18 01:37:28 2012
+++ src/tests/lib/libc/gen/t_glob.c	Wed Jan  2 11:28:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: t_glob.c,v 1.2 2012/12/18 01:37:28 christos Exp $	*/
+/*	$NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $	*/
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -32,7 +32,7 @@
  */
 
 #include sys/cdefs.h
-__RCSID($NetBSD: t_glob.c,v 1.2 2012/12/18 01:37:28 christos Exp $);
+__RCSID($NetBSD: t_glob.c,v 1.3 2013/01/02 11:28:48 martin Exp $);
 
 #include atf-c.h
 
@@ -238,6 +238,7 @@ ATF_TC_BODY(glob_star_not, tc)
 	run(a/**, 0, glob_star_not, __arraycount(glob_star_not));
 }
 
+#if 0
 ATF_TC(glob_nocheck);
 ATF_TC_HEAD(glob_nocheck, tc)
 {
@@ -255,12 +256,18 @@ ATF_TC_BODY(glob_nocheck, tc)
 	};
 	run(pattern, GLOB_NOCHECK, glob_nocheck, __arraycount(glob_nocheck));
 }
+#endif
 
 ATF_TP_ADD_TCS(tp)
 {
 	ATF_TP_ADD_TC(tp, glob_star);
 	ATF_TP_ADD_TC(tp, glob_star_not);
-	ATF_TP_ADD_TC(tp, glob_nocheck);
+/*
+ * Remove this test for now - the GLOB_NOCHECK return value has been
+ * re-defined to return a modified pattern in revision 1.33 of glob.c
+ *
+ *	ATF_TP_ADD_TC(tp, glob_nocheck);
+ */
 
 	return atf_no_error();
 }



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

2012-11-09 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Nov  9 20:13:24 UTC 2012

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

Log Message:
More clean-up, and adjust timing of kevent test to avoid issues with
PR kern/43887


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.4 src/tests/lib/libc/gen/t_sleep.c:1.5
--- src/tests/lib/libc/gen/t_sleep.c:1.4	Fri Nov  9 04:43:25 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Fri Nov  9 20:13:24 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.4 2012/11/09 04:43:25 pgoyette Exp $ */
+/* $NetBSD: t_sleep.c,v 1.5 2012/11/09 20:13:24 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -42,10 +42,10 @@
 #define BILLION		10LL	/* nano-seconds per second */
 #define MILLION		100LL	/* nano-seconds per milli-second */
 
-#define ALARM		12		/* SIGALRM after this many seconds */
-#define KEVNT_TIMEOUT	16300		/* measured in milli-seconds */
+#define ALARM		6		/* SIGALRM after this many seconds */
+#define MAXSLEEP	22		/* Maximum delay in seconds */
+#define KEVNT_TIMEOUT	10300		/* measured in milli-seconds */
 #define FUZZ		(40 * MILLION)	/* scheduling fuzz accepted - 40 ms */
-#define MAXSLEEP	(22 * BILLION)	/* 22 seconds */
 
 /*
  * Timer notes
@@ -54,18 +54,21 @@
  * starts at 1sec (since it cannot handle sub-second intervals).
  * Subsequent passes double the previous interval, up to MAXSLEEP.
  *
- * The ALARM is only set if the current pass's delay is larger.
+ * The current values result in 5 passes for the 'sleep' test (at 1,
+ * 2, 4, 8, and 16 seconds) and 10 passes for the other tests (at
+ * 0.04, 0.08, 0.16, 0.32, 0.64, 1.28, 2.56, 5.12, 10.24, and 20.48
+ * seconds).
  *
- * The 'kevent' test expects the ALARM to be set on the same pass
- * where the delay is larger than the KEVNT_TIMEOUT.  The ALARM
- * needs to fire before the timeout.
+ * The ALARM is only set if the current pass's delay is longer, and
+ * only if the ALARM has not already been triggered.
  *
- * So, ALARM must be less than KEVNT_TIMEOUT, and both must be
- * large enough to occur on the final pass; ie, delay  MAXSLEEP
- * but 2*delay = MAXSLEEP
- *
- * The above values should result in 5 passes for the 'sleep' test
- * and 10 passes for the other tests.
+ * The 'kevent' test needs the ALARM to be set on a different pass
+ * from when the KEVNT_TIMEOUT fires.  So set ALARM to fire on the
+ * penultimate pass, and the KEVNT_TIMEOUT on the final pass.  We
+ * set KEVNT_TIMEOUT just barely long enough to put it into the
+ * last test pass, and set MAXSLEEP a couple seconds longer than
+ * necessary,in order to avoid a QEMU bug which nearly doubles
+ * some timers.
  */
 
 static volatile int sig;
@@ -148,6 +151,16 @@ do_kevent(struct timespec *delay, struct
 	ATF_REQUIRE_MSG((kq = kqueue()) != -1, kqueue: %s, strerror(errno));
 
 	tmo = KEVNT_TIMEOUT;
+
+	/*
+	 * If we expect the KEVNT_TIMEOUT to fire, and we're running
+	 * under QEMU, make sure the delay is long enough to account
+	 * for the effects of PR kern/43997 !
+	 */
+	if (system(cpuctl identify 0 | grep -q QEMU) == 0 
+	tmo/1000  delay-tv_sec  tmo/500  delay-tv_sec)
+		delay-tv_sec = MAXSLEEP;
+
 	EV_SET(ktimer, 1, EVFILT_TIMER, EV_ADD, 0, tmo, 0);
 
 	rtc = kevent(kq, ktimer, 1, kresult, 1, delay);
@@ -162,7 +175,7 @@ do_kevent(struct timespec *delay, struct
 
 	if (delay-tv_sec * BILLION + delay-tv_nsec  tmo * MILLION)
 		ATF_REQUIRE_MSG(rtc  0,
-		kevent: ALARM did not cause EVFILT_TIMER event);
+		kevent: KEVNT_TIMEOUT did not cause EVFILT_TIMER event);
 
 	return 0;
 }
@@ -258,11 +271,11 @@ sleeptest(int (*test)(struct timespec *,
 	tslp.tv_sec = delta3 / 10;
 	tslp.tv_nsec = delta3 % 10;
 
-	while (delta3 = MAXSLEEP) {
+	while (tslp.tv_sec = MAXSLEEP) {
 		/*
 		 * disturb sleep by signal on purpose
 		 */ 
-		if (delta3  ALARM * BILLION  sig == 0)
+		if (tslp.tv_sec  ALARM  sig == 0)
 			alarm(ALARM);
 
 		clock_gettime(CLOCK_REALTIME, tsa);



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

2012-11-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Nov  8 16:33:26 UTC 2012

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

Log Message:
Provide clear explanation of test-case failures.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.2 src/tests/lib/libc/gen/t_sleep.c:1.3
--- src/tests/lib/libc/gen/t_sleep.c:1.2	Thu Nov  8 04:58:44 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Thu Nov  8 16:33:26 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.2 2012/11/08 04:58:44 pgoyette Exp $ */
+/* $NetBSD: t_sleep.c,v 1.3 2012/11/08 16:33:26 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -135,10 +135,9 @@ do_kevent(struct timespec *delay, struct
 	ATF_REQUIRE_MSG(rtc != -1 || kerrno == EINTR, kevent: %s,
 	strerror(errno));
 
-	if (rtc == 0)
-	ATF_REQUIRE_MSG((delay-tv_sec * BILLION + delay-tv_nsec -
-			tmo * MILLION) = 0,
-			kevent - none queued - timing error);
+	if (delay-tv_sec * BILLION + delay-tv_nsec  tmo * MILLION)
+		ATF_REQUIRE_MSG(rtc  0,
+		kevent: ALARM did not cause EVFILT_TIMER event);
 
 	return 0;
 }
@@ -264,7 +263,7 @@ sleeptest(int (*test)(struct timespec *,
 		delta3 *= round;
 
 		ATF_REQUIRE_MSG(delta3 = FUZZ  delta3 = -FUZZ,
-		Elapsed time %PRId64 exceeds allowable fuzz %lld,
+		Reschedule latency %PRId64 exceeds allowable fuzz %lld,
 		delta3, FUZZ);
 
 		delta3 = (int64_t)tslp.tv_sec * 2 * BILLION;



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

2012-11-08 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Fri Nov  9 04:43:25 UTC 2012

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

Log Message:
Remove unnecessary header file and an unused variable.
Adjust timing parameters to reduce overall elapsed time, and document
the parameters.
Clean-up status handling for kevent test.
Deal with QEMU timer-related issues (PR-43997).


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.3 src/tests/lib/libc/gen/t_sleep.c:1.4
--- src/tests/lib/libc/gen/t_sleep.c:1.3	Thu Nov  8 16:33:26 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Fri Nov  9 04:43:25 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.3 2012/11/08 16:33:26 pgoyette Exp $ */
+/* $NetBSD: t_sleep.c,v 1.4 2012/11/09 04:43:25 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -27,7 +27,6 @@
  */
 
 #include atf-c.h
-#include err.h
 #include errno.h
 #include poll.h
 #include stdio.h
@@ -40,14 +39,36 @@
 #include sys/event.h
 #include sys/signal.h
 
-#define ALARM		11		/* SIGALRM after this many seconds */
-#define KEVNT_TIMEOUT	13200		/* measured in milli-seconds */
 #define BILLION		10LL	/* nano-seconds per second */
 #define MILLION		100LL	/* nano-seconds per milli-second */
-#define FUZZ		(50 * MILLION)	/* scheduling fuzz accepted - 50 ms */
-#define MAXSLEEP	(32 * BILLION)	/* 32 seconds */
 
-static volatile int sig, sigs;
+#define ALARM		12		/* SIGALRM after this many seconds */
+#define KEVNT_TIMEOUT	16300		/* measured in milli-seconds */
+#define FUZZ		(40 * MILLION)	/* scheduling fuzz accepted - 40 ms */
+#define MAXSLEEP	(22 * BILLION)	/* 22 seconds */
+
+/*
+ * Timer notes
+ *
+ * Most tests use FUZZ as their initial delay value, but 'sleep'
+ * starts at 1sec (since it cannot handle sub-second intervals).
+ * Subsequent passes double the previous interval, up to MAXSLEEP.
+ *
+ * The ALARM is only set if the current pass's delay is larger.
+ *
+ * The 'kevent' test expects the ALARM to be set on the same pass
+ * where the delay is larger than the KEVNT_TIMEOUT.  The ALARM
+ * needs to fire before the timeout.
+ *
+ * So, ALARM must be less than KEVNT_TIMEOUT, and both must be
+ * large enough to occur on the final pass; ie, delay  MAXSLEEP
+ * but 2*delay = MAXSLEEP
+ *
+ * The above values should result in 5 passes for the 'sleep' test
+ * and 10 passes for the other tests.
+ */
+
+static volatile int sig;
 
 int sleeptest(int (*)(struct timespec *, struct timespec *), bool, bool);
 int do_nanosleep(struct timespec *, struct timespec *);
@@ -60,6 +81,7 @@ void sigalrm(int);
 void
 sigalrm(int s)
 {
+
 	sig++;
 }
 
@@ -121,10 +143,11 @@ do_kevent(struct timespec *delay, struct
 	struct kevent ktimer;
 	struct kevent kresult;
 	int rtc, kq, kerrno;
-	int tmo = KEVNT_TIMEOUT;
+	int tmo;
 
 	ATF_REQUIRE_MSG((kq = kqueue()) != -1, kqueue: %s, strerror(errno));
 
+	tmo = KEVNT_TIMEOUT;
 	EV_SET(ktimer, 1, EVFILT_TIMER, EV_ADD, 0, tmo, 0);
 
 	rtc = kevent(kq, ktimer, 1, kresult, 1, delay);
@@ -132,8 +155,10 @@ do_kevent(struct timespec *delay, struct
 
 	(void)close(kq);
 
-	ATF_REQUIRE_MSG(rtc != -1 || kerrno == EINTR, kevent: %s,
-	strerror(errno));
+	if (rtc == -1) {
+		ATF_REQUIRE_MSG(kerrno == EINTR, kevent: %s, strerror(errno));
+		return 0;
+	}
 
 	if (delay-tv_sec * BILLION + delay-tv_nsec  tmo * MILLION)
 		ATF_REQUIRE_MSG(rtc  0,
@@ -262,10 +287,15 @@ sleeptest(int (*test)(struct timespec *,
 		delta3 /= round;
 		delta3 *= round;
 
-		ATF_REQUIRE_MSG(delta3 = FUZZ  delta3 = -FUZZ,
-		Reschedule latency %PRId64 exceeds allowable fuzz %lld,
-		delta3, FUZZ);
+		if (delta3  FUZZ || delta3  -FUZZ) {
+			if (!sim_remain 
+			system(cpuctl identify 0 | grep -q QEMU) == 0) 
+atf_tc_expect_fail(Long reschedule latency 
+due to PR kern/43997);
 
+			atf_tc_fail(Reschedule latency %PRId64 exceeds 
+			allowable fuzz %lld, delta3, FUZZ);
+		}
 		delta3 = (int64_t)tslp.tv_sec * 2 * BILLION;
 		delta3 += (int64_t)tslp.tv_nsec * 2;
 



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

2012-11-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Nov  8 03:13:47 UTC 2012

Modified Files:
src/tests/lib/libc/gen: Makefile
Added Files:
src/tests/lib/libc/gen: t_sleep.c

Log Message:
Convert old src/regress/timerwaiter tests to ATF


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/tests/lib/libc/gen/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/lib/libc/gen/t_sleep.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/Makefile
diff -u src/tests/lib/libc/gen/Makefile:1.37 src/tests/lib/libc/gen/Makefile:1.38
--- src/tests/lib/libc/gen/Makefile:1.37	Fri Apr 13 12:31:19 2012
+++ src/tests/lib/libc/gen/Makefile	Thu Nov  8 03:13:47 2012
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.37 2012/04/13 12:31:19 njoly Exp $
+# $NetBSD: Makefile,v 1.38 2012/11/08 03:13:47 pgoyette Exp $
 
 .include bsd.own.mk
 
@@ -31,6 +31,7 @@ TESTS_C+=	t_realpath
 TESTS_C+=	t_setdomainname
 TESTS_C+=	t_sethostname
 TESTS_C+=	t_siginfo
+TESTS_C+=	t_sleep
 TESTS_C+=	t_syslog
 TESTS_C+=	t_time
 TESTS_C+=	t_ttyname

Added files:

Index: src/tests/lib/libc/gen/t_sleep.c
diff -u /dev/null src/tests/lib/libc/gen/t_sleep.c:1.1
--- /dev/null	Thu Nov  8 03:13:47 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Thu Nov  8 03:13:47 2012
@@ -0,0 +1,296 @@
+/* $NetBSD: t_sleep.c,v 1.1 2012/11/08 03:13:47 pgoyette Exp $ */
+
+/*-
+ * Copyright (c) 2006 Frank Kardel
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include atf-c.h
+#include err.h
+#include errno.h
+#include poll.h
+#include stdio.h
+#include stdlib.h
+#include string.h
+#include time.h
+#include unistd.h
+
+#include sys/cdefs.h
+#include sys/event.h
+#include sys/signal.h
+
+#define ALARM		11		/* SIGALRM after this many seconds */
+#define KEVNT_TIMEOUT	13200		/* measured in milli-seconds */
+#define BILLION		10LL	/* nano-seconds per second */
+#define MILLION		100LL	/* nano-seconds per milli-second */
+#define FUZZ		(50 * MILLION)	/* scheduling fuzz accepted - 50 ms */
+#define MAXSLEEP	(32 * BILLION)	/* 32 seconds */
+
+static volatile int sig, sigs;
+
+int sleeptest(int (*)(struct timespec *, struct timespec *), bool, bool);
+int do_nanosleep(struct timespec *, struct timespec *);
+int do_select(struct timespec *, struct timespec *);
+int do_poll(struct timespec *, struct timespec *);
+int do_sleep(struct timespec *, struct timespec *);
+int do_kevent(struct timespec *, struct timespec *);
+void sigalrm(int);
+
+void
+sigalrm(int s)
+{
+	sig++;
+}
+
+int
+do_nanosleep(struct timespec *delay, struct timespec *remain)
+{
+	int ret;
+
+	if (nanosleep(delay, remain) == -1)
+		ret = (errno == EINTR ? 0 : errno);
+	else
+		ret = 0;
+	return ret;
+}
+
+int
+do_select(struct timespec *delay, struct timespec *remain)
+{
+	int ret;
+	struct timeval tv;
+
+	TIMESPEC_TO_TIMEVAL(tv, delay);
+	if (select(0, NULL, NULL, NULL, tv) == -1)
+		ret = (errno == EINTR ? 0 : errno);
+	else
+		ret = 0;
+	return ret;
+}
+
+int
+do_poll(struct timespec *delay, struct timespec *remain)
+{
+	int ret;
+	struct timeval tv;
+
+	TIMESPEC_TO_TIMEVAL(tv, delay);
+	if (pollts(NULL, 0, delay, NULL) == -1)
+		ret = (errno == EINTR ? 0 : errno);
+	else
+		ret = 0;
+	return ret;
+}
+
+int
+do_sleep(struct timespec *delay, struct timespec *remain)
+{
+	struct timeval tv;
+
+	TIMESPEC_TO_TIMEVAL(tv, delay);
+	remain-tv_sec = sleep(delay-tv_sec);
+	remain-tv_nsec = 0;
+
+	return 0;
+}
+
+int
+do_kevent(struct timespec *delay, struct timespec *remain)
+{
+	struct kevent ktimer;
+	struct kevent kresult;
+	int rtc, kq, kerrno;
+	int tmo = KEVNT_TIMEOUT;
+
+	ATF_REQUIRE_MSG((kq = 

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

2012-11-07 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Nov  8 04:58:45 UTC 2012

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

Log Message:
Remove a debug printf(), and fix the format in another.

Should resolve build break.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/lib/libc/gen/t_sleep.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_sleep.c
diff -u src/tests/lib/libc/gen/t_sleep.c:1.1 src/tests/lib/libc/gen/t_sleep.c:1.2
--- src/tests/lib/libc/gen/t_sleep.c:1.1	Thu Nov  8 03:13:47 2012
+++ src/tests/lib/libc/gen/t_sleep.c	Thu Nov  8 04:58:44 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_sleep.c,v 1.1 2012/11/08 03:13:47 pgoyette Exp $ */
+/* $NetBSD: t_sleep.c,v 1.2 2012/11/08 04:58:44 pgoyette Exp $ */
 
 /*-
  * Copyright (c) 2006 Frank Kardel
@@ -135,8 +135,6 @@ do_kevent(struct timespec *delay, struct
 	ATF_REQUIRE_MSG(rtc != -1 || kerrno == EINTR, kevent: %s,
 	strerror(errno));
 
-printf(delay %ld.%09ld, tmo %d\n, delay-tv_sec, delay-tv_nsec, tmo);
-
 	if (rtc == 0)
 	ATF_REQUIRE_MSG((delay-tv_sec * BILLION + delay-tv_nsec -
 			tmo * MILLION) = 0,
@@ -266,7 +264,7 @@ sleeptest(int (*test)(struct timespec *,
 		delta3 *= round;
 
 		ATF_REQUIRE_MSG(delta3 = FUZZ  delta3 = -FUZZ,
-		Elapsed time %ld exceeds allowable fuzz %lld,
+		Elapsed time %PRId64 exceeds allowable fuzz %lld,
 		delta3, FUZZ);
 
 		delta3 = (int64_t)tslp.tv_sec * 2 * BILLION;



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

2012-06-13 Thread Nicolas Joly
Module Name:src
Committed By:   njoly
Date:   Wed Jun 13 11:45:18 UTC 2012

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

Log Message:
Skip sigbus_adraln testcase on alpha unless global
machdep.unaligned_sigbus sysctl is enabled.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/tests/lib/libc/gen/t_siginfo.c:1.18
--- src/tests/lib/libc/gen/t_siginfo.c:1.17	Mon Apr 23 15:07:56 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Wed Jun 13 11:45:17 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.17 2012/04/23 15:07:56 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.18 2012/06/13 11:45:17 njoly Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -31,6 +31,7 @@
 
 #include sys/inttypes.h
 #include sys/resource.h
+#include sys/sysctl.h
 #include sys/time.h
 #include sys/ucontext.h
 #include sys/wait.h
@@ -441,8 +442,21 @@ ATF_TC_HEAD(sigbus_adraln, tc)
 
 ATF_TC_BODY(sigbus_adraln, tc)
 {
+	const char *arch = atf_config_get(atf_arch);
 	struct sigaction sa;
 
+	if (strcmp(arch, alpha) == 0) {
+		int rv, val;
+		size_t len = sizeof(val);
+		rv = sysctlbyname(machdep.unaligned_sigbus, val, len,
+			NULL, 0);
+		ATF_REQUIRE(rv == 0);
+		if (val == 0)
+			atf_tc_skip(SIGBUS signal not enabled for
+ unaligned accesses);
+
+	}
+
 	sa.sa_flags = SA_SIGINFO;
 	sa.sa_sigaction = sigbus_action;
 	sigemptyset(sa.sa_mask);
@@ -458,8 +472,7 @@ ATF_TC_BODY(sigbus_adraln, tc)
 	addr = calloc(2, sizeof(int));
 	ATF_REQUIRE(addr != NULL);
 
-	if (strcmp(atf_config_get(atf_arch), i386) == 0 ||
-	strcmp(atf_config_get(atf_arch), x86_64) == 0) {
+	if (strcmp(arch, i386) == 0 || strcmp(arch, x86_64) == 0) {
 		if (system(cpuctl identify 0 | grep -q QEMU) == 0) {
 			atf_tc_expect_fail(QEMU fails to trap unaligned 
 			accesses);



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

2012-04-23 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Mon Apr 23 15:07:56 UTC 2012

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

Log Message:
Revert previous, si_addr is expected to be the faulting *data* address
(mmm, consistent standards).
Add a few tweaks to prevent the compiler's optimizer outsmarting the test.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 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.16 src/tests/lib/libc/gen/t_siginfo.c:1.17
--- src/tests/lib/libc/gen/t_siginfo.c:1.16	Sun Apr 22 08:52:26 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Mon Apr 23 15:07:56 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.16 2012/04/22 08:52:26 martin Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.17 2012/04/23 15:07:56 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@
 #endif
 
 /* for sigbus */
-char *addr;
+volatile char *addr;
 
 /* for sigchild */
 pid_t child;
@@ -412,31 +412,19 @@ static void
 sigbus_action(int signo, siginfo_t *info, void *ptr)
 {
 
+	printf(si_addr = %p\n, info-si_addr);
 	sig_debug(signo, info, (ucontext_t *)ptr);
 
 	ATF_REQUIRE_EQ(info-si_signo, SIGBUS);
 	ATF_REQUIRE_EQ(info-si_errno, 0);
 	ATF_REQUIRE_EQ(info-si_code, BUS_ADRALN);
 
-#if 0
 	if (strcmp(atf_config_get(atf_arch), i386) == 0 ||
 	strcmp(atf_config_get(atf_arch), x86_64) == 0) {
 		atf_tc_expect_fail(x86 architecture does not correctly 
 		report the address where the unaligned access occured);
 	}
-
-	/*
-	 * XXX: This is bogus: si_addr is documented as the text address
-	 * where the fault occurs, addr is the faulting data address,
-	 * see TOG about siginfo_t:
-	 *
-	 *	void *	si_addr	Address of faulting instruction.
-	 *
-	 * Is there a portable way to get the accessed data address from
-	 * the handler?
-	 */
-	ATF_REQUIRE_EQ(info-si_addr, (void *)addr);
-#endif
+	ATF_REQUIRE_EQ(info-si_addr, (volatile void *)addr);
 
 	atf_tc_pass();
 	/* NOTREACHED */
@@ -480,6 +468,7 @@ ATF_TC_BODY(sigbus_adraln, tc)
 
 	/* Force an unaligned access */
 	addr++;
+	printf(now trying to access unaligned address %p\n, addr);
 	ATF_REQUIRE_EQ(*(volatile int *)addr, 0);
 
 	atf_tc_fail(Test did not fault as expected);



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

2012-04-22 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Sun Apr 22 08:52:26 UTC 2012

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

Log Message:
Do not compare si_addr (address of faulting instruction) against the
unaligned data address causing the fault - this will always fail.
If anybody knows a portable way to get the data address involved in the
fault, please fix the test case as originally intended.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 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.15 src/tests/lib/libc/gen/t_siginfo.c:1.16
--- src/tests/lib/libc/gen/t_siginfo.c:1.15	Fri Apr 20 00:40:31 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Sun Apr 22 08:52:26 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.15 2012/04/20 00:40:31 jym Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.16 2012/04/22 08:52:26 martin Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -418,13 +418,26 @@ sigbus_action(int signo, siginfo_t *info
 	ATF_REQUIRE_EQ(info-si_errno, 0);
 	ATF_REQUIRE_EQ(info-si_code, BUS_ADRALN);
 
+#if 0
 	if (strcmp(atf_config_get(atf_arch), i386) == 0 ||
 	strcmp(atf_config_get(atf_arch), x86_64) == 0) {
 		atf_tc_expect_fail(x86 architecture does not correctly 
 		report the address where the unaligned access occured);
 	}
 
+	/*
+	 * XXX: This is bogus: si_addr is documented as the text address
+	 * where the fault occurs, addr is the faulting data address,
+	 * see TOG about siginfo_t:
+	 *
+	 *	void *	si_addr	Address of faulting instruction.
+	 *
+	 * Is there a portable way to get the accessed data address from
+	 * the handler?
+	 */
 	ATF_REQUIRE_EQ(info-si_addr, (void *)addr);
+#endif
+
 	atf_tc_pass();
 	/* NOTREACHED */
 }



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

2012-04-19 Thread Jean-Yves Migeon
Module Name:src
Committed By:   jym
Date:   Fri Apr 20 00:40:32 UTC 2012

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

Log Message:
ATF test for SIGBUS = BUS_ADRALN (invalid address alignment).

That one is tedious to test under x86: alignment exceptions are
not reported by this architecture unless you ask for them explicitely (by
setting the PSL_AC bit). The brokenness does not end there: %cr2 should
contain the address where the unaligned access occured, alas, it does not.

I am not aware of other architectures where this could happen. Still, my
knowledge is limited; if there is one, feel free to send me a mail and I
will update the test accordingly.

Adding insult to injury, this test can fail in various funny ways with VMs:
- under x86 QEMU, no trap() happens. As ring 3 code stays almost untouched by
QEMU VMM, I suppose the exception can only be triggered when the host
itself is capable of catching unaligned accesses.
- under Virtual Box with HVM support, i386 works fine, but amd64 fails with a
SIGILL (Illegal instruction) that happens right before entering the
signal handler. No idea why, and trying to debug it with gdb freezes the VM
(including ddb breaks).

Anyway, tested with:
- i386: P4 host, anita, Virtual Box HVM (Mac OS X)
- amd64: anita, Virtual Box HVM (Mac OS X)

XXX I would appreciate if someone could test it under a real amd64 host with
an up-to-date kernel, so I can reasonably assume that the culprit is
Virtual Box and not our amd64 port (my test machine being off line
I cannot do it myself). Results from other arches would be a plus too.

Initial issue reported by Nicolas Joly on port-amd64. Thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 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.14 src/tests/lib/libc/gen/t_siginfo.c:1.15
--- src/tests/lib/libc/gen/t_siginfo.c:1.14	Sun Mar 18 07:14:08 2012
+++ src/tests/lib/libc/gen/t_siginfo.c	Fri Apr 20 00:40:31 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: t_siginfo.c,v 1.14 2012/03/18 07:14:08 jruoho Exp $ */
+/* $NetBSD: t_siginfo.c,v 1.15 2012/04/20 00:40:31 jym Exp $ */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -48,6 +48,9 @@
 #include ieeefp.h
 #endif
 
+/* for sigbus */
+char *addr;
+
 /* for sigchild */
 pid_t child;
 int code;
@@ -405,6 +408,70 @@ ATF_TC_BODY(sigsegv, tc)
 	atf_tc_fail(Test did not fault as expected);
 }
 
+static void
+sigbus_action(int signo, siginfo_t *info, void *ptr)
+{
+
+	sig_debug(signo, info, (ucontext_t *)ptr);
+
+	ATF_REQUIRE_EQ(info-si_signo, SIGBUS);
+	ATF_REQUIRE_EQ(info-si_errno, 0);
+	ATF_REQUIRE_EQ(info-si_code, BUS_ADRALN);
+
+	if (strcmp(atf_config_get(atf_arch), i386) == 0 ||
+	strcmp(atf_config_get(atf_arch), x86_64) == 0) {
+		atf_tc_expect_fail(x86 architecture does not correctly 
+		report the address where the unaligned access occured);
+	}
+
+	ATF_REQUIRE_EQ(info-si_addr, (void *)addr);
+	atf_tc_pass();
+	/* NOTREACHED */
+}
+
+ATF_TC(sigbus_adraln);
+ATF_TC_HEAD(sigbus_adraln, tc)
+{
+
+	atf_tc_set_md_var(tc, descr,
+	Checks that signal trampoline correctly calls SIGBUS handler 
+	for invalid address alignment);
+}
+
+ATF_TC_BODY(sigbus_adraln, tc)
+{
+	struct sigaction sa;
+
+	sa.sa_flags = SA_SIGINFO;
+	sa.sa_sigaction = sigbus_action;
+	sigemptyset(sa.sa_mask);
+	sigaction(SIGBUS, sa, NULL);
+
+	/* Enable alignement checks for x86. 0x4 is PSL_AC. */
+#if defined(__i386__)
+	__asm__(pushf; orl $0x4, (%esp); popf);
+#elif defined(__amd64__)
+	__asm__(pushf; orl $0x4, (%rsp); popf);
+#endif
+
+	addr = calloc(2, sizeof(int));
+	ATF_REQUIRE(addr != NULL);
+
+	if (strcmp(atf_config_get(atf_arch), i386) == 0 ||
+	strcmp(atf_config_get(atf_arch), x86_64) == 0) {
+		if (system(cpuctl identify 0 | grep -q QEMU) == 0) {
+			atf_tc_expect_fail(QEMU fails to trap unaligned 
+			accesses);
+		}
+	}
+
+	/* Force an unaligned access */
+	addr++;
+	ATF_REQUIRE_EQ(*(volatile int *)addr, 0);
+
+	atf_tc_fail(Test did not fault as expected);
+}
+
 ATF_TP_ADD_TCS(tp)
 {
 
@@ -415,6 +482,7 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, sigfpe_flt);
 	ATF_TP_ADD_TC(tp, sigfpe_int);
 	ATF_TP_ADD_TC(tp, sigsegv);
+	ATF_TP_ADD_TC(tp, sigbus_adraln);
 
 	return atf_no_error();
 }



  1   2   >