summaryrefslogtreecommitdiffstats
path: root/contrib/netbsd-tests/lib/libc/gen
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/gen')
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/isqemu.h28
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c10
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c4
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c12
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_assert.c17
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_dir.c56
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c5
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c30
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c25
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_ftok.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c3
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_nice.c7
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_randomid.c22
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_siginfo.c25
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_sleep.c24
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_time.c17
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_ttyname.c6
-rw-r--r--contrib/netbsd-tests/lib/libc/gen/t_vis.c37
19 files changed, 220 insertions, 119 deletions
diff --git a/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c b/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
index 32de6e7..d3752cd 100644
--- a/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
+++ b/contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c
@@ -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)
diff --git a/contrib/netbsd-tests/lib/libc/gen/isqemu.h b/contrib/netbsd-tests/lib/libc/gen/isqemu.h
index 7d73a22..c44ffda 100644
--- a/contrib/netbsd-tests/lib/libc/gen/isqemu.h
+++ b/contrib/netbsd-tests/lib/libc/gen/isqemu.h
@@ -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,12 +34,37 @@
#include <sys/param.h>
#include <sys/sysctl.h>
#include <stdbool.h>
+#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <err.h>
static __inline bool
isQEMU(void) {
+#ifdef __FreeBSD__
+ char *vm_guest_name_buf;
+ size_t len;
+ bool is_vm;
+
+ if (sysctlbyname("kern.vm_guest", NULL, &len, NULL, 0) == -1)
+ err(EXIT_FAILURE, "sysctl");
+
+ if ((vm_guest_name_buf = malloc(len)) == NULL)
+ err(EXIT_FAILURE, "malloc");
+
+ if (sysctlbyname("kern.vm_guest", vm_guest_name_buf, &len, NULL, 0)
+ == -1)
+ err(EXIT_FAILURE, "sysctl");
+
+ if (strcmp(vm_guest_name_buf, "none") == 0)
+ is_vm = false;
+ else
+ is_vm = true;
+
+ free(vm_guest_name_buf);
+
+ return is_vm;
+#else
#if defined(__i386__) || defined(__x86_64__)
char name[1024];
size_t len = sizeof(name);
@@ -53,6 +78,7 @@ isQEMU(void) {
#else
return false;
#endif
+#endif
}
#ifdef TEST
diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c
index 5bbf337..74009a8 100644
--- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c
+++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_fileactions.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_fileactions.c,v 1.5 2012/04/09 19:42:07 martin Exp $ */
+/* $NetBSD: t_fileactions.c,v 1.6 2017/01/10 22:36:29 christos Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -31,10 +31,11 @@
*/
-#ifdef __FreeBSD__
-#include <sys/stat.h>
-#endif
#include <atf-c.h>
+
+#include <sys/wait.h>
+#include <sys/stat.h>
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -42,7 +43,6 @@
#include <fcntl.h>
#include <spawn.h>
#include <unistd.h>
-#include <sys/wait.h>
ATF_TC(t_spawn_openmode);
diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
index 178374b..12f2760 100644
--- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
+++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c
@@ -1,4 +1,4 @@
-/* $NetBSD: t_spawn.c,v 1.1 2012/02/13 21:03:08 martin Exp $ */
+/* $NetBSD: t_spawn.c,v 1.2 2014/10/18 08:33:30 snj Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -137,7 +137,7 @@ ATF_TC(t_spawn_child);
ATF_TC_HEAD(t_spawn_child, tc)
{
atf_tc_set_md_var(tc, "descr",
- "posix_spawn a child and get it's return code");
+ "posix_spawn a child and get its return code");
}
ATF_TC_BODY(t_spawn_child, tc)
diff --git a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
index 78313cd..2085b9e 100644
--- a/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
+++ b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawnattr.c
@@ -60,16 +60,16 @@ get_different_scheduler(void)
/* get current schedule policy */
scheduler = sched_getscheduler(0);
- for (i = 0; i < nitems(schedulers); i++) {
+ for (i = 0; i < __arraycount(schedulers); i++) {
if (schedulers[i] == scheduler)
break;
}
- ATF_REQUIRE_MSG(i < nitems(schedulers),
+ ATF_REQUIRE_MSG(i < __arraycount(schedulers),
"Unknown current scheduler %d", scheduler);
-
+
/* new scheduler */
i++;
- if (i >= nitems(schedulers))
+ if (i >= __arraycount(schedulers))
i = 0;
return schedulers[i];
}
@@ -85,7 +85,7 @@ get_different_priority(int scheduler)
sched_getparam(0, &param);
priority = param.sched_priority;
-
+
/*
* Change numerical value of the priority, to ensure that it
* was set for the spawned child.
@@ -127,7 +127,7 @@ ATF_TC_BODY(t_spawnattr, tc)
scheduler = get_different_scheduler();
priority = get_different_priority(scheduler);
sp.sched_priority = priority;
-
+
sigemptyset(&sig);
sigaddset(&sig, SIGUSR1);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_assert.c b/contrib/netbsd-tests/lib/libc/gen/t_assert.c
index a09c130..ce73015 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_assert.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_assert.c
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
+#include <sys/resource.h>
+#include <sys/time.h>
#include <sys/wait.h>
#include <assert.h>
@@ -40,11 +43,6 @@ __RCSID("$NetBSD: t_assert.c,v 1.2 2011/06/14 05:28:00 jruoho Exp $");
#include <string.h>
#include <unistd.h>
-#ifdef __FreeBSD__
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/resource.h>
-
static void
disable_corefile(void)
{
@@ -55,7 +53,6 @@ disable_corefile(void)
ATF_REQUIRE(setrlimit(RLIMIT_CORE, &limits) == 0);
}
-#endif
static void handler(int);
@@ -82,9 +79,7 @@ ATF_TC_BODY(assert_false, tc)
if (pid == 0) {
-#ifdef __FreeBSD__
disable_corefile();
-#endif
(void)closefrom(0);
(void)memset(&sa, 0, sizeof(struct sigaction));
@@ -122,9 +117,7 @@ ATF_TC_BODY(assert_true, tc)
if (pid == 0) {
-#ifdef __FreeBSD__
disable_corefile();
-#endif
(void)closefrom(0);
(void)memset(&sa, 0, sizeof(struct sigaction));
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_dir.c b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
index b37d89d..40de116 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_dir.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_dir.c
@@ -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.10 2017/01/11 18:15:02 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -26,22 +26,19 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
-#include <atf-c.h>
-
+#include <sys/stat.h>
#include <assert.h>
+#include <atf-c.h>
#include <dirent.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
-#include <sys/stat.h>
-#ifdef __FreeBSD__
-#include <errno.h>
-#endif
ATF_TC(seekdir_basic);
ATF_TC_HEAD(seekdir_basic, tc)
@@ -58,7 +55,6 @@ ATF_TC_BODY(seekdir_basic, tc)
struct dirent *entry;
long here;
-#ifdef __FreeBSD__
#define CREAT(x, m) do { \
int _creat_fd; \
ATF_REQUIRE_MSG((_creat_fd = creat((x), (m))) != -1, \
@@ -72,12 +68,6 @@ ATF_TC_BODY(seekdir_basic, tc)
CREAT("t/a", 0600);
CREAT("t/b", 0600);
CREAT("t/c", 0600);
-#else
- mkdir("t", 0755);
- creat("t/a", 0600);
- creat("t/b", 0600);
- creat("t/c", 0600);
-#endif
dp = opendir("t");
if ( dp == NULL)
@@ -85,35 +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);
-#ifdef __FreeBSD__
- ATF_REQUIRE_MSG(here != -1,
- "telldir failed: %s", strerror(errno));
-#endif
+ ATF_REQUIRE_MSG(here != -1, "telldir failed: %s", strerror(errno));
/* get second entry */
entry = readdir(dp);
-#ifdef __FreeBSD__
- ATF_REQUIRE_MSG(entry != NULL,
- "readdir failed: %s", strerror(errno));
-#endif
+ 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");
@@ -121,25 +116,22 @@ 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");
closedir(dp);
-#ifdef __FreeBSD__
free(wasname);
-#endif
}
ATF_TC(telldir_leak);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
index ef372f7..c3417bb 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c
@@ -119,6 +119,11 @@ ATF_TC_BODY(floatunditf, tc)
#else
size_t i;
+#if defined(__FreeBSD__) && defined(__i386__)
+ atf_tc_expect_fail("the floating point error on FreeBSD/i386 doesn't "
+ "match the expected floating point error on NetBSD");
+#endif
+
for (i = 0; i < __arraycount(testcases); ++i)
ATF_CHECK_MSG(
testcases[i].ld == (long double)testcases[i].u64,
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
index f90d8cf..69ee8d2 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c
@@ -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.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 <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.7 2016/10/31 05:08:53 dholland Exp $");
#include <atf-c.h>
#include <fnmatch.h>
@@ -153,6 +153,31 @@ 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-\\\\]", "[", 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 +187,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();
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c b/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
index 3366c1f..5edc583 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c
@@ -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.16 2016/03/12 11:55:14 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,11 +338,13 @@ 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]);
ATF_CHECK((fpgetmask() & lst[i]) != 0);
- fpsetmask(msk & lst[i]);
+ fpsetmask(msk & ~lst[i]);
ATF_CHECK((fpgetmask() & lst[i]) == 0);
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ftok.c b/contrib/netbsd-tests/lib/libc/gen/t_ftok.c
index 718d310..4c1ab18 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_ftok.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_ftok.c
@@ -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 <sys/cdefs.h>
-__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 <sys/types.h>
#include <sys/ipc.h>
@@ -68,9 +68,7 @@ ATF_TC_BODY(ftok_link, tc)
fd = open(path, O_RDONLY | O_CREAT);
ATF_REQUIRE(fd >= 0);
-#ifdef __FreeBSD__
(void)close(fd);
-#endif
ATF_REQUIRE(link(path, hlnk) == 0);
ATF_REQUIRE(symlink(path, slnk) == 0);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
index 5836c86..17eac87 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_humanize_number.c
@@ -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.
@@ -247,6 +247,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);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_nice.c b/contrib/netbsd-tests/lib/libc/gen/t_nice.c
index 10b8df7..9a0eac7 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_nice.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_nice.c
@@ -72,11 +72,6 @@ ATF_TC_BODY(nice_err, tc)
{
int i;
-#ifdef __FreeBSD__
- atf_tc_expect_fail("nice(incr) with incr < 0 fails with unprivileged "
- "users and sets errno == EPERM; see PR # 189821 for more details");
-#endif
-
/*
* The call should fail with EPERM if the
* supplied parameter is negative and the
@@ -130,7 +125,7 @@ ATF_TC_BODY(nice_priority, tc)
if (pid == 0) {
errno = 0;
-#ifdef __FreeBSD__
+#ifdef __NetBSD__
pri = getpriority(PRIO_PROCESS, 0);
#else
pri2 = getpriority(PRIO_PROCESS, 0);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_randomid.c b/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
index 8377806..9ab2cca 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_randomid.c
@@ -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.5 2015/03/07 09:59:15 isaki Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -38,7 +38,7 @@
#define PERIOD 30000
-uint64_t last[65536];
+uint32_t last[65536];
ATF_TC(randomid_basic);
ATF_TC_HEAD(randomid_basic, tc)
@@ -50,30 +50,30 @@ 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 < 1000000; n++) {
+ for (n = 0; n < 100000; n++) {
id = randomid(ctx);
if (last[id] > 0) {
diff = n - last[id];
if (diff <= lowest) {
- if (lowest != UINT64_MAX)
- printf("id %5d: last call at %9"PRIu64
- ", current call %9"PRIu64
- " (diff %5"PRIu64"), "
- "lowest %"PRIu64"\n",
+ if (lowest != UINT32_MAX)
+ printf("id %5d: last call at %9"PRIu32
+ ", current call %9"PRIu32
+ " (diff %5"PRIu32"), "
+ "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;
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c b/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
index 9c9a3c7..64f72ac 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c
@@ -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.30 2015/12/22 14:25:58 christos Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -46,8 +46,9 @@
#include <setjmp.h>
#include <float.h>
-#ifdef HAVE_FENV
#include <fenv.h>
+#ifdef __HAVE_FENV
+#include <ieeefp.h> /* only need for ARM Cortex/Neon hack */
#elif defined(_FLOAT_IEEE754)
#include <ieeefp.h>
#endif
@@ -316,13 +317,21 @@ 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;
sa.sa_sigaction = sigfpe_flt_action;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, 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);
@@ -373,7 +382,7 @@ ATF_TC_BODY(sigfpe_int, tc)
sa.sa_sigaction = sigfpe_int_action;
sigemptyset(&sa.sa_mask);
sigaction(SIGFPE, &sa, 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);
@@ -454,15 +463,19 @@ 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
+ /* 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);
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
index f722ec9..e85867a 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_sleep.c
@@ -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.11 2017/01/10 15:43:59 maya Exp $ */
/*-
* Copyright (c) 2006 Frank Kardel
@@ -26,8 +26,18 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
+#ifdef __FreeBSD__
+/* kqueue(2) on FreeBSD requires sys/types.h for uintptr_t; NetBSD doesn't. */
+#include <sys/types.h>
+#endif
+#include <sys/cdefs.h>
+#include <sys/event.h>
+#include <sys/signal.h>
+#include <sys/time.h> /* for TIMESPEC_TO_TIMEVAL on FreeBSD */
+
#include <atf-c.h>
#include <errno.h>
+#include <inttypes.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
@@ -35,10 +45,6 @@
#include <time.h>
#include <unistd.h>
-#include <sys/cdefs.h>
-#include <sys/event.h>
-#include <sys/signal.h>
-
#include "isqemu.h"
#define BILLION 1000000000LL /* nano-seconds per second */
@@ -49,11 +55,6 @@
#define KEVNT_TIMEOUT 10300 /* measured in milli-seconds */
#define FUZZ (40 * MILLION) /* scheduling fuzz accepted - 40 ms */
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#include <inttypes.h>
-#endif
-
/*
* Timer notes
*
@@ -180,7 +181,8 @@ do_kevent(struct timespec *delay, struct timespec *remain)
(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;
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_time.c b/contrib/netbsd-tests/lib/libc/gen/t_time.c
index 790f3ca..15a8d58 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_time.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_time.c
@@ -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.4 2017/01/10 15:32:46 christos Exp $ */
/*-
* Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -29,11 +29,8 @@
* 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.4 2017/01/10 15:32:46 christos Exp $");
-#ifdef __FreeBSD__
-#include <sys/time.h>
-#endif
#include <atf-c.h>
#include <errno.h>
#include <inttypes.h>
@@ -41,6 +38,7 @@ __RCSID("$NetBSD: t_time.c,v 1.2 2011/11/11 05:03:38 jruoho Exp $");
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
+#include <sys/time.h>
#include <unistd.h>
ATF_TC(time_copy);
@@ -94,15 +92,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");
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c
index 1c813fb..61121b8 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c
@@ -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 <sys/cdefs.h>
-__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 <atf-c.h>
#include <errno.h>
@@ -78,9 +78,7 @@ ATF_TC_BODY(ttyname_err, tc)
ATF_REQUIRE(ttyname(fd) == NULL);
ATF_REQUIRE(errno == ENOTTY);
-#ifdef __FreeBSD__
(void)close(fd);
-#endif
}
}
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_vis.c b/contrib/netbsd-tests/lib/libc/gen/t_vis.c
index 525bafa..adb0930 100644
--- a/contrib/netbsd-tests/lib/libc/gen/t_vis.c
+++ b/contrib/netbsd-tests/lib/libc/gen/t_vis.c
@@ -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.9 2017/01/10 15:16:57 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,37 @@ ATF_TC_BODY(strunvis_hex, tc)
}
}
+#ifdef VIS_NOLOCALE
+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);
+}
+#endif /* VIS_NOLOCALE */
+
ATF_TP_ADD_TCS(tp)
{
@@ -150,6 +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();
}
OpenPOWER on IntegriCloud