diff options
author | Renato Botelho <renato@netgate.com> | 2017-02-23 06:28:41 -0300 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2017-02-23 06:28:41 -0300 |
commit | 82ceeb2ea625cd9bff60f2863b9a0830f55b7905 (patch) | |
tree | 263ca9347bf664a4489743f9302e699ce14de1df /lib/libc/tests | |
parent | 4a05f5440acda223e6a0ec5157bc32ecc0f09ff9 (diff) | |
parent | d20dd8b36e7a565be7bfbb22aade51c8ffd753e9 (diff) | |
download | FreeBSD-src-devel.zip FreeBSD-src-devel.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into develdevel
Diffstat (limited to 'lib/libc/tests')
29 files changed, 189 insertions, 86 deletions
diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 9b89152..3a7adc4 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc - SUBDIR= tls_dso TESTS_SUBDIRS= c063 @@ -17,6 +15,7 @@ TESTS_SUBDIRS+= nss TESTS_SUBDIRS+= regex TESTS_SUBDIRS+= resolv TESTS_SUBDIRS+= rpc +TESTS_SUBDIRS+= setjmp TESTS_SUBDIRS+= stdio TESTS_SUBDIRS+= stdlib TESTS_SUBDIRS+= string diff --git a/lib/libc/tests/Makefile.netbsd-tests b/lib/libc/tests/Makefile.netbsd-tests index 56472fb..18b0276 100644 --- a/lib/libc/tests/Makefile.netbsd-tests +++ b/lib/libc/tests/Makefile.netbsd-tests @@ -1,8 +1,8 @@ # $FreeBSD$ -OBJTOP?= ${.OBJDIR:H:H:H:H} -SRCTOP?= ${.CURDIR:H:H:H:H} -TESTSRC?= ${SRCTOP}/contrib/netbsd-tests/lib/libc/${.CURDIR:T} +TESTSRC:= ${SRCTOP}/contrib/netbsd-tests/${RELDIR:C/libc\/tests/libc/} + +TESTSDIR:= ${TESTSBASE}/${RELDIR:C/libc\/tests/libc/} WARNS?= 2 diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index b81f575..c890eda 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -1,8 +1,6 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/c063 - -#TODO: t_o_search, t_utimensat +#TODO: t_o_search NETBSD_ATF_TESTS_C= faccessat_test NETBSD_ATF_TESTS_C+= fchmodat_test @@ -18,6 +16,7 @@ NETBSD_ATF_TESTS_C+= readlinkat_test NETBSD_ATF_TESTS_C+= renameat_test NETBSD_ATF_TESTS_C+= symlinkat_test NETBSD_ATF_TESTS_C+= unlinkat_test +NETBSD_ATF_TESTS_C+= utimensat CFLAGS+= -D_INCOMPLETE_XOPEN_C063 diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index ed1d6ca..c056384 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -1,18 +1,20 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/db - BINDIR= ${TESTSDIR} PROGS= h_db +PROGS+= h_lfsr FILESDIR= ${TESTSDIR} -FILES= README +FILES+= README +NETBSD_ATF_TESTS_C+= db_hash_seq_test NETBSD_ATF_TESTS_SH+= db_test ATF_TESTS_SH_SED_db_test= -e 's,/bin/csh,/bin/cat,g' +CFLAGS+= -I${SRCTOP}/lib/libc/db/btree + .include "../Makefile.netbsd-tests" .include <bsd.test.mk> diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 91097ef..ac9f8e0 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen - ATF_TESTS_C+= arc4random_test ATF_TESTS_C+= fmtcheck2_test ATF_TESTS_C+= fmtmsg_test @@ -14,10 +12,20 @@ ATF_TESTS_C+= popen_test ATF_TESTS_C+= posix_spawn_test ATF_TESTS_C+= wordexp_test -# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, t_sleep +# TODO: t_closefrom, t_cpuset, t_fmtcheck, t_randomid, # TODO: t_siginfo (fixes require further inspection) # TODO: t_sethostname_test (consistently screws up the hostname) +CFLAGS+= -DTEST_LONG_DOUBLE + +# Not sure why this isn't defined for all architectures, since most +# have long double. +.if ${MACHINE_CPUARCH} == "aarch64" || \ + ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "i386" +CFLAGS+= -D__HAVE_LONG_DOUBLE +.endif + NETBSD_ATF_TESTS_C= alarm_test NETBSD_ATF_TESTS_C+= assert_test NETBSD_ATF_TESTS_C+= basedirname_test diff --git a/lib/libc/tests/gen/execve/Makefile b/lib/libc/tests/gen/execve/Makefile index 2106a15..5e8bc6f 100644 --- a/lib/libc/tests/gen/execve/Makefile +++ b/lib/libc/tests/gen/execve/Makefile @@ -1,13 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen/execve - NETBSD_ATF_TESTS_C= execve_test .include "../../Makefile.netbsd-tests" diff --git a/lib/libc/tests/gen/posix_spawn/Makefile b/lib/libc/tests/gen/posix_spawn/Makefile index f20bbd7..9bb2cf1 100644 --- a/lib/libc/tests/gen/posix_spawn/Makefile +++ b/lib/libc/tests/gen/posix_spawn/Makefile @@ -1,13 +1,7 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} -TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/gen/${.CURDIR:T} - .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/gen/posix_spawn - BINDIR= ${TESTSDIR} NETBSD_ATF_TESTS_C= fileactions_test diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile index 4c64c70..7fb8fb6 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -2,11 +2,11 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/hash - NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" +# XXX: doesn't compile +#NETBSD_ATF_TESTS_C+= hmac_test NETBSD_ATF_TESTS_C+= sha2_test .endif @@ -29,8 +29,8 @@ LDADD+= -lmd DPADD.sha2_test+= ${LIBCRYPTO} LDADD.sha2_test+= -lcrypto -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh/openbsd-compat -CFLAGS.sha2_test+= -I${.CURDIR}/../../../../crypto/openssh +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh/openbsd-compat +CFLAGS.sha2_test+= -I${SRCTOP}/crypto/openssh .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile index a15b96a..fa4499c 100644 --- a/lib/libc/tests/inet/Makefile +++ b/lib/libc/tests/inet/Makefile @@ -2,9 +2,8 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/inet - -NETBSD_ATF_TESTS_C= inet_network_test +NETBSD_ATF_TESTS_C+= inet_addr_test +NETBSD_ATF_TESTS_C+= inet_network_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/locale/Makefile b/lib/libc/tests/locale/Makefile index d15fd5e..e05cbae 100644 --- a/lib/libc/tests/locale/Makefile +++ b/lib/libc/tests/locale/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/locale - ATF_TESTS_C+= btowc_test ATF_TESTS_C+= c16rtomb_test ATF_TESTS_C+= iswctype_test diff --git a/lib/libc/tests/net/Makefile b/lib/libc/tests/net/Makefile index fb76f26..bee179f 100644 --- a/lib/libc/tests/net/Makefile +++ b/lib/libc/tests/net/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/net - ATF_TESTS_C+= ether_test ATF_TESTS_C+= eui64_aton_test ATF_TESTS_C+= eui64_ntoa_test diff --git a/lib/libc/tests/net/getaddrinfo/Makefile b/lib/libc/tests/net/getaddrinfo/Makefile index a6b9eb1..d21d336 100644 --- a/lib/libc/tests/net/getaddrinfo/Makefile +++ b/lib/libc/tests/net/getaddrinfo/Makefile @@ -1,13 +1,9 @@ # $FreeBSD$ -OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/net/${.CURDIR:T} .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/net/getaddrinfo - BINDIR= ${TESTSDIR} .error "This testcase needs to be ported to FreeBSD (the output from getaddrinfo_test differs from NetBSD)" diff --git a/lib/libc/tests/regex/Makefile b/lib/libc/tests/regex/Makefile index 37b3277..fa60f6e 100644 --- a/lib/libc/tests/regex/Makefile +++ b/lib/libc/tests/regex/Makefile @@ -4,8 +4,6 @@ BINDIR= ${TESTSDIR} -TESTSDIR= ${TESTSBASE}/lib/libc/regex - IMPLEMENTATION?= -DREGEX_SPENCER CFLAGS.h_regex+=-I${TESTSRC} -I${.CURDIR:H:H}/regex diff --git a/lib/libc/tests/rpc/Makefile b/lib/libc/tests/rpc/Makefile index 153626b..f9819d3 100644 --- a/lib/libc/tests/rpc/Makefile +++ b/lib/libc/tests/rpc/Makefile @@ -1,6 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/rpc SRCS.xdr_test= ${RPCSRC:.x=_xdr.c} t_xdr.c ${RPCSRC:.x=.h} \ h_testbits.h diff --git a/lib/libc/tests/setjmp/Makefile b/lib/libc/tests/setjmp/Makefile index e303726..ac962c2 100644 --- a/lib/libc/tests/setjmp/Makefile +++ b/lib/libc/tests/setjmp/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/setjmp - NETBSD_ATF_TESTS_C= setjmp_test NETBSD_ATF_TESTS_C+= threadjmp_test @@ -10,4 +8,6 @@ LDADD.threadjmp_test+= -lpthread WARNS?= 4 +.include "../Makefile.netbsd-tests" + .include <bsd.test.mk> diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index cf767ce..ec7a82a 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/ssp - NO_WERROR= WARNS?= 2 @@ -26,7 +24,11 @@ PROGS+= h_getcwd PROGS+= h_memcpy PROGS+= h_memmove PROGS+= h_memset +# This testcase doesn't run properly when not compiled with -fsantize=bounds +# with clang, which is currently contingent on a compiler_rt update +.if ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 30500 PROGS+= h_raw +.endif PROGS+= h_read PROGS+= h_readlink PROGS+= h_snprintf diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile index 06ceb46..495bb17 100644 --- a/lib/libc/tests/stdio/Makefile +++ b/lib/libc/tests/stdio/Makefile @@ -2,15 +2,13 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/stdio - ATF_TESTS_C+= fdopen_test ATF_TESTS_C+= fmemopen2_test ATF_TESTS_C+= fopen2_test ATF_TESTS_C+= freopen_test ATF_TESTS_C+= getdelim_test ATF_TESTS_C+= mkostemp_test -ATF_TESTS_C+= open_memstream_test +ATF_TESTS_C+= open_memstream2_test ATF_TESTS_C+= open_wmemstream_test ATF_TESTS_C+= perror_test ATF_TESTS_C+= print_positional_test @@ -26,6 +24,7 @@ NETBSD_ATF_TESTS_C+= fmemopen_test NETBSD_ATF_TESTS_C+= fopen_test NETBSD_ATF_TESTS_C+= fputc_test NETBSD_ATF_TESTS_C+= mktemp_test +NETBSD_ATF_TESTS_C+= open_memstream_test NETBSD_ATF_TESTS_C+= popen_test NETBSD_ATF_TESTS_C+= printf_test NETBSD_ATF_TESTS_C+= scanf_test diff --git a/lib/libc/tests/stdio/open_memstream_test.c b/lib/libc/tests/stdio/open_memstream2_test.c index 3c9e3ec..3c9e3ec 100644 --- a/lib/libc/tests/stdio/open_memstream_test.c +++ b/lib/libc/tests/stdio/open_memstream2_test.c diff --git a/lib/libc/tests/stdio/printbasic_test.c b/lib/libc/tests/stdio/printbasic_test.c index 7f7c6cb..322e747 100644 --- a/lib/libc/tests/stdio/printbasic_test.c +++ b/lib/libc/tests/stdio/printbasic_test.c @@ -78,22 +78,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) va_copy(ap2, ap); smash_stack(); vsnprintf(s, sizeof(s), fmt, ap); - if (strcmp(result, s) != 0) { - atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]", - fmt, argstr, s, result); - } + ATF_CHECK_MSG(strcmp(result, s) == 0, + "printf(\"%s\", %s) ==> [%s], expected [%s]", + fmt, argstr, s, result); smash_stack(); mbstowcs(ws, s, BUF - 1); mbstowcs(wfmt, fmt, BUF - 1); mbstowcs(wresult, result, BUF - 1); vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); - if (wcscmp(wresult, ws) != 0) { - atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", - wfmt, argstr, ws, wresult); - } + ATF_CHECK_MSG(wcscmp(wresult, ws) == 0, + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", + wfmt, argstr, ws, wresult); + va_end(ap); va_end(ap2); } @@ -114,6 +111,11 @@ ATF_TC_BODY(int_within_limits, tc) testfmt("-1", "%jd", (intmax_t)-1); testfmt(S_UINT64MAX, "%ju", UINT64_MAX); + if (sizeof(ptrdiff_t) != sizeof(uintmax_t)) + atf_tc_expect_fail("the %%t qualifier is broken on 32-bit " + "platforms where there's a mismatch between ptrdiff_t and " + "uintmax_t's type width; bug # 191674"); + testfmt("-1", "%td", (ptrdiff_t)-1); testfmt(S_SIZEMAX, "%tu", (size_t)-1); diff --git a/lib/libc/tests/stdio/printfloat_test.c b/lib/libc/tests/stdio/printfloat_test.c index 8c02bec..6655680 100644 --- a/lib/libc/tests/stdio/printfloat_test.c +++ b/lib/libc/tests/stdio/printfloat_test.c @@ -70,22 +70,19 @@ _testfmt(const char *result, const char *argstr, const char *fmt,...) va_copy(ap2, ap); smash_stack(); vsnprintf(s, sizeof(s), fmt, ap); - if (strcmp(result, s) != 0) { - atf_tc_fail( - "printf(\"%s\", %s) ==> [%s], expected [%s]", - fmt, argstr, s, result); - } + ATF_CHECK_MSG(strcmp(result, s) == 0, + "printf(\"%s\", %s) ==> [%s], expected [%s]", + fmt, argstr, s, result); smash_stack(); mbstowcs(ws, s, BUF - 1); mbstowcs(wfmt, fmt, BUF - 1); mbstowcs(wresult, result, BUF - 1); vswprintf(ws, sizeof(ws) / sizeof(ws[0]), wfmt, ap2); - if (wcscmp(wresult, ws) != 0) { - atf_tc_fail( - "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", - wfmt, argstr, ws, wresult); - } + ATF_CHECK_MSG(wcscmp(wresult, ws) == 0, + "wprintf(\"%ls\", %s) ==> [%ls], expected [%ls]", + wfmt, argstr, ws, wresult); + va_end(ap); va_end(ap2); } @@ -318,7 +315,7 @@ ATF_TC_BODY(hexadecimal_floating_point, tc) testfmt("0x1p-1074", "%a", 0x1p-1074); testfmt("0x1.2345p-1024", "%a", 0x1.2345p-1024); -#if (LDBL_MANT_DIG == 64) && !defined(__i386__) +#if (LDBL_MANT_DIG == 64) testfmt("0x1.921fb54442d18468p+1", "%La", 0x3.243f6a8885a308dp0L); testfmt("0x1p-16445", "%La", 0x1p-16445L); testfmt("0x1.30ecap-16381", "%La", 0x9.8765p-16384L); diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index 15d8cbc..1548fac 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,9 +10,15 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .endif -TESTSDIR= ${TESTSBASE}/lib/libc/stdlib +# Not sure why this isn't defined for all architectures, since most +# have long double. +.if ${MACHINE_CPUARCH} == "aarch64" || \ + ${MACHINE_CPUARCH} == "amd64" || \ + ${MACHINE_CPUARCH} == "i386" +CFLAGS+= -D__HAVE_LONG_DOUBLE +.endif -# TODO: t_getenv_thread, t_mi_vector_hash +# TODO: t_getenv_thread, t_mi_vector_hash, t_strtoi NETBSD_ATF_TESTS_C+= abs_test NETBSD_ATF_TESTS_C+= atoi_test NETBSD_ATF_TESTS_C+= div_test diff --git a/lib/libc/tests/string/Makefile b/lib/libc/tests/string/Makefile index 3f97edc..14044f4 100644 --- a/lib/libc/tests/string/Makefile +++ b/lib/libc/tests/string/Makefile @@ -5,8 +5,6 @@ ATF_TESTS_C+= strerror2_test ATF_TESTS_C+= wcscasecmp_test ATF_TESTS_C+= wcsnlen_test -TESTSDIR= ${TESTSBASE}/lib/libc/string - # TODO: popcount, stresep NETBSD_ATF_TESTS_C+= memchr_test diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index 39aec1f..be2f4e7 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -2,13 +2,12 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/sys - ATF_TESTS_C+= queue_test # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, # swapcontext NETBSD_ATF_TESTS_C+= access_test +NETBSD_ATF_TESTS_C+= bind_test NETBSD_ATF_TESTS_C+= chroot_test NETBSD_ATF_TESTS_C+= clock_gettime_test NETBSD_ATF_TESTS_C+= connect_test @@ -21,6 +20,7 @@ NETBSD_ATF_TESTS_C+= getlogin_test NETBSD_ATF_TESTS_C+= getpid_test NETBSD_ATF_TESTS_C+= getrusage_test NETBSD_ATF_TESTS_C+= getsid_test +NETBSD_ATF_TESTS_C+= getsockname_test NETBSD_ATF_TESTS_C+= gettimeofday_test NETBSD_ATF_TESTS_C+= issetugid_test NETBSD_ATF_TESTS_C+= kevent_test @@ -43,6 +43,7 @@ NETBSD_ATF_TESTS_C+= nanosleep_test NETBSD_ATF_TESTS_C+= pipe_test NETBSD_ATF_TESTS_C+= pipe2_test NETBSD_ATF_TESTS_C+= poll_test +NETBSD_ATF_TESTS_C+= posix_fallocate_test NETBSD_ATF_TESTS_C+= revoke_test NETBSD_ATF_TESTS_C+= select_test NETBSD_ATF_TESTS_C+= setrlimit_test @@ -57,6 +58,9 @@ NETBSD_ATF_TESTS_C+= truncate_test NETBSD_ATF_TESTS_C+= ucontext_test NETBSD_ATF_TESTS_C+= umask_test NETBSD_ATF_TESTS_C+= unlink_test +NETBSD_ATF_TESTS_C+= wait_test +NETBSD_ATF_TESTS_C+= wait_noproc_test +NETBSD_ATF_TESTS_C+= wait_noproc_wnohang_test NETBSD_ATF_TESTS_C+= write_test DPADD.getpid_test+= ${LIBPTHREAD} @@ -64,8 +68,13 @@ LDADD.getpid_test+= -lpthread DPADD.timer_create_test+= ${LIBRT} LDADD.timer_create_test+= -lrt +CSTD?= c99 + .include "../Makefile.netbsd-tests" +SRCS.mlock_test+= mlock_helper.c +SRCS.setrlimit_test+= mlock_helper.c + .if ${COMPILER_TYPE} == "gcc" WARNS?= 3 .else diff --git a/lib/libc/tests/sys/mlock_helper.c b/lib/libc/tests/sys/mlock_helper.c new file mode 100644 index 0000000..7fa40d1 --- /dev/null +++ b/lib/libc/tests/sys/mlock_helper.c @@ -0,0 +1,114 @@ +/*- + * Copyright (C) 2016 Bryan Drewery <bdrewery@FreeBSD.org> + * 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. + */ + +/* + * Helper for mlock(3) to avoid EAGAIN errors + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/sysctl.h> + +#include <atf-c.h> +#include <errno.h> +#include <stdio.h> +#include <limits.h> + +#define VM_MAX_WIRED "vm.max_wired" + +static void +vm_max_wired_sysctl(int *old_value, int *new_value) +{ + size_t old_len; + size_t new_len = (new_value == NULL ? 0 : sizeof(int)); + + if (old_value == NULL) + printf("Setting the new value to %d\n", *new_value); + else { + ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, NULL, &old_len, + new_value, new_len) == 0, + "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); + } + + ATF_REQUIRE_MSG(sysctlbyname(VM_MAX_WIRED, old_value, &old_len, + new_value, new_len) == 0, + "sysctlbyname(%s) failed: %s", VM_MAX_WIRED, strerror(errno)); + + if (old_value != NULL) + printf("Saved the old value (%d)\n", *old_value); +} + +void +set_vm_max_wired(int new_value) +{ + FILE *fp; + int old_value; + + fp = fopen(VM_MAX_WIRED, "w"); + if (fp == NULL) { + atf_tc_skip("could not open %s for writing: %s", + VM_MAX_WIRED, strerror(errno)); + return; + } + + vm_max_wired_sysctl(&old_value, NULL); + + ATF_REQUIRE_MSG(fprintf(fp, "%d", old_value) > 0, + "saving %s failed", VM_MAX_WIRED); + + fclose(fp); + + vm_max_wired_sysctl(NULL, &new_value); +} + +void +restore_vm_max_wired(void) +{ + FILE *fp; + int saved_max_wired; + + fp = fopen(VM_MAX_WIRED, "r"); + if (fp == NULL) { + perror("fopen failed\n"); + return; + } + + if (fscanf(fp, "%d", &saved_max_wired) != 1) { + perror("fscanf failed\n"); + fclose(fp); + return; + } + + fclose(fp); + printf("old value in %s: %d\n", VM_MAX_WIRED, saved_max_wired); + + if (saved_max_wired == 0) /* This will cripple the test host */ + return; + + vm_max_wired_sysctl(NULL, &saved_max_wired); +} diff --git a/lib/libc/tests/termios/Makefile b/lib/libc/tests/termios/Makefile index 9a3fd66..0495d68 100644 --- a/lib/libc/tests/termios/Makefile +++ b/lib/libc/tests/termios/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/termios - NETBSD_ATF_TESTS_C= tcsetpgrp_test .include "../Makefile.netbsd-tests" diff --git a/lib/libc/tests/time/Makefile b/lib/libc/tests/time/Makefile index c2a55df..feb543d 100644 --- a/lib/libc/tests/time/Makefile +++ b/lib/libc/tests/time/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/time - NETBSD_ATF_TESTS_C= mktime_test NETBSD_ATF_TESTS_C+= strptime_test diff --git a/lib/libc/tests/tls/Makefile b/lib/libc/tests/tls/Makefile index e224895..b6b6719 100644 --- a/lib/libc/tests/tls/Makefile +++ b/lib/libc/tests/tls/Makefile @@ -2,7 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/tls .if !defined(NO_PIC) SUBDIR+= dso .endif diff --git a/lib/libc/tests/tls/dso/Makefile b/lib/libc/tests/tls/dso/Makefile index 466f950..9b698cd 100644 --- a/lib/libc/tests/tls/dso/Makefile +++ b/lib/libc/tests/tls/dso/Makefile @@ -1,7 +1,6 @@ # $FreeBSD$ OBJTOP= ${.OBJDIR:H:H:H:H:H} -SRCTOP= ${.CURDIR:H:H:H:H:H} TESTSRC= ${SRCTOP}/contrib/netbsd-tests/lib/libc/tls/${.CURDIR:T} LIB= h_tls_dlopen diff --git a/lib/libc/tests/ttyio/Makefile b/lib/libc/tests/ttyio/Makefile index a1f320d..242f332 100644 --- a/lib/libc/tests/ttyio/Makefile +++ b/lib/libc/tests/ttyio/Makefile @@ -2,8 +2,6 @@ .include <bsd.own.mk> -TESTSDIR= ${TESTSBASE}/lib/libc/ttyio - # TODO: ptm_test NETBSD_ATF_TESTS_C= ttyio_test |