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_BODY(fork_wait__core_size, tc) { struct rlimit rl; rl.rlim_cur = 0; rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) == -1) atf_tc_skip("Failed to lower the core size limit"); kyua_run_params_t run_params; kyua_run_params_init(&run_params); pid_t pid; kyua_error_t error = kyua_run_fork(&run_params, &pid); if (!kyua_error_is_set(error) && pid == 0) abort(); ATF_REQUIRE(!kyua_error_is_set(error)); int status; bool timed_out; error = kyua_run_wait(pid, &status, &timed_out); if (kyua_error_is_set(error)) atf_tc_fail("wait failed; unexpected problem during exec?"); ATF_REQUIRE(!timed_out); ATF_REQUIRE(WIFSIGNALED(status)); ATF_REQUIRE_MSG(WCOREDUMP(status), "Core not dumped as expected"); }
ATF_TC_BODY(fpsetround_basic, tc) { #ifndef _FLOAT_IEEE754 atf_tc_skip("Test not applicable on this architecture."); #else int r; ATF_CHECK_EQ(r = fpgetround(), FP_RN); if (FP_RN != r) fprintf(stderr, "default expected=%s got=%s\n", getname(FP_RN), getname(r)); ATF_CHECK_EQ(FLT_ROUNDS, 1); for (size_t i = 0; i < __arraycount(rnd); i++) { const size_t j = (i + 1) & 3; const int o = rnd[i].rm; const int n = rnd[j].rm; ATF_CHECK_EQ(r = fpsetround(n), o); if (o != r) fprintf(stderr, "set %s expected=%s got=%s\n", getname(n), getname(o), getname(r)); ATF_CHECK_EQ(r = fpgetround(), n); if (n != r) fprintf(stderr, "get expected=%s got=%s\n", getname(n), getname(r)); ATF_CHECK_EQ(r = FLT_ROUNDS, rnd[j].rf); if (r != rnd[j].rf) fprintf(stderr, "rounds expected=%x got=%x\n", rnd[j].rf, r); test(r); } #endif /* _FLOAT_IEEE754 */ }
/// Generates a wait(2) status for a termination due to a signal. /// /// \param signo The signal number to encode in the status. /// /// \return The wait(2) status. static int generate_wait_termsig(const int signo) { // Explicitly disable core files to avoid inconsistent behaviors across // operating systems. Some of the signal numbers passed to this function // may have a meaning or not depending on the system, and this might mean // that a core gets generated arbitrarily. As a result of this, our string // comparisons below fail. struct rlimit rl; rl.rlim_cur = 0; rl.rlim_max = RLIM_INFINITY; if (setrlimit(RLIMIT_CORE, &rl) == -1) atf_tc_skip("Failed to lower the core size limit"); const pid_t pid = fork(); ATF_REQUIRE(pid != -1); if (pid == 0) { kill(getpid(), signo); abort(); } else { int status; ATF_REQUIRE(waitpid(pid, &status, 0) != -1); return status; } }
ATF_TC_BODY(t_tls_dlopen, tc) { void *handle; pthread_t t; #ifdef __HAVE_NO___THREAD atf_tc_skip("no TLS support on this platform"); #endif handle = dlopen("h_tls_dlopen.so", RTLD_NOW | RTLD_LOCAL); ATF_REQUIRE(handle != NULL); testf_helper = dlsym(handle, "testf_dso_helper"); ATF_REQUIRE(testf_helper != NULL); testf(NULL); pthread_create(&t, 0, testf, 0); pthread_join(t, NULL); pthread_create(&t, 0, testf, 0); pthread_join(t, NULL); dlclose(handle); }
ATF_TC_BODY(t_exect_null, tc) { struct sigaction act; /* * Currently exect(3) is misdesigned -- see PR port-amd64/51700 and it * needs to be redone from scratch. * * This test affects amd64 releng machines causing tests to hang or * fail. As there is little point to test interface that is still not, * designed and implemented and is breaking tests - skip it * unconditionally for all ports. */ /* Prevent static analysis from requiring t_exec_null to be __dead. */ if (!caught) atf_tc_skip("exect(3) misdesigned and hangs - PR port-amd64/51700"); ATF_REQUIRE(sigemptyset(&act.sa_mask) == 0); act.sa_sigaction = sigtrap_handler; act.sa_flags = SA_SIGINFO; ATF_REQUIRE(sigaction(SIGTRAP, &act, 0) == 0); ATF_REQUIRE_ERRNO(EFAULT, exect(NULL, NULL, NULL) == -1); ATF_REQUIRE_EQ_MSG(caught, 1, "expected caught (1) != received (%d)", (int)caught); }
ATF_TC_BODY(conv_ulong, tc) { unsigned long ul; long double dt; double d; /* unsigned long vs. {long} double test */ if (sizeof(d) > sizeof(ul)) { d = ULONG_TESTVALUE; ul = (unsigned long)d; printf("testing double vs. long\n"); } else if (sizeof(dt) > sizeof(ul)) { dt = ULONG_TESTVALUE; ul = (unsigned long)dt; printf("testing long double vs. long\n"); } else { printf("sizeof(long) = %zu, sizeof(double) = %zu, " "sizeof(long double) = %zu\n", sizeof(ul), sizeof(d), sizeof(dt)); atf_tc_skip("no suitable {long} double type found"); } if (ul != ULONG_TESTVALUE) atf_tc_fail("unsigned long %lu (0x%lx) != %lu (0x%lx)", ul, ul, ULONG_TESTVALUE, ULONG_TESTVALUE); }
static void rename_dotdot(const atf_tc_t *tc, const char *mp) { if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); USES_DIRS; if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); if (rump_sys_mkdir("dir1", 0777) == -1) atf_tc_fail_errno("mkdir 1"); if (rump_sys_mkdir("dir2", 0777) == -1) atf_tc_fail_errno("mkdir 2"); if (rump_sys_rename("dir1", "dir1/..") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot to"); if (rump_sys_rename("dir1/..", "sometarget") != -1 || errno != EINVAL) atf_tc_fail_errno("self-dotdot from"); if (rump_sys_rename("dir1", "dir2/..") != -1 || errno != EINVAL) atf_tc_fail("other-dotdot"); rump_sys_chdir("/"); }
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_BODY(strtod_round, tc) { #ifdef HAVE_FENV /* * 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 <fenv.h> support"); #endif }
ATF_TC_BODY(swapcontext1, tc) { pthread_t thread; #if defined(__FreeBSD__) && defined(__mips__) /* * MIPS modifies TLS pointer in set_mcontext(), so * swapping contexts obtained from different threads * gives us different pthread_self() return value. */ atf_tc_skip("Platform is not supported."); #endif oself = (void *)&val1; nself = (void *)&val2; printf("Testing if swapcontext() alters pthread_self()\n"); #ifdef __FreeBSD__ ATF_REQUIRE_MSG(getcontext(&nctx) != -1, "getcontext failed: %s", strerror(errno)); #else PTHREAD_REQUIRE(getcontext(&nctx)); #endif PTHREAD_REQUIRE(pthread_create(&thread, NULL, threadfunc, NULL)); PTHREAD_REQUIRE(pthread_join(thread, NULL)); }
ATF_TC_BODY(mmap__map_at_zero, tc) { void *p; size_t len; unsigned int i; int map_at_zero; len = sizeof(map_at_zero); if (sysctlbyname(MAP_AT_ZERO, &map_at_zero, &len, NULL, 0) == -1) { atf_tc_skip("sysctl for %s failed: %s\n", MAP_AT_ZERO, strerror(errno)); return; } /* Normalize to 0 or 1 for array access. */ map_at_zero = !!map_at_zero; for (i = 0; i < nitems(map_at_zero_tests); i++) { p = mmap((void *)map_at_zero_tests[i].addr, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC, MAP_ANON | MAP_FIXED, -1, 0); if (p == MAP_FAILED) { ATF_CHECK_MSG(map_at_zero_tests[i].ok[map_at_zero] == 0, "mmap(%p, ...) failed", map_at_zero_tests[i].addr); } else { ATF_CHECK_MSG(map_at_zero_tests[i].ok[map_at_zero] == 1, "mmap(%p, ...) succeeded: p=%p\n", map_at_zero_tests[i].addr, p); } } }
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); ATF_REQUIRE(__isnanl(ld) != 0); 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_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_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_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 (strcmp(atf_config_get("atf_arch"),"powerpc") == 0) atf_tc_skip("Test not valid on powerpc"); 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 _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"); }
ATF_TC_BODY(mmap_block, tc) { static const int mib[] = { CTL_HW, HW_DISKNAMES }; static const unsigned int miblen = __arraycount(mib); char *map, *dk, *drives, dev[PATH_MAX]; size_t len; int fd = -1; atf_tc_skip("The test case causes a panic (PR kern/38889, kern/46592)"); ATF_REQUIRE(sysctl(mib, miblen, NULL, &len, NULL, 0) == 0); drives = malloc(len); ATF_REQUIRE(drives != NULL); ATF_REQUIRE(sysctl(mib, miblen, drives, &len, NULL, 0) == 0); for (dk = strtok(drives, " "); dk != NULL; dk = strtok(NULL, " ")) { sprintf(dev, _PATH_DEV "%s%c", dk, 'a'+RAW_PART); fprintf(stderr, "trying: %s\n", dev); if ((fd = open(dev, O_RDONLY)) >= 0) { (void)fprintf(stderr, "using %s\n", dev); break; } } free(drives); if (fd < 0) atf_tc_skip("failed to find suitable block device"); map = mmap(NULL, 4096, PROT_READ, MAP_FILE, fd, 0); ATF_REQUIRE(map != MAP_FAILED); (void)fprintf(stderr, "first byte %x\n", *map); ATF_REQUIRE(close(fd) == 0); (void)fprintf(stderr, "first byte %x\n", *map); ATF_REQUIRE(munmap(map, 4096) == 0); }
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_TC_BODY(large_blk, tc) { char buf[128]; char cmpbuf[128]; ssize_t n; int rv, tfd; /* * mount mfs. it would be nice if this would not be required, * but a) tmpfs doesn't "support" sparse files b) we don't really * know what fs atf workdir is on anyway. */ if (mkdir("mfsdir", 0777) == -1) atf_tc_fail_errno("mkdir failed"); if (system("mount_mfs -s 64m -o nosuid,nodev mfs mfsdir") != 0) atf_tc_skip("could not mount mfs"); /* create a 8TB sparse file */ rv = system("dd if=/dev/zero of=" IMG_ON_MFS " bs=1 count=1 seek=8t"); ATF_REQUIRE_EQ(rv, 0); /* * map it and issue write at 6TB, then unmap+remap and check * we get the same stuff back */ rump_init(); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, IMG_ON_MFS, RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH1, O_RDWR); ATF_REQUIRE(tfd != -1); memset(buf, 12, sizeof(buf)); n = rump_sys_pwrite(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); ATF_REQUIRE_EQ(n, sizeof(buf)); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, IMG_ON_MFS, RUMP_ETFS_BLK), 0); tfd = rump_sys_open(TESTPATH2, O_RDWR); ATF_REQUIRE(tfd != -1); memset(buf, 0, sizeof(buf)); n = rump_sys_pread(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); ATF_REQUIRE_EQ(n, sizeof(buf)); memset(cmpbuf, 12, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(cmpbuf, buf, 128), 0); }
static void rename_nametoolong(const atf_tc_t *tc, const char *mp) { char *name; int res, fd; long val; size_t len; if (FSTYPE_RUMPFS(tc)) atf_tc_skip("rename not supported by file system"); if (rump_sys_chdir(mp) == -1) atf_tc_fail_errno("chdir mountpoint"); val = rump_sys_pathconf(".", _PC_NAME_MAX); if (val == -1) atf_tc_fail_errno("pathconf"); len = val + 1; name = malloc(len+1); if (name == NULL) atf_tc_fail_errno("malloc"); memset(name, 'a', len); *(name+len) = '\0'; fd = rump_sys_open("dummy", O_RDWR|O_CREAT, 0666); if (fd == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); val = rump_sys_pathconf(".", _PC_NO_TRUNC); if (val == -1) atf_tc_fail_errno("pathconf"); res = rump_sys_rename("dummy", name); if (val != 0 && (res != -1 || errno != ENAMETOOLONG)) atf_tc_fail_errno("rename"); if (val == 0 && rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); free(name); rump_sys_chdir("/"); }
static void support(void) { errno = 0; if (mkfifo(path, 0600) == 0) { ATF_REQUIRE(unlink(path) == 0); return; } if (errno == EOPNOTSUPP) atf_tc_skip("the kernel does not support FIFOs"); else { atf_tc_fail("mkfifo(2) failed"); } }
ATF_TC_BODY(mlock_clip, tc) { void *buf; buf = malloc(page); ATF_REQUIRE(buf != NULL); if (page < 1024) atf_tc_skip("page size too small"); for (size_t i = page; i >= 1; i = i - 1024) { (void)mlock(buf, page - i); (void)munlock(buf, page - i); } free(buf); }
static void flags(const atf_tc_t *tc, const char *mp) { const char *name = "file.test"; int fd, fflags; struct stat st; FSTEST_ENTER(); if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); if (rump_sys_stat(name, &st) == -1) atf_tc_fail_errno("stat"); if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (rump_sys_chflags(name, st.st_flags) == -1) { if (errno == EOPNOTSUPP) atf_tc_skip("file flags not supported by file system"); atf_tc_fail_errno("chflags"); } fflags = st.st_flags | UF_IMMUTABLE; rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); fflags |= UF_IMMUTABLE; if (rump_sys_chflags(name, fflags) != -1 || errno != EPERM) atf_tc_fail_errno("chflags"); rump_pub_lwproc_releaselwp(); if (rump_sys_chflags(name, fflags) == -1) atf_tc_fail_errno("chflags"); fflags &= ~UF_IMMUTABLE; if (rump_sys_chflags(name, fflags) == -1) atf_tc_fail_errno("chflags"); if (rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); FSTEST_EXIT(); }
ATF_TC_BODY(ptm, tc) { struct stat stm, sts; struct ptmget ptm; int fdm; struct group *gp; if ((fdm = open("/dev/ptm", O_RDWR)) == -1) { if (errno == ENOENT || errno == ENODEV) atf_tc_skip("/dev/ptm: %s", strerror(errno)); atf_tc_fail("/dev/ptm: %s", strerror(errno)); } REQUIRE_ERRNO(fstat(fdm, &stm), -1); ATF_REQUIRE_EQ(major(stm.st_rdev), 165); REQUIRE_ERRNO(ioctl(fdm, TIOCPTMGET, &ptm), -1); ATF_REQUIRE_MSG(strncmp(ptm.cn, "/dev/pty", 8) == 0 || strncmp(ptm.cn, "/dev/null", 9) == 0, "bad master name: %s", ptm.cn); ATF_REQUIRE_MSG(strncmp(ptm.sn, "/dev/tty", 8) == 0 || strncmp(ptm.sn, "/dev/pts/", 9) == 0, "bad slave name: %s", ptm.sn); if (strncmp(ptm.cn, "/dev/null", 9) != 0) { REQUIRE_ERRNO(fstat(ptm.cfd, &stm), -1); REQUIRE_ERRNO(stat(ptm.cn, &sts), -1); ATF_REQUIRE_EQ(stm.st_rdev, sts.st_rdev); } REQUIRE_ERRNO(fstat(ptm.sfd, &stm), -1); REQUIRE_ERRNO(stat(ptm.sn, &sts), -1); ATF_REQUIRE_EQ(stm.st_rdev, sts.st_rdev); ATF_REQUIRE_EQ_MSG(sts.st_uid, getuid(), "bad slave uid"); ATF_REQUIRE_MSG((gp = getgrnam("tty")) != NULL, "cannot find `tty' group"); ATF_REQUIRE_EQ_MSG(sts.st_gid, gp->gr_gid, "bad slave grid"); (void)close(ptm.sfd); (void)close(ptm.cfd); (void)close(fdm); }
static void dirperms(const atf_tc_t *tc, const char *mp) { char name[] = "dir.test/file.test"; char *dir = dirname(name); int fd; if (FSTYPE_SYSVBFS(tc)) atf_tc_skip("directories not supported by file system"); FSTEST_ENTER(); if (rump_sys_mkdir(dir, 0777) == -1) atf_tc_fail_errno("mkdir"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (FSTYPE_ZFS(tc)) atf_tc_expect_fail("PR kern/47656: Test known to be broken"); if (rump_sys_open(name, O_RDWR|O_CREAT, 0666) != -1 || errno != EACCES) atf_tc_fail_errno("open"); rump_pub_lwproc_releaselwp(); if ((fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666)) == -1) atf_tc_fail_errno("open"); if (rump_sys_close(fd) == -1) atf_tc_fail_errno("close"); rump_pub_lwproc_rfork(RUMP_RFCFDG); if (rump_sys_setuid(1) == -1) atf_tc_fail_errno("setuid"); if (rump_sys_unlink(name) != -1 || errno != EACCES) atf_tc_fail_errno("unlink"); rump_pub_lwproc_releaselwp(); if (rump_sys_unlink(name) == -1) atf_tc_fail_errno("unlink"); if (rump_sys_rmdir(dir) == -1) atf_tc_fail_errno("rmdir"); FSTEST_EXIT(); }
ATF_TC_BODY(sigbus_adraln, tc) { const char *arch = atf_config_get("atf_arch"); struct sigaction sa; if (strcmp(arch, "alpha") == 0) { int rv, val; size_t len = sizeof(val); rv = sysctlbyname("machdep.unaligned_sigbus", &val, &len, NULL, 0); ATF_REQUIRE(rv == 0); if (val == 0) atf_tc_skip("SIGBUS signal not enabled for" " unaligned accesses"); } sa.sa_flags = SA_SIGINFO; sa.sa_sigaction = sigbus_action; sigemptyset(&sa.sa_mask); sigaction(SIGBUS, &sa, NULL); /* Enable alignement 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_TC_BODY(sigfpe_int, tc) { struct sigaction sa; long l = strtol("0", NULL, 10); if (strcmp(atf_config_get("atf_arch"),"powerpc") == 0) atf_tc_skip("Test not valid on powerpc"); 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 _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"); }
ATF_TC_BODY(infinity_long_double, tc) { #ifndef LDBL_MAX atf_tc_skip("no long double support on this architecture"); return; #else long double v; v = LDBL_MAX; v *= v; ATF_REQUIRE(isinf(v)); ATF_REQUIRE(fpclassify(v) == FP_INFINITE); v = -LDBL_MAX; v *= v; ATF_REQUIRE(isinf(v)); ATF_REQUIRE(fpclassify(v) == FP_INFINITE); #endif }
ATF_TC_BODY (status_coredump, tc) { struct rlimit rl; rl.rlim_cur = RLIM_INFINITY; rl.rlim_max = RLIM_INFINITY; if (setrlimit (RLIMIT_CORE, &rl) == -1) atf_tc_skip ("Cannot unlimit the core file size; check limits " "manually"); const int rawstatus = fork_and_wait_child (child_sigquit); atf_process_status_t s; RE (atf_process_status_init (&s, rawstatus)); ATF_CHECK (!atf_process_status_exited (&s)); ATF_CHECK (atf_process_status_signaled (&s)); ATF_CHECK_EQ (atf_process_status_termsig (&s), SIGQUIT); ATF_CHECK (atf_process_status_coredump (&s)); atf_process_status_fini (&s); }
ATF_TC_BODY(ptmx, tc) { struct stat stm, sts; char *pty; int fdm, fds; struct group *gp; if ((fdm = posix_openpt(O_RDWR|O_NOCTTY)) == -1) { if (errno == ENOENT || errno == ENODEV) atf_tc_skip("/dev/ptmx: %s", strerror(errno)); atf_tc_fail("/dev/ptmx: %s", strerror(errno)); } REQUIRE_ERRNO(fstat(fdm, &stm), -1); #ifdef PTY_DEVNO_CHECK REQUIRE_ERRNO(stat("/dev/ptyp0", &sts), -1); ATF_REQUIRE_EQ_MSG(major(stm.st_rdev), major(sts.st_rdev), "bad master major number"); #endif REQUIRE_ERRNO(grantpt(fdm), -1); REQUIRE_ERRNO(unlockpt(fdm), -1); REQUIRE_ERRNO((pty = ptsname(fdm)), NULL); REQUIRE_ERRNO((fds = open(pty, O_RDWR|O_NOCTTY)), -1); REQUIRE_ERRNO(fstat(fds, &sts), -1); #ifdef PTY_DEVNO_CHECK ATF_REQUIRE_EQ_MSG(minor(stm.st_rdev), minor(sts.st_rdev), "bad slave minor number"); #endif ATF_REQUIRE_EQ_MSG(sts.st_uid, getuid(), "bad slave uid"); ATF_REQUIRE_MSG((gp = getgrnam("tty")) != NULL, "cannot find `tty' group"); ATF_REQUIRE_EQ_MSG(sts.st_gid, gp->gr_gid, "bad slave gid"); }