diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-09-03 19:09:01 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-09-03 19:09:01 +0000 |
commit | c22165b4f1f5d38b681921797a44b3ba8c13b7e0 (patch) | |
tree | 252c24b568ad866ae902fd3b64462c1df486afd1 /contrib/netbsd-tests/lib/libc/gen | |
parent | 86ea5291326635f26a1f6a923852f706d44a4be1 (diff) | |
parent | 2db7b9f259535c36879c35f6c656090034f33101 (diff) | |
download | src-c22165b4f1f5d38b681921797a44b3ba8c13b7e0.tar.gz src-c22165b4f1f5d38b681921797a44b3ba8c13b7e0.zip |
Merge ^/head r305346 through r305360.
Notes
Notes:
svn path=/projects/clang390-import/; revision=305361
Diffstat (limited to 'contrib/netbsd-tests/lib/libc/gen')
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/execve/t_execve.c | 5 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/isqemu.h | 28 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c | 4 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c | 29 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c | 25 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_randomid.c | 22 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_siginfo.c | 25 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_sleep.c | 5 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_time.c | 13 | ||||
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_vis.c | 33 |
10 files changed, 152 insertions, 37 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 32de6e765780..d3752cd5f948 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 7d73a227ce79..c44ffda082a0 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_spawn.c b/contrib/netbsd-tests/lib/libc/gen/posix_spawn/t_spawn.c index 178374b863df..12f276050bdd 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/t_fnmatch.c b/contrib/netbsd-tests/lib/libc/gen/t_fnmatch.c index f90d8cfdd0d1..c0064c38f66a 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.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.3 2012/04/08 09:58:59 jruoho Exp $"); +__RCSID("$NetBSD: t_fnmatch.c,v 1.6 2014/10/12 22:33:41 christos 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(); } diff --git a/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c b/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c index 3366c1f2f5cb..5edc583ce2a8 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_randomid.c b/contrib/netbsd-tests/lib/libc/gen/t_randomid.c index 8377806252cd..9ab2ccaaa073 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 9c9a3c743c0b..64f72acabdcf 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 f722ec9691b4..e89df690e4e7 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.9 2016/08/11 21:34:11 kre Exp $ */ /*- * Copyright (c) 2006 Frank Kardel @@ -180,7 +180,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 790f3caada48..290540366d1d 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.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 $"); #ifdef __FreeBSD__ #include <sys/time.h> @@ -94,15 +94,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_vis.c b/contrib/netbsd-tests/lib/libc/gen/t_vis.c index 525bafafb17e..38decb3069c9 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.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(); } |