Index: head/contrib/netbsd-tests/include/t_paths.c =================================================================== --- head/contrib/netbsd-tests/include/t_paths.c (revision 274078) +++ head/contrib/netbsd-tests/include/t_paths.c (revision 274079) @@ -1,205 +1,204 @@ -/* $NetBSD: t_paths.c,v 1.13 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_paths.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_paths.c,v 1.13 2014/02/09 21:26:07 jmmv Exp $"); +__RCSID("$NetBSD: t_paths.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); #include #include #include #include #include #include #include #include #include -#include #define PATH_DEV __BIT(0) /* A device node */ #define PATH_DIR __BIT(1) /* A directory */ #define PATH_FILE __BIT(2) /* A file */ #define PATH_ROOT __BIT(3) /* Access for root only */ static const struct { const char *path; int flags; } paths[] = { { _PATH_AUDIO, PATH_DEV }, { _PATH_AUDIO0, PATH_DEV }, { _PATH_AUDIOCTL, PATH_DEV }, { _PATH_AUDIOCTL0, PATH_DEV }, { _PATH_BPF, PATH_DEV | PATH_ROOT }, { _PATH_CLOCKCTL, PATH_DEV | PATH_ROOT }, { _PATH_CONSOLE, PATH_DEV | PATH_ROOT }, { _PATH_CONSTTY, PATH_DEV | PATH_ROOT }, { _PATH_CPUCTL, PATH_DEV }, { _PATH_CSMAPPER, PATH_DIR }, { _PATH_DEFTAPE, PATH_DEV | PATH_ROOT }, { _PATH_DEVCDB, PATH_FILE }, { _PATH_DEVDB, PATH_FILE }, { _PATH_DEVNULL, PATH_DEV }, { _PATH_DRUM, PATH_DEV | PATH_ROOT }, { _PATH_ESDB, PATH_DIR }, { _PATH_FTPUSERS, PATH_FILE }, { _PATH_GETTYTAB, PATH_FILE }, { _PATH_I18NMODULE, PATH_DIR }, { _PATH_ICONV, PATH_DIR }, { _PATH_KMEM, PATH_DEV | PATH_ROOT }, { _PATH_KSYMS, PATH_DEV }, { _PATH_KVMDB, PATH_FILE }, { _PATH_LOCALE, PATH_DIR }, { _PATH_MAILDIR, PATH_DIR }, { _PATH_MAN, PATH_DIR }, { _PATH_MEM, PATH_DEV | PATH_ROOT }, { _PATH_MIXER, PATH_DEV }, { _PATH_MIXER0, PATH_DEV }, { _PATH_NOLOGIN, PATH_FILE }, { _PATH_POWER, PATH_DEV | PATH_ROOT }, { _PATH_PRINTCAP, PATH_FILE }, { _PATH_PUD, PATH_DEV | PATH_ROOT }, { _PATH_PUFFS, PATH_DEV | PATH_ROOT }, { _PATH_RANDOM, PATH_DEV }, { _PATH_SENDMAIL, PATH_FILE }, { _PATH_SHELLS, PATH_FILE }, { _PATH_SKEYKEYS, PATH_FILE | PATH_ROOT }, { _PATH_SOUND, PATH_DEV }, { _PATH_SOUND0, PATH_DEV }, { _PATH_SYSMON, PATH_DEV }, { _PATH_TTY, PATH_DEV }, { _PATH_UNIX, PATH_FILE | PATH_ROOT }, { _PATH_URANDOM, PATH_DEV }, { _PATH_VIDEO, PATH_DEV }, { _PATH_VIDEO0, PATH_DEV }, { _PATH_DEV, PATH_DIR }, { _PATH_DEV_PTS, PATH_DIR }, { _PATH_EMUL_AOUT, PATH_DIR }, { _PATH_TMP, PATH_DIR }, { _PATH_VARDB, PATH_DIR }, { _PATH_VARRUN, PATH_DIR }, { _PATH_VARTMP, PATH_DIR }, { _PATH_BSHELL, PATH_FILE }, { _PATH_CSHELL, PATH_FILE }, { _PATH_VI, PATH_FILE }, }; ATF_TC(paths); ATF_TC_HEAD(paths, tc) { atf_tc_set_md_var(tc, "descr", "A basic test for "); } ATF_TC_BODY(paths, tc) { struct stat st; uid_t uid; mode_t m; size_t i; int fd; #if defined(__sparc__) atf_tc_skip("PR port-sparc/45580"); #endif uid = getuid(); for (i = 0; i < __arraycount(paths); i++) { (void)fprintf(stderr, "testing '%s'\n", paths[i].path); errno = 0; fd = open(paths[i].path, O_RDONLY); if (fd < 0) { switch (errno) { case EPERM: /* FALLTHROUGH */ case EACCES: /* FALLTHROUGH */ if ((paths[i].flags & PATH_ROOT) == 0) { atf_tc_fail("UID %u failed to open %s", (uint32_t)uid, paths[i].path); } case EBUSY: /* FALLTHROUGH */ case ENXIO: /* FALLTHROUGH */ case ENOENT: /* FALLTHROUGH */ default: continue; } } (void)memset(&st, 0, sizeof(struct stat)); ATF_REQUIRE(fstat(fd, &st) == 0); m = st.st_mode; if ((paths[i].flags & PATH_DEV) != 0) { ATF_CHECK(S_ISBLK(m) != 0 || S_ISCHR(m) != 0); ATF_CHECK((paths[i].flags & PATH_DIR) == 0); ATF_CHECK((paths[i].flags & PATH_FILE) == 0); } if ((paths[i].flags & PATH_DIR) != 0) { ATF_CHECK(S_ISDIR(m) != 0); ATF_CHECK((paths[i].flags & PATH_DEV) == 0); ATF_CHECK((paths[i].flags & PATH_FILE) == 0); } if ((paths[i].flags & PATH_FILE) != 0) { ATF_CHECK(S_ISREG(m) != 0); ATF_CHECK((paths[i].flags & PATH_DEV) == 0); ATF_CHECK((paths[i].flags & PATH_DIR) == 0); } ATF_REQUIRE(close(fd) == 0); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, paths); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/gen/t_floatunditf.c (revision 274079) @@ -1,136 +1,135 @@ -/* $NetBSD: t_floatunditf.c,v 1.5 2014/02/02 08:16:22 martin Exp $ */ +/* $NetBSD: t_floatunditf.c,v 1.6 2014/11/04 00:20:19 justin 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 #ifdef __HAVE_LONG_DOUBLE static const struct { uint64_t u64; long double ld; } testcases[] = { { 0xffffffffffffffffULL, 0xf.fffffffffffffffp+60L }, { 0xfffffffffffffffeULL, 0xf.ffffffffffffffep+60L }, { 0xfffffffffffffffdULL, 0xf.ffffffffffffffdp+60L }, { 0xfffffffffffffffcULL, 0xf.ffffffffffffffcp+60L }, { 0x7fffffffffffffffULL, 0xf.ffffffffffffffep+59L }, { 0x3fffffffffffffffULL, 0xf.ffffffffffffffcp+58L }, { 0x1fffffffffffffffULL, 0xf.ffffffffffffff8p+57L }, { 0xfffffffffffffffULL, 0xf.ffffffffffffffp+56L }, { 0x7ffffffffffffffULL, 0xf.fffffffffffffep+55L }, { 0x3ffffffffffffffULL, 0xf.fffffffffffffcp+54L }, { 0x1ffffffffffffffULL, 0xf.fffffffffffff8p+53L }, { 0xffffffffffffffULL, 0xf.fffffffffffffp+52L }, { 0x7fffffffffffffULL, 0xf.ffffffffffffep+51L }, { 0x3fffffffffffffULL, 0xf.ffffffffffffcp+50L }, { 0x1fffffffffffffULL, 0xf.ffffffffffff8p+49L }, { 0xfffffffffffffULL, 0xf.ffffffffffffp+48L }, { 0x7ffffffffffffULL, 0xf.fffffffffffep+47L }, { 0x3ffffffffffffULL, 0xf.fffffffffffcp+46L }, { 0x1ffffffffffffULL, 0xf.fffffffffff8p+45L }, { 0xffffffffffffULL, 0xf.fffffffffffp+44L }, { 0x7fffffffffffULL, 0xf.ffffffffffep+43L }, { 0x3fffffffffffULL, 0xf.ffffffffffcp+42L }, { 0x1fffffffffffULL, 0xf.ffffffffff8p+41L }, { 0xfffffffffffULL, 0xf.ffffffffffp+40L }, { 0x7ffffffffffULL, 0xf.fffffffffep+39L }, { 0x3ffffffffffULL, 0xf.fffffffffcp+38L }, { 0x1ffffffffffULL, 0xf.fffffffff8p+37L }, { 0xffffffffffULL, 0xf.fffffffffp+36L }, { 0x7fffffffffULL, 0xf.ffffffffep+35L }, { 0x3fffffffffULL, 0xf.ffffffffcp+34L }, { 0x1fffffffffULL, 0xf.ffffffff8p+33L }, { 0xfffffffffULL, 0xf.ffffffffp+32L }, { 0x7ffffffffULL, 0xf.fffffffep+31L }, { 0x3ffffffffULL, 0xf.fffffffcp+30L }, { 0x1ffffffffULL, 0xf.fffffff8p+29L }, { 0xffffffffULL, 0xf.fffffffp+28L }, { 0x7fffffffULL, 0xf.ffffffep+27L }, { 0x3fffffffULL, 0xf.ffffffcp+26L }, { 0x1fffffffULL, 0xf.ffffff8p+25L }, { 0xfffffffULL, 0xf.ffffffp+24L }, { 0x7ffffffULL, 0xf.fffffep+23L }, { 0x3ffffffULL, 0xf.fffffcp+22L }, { 0x1ffffffULL, 0xf.fffff8p+21L }, { 0xffffffULL, 0xf.fffffp+20L }, { 0x7fffffULL, 0xf.ffffep+19L }, { 0x3fffffULL, 0xf.ffffcp+18L }, { 0x1fffffULL, 0xf.ffff8p+17L }, { 0xfffffULL, 0xf.ffffp+16L }, { 0x7ffffULL, 0xf.fffep+15L }, { 0x3ffffULL, 0xf.fffcp+14L }, { 0x1ffffULL, 0xf.fff8p+13L }, { 0xffffULL, 0xf.fffp+12L }, { 0x7fffULL, 0xf.ffep+11L }, { 0x3fffULL, 0xf.ffcp+10L }, { 0x1fffULL, 0xf.ff8p+9L }, { 0xfffULL, 0xf.ffp+8L }, { 0x7ffULL, 0xf.fep+7L }, { 0x3ffULL, 0xf.fcp+6L }, { 0x1ffULL, 0xf.f8p+5L }, { 0xffULL, 0xf.fp+4L }, { 0x7fULL, 0xf.ep+3L }, { 0x3fULL, 0xf.cp+2L }, { 0x1fULL, 0xf.8p+1L }, { 0xfULL, 0xfp+0L }, { 0x7ULL, 0xep-1L }, { 0x3ULL, 0xcp-2L }, { 0x1ULL, 0x8p-3L }, }; #endif ATF_TC(floatunditf); ATF_TC_HEAD(floatunditf, tc) { atf_tc_set_md_var(tc, "descr", "Verify that uint64 -> long double conversion works"); } 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) 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 } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, floatunditf); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/gen/t_fpsetmask.c (revision 274079) @@ -1,355 +1,354 @@ -/* $NetBSD: t_fpsetmask.c,v 1.13 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_fpsetmask.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 1995 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 #include #include #include #include #include "isqemu.h" #ifndef _FLOAT_IEEE754 ATF_TC(no_test); ATF_TC_HEAD(no_test, tc) { atf_tc_set_md_var(tc, "descr", "Dummy test case"); } ATF_TC_BODY(no_test, tc) { atf_tc_skip("Test not available on this architecture."); } #else /* defined(_FLOAT_IEEE754) */ #include const char *skip_mesg; const char *skip_arch; void sigfpe(int, siginfo_t *, void *); volatile sig_atomic_t signal_caught; volatile int sicode; static volatile const float f_one = 1.0; static volatile const float f_zero = 0.0; static volatile const double d_one = 1.0; static volatile const double d_zero = 0.0; static volatile const long double ld_one = 1.0; static volatile const long double ld_zero = 0.0; static volatile const float f_huge = FLT_MAX; static volatile const float f_tiny = FLT_MIN; static volatile const double d_huge = DBL_MAX; static volatile const double d_tiny = DBL_MIN; static volatile const long double ld_huge = LDBL_MAX; static volatile const long double ld_tiny = LDBL_MIN; static volatile float f_x; static volatile double d_x; static volatile long double ld_x; /* trip divide by zero */ static void f_dz(void) { f_x = f_one / f_zero; } static void d_dz(void) { d_x = d_one / d_zero; } static void ld_dz(void) { ld_x = ld_one / ld_zero; } /* trip invalid operation */ static void d_inv(void) { d_x = d_zero / d_zero; } static void ld_inv(void) { ld_x = ld_zero / ld_zero; } static void f_inv(void) { f_x = f_zero / f_zero; } /* trip overflow */ static void f_ofl(void) { f_x = f_huge * f_huge; } static void d_ofl(void) { d_x = d_huge * d_huge; } static void ld_ofl(void) { ld_x = ld_huge * ld_huge; } /* trip underflow */ static void f_ufl(void) { f_x = f_tiny * f_tiny; } static void d_ufl(void) { d_x = d_tiny * d_tiny; } static void ld_ufl(void) { ld_x = ld_tiny * ld_tiny; } struct ops { void (*op)(void); fp_except mask; int sicode; }; static const struct ops float_ops[] = { { f_dz, FP_X_DZ, FPE_FLTDIV }, { f_inv, FP_X_INV, FPE_FLTINV }, { f_ofl, FP_X_OFL, FPE_FLTOVF }, { f_ufl, FP_X_UFL, FPE_FLTUND }, { NULL, 0, 0 } }; static const struct ops double_ops[] = { { d_dz, FP_X_DZ, FPE_FLTDIV }, { d_inv, FP_X_INV, FPE_FLTINV }, { d_ofl, FP_X_OFL, FPE_FLTOVF }, { d_ufl, FP_X_UFL, FPE_FLTUND }, { NULL, 0, 0 } }; static const struct ops long_double_ops[] = { { ld_dz, FP_X_DZ, FPE_FLTDIV }, { ld_inv, FP_X_INV, FPE_FLTINV }, { ld_ofl, FP_X_OFL, FPE_FLTOVF }, { ld_ufl, FP_X_UFL, FPE_FLTUND }, { NULL, 0, 0 } }; static sigjmp_buf b; static void fpsetmask_masked(const struct ops *test_ops) { struct sigaction sa; fp_except ex1, ex2; const struct ops *t; /* mask all exceptions, clear history */ fpsetmask(0); fpsetsticky(0); /* set up signal handler */ sa.sa_sigaction = sigfpe; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &sa, 0); signal_caught = 0; /* * exceptions masked, check whether "sticky" bits are set correctly */ for (t = test_ops; t->op != NULL; t++) { (*t->op)(); ex1 = fpgetsticky(); ATF_CHECK_EQ(ex1 & t->mask, t->mask); ATF_CHECK_EQ(signal_caught, 0); /* check correct fpsetsticky() behaviour */ ex2 = fpsetsticky(0); ATF_CHECK_EQ(fpgetsticky(), 0); ATF_CHECK_EQ(ex1, ex2); } } /* force delayed exceptions to be delivered */ #define BARRIER() fpsetmask(0); f_x = f_one * f_one static void fpsetmask_unmasked(const struct ops *test_ops) { struct sigaction sa; int r; const struct ops *volatile t; /* mask all exceptions, clear history */ fpsetmask(0); fpsetsticky(0); /* set up signal handler */ sa.sa_sigaction = sigfpe; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_SIGINFO; sigaction(SIGFPE, &sa, 0); signal_caught = 0; /* * exception unmasked, check SIGFPE delivery and correct siginfo */ for (t = test_ops; t->op != NULL; t++) { fpsetmask(t->mask); r = sigsetjmp(b, 1); if (!r) { (*t->op)(); BARRIER(); } ATF_CHECK_EQ(signal_caught, 1); ATF_CHECK_EQ(sicode, t->sicode); signal_caught = 0; } } void sigfpe(int s, siginfo_t *si, void *c) { signal_caught = 1; sicode = si->si_code; siglongjmp(b, 1); } #define TEST(m, t) \ ATF_TC(m##_##t); \ \ ATF_TC_HEAD(m##_##t, tc) \ { \ \ atf_tc_set_md_var(tc, "descr", \ "Test " ___STRING(m) " exceptions for " \ ___STRING(t) "values"); \ } \ \ ATF_TC_BODY(m##_##t, tc) \ { \ if (strcmp(MACHINE, "macppc") == 0) \ atf_tc_expect_fail("PR port-macppc/46319"); \ \ if (isQEMU()) \ atf_tc_expect_fail("PR misc/44767"); \ \ m(t##_ops); \ } TEST(fpsetmask_masked, float) TEST(fpsetmask_masked, double) TEST(fpsetmask_masked, long_double) TEST(fpsetmask_unmasked, float) TEST(fpsetmask_unmasked, double) TEST(fpsetmask_unmasked, long_double) ATF_TC(fpsetmask_basic); ATF_TC_HEAD(fpsetmask_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of fpsetmask(3)"); } 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 }; msk = fpgetmask(); for (i = 0; i < __arraycount(lst); i++) { fpsetmask(msk | lst[i]); ATF_CHECK((fpgetmask() & lst[i]) != 0); fpsetmask(msk & lst[i]); ATF_CHECK((fpgetmask() & lst[i]) == 0); } } #endif /* defined(_FLOAT_IEEE754) */ ATF_TP_ADD_TCS(tp) { #ifndef _FLOAT_IEEE754 ATF_TP_ADD_TC(tp, no_test); #else ATF_TP_ADD_TC(tp, fpsetmask_basic); ATF_TP_ADD_TC(tp, fpsetmask_masked_float); ATF_TP_ADD_TC(tp, fpsetmask_masked_double); ATF_TP_ADD_TC(tp, fpsetmask_masked_long_double); ATF_TP_ADD_TC(tp, fpsetmask_unmasked_float); ATF_TP_ADD_TC(tp, fpsetmask_unmasked_double); ATF_TP_ADD_TC(tp, fpsetmask_unmasked_long_double); #endif return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_isnan.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_isnan.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/gen/t_isnan.c (revision 274079) @@ -1,67 +1,66 @@ -/* $NetBSD: t_isnan.c,v 1.4 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_isnan.c,v 1.5 2014/11/04 00:20:19 justin Exp $ */ /* * This file is in the Public Domain. * * The nan test is blatently copied by Simon Burge from the infinity * test by Ben Harris. */ #include #include -#include #include #include ATF_TC(isnan_basic); ATF_TC_HEAD(isnan_basic, tc) { atf_tc_set_md_var(tc, "descr", "Verify that isnan(3) works"); } ATF_TC_BODY(isnan_basic, tc) { #if defined(__m68k__) atf_tc_skip("Test not applicable on " MACHINE_ARCH); #endif #ifdef NAN /* 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 } ATF_TC(isinf_basic); ATF_TC_HEAD(isinf_basic, tc) { atf_tc_set_md_var(tc, "descr", "Verify that isinf(3) works"); } ATF_TC_BODY(isinf_basic, tc) { #if defined(__m68k__) atf_tc_skip("Test not applicable on " MACHINE_ARCH); #endif /* HUGE_VAL is meant to be an infinity. */ ATF_CHECK(isinf(HUGE_VAL) != 0); /* HUGE_VALF is the float analog of HUGE_VAL. */ ATF_CHECK(isinf(HUGE_VALF) != 0); /* HUGE_VALL is the long double analog of HUGE_VAL. */ ATF_CHECK(isinf(HUGE_VALL) != 0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, isnan_basic); ATF_TP_ADD_TC(tp, isinf_basic); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/gen/t_siginfo.c (revision 274079) @@ -1,506 +1,505 @@ -/* $NetBSD: t_siginfo.c,v 1.23 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_siginfo.c,v 1.24 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2010 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 #if defined(__NetBSD__) #include #endif #include #include #include #include #include #include #include #include #include #include #include #include #include #ifdef HAVE_FENV #include #elif defined(_FLOAT_IEEE754) #include #endif #include "isqemu.h" /* for sigbus */ volatile char *addr; /* for sigchild */ pid_t child; int code; int status; /* for sigfpe */ sig_atomic_t fltdiv_signalled = 0; sig_atomic_t intdiv_signalled = 0; static void sig_debug(int signo, siginfo_t *info, ucontext_t *ctx) { unsigned int i; printf("%d %p %p\n", signo, info, ctx); if (info != NULL) { printf("si_signo=%d\n", info->si_signo); printf("si_errno=%d\n", info->si_errno); printf("si_code=%d\n", info->si_code); printf("si_value.sival_int=%d\n", info->si_value.sival_int); } if (ctx != NULL) { printf("uc_flags 0x%x\n", ctx->uc_flags); printf("uc_link %p\n", ctx->uc_link); for (i = 0; i < __arraycount(ctx->uc_sigmask.__bits); i++) printf("uc_sigmask[%d] 0x%x\n", i, ctx->uc_sigmask.__bits[i]); printf("uc_stack %p %lu 0x%x\n", ctx->uc_stack.ss_sp, (unsigned long)ctx->uc_stack.ss_size, ctx->uc_stack.ss_flags); #if defined(__NetBSD__) for (i = 0; i < __arraycount(ctx->uc_mcontext.__gregs); i++) printf("uc_mcontext.greg[%d] 0x%lx\n", i, (long)ctx->uc_mcontext.__gregs[i]); #endif } } static void sigalrm_action(int signo, siginfo_t *info, void *ptr) { sig_debug(signo, info, (ucontext_t *)ptr); ATF_REQUIRE_EQ(info->si_signo, SIGALRM); ATF_REQUIRE_EQ(info->si_code, SI_TIMER); ATF_REQUIRE_EQ(info->si_value.sival_int, ITIMER_REAL); atf_tc_pass(); /* NOTREACHED */ } ATF_TC(sigalarm); ATF_TC_HEAD(sigalarm, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGALRM handler"); } ATF_TC_BODY(sigalarm, tc) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigalrm_action; sigemptyset(&sa.sa_mask); sigaction(SIGALRM, &sa, NULL); for (;;) { alarm(1); sleep(1); } atf_tc_fail("SIGALRM handler wasn't called"); } static void sigchild_action(int signo, siginfo_t *info, void *ptr) { if (info != NULL) { printf("info=%p\n", info); printf("ptr=%p\n", ptr); printf("si_signo=%d\n", info->si_signo); printf("si_errno=%d\n", info->si_errno); printf("si_code=%d\n", info->si_code); printf("si_uid=%d\n", info->si_uid); printf("si_pid=%d\n", info->si_pid); printf("si_status=%d\n", info->si_status); #if defined(__NetBSD__) printf("si_utime=%lu\n", (unsigned long int)info->si_utime); printf("si_stime=%lu\n", (unsigned long int)info->si_stime); #endif } ATF_REQUIRE_EQ(info->si_code, code); ATF_REQUIRE_EQ(info->si_signo, SIGCHLD); ATF_REQUIRE_EQ(info->si_uid, getuid()); ATF_REQUIRE_EQ(info->si_pid, child); if (WIFEXITED(info->si_status)) ATF_REQUIRE_EQ(WEXITSTATUS(info->si_status), status); else if (WIFSTOPPED(info->si_status)) ATF_REQUIRE_EQ(WSTOPSIG(info->si_status), status); else if (WIFSIGNALED(info->si_status)) ATF_REQUIRE_EQ(WTERMSIG(info->si_status), status); } static void setchildhandler(void (*action)(int, siginfo_t *, void *)) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = action; sigemptyset(&sa.sa_mask); sigaction(SIGCHLD, &sa, NULL); } static void sigchild_setup(void) { sigset_t set; struct rlimit rlim; (void)getrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max; (void)setrlimit(RLIMIT_CORE, &rlim); setchildhandler(sigchild_action); sigemptyset(&set); sigaddset(&set, SIGCHLD); sigprocmask(SIG_BLOCK, &set, NULL); } ATF_TC(sigchild_normal); ATF_TC_HEAD(sigchild_normal, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGCHLD handler " "when child exits normally"); } ATF_TC_BODY(sigchild_normal, tc) { sigset_t set; sigchild_setup(); status = 25; code = CLD_EXITED; switch ((child = fork())) { case 0: sleep(1); exit(status); case -1: atf_tc_fail("fork failed"); default: sigemptyset(&set); sigsuspend(&set); } } ATF_TC(sigchild_dump); ATF_TC_HEAD(sigchild_dump, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGCHLD handler " "when child segfaults"); } ATF_TC_BODY(sigchild_dump, tc) { sigset_t set; sigchild_setup(); status = SIGSEGV; code = CLD_DUMPED; switch ((child = fork())) { case 0: sleep(1); *(volatile long *)0 = 0; atf_tc_fail("Child did not segfault"); /* NOTREACHED */ case -1: atf_tc_fail("fork failed"); default: sigemptyset(&set); sigsuspend(&set); } } ATF_TC(sigchild_kill); ATF_TC_HEAD(sigchild_kill, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGCHLD handler " "when child is killed"); } ATF_TC_BODY(sigchild_kill, tc) { sigset_t set; sigchild_setup(); status = SIGPIPE; code = CLD_KILLED; switch ((child = fork())) { case 0: sigemptyset(&set); sigsuspend(&set); break; case -1: atf_tc_fail("fork failed"); default: kill(child, SIGPIPE); sigemptyset(&set); sigsuspend(&set); } } static sigjmp_buf sigfpe_flt_env; static void sigfpe_flt_action(int signo, siginfo_t *info, void *ptr) { sig_debug(signo, info, (ucontext_t *)ptr); if (fltdiv_signalled++ != 0) atf_tc_fail("FPE handler called more than once"); ATF_REQUIRE_EQ(info->si_signo, SIGFPE); ATF_REQUIRE_EQ(info->si_code, FPE_FLTDIV); ATF_REQUIRE_EQ(info->si_errno, 0); siglongjmp(sigfpe_flt_env, 1); } ATF_TC(sigfpe_flt); ATF_TC_HEAD(sigfpe_flt, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGFPE handler " "for floating div-by-zero"); } ATF_TC_BODY(sigfpe_flt, tc) { struct sigaction sa; double d = strtod("0", NULL); if (isQEMU()) atf_tc_skip("Test does not run correctly under QEMU"); #if defined(__powerpc__) atf_tc_skip("Test not valid on powerpc"); #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 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); } if (fltdiv_signalled == 0) atf_tc_fail("FPE signal handler was not invoked"); } static sigjmp_buf sigfpe_int_env; static void sigfpe_int_action(int signo, siginfo_t *info, void *ptr) { sig_debug(signo, info, (ucontext_t *)ptr); if (intdiv_signalled++ != 0) atf_tc_fail("INTDIV handler called more than once"); ATF_REQUIRE_EQ(info->si_signo, SIGFPE); ATF_REQUIRE_EQ(info->si_code, FPE_INTDIV); atf_tc_expect_pass(); ATF_REQUIRE_EQ(info->si_errno, 0); siglongjmp(sigfpe_int_env, 1); } ATF_TC(sigfpe_int); ATF_TC_HEAD(sigfpe_int, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGFPE handler " "for integer div-by-zero (PR port-i386/43655)"); } 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"); #endif if (sigsetjmp(sigfpe_int_env, 0) == 0) { sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigfpe_int_action; sigemptyset(&sa.sa_mask); sigaction(SIGFPE, &sa, NULL); #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); } if (intdiv_signalled == 0) atf_tc_fail("FPE signal handler was not invoked"); } static void sigsegv_action(int signo, siginfo_t *info, void *ptr) { sig_debug(signo, info, (ucontext_t *)ptr); ATF_REQUIRE_EQ(info->si_signo, SIGSEGV); ATF_REQUIRE_EQ(info->si_errno, 0); ATF_REQUIRE_EQ(info->si_code, SEGV_MAPERR); ATF_REQUIRE_EQ(info->si_addr, (void *)0); atf_tc_pass(); /* NOTREACHED */ } ATF_TC(sigsegv); ATF_TC_HEAD(sigsegv, tc) { atf_tc_set_md_var(tc, "descr", "Checks that signal trampoline correctly calls SIGSEGV handler"); } ATF_TC_BODY(sigsegv, tc) { struct sigaction sa; sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigsegv_action; sigemptyset(&sa.sa_mask); sigaction(SIGSEGV, &sa, NULL); *(volatile long *)0 = 0; atf_tc_fail("Test did not fault as expected"); } 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 defined(__i386__) || defined(__x86_64__) atf_tc_expect_fail("x86 architecture does not correctly " "report the address where the unaligned access occured"); #endif ATF_REQUIRE_EQ(info->si_addr, (volatile 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; #if defined(__alpha__) 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"); #endif sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigbus_action; sigemptyset(&sa.sa_mask); sigaction(SIGBUS, &sa, NULL); /* Enable alignment checks for x86. 0x40000 is PSL_AC. */ #if defined(__i386__) __asm__("pushf; orl $0x40000, (%esp); popf"); #elif defined(__amd64__) __asm__("pushf; orl $0x40000, (%rsp); popf"); #endif addr = calloc(2, sizeof(int)); ATF_REQUIRE(addr != NULL); if (isQEMU()) atf_tc_expect_fail("QEMU fails to trap unaligned accesses"); /* 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"); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sigalarm); ATF_TP_ADD_TC(tp, sigchild_normal); ATF_TP_ADD_TC(tp, sigchild_dump); ATF_TP_ADD_TC(tp, sigchild_kill); 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(); } Index: head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/stdlib/t_strtod.c (revision 274079) @@ -1,343 +1,342 @@ -/* $NetBSD: t_strtod.c,v 1.31 2012/09/26 07:24:38 jruoho Exp $ */ +/* $NetBSD: t_strtod.c,v 1.32 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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. */ /* Public domain, Otto Moerbeek , 2006. */ #include -__RCSID("$NetBSD: t_strtod.c,v 1.31 2012/09/26 07:24:38 jruoho Exp $"); +__RCSID("$NetBSD: t_strtod.c,v 1.32 2014/11/04 00:20:19 justin Exp $"); #include #include #include #include #include #include -#include #if defined(__i386__) || defined(__amd64__) || defined(__sparc__) #include #endif #if !defined(__vax__) static const char * const inf_strings[] = { "Inf", "INF", "-Inf", "-INF", "Infinity", "+Infinity", "INFINITY", "-INFINITY", "InFiNiTy", "+InFiNiTy" }; const char *nan_string = "NaN(x)y"; #endif #ifdef __FreeBSD__ #define __HAVE_LONG_DOUBLE #endif ATF_TC(strtod_basic); ATF_TC_HEAD(strtod_basic, tc) { atf_tc_set_md_var(tc, "descr", "A basic test of strtod(3)"); } ATF_TC_BODY(strtod_basic, tc) { static const size_t n = 1024 * 1000; for (size_t i = 1; i < n; i = i + 1024) { char buf[512]; (void)snprintf(buf, sizeof(buf), "%zu.%zu", i, i + 1); errno = 0; double d = strtod(buf, NULL); ATF_REQUIRE(d > 0.0); ATF_REQUIRE(errno == 0); } } ATF_TC(strtod_hex); ATF_TC_HEAD(strtod_hex, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with hexadecimals"); } #ifdef __vax__ #define SMALL_NUM 1.0e-38 #else #define SMALL_NUM 1.0e-40 #endif ATF_TC_BODY(strtod_hex, tc) { const char *str; char *end; volatile double d; str = "-0x0"; d = strtod(str, &end); /* -0.0 */ ATF_REQUIRE(end == str + 4); ATF_REQUIRE(signbit(d) != 0); ATF_REQUIRE(fabs(d) < SMALL_NUM); str = "-0x"; d = strtod(str, &end); /* -0.0 */ ATF_REQUIRE(end == str + 2); ATF_REQUIRE(signbit(d) != 0); ATF_REQUIRE(fabs(d) < SMALL_NUM); } ATF_TC(strtod_inf); ATF_TC_HEAD(strtod_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtod_inf, tc) { #ifndef __vax__ for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile double d = strtod(inf_strings[i], NULL); ATF_REQUIRE(isinf(d) != 0); } #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtof_inf); ATF_TC_HEAD(strtof_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtof(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtof_inf, tc) { #ifndef __vax__ for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile float f = strtof(inf_strings[i], NULL); ATF_REQUIRE(isinf(f) != 0); } #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtold_inf); ATF_TC_HEAD(strtold_inf, tc) { atf_tc_set_md_var(tc, "descr", "A strtold(3) with INF (PR lib/33262)"); } ATF_TC_BODY(strtold_inf, tc) { #ifndef __vax__ # ifdef __HAVE_LONG_DOUBLE for (size_t i = 0; i < __arraycount(inf_strings); i++) { volatile long double ld = strtold(inf_strings[i], NULL); ATF_REQUIRE(isinf(ld) != 0); } # else atf_tc_skip("Requires long double support"); # endif #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtod_nan); ATF_TC_HEAD(strtod_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtod(3) with NaN"); } ATF_TC_BODY(strtod_nan, tc) { #ifndef __vax__ char *end; volatile double d = strtod(nan_string, &end); ATF_REQUIRE(isnan(d) != 0); ATF_REQUIRE(strcmp(end, "y") == 0); #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtof_nan); ATF_TC_HEAD(strtof_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtof(3) with NaN"); } ATF_TC_BODY(strtof_nan, tc) { #ifndef __vax__ char *end; volatile float f = strtof(nan_string, &end); ATF_REQUIRE(isnanf(f) != 0); ATF_REQUIRE(strcmp(end, "y") == 0); #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtold_nan); ATF_TC_HEAD(strtold_nan, tc) { atf_tc_set_md_var(tc, "descr", "A strtold(3) with NaN (PR lib/45020)"); } ATF_TC_BODY(strtold_nan, tc) { #ifndef __vax__ # ifdef __HAVE_LONG_DOUBLE char *end; volatile long double ld = strtold(nan_string, &end); ATF_REQUIRE(isnan(ld) != 0); #ifdef __FreeBSD__ ATF_REQUIRE(strcmp(end, "y") == 0); #else ATF_REQUIRE(__isnanl(ld) != 0); #endif ATF_REQUIRE(strcmp(end, "y") == 0); # else atf_tc_skip("Requires long double support"); # endif #else atf_tc_skip("vax not supported"); #endif } ATF_TC(strtod_round); ATF_TC_HEAD(strtod_round, tc) { atf_tc_set_md_var(tc, "descr", "Test rouding in strtod(3)"); } ATF_TC_BODY(strtod_round, tc) { #if defined(__i386__) || defined(__amd64__) || defined(__sparc__) /* * Test that strtod(3) honors the current rounding mode. * The used value is somewhere near 1 + DBL_EPSILON + FLT_EPSILON. */ const char *val = "1.00000011920928977282585492503130808472633361816406"; (void)fesetround(FE_UPWARD); volatile double d1 = strtod(val, NULL); (void)fesetround(FE_DOWNWARD); volatile double d2 = strtod(val, NULL); if (fabs(d1 - d2) > 0.0) return; else { atf_tc_expect_fail("PR misc/44767"); atf_tc_fail("strtod(3) did not honor fesetround(3)"); } #else atf_tc_skip("Requires one of i386, amd64 or sparc"); #endif } ATF_TC(strtod_underflow); ATF_TC_HEAD(strtod_underflow, tc) { atf_tc_set_md_var(tc, "descr", "Test underflow in strtod(3)"); } ATF_TC_BODY(strtod_underflow, tc) { const char *tmp = "0.0000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000000000000000000000000000000000000000000" "000000000000000002"; errno = 0; volatile double d = strtod(tmp, NULL); if (d != 0 || errno != ERANGE) atf_tc_fail("strtod(3) did not detect underflow"); } /* * Bug found by Geza Herman. * See * http://www.exploringbinary.com/a-bug-in-the-bigcomp-function-of-david-gays-strtod/ */ ATF_TC(strtod_gherman_bug); ATF_TC_HEAD(strtod_gherman_bug, tc) { atf_tc_set_md_var(tc, "descr", "Test a bug found by Geza Herman"); } ATF_TC_BODY(strtod_gherman_bug, tc) { const char *str = "1.8254370818746402660437411213933955878019332885742187"; errno = 0; volatile double d = strtod(str, NULL); ATF_CHECK(d == 0x1.d34fd8378ea83p+0); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, strtod_basic); ATF_TP_ADD_TC(tp, strtod_hex); ATF_TP_ADD_TC(tp, strtod_inf); ATF_TP_ADD_TC(tp, strtof_inf); ATF_TP_ADD_TC(tp, strtold_inf); ATF_TP_ADD_TC(tp, strtod_nan); ATF_TP_ADD_TC(tp, strtof_nan); ATF_TP_ADD_TC(tp, strtold_nan); ATF_TP_ADD_TC(tp, strtod_round); ATF_TP_ADD_TC(tp, strtod_underflow); ATF_TP_ADD_TC(tp, strtod_gherman_bug); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/sys/t_sigaction.c (revision 274079) @@ -1,166 +1,165 @@ -/* $NetBSD: t_sigaction.c,v 1.2 2012/11/07 16:51:16 pgoyette Exp $ */ +/* $NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2010 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 __COPYRIGHT("@(#) Copyright (c) 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sigaction.c,v 1.2 2012/11/07 16:51:16 pgoyette Exp $"); +__RCSID("$NetBSD: t_sigaction.c,v 1.3 2014/11/04 00:20:19 justin Exp $"); #include #include #include #include #include #include #include -#include #ifdef __NetBSD__ #include "../../../h_macros.h" #else #include "h_macros.h" #endif static bool handler_called = false; static void #ifdef __FreeBSD__ handler(int signo __unused) #else handler(int signo) #endif { handler_called = true; } static void sa_resethand_child(const int flags) { struct sigaction sa; sa.sa_flags = flags; sa.sa_handler = &handler; sigemptyset(&sa.sa_mask); sigaction(SIGUSR1, &sa, NULL); kill(getpid(), SIGUSR1); exit(handler_called ? EXIT_SUCCESS : EXIT_FAILURE); } static void wait_and_check_child(const pid_t pid, const char *fail_message) { int status; (void)waitpid(pid, &status, 0); if (WIFEXITED(status)) ATF_CHECK_EQ(EXIT_SUCCESS, WEXITSTATUS(status)); else atf_tc_fail("%s; raw exit status was %d", fail_message, status); } static void #ifdef __FreeBSD__ catch(int sig __unused) #else catch(int sig) #endif { return; } ATF_TC(sigaction_basic); ATF_TC_HEAD(sigaction_basic, tc) { atf_tc_set_md_var(tc, "descr", "Checks for correct I&D cache" "synchronization after copying out the trampoline code."); } ATF_TC_BODY(sigaction_basic, tc) { static struct sigaction sa; sa.sa_handler = catch; sigaction(SIGUSR1, &sa, 0); kill(getpid(), SIGUSR1); atf_tc_pass(); } ATF_TC(sigaction_noflags); ATF_TC_HEAD(sigaction_noflags, tc) { atf_tc_set_md_var(tc, "descr", "Checks programming a signal with " "sigaction(2) but without any flags"); } ATF_TC_BODY(sigaction_noflags, tc) { const pid_t pid = fork(); if (pid == -1) atf_tc_fail_errno("fork(2) failed"); else if (pid == 0) sa_resethand_child(0); else wait_and_check_child(pid, "Child process did not exit cleanly;" " it failed to process the signal"); } ATF_TC(sigaction_resethand); ATF_TC_HEAD(sigaction_resethand, tc) { atf_tc_set_md_var(tc, "descr", "Checks that SA_RESETHAND works"); } ATF_TC_BODY(sigaction_resethand, tc) { const pid_t pid = fork(); if (pid == -1) atf_tc_fail_errno("fork(2) failed"); else if (pid == 0) sa_resethand_child(SA_RESETHAND); else { wait_and_check_child(pid, "Child process did not exit cleanly;" " it either failed to process the signal or SA_RESETHAND" " is broken"); } } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, sigaction_basic); ATF_TP_ADD_TC(tp, sigaction_noflags); ATF_TP_ADD_TC(tp, sigaction_resethand); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libc/time/t_mktime.c =================================================================== --- head/contrib/netbsd-tests/lib/libc/time/t_mktime.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libc/time/t_mktime.c (revision 274079) @@ -1,160 +1,155 @@ /* $NetBSD: t_mktime.c,v 1.5 2012/03/18 07:33:58 jruoho Exp $ */ /*- * Copyright (c) 2011 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(localtime_r_gmt); ATF_TC_HEAD(localtime_r_gmt, tc) { atf_tc_set_md_var(tc, "descr", "Test that localtime_r(3) " "returns localtime, not GMT (PR lib/28324)"); } ATF_TC_BODY(localtime_r_gmt, tc) { struct tm *t; struct tm tt; time_t x; x = time(NULL); localtime_r(&x, &tt); t = localtime(&x); if (t->tm_sec != tt.tm_sec || t->tm_min != tt.tm_min || t->tm_hour != tt.tm_hour || t->tm_mday != tt.tm_mday) atf_tc_fail("inconsistencies between " "localtime(3) and localtime_r(3)"); } ATF_TC(mktime_negyear); ATF_TC_HEAD(mktime_negyear, tc) { atf_tc_set_md_var(tc, "descr", "Test mktime(3) with negative year"); } ATF_TC_BODY(mktime_negyear, tc) { struct tm tms; time_t t; (void)memset(&tms, 0, sizeof(tms)); tms.tm_year = ~0; errno = 0; t = mktime(&tms); -#if defined(__FreeBSD__) - /* Open Group says "and may set errno to indicate the error" */ - ATF_REQUIRE(t == (time_t)-1); -#else ATF_REQUIRE_ERRNO(0, t != (time_t)-1); -#endif } ATF_TC(timegm_epoch); ATF_TC_HEAD(timegm_epoch, tc) { atf_tc_set_md_var(tc, "descr", "Test timegm(3) close to the epoch"); } ATF_TC_BODY(timegm_epoch, tc) { struct tm tms; time_t t; /* midnight on 1 Jan 1970 */ (void)memset(&tms, 0, sizeof(tms)); errno = 0; tms.tm_year = 1970 - 1900; tms.tm_mday = 1; t = timegm(&tms); ATF_REQUIRE_ERRNO(0, t == (time_t)0); /* one second after midnight on 1 Jan 1970 */ (void)memset(&tms, 0, sizeof(tms)); errno = 0; tms.tm_year = 1970 - 1900; tms.tm_mday = 1; tms.tm_sec = 1; t = timegm(&tms); ATF_REQUIRE_ERRNO(0, t == (time_t)1); /* * 1969-12-31 23:59:59 = one second before the epoch. * Result should be -1 with errno = 0. */ (void)memset(&tms, 0, sizeof(tms)); errno = 0; tms.tm_year = 1969 - 1900; tms.tm_mon = 12 - 1; tms.tm_mday = 31; tms.tm_hour = 23; tms.tm_min = 59; tms.tm_sec = 59; t = timegm(&tms); ATF_REQUIRE_ERRNO(0, t == (time_t)-1); /* * Another way of getting one second before the epoch: * Set date to 1 Jan 1970, and time to -1 second. */ (void)memset(&tms, 0, sizeof(tms)); errno = 0; tms.tm_year = 1970 - 1900; tms.tm_mday = 1; tms.tm_sec = -1; t = timegm(&tms); ATF_REQUIRE_ERRNO(0, t == (time_t)-1); /* * Two seconds before the epoch. */ (void)memset(&tms, 0, sizeof(tms)); errno = 0; tms.tm_year = 1970 - 1900; tms.tm_mday = 1; tms.tm_sec = -2; t = timegm(&tms); ATF_REQUIRE_ERRNO(0, t == (time_t)-2); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, localtime_r_gmt); ATF_TP_ADD_TC(tp, mktime_negyear); ATF_TP_ADD_TC(tp, timegm_epoch); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c =================================================================== --- head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libexecinfo/t_backtrace.c (revision 274079) @@ -1,168 +1,167 @@ -/* $NetBSD: t_backtrace.c,v 1.15 2014/05/01 03:46:11 joerg Exp $ */ +/* $NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2012 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. * * 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 -__RCSID("$NetBSD: t_backtrace.c,v 1.15 2014/05/01 03:46:11 joerg Exp $"); +__RCSID("$NetBSD: t_backtrace.c,v 1.16 2014/11/04 00:20:19 justin Exp $"); #include -#include #include #include #include #include #include #ifndef __arraycount #define __arraycount(a) (sizeof(a) / sizeof(a[0])) #endif void myfunc3(size_t ncalls); void myfunc2(size_t ncalls); void myfunc1(size_t origcalls, volatile size_t ncalls); void myfunc(size_t ncalls); volatile int prevent_inline; void myfunc3(size_t ncalls) { static const struct { const char *name; bool is_optional; } frames[] = { { "myfunc", false }, { "atfu_backtrace_fmt_basic_body", false }, { "atf_tc_run", false }, { "atf_tp_run", true }, { "run_tc", true }, { "controlled_main", true }, { "atf_tp_main", false }, { "main", true }, { "___start", true }, }; size_t j, nptrs, min_frames, max_frames; void *buffer[ncalls + 10]; char **strings; min_frames = 0; max_frames = 0; for (j = 0; j < __arraycount(frames); ++j) { if (!frames[j].is_optional) ++min_frames; ++max_frames; } nptrs = backtrace(buffer, __arraycount(buffer)); ATF_REQUIRE(nptrs != (size_t)-1); strings = backtrace_symbols_fmt(buffer, nptrs, "%n"); ATF_CHECK(strings != NULL); printf("got nptrs=%zu ncalls=%zu (min_frames: %zu, max_frames: %zu)\n", nptrs, ncalls, min_frames, max_frames); printf("backtrace is:\n"); for (j = 0; j < nptrs; j++) { printf("#%zu: %s\n", j, strings[j]); } ATF_REQUIRE(nptrs >= ncalls + 2 + min_frames); ATF_REQUIRE(nptrs <= ncalls + 2 + max_frames); ATF_CHECK_STREQ(strings[0], "myfunc3"); ATF_CHECK_STREQ(strings[1], "myfunc2"); for (j = 2; j < ncalls + 2; j++) ATF_CHECK_STREQ(strings[j], "myfunc1"); for (size_t i = 0; j < nptrs; i++, j++) { if (frames[i].is_optional && strcmp(strings[j], frames[i].name)) { --i; continue; } ATF_CHECK_STREQ(strings[j], frames[i].name); } free(strings); if (prevent_inline) vfork(); } void myfunc2(size_t ncalls) { myfunc3(ncalls); if (prevent_inline) vfork(); } void myfunc1(size_t origcalls, volatile size_t ncalls) { if (ncalls > 1) myfunc1(origcalls, ncalls - 1); else myfunc2(origcalls); if (prevent_inline) vfork(); } void myfunc(size_t ncalls) { myfunc1(ncalls, ncalls); if (prevent_inline) vfork(); } ATF_TC(backtrace_fmt_basic); ATF_TC_HEAD(backtrace_fmt_basic, tc) { atf_tc_set_md_var(tc, "descr", "Test backtrace_fmt(3)"); atf_tc_set_md_var(tc, "require.files", "/proc/self"); } ATF_TC_BODY(backtrace_fmt_basic, tc) { myfunc(12); if (prevent_inline) vfork(); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, backtrace_fmt_basic); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libm/t_ldexp.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_ldexp.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libm/t_ldexp.c (revision 274079) @@ -1,481 +1,480 @@ -/* $NetBSD: t_ldexp.c,v 1.13 2014/03/12 21:40:07 martin Exp $ */ +/* $NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_ldexp.c,v 1.13 2014/03/12 21:40:07 martin Exp $"); +__RCSID("$NetBSD: t_ldexp.c,v 1.14 2014/11/04 00:20:19 justin Exp $"); #include #include -#include #include #include #include #include #define SKIP 9999 #define FORMAT "%23.23lg" static const int exps[] = { 0, 1, -1, 100, -100 }; struct ldexp_test { double x; int exp1; int exp2; const char *result; }; struct ldexp_test ldexp_basic[] = { { 1.0, 5, SKIP, " 32" }, { 1.0, 1022, SKIP, "4.4942328371557897693233e+307" }, { 1.0, 1023, -1, "4.4942328371557897693233e+307" }, { 1.0, 1023, SKIP, "8.9884656743115795386465e+307" }, { 1.0, 1022, 1, "8.9884656743115795386465e+307" }, { 1.0, -1022, 2045, "8.9884656743115795386465e+307" }, { 1.0, -5, SKIP, " 0.03125" }, { 1.0, -1021, SKIP, "4.4501477170144027661805e-308" }, { 1.0, -1022, 1, "4.4501477170144027661805e-308" }, { 1.0, -1022, SKIP, "2.2250738585072013830902e-308" }, { 1.0, -1021, -1, "2.2250738585072013830902e-308" }, { 1.0, 1023, -2045, "2.2250738585072013830902e-308" }, { 1.0, 1023, -1023, " 1" }, { 1.0, -1022, 1022, " 1" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_zero[] = { { 0.0, -1, SKIP, " 0" }, { 0.0, 0, SKIP, " 0" }, { 0.0, 1, SKIP, " 0" }, { 0.0, 1024, SKIP, " 0" }, { 0.0, 1025, SKIP, " 0" }, { 0.0, -1023, SKIP, " 0" }, { 0.0, -1024, SKIP, " 0" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_infinity[] = { { 1.0, 1024, -1, " inf" }, { 1.0, 1024, 0, " inf" }, { 1.0, 1024, 1, " inf" }, { -1.0, 1024, -1, " -inf" }, { -1.0, 1024, 0, " -inf" }, { -1.0, 1024, 1, " -inf" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_overflow[] = { { 1.0, 1024, SKIP, " inf" }, { 1.0, 1023, 1, " inf" }, { 1.0, -1022, 2046, " inf" }, { 1.0, 1025, SKIP, " inf" }, { -1.0, 1024, SKIP, " -inf" }, { -1.0, 1023, 1, " -inf" }, { -1.0, -1022, 2046, " -inf" }, { -1.0, 1025, SKIP, " -inf" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_denormal[] = { { 1.0, -1023, SKIP, "1.1125369292536006915451e-308" }, { 1.0, -1022, -1, "1.1125369292536006915451e-308" }, { 1.0, 1023, -2046, "1.1125369292536006915451e-308" }, { 1.0, -1024, SKIP, "5.5626846462680034577256e-309" }, { 1.0, -1074, SKIP, "4.9406564584124654417657e-324" }, { -1.0, -1023, SKIP, "-1.1125369292536006915451e-308" }, { -1.0, -1022, -1, "-1.1125369292536006915451e-308" }, { -1.0, 1023, -2046, "-1.1125369292536006915451e-308" }, { -1.0, -1024, SKIP, "-5.5626846462680034577256e-309" }, { -1.0, -1074, SKIP, "-4.9406564584124654417657e-324" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_underflow[] = { { 1.0, -1075, SKIP, " 0" }, { 1.0, -1074, -1, " 0" }, { 1.0, 1023, -2098, " 0" }, { 1.0, -1076, SKIP, " 0" }, { -1.0, -1075, SKIP, " -0" }, { -1.0, -1074, -1, " -0" }, { -1.0, 1023, -2098, " -0" }, { -1.0, -1076, SKIP, " -0" }, { 0, 0, 0, NULL } }; struct ldexp_test ldexp_denormal_large[] = { { 1.0, -1028, 1024, " 0.0625" }, { 1.0, -1028, 1025, " 0.125" }, { 1.0, -1028, 1026, " 0.25" }, { 1.0, -1028, 1027, " 0.5" }, { 1.0, -1028, 1028, " 1" }, { 1.0, -1028, 1029, " 2" }, { 1.0, -1028, 1030, " 4" }, { 1.0, -1028, 1040, " 4096" }, { 1.0, -1028, 1050, " 4194304" }, { 1.0, -1028, 1060, " 4294967296" }, { 1.0, -1028, 1100, " 4722366482869645213696" }, { 1.0, -1028, 1200, "5.9863107065073783529623e+51" }, { 1.0, -1028, 1300, "7.5885503602567541832791e+81" }, { 1.0, -1028, 1400, "9.6196304190416209014353e+111" }, { 1.0, -1028, 1500, "1.2194330274671844653834e+142" }, { 1.0, -1028, 1600, "1.5458150092069033378781e+172" }, { 1.0, -1028, 1700, "1.9595533242629369747791e+202" }, { 1.0, -1028, 1800, "2.4840289476811342962384e+232" }, { 1.0, -1028, 1900, "3.1488807865122869393369e+262" }, { 1.0, -1028, 2000, "3.9916806190694396233127e+292" }, { 1.0, -1028, 2046, "2.808895523222368605827e+306" }, { 1.0, -1028, 2047, "5.6177910464447372116541e+306" }, { 1.0, -1028, 2048, "1.1235582092889474423308e+307" }, { 1.0, -1028, 2049, "2.2471164185778948846616e+307" }, { 1.0, -1028, 2050, "4.4942328371557897693233e+307" }, { 1.0, -1028, 2051, "8.9884656743115795386465e+307" }, { 0, 0, 0, NULL } }; static void run_test(struct ldexp_test *table) { char outbuf[64]; size_t i; double v; for (i = 0; table->result != NULL; table++, i++) { v = ldexp(table->x, table->exp1); if (table->exp2 == SKIP) continue; v = ldexp(v, table->exp2); (void)snprintf(outbuf, sizeof(outbuf), FORMAT, v); ATF_CHECK_STREQ_MSG(table->result, outbuf, "Entry %zu:\n\tExp: \"%s\"\n\tAct: \"%s\"", i, table->result, outbuf); } } /* * ldexp(3) */ ATF_TC(ldexp_exp2); ATF_TC_HEAD(ldexp_exp2, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(x, n) == x * exp2(n)"); } ATF_TC_BODY(ldexp_exp2, tc) { const double n[] = { 1, 2, 3, 10, 50, 100 }; #if __DBL_MIN_10_EXP__ <= -40 const double eps = 1.0e-40; #else const double eps = __DBL_MIN__*4.0; #endif const double x = 12.0; double y; size_t i; for (i = 0; i < __arraycount(n); i++) { y = ldexp(x, n[i]); if (fabs(y - (x * exp2(n[i]))) > eps) { atf_tc_fail_nonfatal("ldexp(%0.01f, %0.01f) " "!= %0.01f * exp2(%0.01f)", x, n[i], x, n[i]); } } } ATF_TC(ldexp_nan); ATF_TC_HEAD(ldexp_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(NaN) == NaN"); } ATF_TC_BODY(ldexp_nan, tc) { const double x = 0.0L / 0.0L; double y; size_t i; ATF_REQUIRE(isnan(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexp(x, exps[i]); ATF_CHECK(isnan(y) != 0); } } ATF_TC(ldexp_inf_neg); ATF_TC_HEAD(ldexp_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(-Inf) == -Inf"); } ATF_TC_BODY(ldexp_inf_neg, tc) { const double x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(ldexp(x, exps[i]) == x); } ATF_TC(ldexp_inf_pos); ATF_TC_HEAD(ldexp_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(+Inf) == +Inf"); } ATF_TC_BODY(ldexp_inf_pos, tc) { const double x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(ldexp(x, exps[i]) == x); } ATF_TC(ldexp_zero_neg); ATF_TC_HEAD(ldexp_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(-0.0) == -0.0"); } ATF_TC_BODY(ldexp_zero_neg, tc) { const double x = -0.0L; double y; size_t i; ATF_REQUIRE(signbit(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexp(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } } ATF_TC(ldexp_zero_pos); ATF_TC_HEAD(ldexp_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexp(+0.0) == +0.0"); } ATF_TC_BODY(ldexp_zero_pos, tc) { const double x = 0.0L; double y; size_t i; ATF_REQUIRE(signbit(x) == 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexp(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } } /* * ldexpf(3) */ ATF_TC(ldexpf_exp2f); ATF_TC_HEAD(ldexpf_exp2f, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(x, n) == x * exp2f(n)"); } ATF_TC_BODY(ldexpf_exp2f, tc) { const float n[] = { 1, 2, 3, 10, 50, 100 }; const float eps = 1.0e-9; const float x = 12.0; float y; size_t i; for (i = 0; i < __arraycount(n); i++) { y = ldexpf(x, n[i]); if (fabsf(y - (x * exp2f(n[i]))) > eps) { atf_tc_fail_nonfatal("ldexpf(%0.01f, %0.01f) " "!= %0.01f * exp2f(%0.01f)", x, n[i], x, n[i]); } } } ATF_TC(ldexpf_nan); ATF_TC_HEAD(ldexpf_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(NaN) == NaN"); } ATF_TC_BODY(ldexpf_nan, tc) { const float x = 0.0L / 0.0L; float y; size_t i; ATF_REQUIRE(isnan(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexpf(x, exps[i]); ATF_CHECK(isnan(y) != 0); } } ATF_TC(ldexpf_inf_neg); ATF_TC_HEAD(ldexpf_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(-Inf) == -Inf"); } ATF_TC_BODY(ldexpf_inf_neg, tc) { const float x = -1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(ldexpf(x, exps[i]) == x); } ATF_TC(ldexpf_inf_pos); ATF_TC_HEAD(ldexpf_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(+Inf) == +Inf"); } ATF_TC_BODY(ldexpf_inf_pos, tc) { const float x = 1.0L / 0.0L; size_t i; for (i = 0; i < __arraycount(exps); i++) ATF_CHECK(ldexpf(x, exps[i]) == x); } ATF_TC(ldexpf_zero_neg); ATF_TC_HEAD(ldexpf_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(-0.0) == -0.0"); } ATF_TC_BODY(ldexpf_zero_neg, tc) { const float x = -0.0L; float y; size_t i; ATF_REQUIRE(signbit(x) != 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexpf(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) != 0); } } ATF_TC(ldexpf_zero_pos); ATF_TC_HEAD(ldexpf_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test ldexpf(+0.0) == +0.0"); } ATF_TC_BODY(ldexpf_zero_pos, tc) { const float x = 0.0L; float y; size_t i; ATF_REQUIRE(signbit(x) == 0); for (i = 0; i < __arraycount(exps); i++) { y = ldexpf(x, exps[i]); ATF_CHECK(x == y); ATF_CHECK(signbit(y) == 0); } } #define TEST(name, desc) \ ATF_TC(name); \ ATF_TC_HEAD(name, tc) \ { \ \ atf_tc_set_md_var(tc, "descr", \ "Test ldexp(3) for " ___STRING(desc)); \ } \ ATF_TC_BODY(name, tc) \ { \ if (strcmp("vax", MACHINE_ARCH) == 0) \ atf_tc_skip("Test not valid for " MACHINE_ARCH); \ run_test(name); \ } TEST(ldexp_basic, basics) TEST(ldexp_zero, zero) TEST(ldexp_infinity, infinity) TEST(ldexp_overflow, overflow) TEST(ldexp_denormal, denormal) TEST(ldexp_denormal_large, large) TEST(ldexp_underflow, underflow) ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, ldexp_basic); ATF_TP_ADD_TC(tp, ldexp_zero); ATF_TP_ADD_TC(tp, ldexp_infinity); ATF_TP_ADD_TC(tp, ldexp_overflow); ATF_TP_ADD_TC(tp, ldexp_denormal); ATF_TP_ADD_TC(tp, ldexp_underflow); ATF_TP_ADD_TC(tp, ldexp_denormal_large); ATF_TP_ADD_TC(tp, ldexp_exp2); ATF_TP_ADD_TC(tp, ldexp_nan); ATF_TP_ADD_TC(tp, ldexp_inf_neg); ATF_TP_ADD_TC(tp, ldexp_inf_pos); ATF_TP_ADD_TC(tp, ldexp_zero_neg); ATF_TP_ADD_TC(tp, ldexp_zero_pos); ATF_TP_ADD_TC(tp, ldexpf_exp2f); ATF_TP_ADD_TC(tp, ldexpf_nan); ATF_TP_ADD_TC(tp, ldexpf_inf_neg); ATF_TP_ADD_TC(tp, ldexpf_inf_pos); ATF_TP_ADD_TC(tp, ldexpf_zero_neg); ATF_TP_ADD_TC(tp, ldexpf_zero_pos); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libm/t_log.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_log.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libm/t_log.c (revision 274079) @@ -1,885 +1,884 @@ -/* $NetBSD: t_log.c,v 1.11 2014/03/03 10:39:08 martin Exp $ */ +/* $NetBSD: t_log.c,v 1.12 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Jukka Ruohonen. * * 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 -__RCSID("$NetBSD: t_log.c,v 1.11 2014/03/03 10:39:08 martin Exp $"); +__RCSID("$NetBSD: t_log.c,v 1.12 2014/11/04 00:20:19 justin Exp $"); #include -#include #include #include #include /* * log10(3) */ ATF_TC(log10_base); ATF_TC_HEAD(log10_base, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(10) == 1"); } ATF_TC_BODY(log10_base, tc) { ATF_CHECK(log10(10.0) == 1.0); } ATF_TC(log10_nan); ATF_TC_HEAD(log10_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(NaN) == NaN"); } ATF_TC_BODY(log10_nan, tc) { const double x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log10(x)) != 0); } ATF_TC(log10_inf_neg); ATF_TC_HEAD(log10_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(-Inf) == NaN"); } ATF_TC_BODY(log10_inf_neg, tc) { const double x = -1.0L / 0.0L; const double y = log10(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(log10_inf_pos); ATF_TC_HEAD(log10_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(+Inf) == +Inf"); } ATF_TC_BODY(log10_inf_pos, tc) { const double x = 1.0L / 0.0L; ATF_CHECK(log10(x) == x); } ATF_TC(log10_one_pos); ATF_TC_HEAD(log10_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(1.0) == +0.0"); } ATF_TC_BODY(log10_one_pos, tc) { const double x = log10(1.0); const double y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(log10_zero_neg); ATF_TC_HEAD(log10_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(-0.0) == -HUGE_VAL"); } ATF_TC_BODY(log10_zero_neg, tc) { const double x = -0.0L; ATF_CHECK(log10(x) == -HUGE_VAL); } ATF_TC(log10_zero_pos); ATF_TC_HEAD(log10_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10(+0.0) == -HUGE_VAL"); } ATF_TC_BODY(log10_zero_pos, tc) { const double x = 0.0L; ATF_CHECK(log10(x) == -HUGE_VAL); } /* * log10f(3) */ ATF_TC(log10f_base); ATF_TC_HEAD(log10f_base, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(10) == 1"); } ATF_TC_BODY(log10f_base, tc) { ATF_CHECK(log10f(10.0) == 1.0); } ATF_TC(log10f_nan); ATF_TC_HEAD(log10f_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(NaN) == NaN"); } ATF_TC_BODY(log10f_nan, tc) { const float x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log10f(x)) != 0); } ATF_TC(log10f_inf_neg); ATF_TC_HEAD(log10f_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(-Inf) == NaN"); } ATF_TC_BODY(log10f_inf_neg, tc) { const float x = -1.0L / 0.0L; const float y = log10f(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(log10f_inf_pos); ATF_TC_HEAD(log10f_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(+Inf) == +Inf"); } ATF_TC_BODY(log10f_inf_pos, tc) { const float x = 1.0L / 0.0L; #if defined(__alpha__) atf_tc_expect_fail("PR port-alpha/46301"); #endif ATF_CHECK(log10f(x) == x); } ATF_TC(log10f_one_pos); ATF_TC_HEAD(log10f_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(1.0) == +0.0"); } ATF_TC_BODY(log10f_one_pos, tc) { const float x = log10f(1.0); const float y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(log10f_zero_neg); ATF_TC_HEAD(log10f_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(-0.0) == -HUGE_VALF"); } ATF_TC_BODY(log10f_zero_neg, tc) { const float x = -0.0L; ATF_CHECK(log10f(x) == -HUGE_VALF); } ATF_TC(log10f_zero_pos); ATF_TC_HEAD(log10f_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log10f(+0.0) == -HUGE_VALF"); } ATF_TC_BODY(log10f_zero_pos, tc) { const float x = 0.0L; ATF_CHECK(log10f(x) == -HUGE_VALF); } /* * log1p(3) */ ATF_TC(log1p_nan); ATF_TC_HEAD(log1p_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(NaN) == NaN"); } ATF_TC_BODY(log1p_nan, tc) { const double x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log1p(x)) != 0); } ATF_TC(log1p_inf_neg); ATF_TC_HEAD(log1p_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(-Inf) == NaN"); } ATF_TC_BODY(log1p_inf_neg, tc) { const double x = -1.0L / 0.0L; const double y = log1p(x); if (isnan(y) == 0) { atf_tc_expect_fail("PR lib/45362"); atf_tc_fail("log1p(-Inf) != NaN"); } } ATF_TC(log1p_inf_pos); ATF_TC_HEAD(log1p_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(+Inf) == +Inf"); } ATF_TC_BODY(log1p_inf_pos, tc) { const double x = 1.0L / 0.0L; ATF_CHECK(log1p(x) == x); } ATF_TC(log1p_one_neg); ATF_TC_HEAD(log1p_one_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(-1.0) == -HUGE_VAL"); } ATF_TC_BODY(log1p_one_neg, tc) { const double x = log1p(-1.0); if (x != -HUGE_VAL) { atf_tc_expect_fail("PR lib/45362"); atf_tc_fail("log1p(-1.0) != -HUGE_VAL"); } } ATF_TC(log1p_zero_neg); ATF_TC_HEAD(log1p_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(-0.0) == -0.0"); } ATF_TC_BODY(log1p_zero_neg, tc) { const double x = -0.0L; ATF_CHECK(log1p(x) == x); } ATF_TC(log1p_zero_pos); ATF_TC_HEAD(log1p_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log1p(+0.0) == +0.0"); } ATF_TC_BODY(log1p_zero_pos, tc) { const double x = 0.0L; ATF_CHECK(log1p(x) == x); } /* * log1pf(3) */ ATF_TC(log1pf_nan); ATF_TC_HEAD(log1pf_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(NaN) == NaN"); } ATF_TC_BODY(log1pf_nan, tc) { const float x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log1pf(x)) != 0); } ATF_TC(log1pf_inf_neg); ATF_TC_HEAD(log1pf_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(-Inf) == NaN"); } ATF_TC_BODY(log1pf_inf_neg, tc) { const float x = -1.0L / 0.0L; const float y = log1pf(x); if (isnan(y) == 0) { atf_tc_expect_fail("PR lib/45362"); atf_tc_fail("log1pf(-Inf) != NaN"); } } ATF_TC(log1pf_inf_pos); ATF_TC_HEAD(log1pf_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(+Inf) == +Inf"); } ATF_TC_BODY(log1pf_inf_pos, tc) { const float x = 1.0L / 0.0L; ATF_CHECK(log1pf(x) == x); } ATF_TC(log1pf_one_neg); ATF_TC_HEAD(log1pf_one_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(-1.0) == -HUGE_VALF"); } ATF_TC_BODY(log1pf_one_neg, tc) { const float x = log1pf(-1.0); if (x != -HUGE_VALF) { atf_tc_expect_fail("PR lib/45362"); atf_tc_fail("log1pf(-1.0) != -HUGE_VALF"); } } ATF_TC(log1pf_zero_neg); ATF_TC_HEAD(log1pf_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(-0.0) == -0.0"); } ATF_TC_BODY(log1pf_zero_neg, tc) { const float x = -0.0L; ATF_CHECK(log1pf(x) == x); } ATF_TC(log1pf_zero_pos); ATF_TC_HEAD(log1pf_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log1pf(+0.0) == +0.0"); } ATF_TC_BODY(log1pf_zero_pos, tc) { const float x = 0.0L; ATF_CHECK(log1pf(x) == x); } /* * log2(3) */ ATF_TC(log2_base); ATF_TC_HEAD(log2_base, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(2) == 1"); } ATF_TC_BODY(log2_base, tc) { ATF_CHECK(log2(2.0) == 1.0); } ATF_TC(log2_nan); ATF_TC_HEAD(log2_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(NaN) == NaN"); } ATF_TC_BODY(log2_nan, tc) { const double x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log2(x)) != 0); } ATF_TC(log2_inf_neg); ATF_TC_HEAD(log2_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(-Inf) == NaN"); } ATF_TC_BODY(log2_inf_neg, tc) { const double x = -1.0L / 0.0L; const double y = log2(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(log2_inf_pos); ATF_TC_HEAD(log2_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(+Inf) == +Inf"); } ATF_TC_BODY(log2_inf_pos, tc) { const double x = 1.0L / 0.0L; ATF_CHECK(log2(x) == x); } ATF_TC(log2_one_pos); ATF_TC_HEAD(log2_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(1.0) == +0.0"); } ATF_TC_BODY(log2_one_pos, tc) { const double x = log2(1.0); const double y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(log2_zero_neg); ATF_TC_HEAD(log2_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(-0.0) == -HUGE_VAL"); } ATF_TC_BODY(log2_zero_neg, tc) { const double x = -0.0L; ATF_CHECK(log2(x) == -HUGE_VAL); } ATF_TC(log2_zero_pos); ATF_TC_HEAD(log2_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2(+0.0) == -HUGE_VAL"); } ATF_TC_BODY(log2_zero_pos, tc) { const double x = 0.0L; ATF_CHECK(log2(x) == -HUGE_VAL); } /* * log2f(3) */ ATF_TC(log2f_base); ATF_TC_HEAD(log2f_base, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(2) == 1"); } ATF_TC_BODY(log2f_base, tc) { ATF_CHECK(log2f(2.0) == 1.0); } ATF_TC(log2f_nan); ATF_TC_HEAD(log2f_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(NaN) == NaN"); } ATF_TC_BODY(log2f_nan, tc) { const float x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log2f(x)) != 0); } ATF_TC(log2f_inf_neg); ATF_TC_HEAD(log2f_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(-Inf) == NaN"); } ATF_TC_BODY(log2f_inf_neg, tc) { const float x = -1.0L / 0.0L; const float y = log2f(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(log2f_inf_pos); ATF_TC_HEAD(log2f_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(+Inf) == +Inf"); } ATF_TC_BODY(log2f_inf_pos, tc) { const float x = 1.0L / 0.0L; #if defined(__alpha__) atf_tc_expect_fail("PR port-alpha/46301"); #endif ATF_CHECK(log2f(x) == x); } ATF_TC(log2f_one_pos); ATF_TC_HEAD(log2f_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(1.0) == +0.0"); } ATF_TC_BODY(log2f_one_pos, tc) { const float x = log2f(1.0); const float y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(log2f_zero_neg); ATF_TC_HEAD(log2f_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(-0.0) == -HUGE_VALF"); } ATF_TC_BODY(log2f_zero_neg, tc) { const float x = -0.0L; ATF_CHECK(log2f(x) == -HUGE_VALF); } ATF_TC(log2f_zero_pos); ATF_TC_HEAD(log2f_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log2f(+0.0) == -HUGE_VALF"); } ATF_TC_BODY(log2f_zero_pos, tc) { const float x = 0.0L; ATF_CHECK(log2f(x) == -HUGE_VALF); } /* * log(3) */ ATF_TC(log_base); ATF_TC_HEAD(log_base, tc) { atf_tc_set_md_var(tc, "descr", "Test log(e) == 1"); } ATF_TC_BODY(log_base, tc) { const double eps = 1.0e-38; if (fabs(log(M_E) - 1.0) > eps) atf_tc_fail_nonfatal("log(e) != 1"); } ATF_TC(log_nan); ATF_TC_HEAD(log_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test log(NaN) == NaN"); } ATF_TC_BODY(log_nan, tc) { const double x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(log(x)) != 0); } ATF_TC(log_inf_neg); ATF_TC_HEAD(log_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log(-Inf) == NaN"); } ATF_TC_BODY(log_inf_neg, tc) { const double x = -1.0L / 0.0L; const double y = log(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(log_inf_pos); ATF_TC_HEAD(log_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log(+Inf) == +Inf"); } ATF_TC_BODY(log_inf_pos, tc) { const double x = 1.0L / 0.0L; ATF_CHECK(log(x) == x); } ATF_TC(log_one_pos); ATF_TC_HEAD(log_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log(1.0) == +0.0"); } ATF_TC_BODY(log_one_pos, tc) { const double x = log(1.0); const double y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(log_zero_neg); ATF_TC_HEAD(log_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test log(-0.0) == -HUGE_VAL"); } ATF_TC_BODY(log_zero_neg, tc) { const double x = -0.0L; ATF_CHECK(log(x) == -HUGE_VAL); } ATF_TC(log_zero_pos); ATF_TC_HEAD(log_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test log(+0.0) == -HUGE_VAL"); } ATF_TC_BODY(log_zero_pos, tc) { const double x = 0.0L; ATF_CHECK(log(x) == -HUGE_VAL); } /* * logf(3) */ ATF_TC(logf_base); ATF_TC_HEAD(logf_base, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(e) == 1"); } ATF_TC_BODY(logf_base, tc) { const float eps = 1.0e-7; if (fabsf(logf(M_E) - 1.0f) > eps) atf_tc_fail_nonfatal("logf(e) != 1"); } ATF_TC(logf_nan); ATF_TC_HEAD(logf_nan, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(NaN) == NaN"); } ATF_TC_BODY(logf_nan, tc) { const float x = 0.0L / 0.0L; ATF_CHECK(isnan(x) != 0); ATF_CHECK(isnan(logf(x)) != 0); } ATF_TC(logf_inf_neg); ATF_TC_HEAD(logf_inf_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(-Inf) == NaN"); } ATF_TC_BODY(logf_inf_neg, tc) { const float x = -1.0L / 0.0L; const float y = logf(x); ATF_CHECK(isnan(y) != 0); } ATF_TC(logf_inf_pos); ATF_TC_HEAD(logf_inf_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(+Inf) == +Inf"); } ATF_TC_BODY(logf_inf_pos, tc) { const float x = 1.0L / 0.0L; #if defined(__alpha__) atf_tc_expect_fail("PR port-alpha/46301"); #endif ATF_CHECK(logf(x) == x); } ATF_TC(logf_one_pos); ATF_TC_HEAD(logf_one_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(1.0) == +0.0"); } ATF_TC_BODY(logf_one_pos, tc) { const float x = logf(1.0); const float y = 0.0L; ATF_CHECK(x == y); ATF_CHECK(signbit(x) == 0); ATF_CHECK(signbit(y) == 0); } ATF_TC(logf_zero_neg); ATF_TC_HEAD(logf_zero_neg, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(-0.0) == -HUGE_VALF"); } ATF_TC_BODY(logf_zero_neg, tc) { const float x = -0.0L; ATF_CHECK(logf(x) == -HUGE_VALF); } ATF_TC(logf_zero_pos); ATF_TC_HEAD(logf_zero_pos, tc) { atf_tc_set_md_var(tc, "descr", "Test logf(+0.0) == -HUGE_VALF"); } ATF_TC_BODY(logf_zero_pos, tc) { const float x = 0.0L; ATF_CHECK(logf(x) == -HUGE_VALF); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, log10_base); ATF_TP_ADD_TC(tp, log10_nan); ATF_TP_ADD_TC(tp, log10_inf_neg); ATF_TP_ADD_TC(tp, log10_inf_pos); ATF_TP_ADD_TC(tp, log10_one_pos); ATF_TP_ADD_TC(tp, log10_zero_neg); ATF_TP_ADD_TC(tp, log10_zero_pos); ATF_TP_ADD_TC(tp, log10f_base); ATF_TP_ADD_TC(tp, log10f_nan); ATF_TP_ADD_TC(tp, log10f_inf_neg); ATF_TP_ADD_TC(tp, log10f_inf_pos); ATF_TP_ADD_TC(tp, log10f_one_pos); ATF_TP_ADD_TC(tp, log10f_zero_neg); ATF_TP_ADD_TC(tp, log10f_zero_pos); ATF_TP_ADD_TC(tp, log1p_nan); ATF_TP_ADD_TC(tp, log1p_inf_neg); ATF_TP_ADD_TC(tp, log1p_inf_pos); ATF_TP_ADD_TC(tp, log1p_one_neg); ATF_TP_ADD_TC(tp, log1p_zero_neg); ATF_TP_ADD_TC(tp, log1p_zero_pos); ATF_TP_ADD_TC(tp, log1pf_nan); ATF_TP_ADD_TC(tp, log1pf_inf_neg); ATF_TP_ADD_TC(tp, log1pf_inf_pos); ATF_TP_ADD_TC(tp, log1pf_one_neg); ATF_TP_ADD_TC(tp, log1pf_zero_neg); ATF_TP_ADD_TC(tp, log1pf_zero_pos); ATF_TP_ADD_TC(tp, log2_base); ATF_TP_ADD_TC(tp, log2_nan); ATF_TP_ADD_TC(tp, log2_inf_neg); ATF_TP_ADD_TC(tp, log2_inf_pos); ATF_TP_ADD_TC(tp, log2_one_pos); ATF_TP_ADD_TC(tp, log2_zero_neg); ATF_TP_ADD_TC(tp, log2_zero_pos); ATF_TP_ADD_TC(tp, log2f_base); ATF_TP_ADD_TC(tp, log2f_nan); ATF_TP_ADD_TC(tp, log2f_inf_neg); ATF_TP_ADD_TC(tp, log2f_inf_pos); ATF_TP_ADD_TC(tp, log2f_one_pos); ATF_TP_ADD_TC(tp, log2f_zero_neg); ATF_TP_ADD_TC(tp, log2f_zero_pos); ATF_TP_ADD_TC(tp, log_base); ATF_TP_ADD_TC(tp, log_nan); ATF_TP_ADD_TC(tp, log_inf_neg); ATF_TP_ADD_TC(tp, log_inf_pos); ATF_TP_ADD_TC(tp, log_one_pos); ATF_TP_ADD_TC(tp, log_zero_neg); ATF_TP_ADD_TC(tp, log_zero_pos); ATF_TP_ADD_TC(tp, logf_base); ATF_TP_ADD_TC(tp, logf_nan); ATF_TP_ADD_TC(tp, logf_inf_neg); ATF_TP_ADD_TC(tp, logf_inf_pos); ATF_TP_ADD_TC(tp, logf_one_pos); ATF_TP_ADD_TC(tp, logf_zero_neg); ATF_TP_ADD_TC(tp, logf_zero_pos); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libm/t_precision.c =================================================================== --- head/contrib/netbsd-tests/lib/libm/t_precision.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libm/t_precision.c (revision 274079) @@ -1,76 +1,75 @@ -/* $NetBSD: t_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $ */ +/* $NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $ */ /*- * Copyright (c) 2013 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation * by Joerg Sonnenberger. * * 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 -__RCSID("$NetBSD: t_precision.c,v 1.1 2013/11/11 11:10:45 joerg Exp $"); +__RCSID("$NetBSD: t_precision.c,v 1.2 2014/11/04 00:20:19 justin Exp $"); #include -#include #include #include ATF_TC(t_precision); ATF_TC_HEAD(t_precision, tc) { atf_tc_set_md_var(tc, "descr", "Basic precision test for double and long double"); } volatile double x = 1; volatile long double y = 1; ATF_TC_BODY(t_precision, tc) { x += DBL_EPSILON; ATF_CHECK(x != 1.0); x -= 1; ATF_CHECK(x == DBL_EPSILON); x = 2; x += DBL_EPSILON; ATF_CHECK(x == 2.0); y += LDBL_EPSILON; ATF_CHECK(y != 1.0L); y -= 1; ATF_CHECK(y == LDBL_EPSILON); y = 2; y += LDBL_EPSILON; ATF_CHECK(y == 2.0L); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, t_precision); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_mutex.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_mutex.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libpthread/t_mutex.c (revision 274079) @@ -1,316 +1,315 @@ -/* $NetBSD: t_mutex.c,v 1.6 2014/02/09 21:26:07 jmmv Exp $ */ +/* $NetBSD: t_mutex.c,v 1.7 2014/11/04 00:20:19 justin Exp $ */ /* * Copyright (c) 2008 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 __COPYRIGHT("@(#) Copyright (c) 2008\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_mutex.c,v 1.6 2014/02/09 21:26:07 jmmv Exp $"); +__RCSID("$NetBSD: t_mutex.c,v 1.7 2014/11/04 00:20:19 justin Exp $"); #include #include #include #include #include -#include #include "h_common.h" static pthread_mutex_t mutex; static pthread_mutex_t static_mutex = PTHREAD_MUTEX_INITIALIZER; static int global_x; static void * mutex1_threadfunc(void *arg) { int *param; printf("2: Second thread.\n"); param = arg; printf("2: Locking mutex\n"); pthread_mutex_lock(&mutex); printf("2: Got mutex. *param = %d\n", *param); ATF_REQUIRE_EQ(*param, 20); (*param)++; pthread_mutex_unlock(&mutex); return param; } ATF_TC(mutex1); ATF_TC_HEAD(mutex1, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); } ATF_TC_BODY(mutex1, tc) { int x; pthread_t new; void *joinval; printf("1: Mutex-test 1\n"); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); x = 1; PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex1_threadfunc, &x)); printf("1: Before changing the value.\n"); sleep(2); x = 20; printf("1: Before releasing the mutex.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); ATF_REQUIRE_EQ(*(int *)joinval, 21); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } static void * mutex2_threadfunc(void *arg) { long count = *(int *)arg; printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } return (void *)count; } ATF_TC(mutex2); ATF_TC_HEAD(mutex2, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); #if defined(__powerpc__) atf_tc_set_md_var(tc, "timeout", "40"); #endif } ATF_TC_BODY(mutex2, tc) { int count, count2; pthread_t new; void *joinval; printf("1: Mutex-test 2\n"); #if defined(__powerpc__) atf_tc_expect_timeout("PR port-powerpc/44387"); #endif PTHREAD_REQUIRE(pthread_mutex_init(&mutex, NULL)); global_x = 0; count = count2 = 10000000; PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex2_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); while (count--) { PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); #if defined(__powerpc__) /* XXX force a timeout in ppc case since an un-triggered race otherwise looks like a "failure" */ /* We sleep for longer than the timeout to make ATF not complain about unexpected success */ sleep(41); #endif } static void * mutex3_threadfunc(void *arg) { long count = *(int *)arg; printf("2: Second thread (%p). Count is %ld\n", pthread_self(), count); while (count--) { PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } return (void *)count; } ATF_TC(mutex3); ATF_TC_HEAD(mutex3, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes using a static " "initializer"); #if defined(__powerpc__) atf_tc_set_md_var(tc, "timeout", "40"); #endif } ATF_TC_BODY(mutex3, tc) { int count, count2; pthread_t new; void *joinval; printf("1: Mutex-test 3\n"); #if defined(__powerpc__) atf_tc_expect_timeout("PR port-powerpc/44387"); #endif global_x = 0; count = count2 = 10000000; PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex3_threadfunc, &count2)); printf("1: Thread %p\n", pthread_self()); PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); while (count--) { PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); global_x++; PTHREAD_REQUIRE(pthread_mutex_unlock(&static_mutex)); } PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(pthread_mutex_lock(&static_mutex)); printf("1: Thread joined. X was %d. Return value (long) was %ld\n", global_x, (long)joinval); ATF_REQUIRE_EQ(global_x, 20000000); #if defined(__powerpc__) /* XXX force a timeout in ppc case since an un-triggered race otherwise looks like a "failure" */ /* We sleep for longer than the timeout to make ATF not complain about unexpected success */ sleep(41); #endif } static void * mutex4_threadfunc(void *arg) { int *param; printf("2: Second thread.\n"); param = arg; printf("2: Locking mutex\n"); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("2: Got mutex. *param = %d\n", *param); (*param)++; PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); return param; } ATF_TC(mutex4); ATF_TC_HEAD(mutex4, tc) { atf_tc_set_md_var(tc, "descr", "Checks mutexes"); } ATF_TC_BODY(mutex4, tc) { int x; pthread_t new; pthread_mutexattr_t mattr; void *joinval; printf("1: Mutex-test 4\n"); PTHREAD_REQUIRE(pthread_mutexattr_init(&mattr)); PTHREAD_REQUIRE(pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE)); PTHREAD_REQUIRE(pthread_mutex_init(&mutex, &mattr)); PTHREAD_REQUIRE(pthread_mutexattr_destroy(&mattr)); x = 1; PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); PTHREAD_REQUIRE(pthread_create(&new, NULL, mutex4_threadfunc, &x)); printf("1: Before recursively acquiring the mutex.\n"); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("1: Before releasing the mutex once.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex once.\n"); x = 20; printf("1: Before releasing the mutex twice.\n"); sleep(2); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); printf("1: After releasing the mutex twice.\n"); PTHREAD_REQUIRE(pthread_join(new, &joinval)); PTHREAD_REQUIRE(pthread_mutex_lock(&mutex)); printf("1: Thread joined. X was %d. Return value (int) was %d\n", x, *(int *)joinval); ATF_REQUIRE_EQ(x, 21); ATF_REQUIRE_EQ(*(int *)joinval, 21); PTHREAD_REQUIRE(pthread_mutex_unlock(&mutex)); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, mutex1); ATF_TP_ADD_TC(tp, mutex2); ATF_TP_ADD_TC(tp, mutex3); ATF_TP_ADD_TC(tp, mutex4); return atf_no_error(); } Index: head/contrib/netbsd-tests/lib/libpthread/t_sem.c =================================================================== --- head/contrib/netbsd-tests/lib/libpthread/t_sem.c (revision 274078) +++ head/contrib/netbsd-tests/lib/libpthread/t_sem.c (revision 274079) @@ -1,307 +1,306 @@ -/* $NetBSD: t_sem.c,v 1.7 2012/03/09 19:46:37 joerg Exp $ */ +/* $NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $ */ /* * Copyright (c) 2008, 2010 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. */ /*- * Copyright (c)2004 YAMAMOTO Takashi, * 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 AUTHOR 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 AUTHOR 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. */ /**************************************************************************** * * Copyright (C) 2000 Jason Evans . * 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(s), this list of conditions and the following disclaimer as * the first lines of this file unmodified other than the possible * addition of one or more copyright notices. * 2. Redistributions in binary form must reproduce the above copyright * notice(s), 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 COPYRIGHT HOLDER(S) ``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 COPYRIGHT HOLDER(S) 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 __COPYRIGHT("@(#) Copyright (c) 2008, 2010\ The NetBSD Foundation, inc. All rights reserved."); -__RCSID("$NetBSD: t_sem.c,v 1.7 2012/03/09 19:46:37 joerg Exp $"); +__RCSID("$NetBSD: t_sem.c,v 1.8 2014/11/04 00:20:19 justin Exp $"); #include #include #include #include #include #include #include #include #include #include -#include #include "h_common.h" #define NTHREADS 10 #define _LIBC_R_ #define SEM_REQUIRE(x) \ ATF_REQUIRE_EQ_MSG(x, 0, "%s", strerror(errno)) static sem_t sem; ATF_TC(named); ATF_TC_HEAD(named, tc) { atf_tc_set_md_var(tc, "descr", "Checks named semaphores"); } ATF_TC_BODY(named, tc) { sem_t *semp; ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); printf("Test begin\n"); (void) sem_unlink("/foo"); semp = sem_open("/foo", O_CREAT | O_EXCL, 0644, 0); ATF_REQUIRE_MSG(semp != SEM_FAILED, "%s", strerror(errno)); SEM_REQUIRE(sem_close(semp)); SEM_REQUIRE(sem_unlink("/foo")); printf("Test end\n"); } ATF_TC(unnamed); ATF_TC_HEAD(unnamed, tc) { atf_tc_set_md_var(tc, "descr", "Checks unnamed semaphores"); } static void * entry(void * a_arg) { pthread_t self = pthread_self(); sem_t *semp = (sem_t *) a_arg; printf("Thread %p waiting for semaphore...\n", self); sem_wait(semp); printf("Thread %p got semaphore\n", self); return NULL; } ATF_TC_BODY(unnamed, tc) { sem_t sem_a, sem_b; pthread_t threads[NTHREADS]; unsigned i, j; int val; ATF_REQUIRE_MSG(-1 != sysconf(_SC_SEMAPHORES), "%s", strerror(errno)); printf("Test begin\n"); SEM_REQUIRE(sem_init(&sem_b, 0, 0)); SEM_REQUIRE(sem_getvalue(&sem_b, &val)); ATF_REQUIRE_EQ(0, val); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_getvalue(&sem_b, &val)); ATF_REQUIRE_EQ(1, val); SEM_REQUIRE(sem_wait(&sem_b)); ATF_REQUIRE_EQ(sem_trywait(&sem_b), -1); ATF_REQUIRE_EQ(errno, EAGAIN); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_trywait(&sem_b)); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_wait(&sem_b)); SEM_REQUIRE(sem_post(&sem_b)); SEM_REQUIRE(sem_destroy(&sem_b)); SEM_REQUIRE(sem_init(&sem_a, 0, 0)); for (j = 0; j < 2; j++) { for (i = 0; i < NTHREADS; i++) { PTHREAD_REQUIRE(pthread_create(&threads[i], NULL, entry, (void *) &sem_a)); } for (i = 0; i < NTHREADS; i++) { usleep(10000); printf("main loop %u: posting...\n", j+1); SEM_REQUIRE(sem_post(&sem_a)); } for (i = 0; i < NTHREADS; i++) { PTHREAD_REQUIRE(pthread_join(threads[i], NULL)); } } SEM_REQUIRE(sem_destroy(&sem_a)); printf("Test end\n"); } static void sighandler(int signo) { /* printf("signal %d\n", signo); */ ATF_REQUIRE_EQ_MSG(signo, SIGALRM, "unexpected signal"); SEM_REQUIRE(sem_post(&sem)); } static void alarm_ms(const int ms) { struct itimerval timer; timer.it_interval.tv_sec = 0; timer.it_interval.tv_usec = 0; timer.it_value.tv_sec = 0; timer.it_value.tv_usec = ms * 1000; ATF_REQUIRE(setitimer(ITIMER_REAL, &timer, NULL) == 0); } static void * threadfunc(void *arg) { int i, ret; printf("Entering loop\n"); for (i = 0; i < 500; ) { if ((i & 1) != 0) { do { ret = sem_wait(&sem); } while (ret == -1 && errno == EINTR); ATF_REQUIRE(ret == 0); } else { ret = sem_trywait(&sem); if (ret == -1) { ATF_REQUIRE(errno == EAGAIN); continue; } } printf("%s: %d\n", __func__, i); alarm_ms(5); i++; } return NULL; } static void before_start_test(const bool use_pthread) { pthread_t t; SEM_REQUIRE(sem_init(&sem, 0, 0)); ATF_REQUIRE(SIG_ERR != signal(SIGALRM, sighandler)); alarm_ms(5); if (use_pthread) { PTHREAD_REQUIRE(pthread_create(&t, NULL, threadfunc, NULL)); PTHREAD_REQUIRE(pthread_join(t, NULL)); } else { threadfunc(NULL); } } ATF_TC(before_start_no_threads); ATF_TC_HEAD(before_start_no_threads, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores without any " "thread running"); atf_tc_set_md_var(tc, "timeout", "40"); } ATF_TC_BODY(before_start_no_threads, tc) { before_start_test(false); } ATF_TC(before_start_one_thread); ATF_TC_HEAD(before_start_one_thread, tc) { atf_tc_set_md_var(tc, "descr", "Checks using semaphores before " "starting one thread"); atf_tc_set_md_var(tc, "timeout", "40"); } ATF_TC_BODY(before_start_one_thread, tc) { before_start_test(true); } ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, named); ATF_TP_ADD_TC(tp, unnamed); ATF_TP_ADD_TC(tp, before_start_no_threads); ATF_TP_ADD_TC(tp, before_start_one_thread); return atf_no_error(); } Index: head/share/mk/bsd.progs.mk =================================================================== --- head/share/mk/bsd.progs.mk (revision 274078) +++ head/share/mk/bsd.progs.mk (revision 274079) @@ -1,123 +1,129 @@ # $FreeBSD$ # $Id: progs.mk,v 1.11 2012/11/06 17:18:54 sjg Exp $ # # @(#) Copyright (c) 2006, Simon J. Gerraty # # This file is provided in the hope that it will # be of use. There is absolutely NO WARRANTY. # Permission to copy, redistribute or otherwise # use this file is hereby granted provided that # the above copyright notice and this notice are # left intact. # # Please send copies of changes and bug-fixes to: # sjg@crufty.net # .MAIN: all .if defined(PROGS) || defined(PROGS_CXX) # we really only use PROGS below... PROGS += ${PROGS_CXX} # In meta mode, we can capture dependenices for _one_ of the progs. # if makefile doesn't nominate one, we use the first. .if defined(.PARSEDIR) .ifndef UPDATE_DEPENDFILE_PROG UPDATE_DEPENDFILE_PROG = ${PROGS:[1]} .export UPDATE_DEPENDFILE_PROG .endif .else UPDATE_DEPENDFILE_PROG?= no .endif .ifndef PROG # They may have asked us to build just one .for t in ${PROGS} .if make($t) PROG ?= $t .endif .endfor .endif .if defined(PROG) # just one of many -PROG_OVERRIDE_VARS += BINDIR MAN SRCS +PROG_OVERRIDE_VARS += BINDIR DPSRCS MAN SRCS PROG_VARS += CFLAGS CPPFLAGS CXXFLAGS DPADD DPLIBS LDADD LDFLAGS ${PROG_OVERRIDE_VARS} .for v in ${PROG_VARS:O:u} .if empty(${PROG_OVERRIDE_VARS:M$v}) .if defined(${v}.${PROG}) $v += ${${v}.${PROG}} .elif defined(${v}_${PROG}) $v += ${${v}_${PROG}} .endif .else $v ?= .endif .endfor # for meta mode, there can be only one! .if ${PROG} == ${UPDATE_DEPENDFILE_PROG} UPDATE_DEPENDFILE ?= yes .endif UPDATE_DEPENDFILE ?= NO # ensure that we don't clobber each other's dependencies DEPENDFILE?= .depend.${PROG} # prog.mk will do the rest .else all: ${FILES} ${PROGS} ${SCRIPTS} # We cannot capture dependencies for meta mode here UPDATE_DEPENDFILE = NO # nor can we safely run in parallel. .NOTPARALLEL: .endif +.endif + +# The non-recursive call to bsd.progs.mk will handle FILES; NUL out +# FILESGROUPS so recursive calls don't duplicate the work +.ifdef _RECURSING_PROGS +FILESGROUPS= .endif # handle being called [bsd.]progs.mk .include .ifndef _RECURSING_PROGS # tell progs.mk we might want to install things PROGS_TARGETS+= checkdpadd clean cleandepend cleandir cleanobj depend install .for p in ${PROGS} .if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) # bsd.prog.mk may need to know this x.$p= PROG_CXX=$p .endif $p ${p}_p: .PHONY .MAKE (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \ SUBDIR= PROG=$p \ DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \ ${x.$p}) .for t in ${PROGS_TARGETS:O:u} $p.$t: .PHONY .MAKE (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} _RECURSING_PROGS= \ SUBDIR= PROG=$p \ DEPENDFILE=.depend.$p .MAKE.DEPENDFILE=.depend.$p \ ${x.$p} ${@:E}) .endfor .endfor .if !empty(PROGS) .for t in ${PROGS_TARGETS:O:u} $t: ${PROGS:%=%.$t} .endfor .endif .if empty(PROGS) && !empty(SCRIPTS) .for t in ${PROGS_TARGETS:O:u} scripts.$t: .PHONY .MAKE (cd ${.CURDIR} && ${MAKE} -f ${MAKEFILE} SUBDIR= _RECURSING_PROGS= \ $t) $t: scripts.$t .endfor .endif .endif Index: head/share/mk/netbsd-tests.test.mk =================================================================== --- head/share/mk/netbsd-tests.test.mk (revision 274078) +++ head/share/mk/netbsd-tests.test.mk (revision 274079) @@ -1,49 +1,46 @@ # $FreeBSD$ .if !target(__netbsd_tests.test.mk__) __netbsd_tests.test.mk__: .if !defined(OBJTOP) .error "Please define OBJTOP to the absolute path of the top of the object tree" .endif .if !defined(SRCTOP) .error "Please define SRCTOP to the absolute path of the top of the source tree" .endif .if !defined(TESTSRC) .error "Please define TESTSRC to the absolute path of the test sources, e.g. contrib/netbsd-tests/lib/libc/stdio" .endif .PATH: ${TESTSRC} LIBNETBSD_SRCDIR= ${SRCTOP}/lib/libnetbsd LIBNETBSD_OBJDIR= ${OBJTOP}/lib/libnetbsd .for t in ${NETBSD_ATF_TESTS_C} -# XXX: needed for atf-c/config.h after v0.2.1 upgrade. See NetBSD PR # -# misc/49356 for more details -CFLAGS.$t+= -I${SRCTOP}/contrib/atf CFLAGS.$t+= -I${LIBNETBSD_SRCDIR} -I${SRCTOP}/contrib/netbsd-tests LDFLAGS.$t+= -L${LIBNETBSD_OBJDIR} DPADD.$t+= ${LIBNETBSD} LDADD.$t+= -lnetbsd SRCS.$t?= ${t:C/^/t_/:C/_test$//g}.c .endfor ATF_TESTS_C+= ${NETBSD_ATF_TESTS_C} # A C++ analog isn't provided because there aren't any C++ testcases in # contrib/netbsd-tests .for t in ${NETBSD_ATF_TESTS_SH} ATF_TESTS_SH_SRC_$t?= ${t:C/^/t_/:C/_test$//g}.sh .endfor ATF_TESTS_SH+= ${NETBSD_ATF_TESTS_SH} .endif # vim: syntax=make