From fec4dffc3487939185515738cb54d7b0e89a1921 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:26:14 +0000 Subject: MFC r277648: r277648 (by jilles): Enable utimensat tests from NetBSD. As with other tests from c063, a required #include was missing. --- lib/libc/tests/c063/Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/c063/Makefile b/lib/libc/tests/c063/Makefile index b81f575..27c44dc 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -2,7 +2,7 @@ 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 +18,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 -- cgit v1.1 From 237637fa313dcd7c981f44ea35296cda3be981cb Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 21:29:18 +0000 Subject: MFC r276527: Don't install h_raw if dealing with clang 3.5.0+ to unbreak the tests2 Jenkins job The h_raw application doesn't do proper bounds checking without the option being supplied via the build, which means that it doesn't throw signals and fail as expected PR: 196430 --- lib/libc/tests/ssp/Makefile | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index cf767ce..7bc8660 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -26,7 +26,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 -- cgit v1.1 From 6b3722162f25f17568ac341320ee8e7ede42bc7e Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:49:48 +0000 Subject: MFC r289172,r290254: r289172: Refactor the test/ Makefiles after recent changes to bsd.test.mk (r289158) and netbsd-tests.test.mk (r289151) - Eliminate explicit OBJTOP/SRCTOP setting - Convert all ad hoc NetBSD test integration over to netbsd-tests.test.mk - Remove unnecessary TESTSDIR setting - Use SRCTOP where possible for clarity r290254: Remove unused variable (SRCDIR) --- lib/libc/tests/Makefile | 2 -- lib/libc/tests/Makefile.netbsd-tests | 6 +++--- lib/libc/tests/c063/Makefile | 2 -- lib/libc/tests/db/Makefile | 2 -- lib/libc/tests/gen/Makefile | 2 -- lib/libc/tests/gen/execve/Makefile | 6 ------ lib/libc/tests/gen/posix_spawn/Makefile | 6 ------ lib/libc/tests/hash/Makefile | 6 ++---- lib/libc/tests/inet/Makefile | 2 -- lib/libc/tests/locale/Makefile | 2 -- lib/libc/tests/net/Makefile | 2 -- lib/libc/tests/net/getaddrinfo/Makefile | 4 ---- lib/libc/tests/regex/Makefile | 2 -- lib/libc/tests/rpc/Makefile | 1 - lib/libc/tests/setjmp/Makefile | 4 ++-- lib/libc/tests/ssp/Makefile | 2 -- lib/libc/tests/stdio/Makefile | 2 -- lib/libc/tests/stdlib/Makefile | 2 -- lib/libc/tests/string/Makefile | 2 -- lib/libc/tests/sys/Makefile | 2 -- lib/libc/tests/termios/Makefile | 2 -- lib/libc/tests/time/Makefile | 2 -- lib/libc/tests/tls/Makefile | 1 - lib/libc/tests/tls/dso/Makefile | 1 - lib/libc/tests/ttyio/Makefile | 2 -- 25 files changed, 7 insertions(+), 60 deletions(-) (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 9b89152..677f697 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc - SUBDIR= tls_dso TESTS_SUBDIRS= c063 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 27c44dc..c890eda 100644 --- a/lib/libc/tests/c063/Makefile +++ b/lib/libc/tests/c063/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/c063 - #TODO: t_o_search NETBSD_ATF_TESTS_C= faccessat_test diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index ed1d6ca..eb0ce39 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -1,7 +1,5 @@ # $FreeBSD$ -TESTSDIR= ${TESTSBASE}/lib/libc/db - BINDIR= ${TESTSDIR} PROGS= h_db diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 91097ef..476b5b7 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/gen - ATF_TESTS_C+= arc4random_test ATF_TESTS_C+= fmtcheck2_test ATF_TESTS_C+= fmtmsg_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 -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 -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..1a71eaa 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/hash - NETBSD_ATF_TESTS_C= .if ${MK_OPENSSL} != "no" @@ -29,8 +27,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..ee6f98e 100644 --- a/lib/libc/tests/inet/Makefile +++ b/lib/libc/tests/inet/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/inet - 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 -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 -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 diff --git a/lib/libc/tests/ssp/Makefile b/lib/libc/tests/ssp/Makefile index 7bc8660..ec7a82a 100644 --- a/lib/libc/tests/ssp/Makefile +++ b/lib/libc/tests/ssp/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/ssp - NO_WERROR= WARNS?= 2 diff --git a/lib/libc/tests/stdio/Makefile b/lib/libc/tests/stdio/Makefile index 06ceb46..7896422 100644 --- a/lib/libc/tests/stdio/Makefile +++ b/lib/libc/tests/stdio/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/stdio - ATF_TESTS_C+= fdopen_test ATF_TESTS_C+= fmemopen2_test ATF_TESTS_C+= fopen2_test diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index 15d8cbc..99d17e2 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,8 +10,6 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .endif -TESTSDIR= ${TESTSBASE}/lib/libc/stdlib - # TODO: t_getenv_thread, t_mi_vector_hash NETBSD_ATF_TESTS_C+= abs_test NETBSD_ATF_TESTS_C+= atoi_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..816b962 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -2,8 +2,6 @@ .include -TESTSDIR= ${TESTSBASE}/lib/libc/sys - ATF_TESTS_C+= queue_test # TODO: clone, lwp_create, lwp_ctl, posix_fadvise, recvmmsg, 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 -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 -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 -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 -TESTSDIR= ${TESTSBASE}/lib/libc/ttyio - # TODO: ptm_test NETBSD_ATF_TESTS_C= ttyio_test -- cgit v1.1 From 9c6235cf2af8bdadcd0f0a80288683f0c88f3e55 Mon Sep 17 00:00:00 2001 From: ngie Date: Thu, 9 Feb 2017 22:57:56 +0000 Subject: MFC r296586: r296586 (by bdrewery): Fix and connect setjmp test. --- lib/libc/tests/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/Makefile b/lib/libc/tests/Makefile index 677f697..3a7adc4 100644 --- a/lib/libc/tests/Makefile +++ b/lib/libc/tests/Makefile @@ -15,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 -- cgit v1.1 From 8864cde3495dbfd6b476c1b77a8bde035e1cf000 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 01:13:12 +0000 Subject: MFC r305358,r305449,r305451,r306367,r306397,r309474: This also contains a merge of ^/projects/netbsd-tests-update-12@r304035 . This change never hit ^/head because bin/cat's behavior was changed (on ^/head) to match NetBSD. PR: 210607 r305358: Update contrib/netbsd-tests with new content from NetBSD This updates the snapshot from 09/30/2014 to 08/11/2016 This brings in a number of new testcases from upstream, most notably: - bin/cat - lib/libc - lib/msun - lib/libthr - usr.bin/sort lib/libc/tests/stdio/open_memstream_test.c was moved to lib/libc/tests/stdio/open_memstream2_test.c to accomodate the new open_memstream test from NetBSD. Tested on: amd64 (VMware fusion VM; various bare metal platforms); i386 (VMware fusion VM); make tinderbox r305449: Install h_db to unbreak some of the lib/libc/db testcases after r305358 r305451: Fix lib/libc/rpc test assumptions added in r305358 - Require root in the tcp/udp subtests (it's needed on FreeBSD when registering services). - Skip the tests if service registration fails. r306367 (by br): Allow up to 6 arguments only on MIPS. r306397 (by br): Use right piece of code for FreeBSD. r309474: Don't build :strvis_locale if VIS_NOLOCALE is undefined The copy of contrib/libc-vis on ^/stable/10 doesn't contain all of the features in the ^/stable/11 // ^/head version, including VIS_NOLOCALE. The risk is lower in conditionally running the test instead of backporting the newer version of libc-vis --- lib/libc/tests/db/Makefile | 2 + lib/libc/tests/hash/Makefile | 2 + lib/libc/tests/inet/Makefile | 3 +- lib/libc/tests/stdio/Makefile | 3 +- lib/libc/tests/stdio/open_memstream2_test.c | 201 ++++++++++++++++++++++++++++ lib/libc/tests/stdio/open_memstream_test.c | 201 ---------------------------- lib/libc/tests/stdlib/Makefile | 2 +- lib/libc/tests/sys/Makefile | 4 + 8 files changed, 214 insertions(+), 204 deletions(-) create mode 100644 lib/libc/tests/stdio/open_memstream2_test.c delete mode 100644 lib/libc/tests/stdio/open_memstream_test.c (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index eb0ce39..fe54d3b 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -3,11 +3,13 @@ BINDIR= ${TESTSDIR} PROGS= h_db +PROGS+= h_lfsr FILESDIR= ${TESTSDIR} 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' diff --git a/lib/libc/tests/hash/Makefile b/lib/libc/tests/hash/Makefile index 1a71eaa..7fb8fb6 100644 --- a/lib/libc/tests/hash/Makefile +++ b/lib/libc/tests/hash/Makefile @@ -5,6 +5,8 @@ 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 diff --git a/lib/libc/tests/inet/Makefile b/lib/libc/tests/inet/Makefile index ee6f98e..fa4499c 100644 --- a/lib/libc/tests/inet/Makefile +++ b/lib/libc/tests/inet/Makefile @@ -2,7 +2,8 @@ .include -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/stdio/Makefile b/lib/libc/tests/stdio/Makefile index 7896422..495bb17 100644 --- a/lib/libc/tests/stdio/Makefile +++ b/lib/libc/tests/stdio/Makefile @@ -8,7 +8,7 @@ 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 @@ -24,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_memstream2_test.c b/lib/libc/tests/stdio/open_memstream2_test.c new file mode 100644 index 0000000..3c9e3ec --- /dev/null +++ b/lib/libc/tests/stdio/open_memstream2_test.c @@ -0,0 +1,201 @@ +/*- + * Copyright (c) 2013 Hudson River Trading LLC + * Written by: John H. Baldwin + * 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. + */ + +#include +__FBSDID("$FreeBSD$"); + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +static char *buf; +static size_t len; + +static void +assert_stream(const char *contents) +{ + if (strlen(contents) != len) + printf("bad length %zd for \"%s\"\n", len, contents); + else if (strncmp(buf, contents, strlen(contents)) != 0) + printf("bad buffer \"%s\" for \"%s\"\n", buf, contents); +} + +ATF_TC_WITHOUT_HEAD(open_group_test); +ATF_TC_BODY(open_group_test, tc) +{ + FILE *fp; + off_t eob; + + fp = open_memstream(&buf, &len); + ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed"); + + fprintf(fp, "hello my world"); + fflush(fp); + assert_stream("hello my world"); + eob = ftello(fp); + rewind(fp); + fprintf(fp, "good-bye"); + fseeko(fp, eob, SEEK_SET); + fclose(fp); + assert_stream("good-bye world"); + free(buf); +} + +ATF_TC_WITHOUT_HEAD(simple_tests); +ATF_TC_BODY(simple_tests, tc) +{ + static const char zerobuf[] = + { 'f', 'o', 'o', 0, 0, 0, 0, 'b', 'a', 'r', 0 }; + char c; + FILE *fp; + + fp = open_memstream(&buf, NULL); + ATF_REQUIRE_MSG(fp == NULL, "open_memstream did not fail"); + ATF_REQUIRE_MSG(errno == EINVAL, + "open_memstream didn't fail with EINVAL"); + fp = open_memstream(NULL, &len); + ATF_REQUIRE_MSG(fp == NULL, "open_memstream did not fail"); + ATF_REQUIRE_MSG(errno == EINVAL, + "open_memstream didn't fail with EINVAL"); + fp = open_memstream(&buf, &len); + ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed; errno=%d", errno); + fflush(fp); + assert_stream(""); + if (fwide(fp, 0) >= 0) + printf("stream is not byte-oriented\n"); + + fprintf(fp, "fo"); + fflush(fp); + assert_stream("fo"); + fputc('o', fp); + fflush(fp); + assert_stream("foo"); + rewind(fp); + fflush(fp); + assert_stream(""); + fseek(fp, 0, SEEK_END); + fflush(fp); + assert_stream("foo"); + + /* + * Test seeking out past the current end. Should zero-fill the + * intermediate area. + */ + fseek(fp, 4, SEEK_END); + fprintf(fp, "bar"); + fflush(fp); + + /* + * Can't use assert_stream() here since this should contain + * embedded null characters. + */ + if (len != 10) + printf("bad length %zd for zero-fill test\n", len); + else if (memcmp(buf, zerobuf, sizeof(zerobuf)) != 0) + printf("bad buffer for zero-fill test\n"); + + fseek(fp, 3, SEEK_SET); + fprintf(fp, " in "); + fflush(fp); + assert_stream("foo in "); + fseek(fp, 0, SEEK_END); + fflush(fp); + assert_stream("foo in bar"); + + rewind(fp); + if (fread(&c, sizeof(c), 1, fp) != 0) + printf("fread did not fail\n"); + else if (!ferror(fp)) + printf("error indicator not set after fread\n"); + else + clearerr(fp); + + fseek(fp, 4, SEEK_SET); + fprintf(fp, "bar baz"); + fclose(fp); + assert_stream("foo bar baz"); + free(buf); +} + +ATF_TC_WITHOUT_HEAD(seek_tests); +ATF_TC_BODY(seek_tests, tc) +{ + FILE *fp; + + fp = open_memstream(&buf, &len); + ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed: %d", errno); + +#define SEEK_FAIL(offset, whence, error) do { \ + errno = 0; \ + ATF_REQUIRE_MSG(fseeko(fp, (offset), (whence)) != 0, \ + "fseeko(%s, %s) did not fail, set pos to %jd\n", \ + __STRING(offset), __STRING(whence), \ + (intmax_t)ftello(fp)); \ + ATF_REQUIRE_MSG(errno == (error), \ + "fseeko(%s, %s) failed with %d rather than %s\n", \ + __STRING(offset), __STRING(whence), errno, \ + __STRING(error)); \ +} while (0) + +#define SEEK_OK(offset, whence, result) do { \ + ATF_REQUIRE_MSG(fseeko(fp, (offset), (whence)) == 0, \ + "fseeko(%s, %s) failed: %s", \ + __STRING(offset), __STRING(whence), strerror(errno)); \ + ATF_REQUIRE_MSG(ftello(fp) == (result), \ + "fseeko(%s, %s) seeked to %jd rather than %s\n", \ + __STRING(offset), __STRING(whence), \ + (intmax_t)ftello(fp), __STRING(result)); \ +} while (0) + + SEEK_FAIL(-1, SEEK_SET, EINVAL); + SEEK_FAIL(-1, SEEK_CUR, EINVAL); + SEEK_FAIL(-1, SEEK_END, EINVAL); + fprintf(fp, "foo"); + SEEK_OK(-1, SEEK_CUR, 2); + SEEK_OK(0, SEEK_SET, 0); + SEEK_OK(-1, SEEK_END, 2); + SEEK_OK(OFF_MAX - 1, SEEK_SET, OFF_MAX - 1); + SEEK_FAIL(2, SEEK_CUR, EOVERFLOW); + fclose(fp); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, open_group_test); + ATF_TP_ADD_TC(tp, simple_tests); + ATF_TP_ADD_TC(tp, seek_tests); + + return (atf_no_error()); +} diff --git a/lib/libc/tests/stdio/open_memstream_test.c b/lib/libc/tests/stdio/open_memstream_test.c deleted file mode 100644 index 3c9e3ec..0000000 --- a/lib/libc/tests/stdio/open_memstream_test.c +++ /dev/null @@ -1,201 +0,0 @@ -/*- - * Copyright (c) 2013 Hudson River Trading LLC - * Written by: John H. Baldwin - * 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. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -static char *buf; -static size_t len; - -static void -assert_stream(const char *contents) -{ - if (strlen(contents) != len) - printf("bad length %zd for \"%s\"\n", len, contents); - else if (strncmp(buf, contents, strlen(contents)) != 0) - printf("bad buffer \"%s\" for \"%s\"\n", buf, contents); -} - -ATF_TC_WITHOUT_HEAD(open_group_test); -ATF_TC_BODY(open_group_test, tc) -{ - FILE *fp; - off_t eob; - - fp = open_memstream(&buf, &len); - ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed"); - - fprintf(fp, "hello my world"); - fflush(fp); - assert_stream("hello my world"); - eob = ftello(fp); - rewind(fp); - fprintf(fp, "good-bye"); - fseeko(fp, eob, SEEK_SET); - fclose(fp); - assert_stream("good-bye world"); - free(buf); -} - -ATF_TC_WITHOUT_HEAD(simple_tests); -ATF_TC_BODY(simple_tests, tc) -{ - static const char zerobuf[] = - { 'f', 'o', 'o', 0, 0, 0, 0, 'b', 'a', 'r', 0 }; - char c; - FILE *fp; - - fp = open_memstream(&buf, NULL); - ATF_REQUIRE_MSG(fp == NULL, "open_memstream did not fail"); - ATF_REQUIRE_MSG(errno == EINVAL, - "open_memstream didn't fail with EINVAL"); - fp = open_memstream(NULL, &len); - ATF_REQUIRE_MSG(fp == NULL, "open_memstream did not fail"); - ATF_REQUIRE_MSG(errno == EINVAL, - "open_memstream didn't fail with EINVAL"); - fp = open_memstream(&buf, &len); - ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed; errno=%d", errno); - fflush(fp); - assert_stream(""); - if (fwide(fp, 0) >= 0) - printf("stream is not byte-oriented\n"); - - fprintf(fp, "fo"); - fflush(fp); - assert_stream("fo"); - fputc('o', fp); - fflush(fp); - assert_stream("foo"); - rewind(fp); - fflush(fp); - assert_stream(""); - fseek(fp, 0, SEEK_END); - fflush(fp); - assert_stream("foo"); - - /* - * Test seeking out past the current end. Should zero-fill the - * intermediate area. - */ - fseek(fp, 4, SEEK_END); - fprintf(fp, "bar"); - fflush(fp); - - /* - * Can't use assert_stream() here since this should contain - * embedded null characters. - */ - if (len != 10) - printf("bad length %zd for zero-fill test\n", len); - else if (memcmp(buf, zerobuf, sizeof(zerobuf)) != 0) - printf("bad buffer for zero-fill test\n"); - - fseek(fp, 3, SEEK_SET); - fprintf(fp, " in "); - fflush(fp); - assert_stream("foo in "); - fseek(fp, 0, SEEK_END); - fflush(fp); - assert_stream("foo in bar"); - - rewind(fp); - if (fread(&c, sizeof(c), 1, fp) != 0) - printf("fread did not fail\n"); - else if (!ferror(fp)) - printf("error indicator not set after fread\n"); - else - clearerr(fp); - - fseek(fp, 4, SEEK_SET); - fprintf(fp, "bar baz"); - fclose(fp); - assert_stream("foo bar baz"); - free(buf); -} - -ATF_TC_WITHOUT_HEAD(seek_tests); -ATF_TC_BODY(seek_tests, tc) -{ - FILE *fp; - - fp = open_memstream(&buf, &len); - ATF_REQUIRE_MSG(fp != NULL, "open_memstream failed: %d", errno); - -#define SEEK_FAIL(offset, whence, error) do { \ - errno = 0; \ - ATF_REQUIRE_MSG(fseeko(fp, (offset), (whence)) != 0, \ - "fseeko(%s, %s) did not fail, set pos to %jd\n", \ - __STRING(offset), __STRING(whence), \ - (intmax_t)ftello(fp)); \ - ATF_REQUIRE_MSG(errno == (error), \ - "fseeko(%s, %s) failed with %d rather than %s\n", \ - __STRING(offset), __STRING(whence), errno, \ - __STRING(error)); \ -} while (0) - -#define SEEK_OK(offset, whence, result) do { \ - ATF_REQUIRE_MSG(fseeko(fp, (offset), (whence)) == 0, \ - "fseeko(%s, %s) failed: %s", \ - __STRING(offset), __STRING(whence), strerror(errno)); \ - ATF_REQUIRE_MSG(ftello(fp) == (result), \ - "fseeko(%s, %s) seeked to %jd rather than %s\n", \ - __STRING(offset), __STRING(whence), \ - (intmax_t)ftello(fp), __STRING(result)); \ -} while (0) - - SEEK_FAIL(-1, SEEK_SET, EINVAL); - SEEK_FAIL(-1, SEEK_CUR, EINVAL); - SEEK_FAIL(-1, SEEK_END, EINVAL); - fprintf(fp, "foo"); - SEEK_OK(-1, SEEK_CUR, 2); - SEEK_OK(0, SEEK_SET, 0); - SEEK_OK(-1, SEEK_END, 2); - SEEK_OK(OFF_MAX - 1, SEEK_SET, OFF_MAX - 1); - SEEK_FAIL(2, SEEK_CUR, EOVERFLOW); - fclose(fp); -} - -ATF_TP_ADD_TCS(tp) -{ - - ATF_TP_ADD_TC(tp, open_group_test); - ATF_TP_ADD_TC(tp, simple_tests); - ATF_TP_ADD_TC(tp, seek_tests); - - return (atf_no_error()); -} diff --git a/lib/libc/tests/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index 99d17e2..af0341c 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,7 +10,7 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .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/sys/Makefile b/lib/libc/tests/sys/Makefile index 816b962..233cff4 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -7,6 +7,7 @@ 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 @@ -19,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 @@ -41,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 @@ -55,6 +58,7 @@ 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+= write_test DPADD.getpid_test+= ${LIBPTHREAD} -- cgit v1.1 From 9e0c92b812b404c1d5124f2e2d81cb448ec22b07 Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 02:57:37 +0000 Subject: MFC r309373: r309373 (by bdrewery): Fix setrlimit_test:setrlimit_memlock when the system has exceeded vm.max_wired. This uses the same fix as r294894 did for the mlock test. The code from that commit is moved into a common object file which PROGS supports building first. --- lib/libc/tests/sys/Makefile | 3 + lib/libc/tests/sys/mlock_helper.c | 114 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 117 insertions(+) create mode 100644 lib/libc/tests/sys/mlock_helper.c (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index 233cff4..ed5eaa9 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -68,6 +68,9 @@ LDADD.timer_create_test+= -lrt .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 + * 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 +__FBSDID("$FreeBSD$"); + +#include +#include + +#include +#include +#include +#include + +#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); +} -- cgit v1.1 From b39322d52d2dd66d37af0ffcbfb48d13896804ea Mon Sep 17 00:00:00 2001 From: ngie Date: Fri, 10 Feb 2017 07:13:16 +0000 Subject: MFC r311925,r311968,r311969,r312008: r311925: Import testcase updates with code contributed back to NetBSD This also (inadvertently) contains an update to contrib/netbsd-tests/lib/libc/sys/t_wait.c (new testcases). In collaboration with: christos@NetBSD.org r311968: Fix lib/libc/sys/access_test after r311925 sys/param.h needs to be #included in order for __FreeBSD_version to be checked r311969: Remove __HAVE_LONG_DOUBLE #define from t_strtod.c and place it in Makefile This is to enable support in other testcases Inspired by lib/msun/tests/Makefile . r312008: Upgrade NetBSD tests to 01.11.2017_23.20 snapshot This contains some new testcases in /usr/tests/...: - .../lib/libc - .../lib/libthr - .../lib/msun - .../sys/kern Tested on: amd64, i386 --- lib/libc/tests/db/Makefile | 4 +++- lib/libc/tests/gen/Makefile | 12 +++++++++++- lib/libc/tests/stdlib/Makefile | 8 ++++++++ lib/libc/tests/sys/Makefile | 4 ++++ 4 files changed, 26 insertions(+), 2 deletions(-) (limited to 'lib/libc/tests') diff --git a/lib/libc/tests/db/Makefile b/lib/libc/tests/db/Makefile index fe54d3b..c056384 100644 --- a/lib/libc/tests/db/Makefile +++ b/lib/libc/tests/db/Makefile @@ -7,12 +7,14 @@ 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 diff --git a/lib/libc/tests/gen/Makefile b/lib/libc/tests/gen/Makefile index 476b5b7..ac9f8e0 100644 --- a/lib/libc/tests/gen/Makefile +++ b/lib/libc/tests/gen/Makefile @@ -12,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/stdlib/Makefile b/lib/libc/tests/stdlib/Makefile index af0341c..1548fac 100644 --- a/lib/libc/tests/stdlib/Makefile +++ b/lib/libc/tests/stdlib/Makefile @@ -10,6 +10,14 @@ ATF_TESTS_CXX+= cxa_thread_atexit_test ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test .endif +# 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, t_strtoi NETBSD_ATF_TESTS_C+= abs_test NETBSD_ATF_TESTS_C+= atoi_test diff --git a/lib/libc/tests/sys/Makefile b/lib/libc/tests/sys/Makefile index ed5eaa9..be2f4e7 100644 --- a/lib/libc/tests/sys/Makefile +++ b/lib/libc/tests/sys/Makefile @@ -59,6 +59,8 @@ 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} @@ -66,6 +68,8 @@ 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 -- cgit v1.1 From 44e806ba3aa0d53f31bdef57fb11f38ffdd6d447 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:46:19 +0000 Subject: MFC r313376: Fix :hexadecimal_floating_point on i386 Don't exclude i386 from LDBL_MANT_DIG == 64; it works properly in that case. While here, replace strcmp + atf_tc_fail with ATF_CHECK_MSG for 2 reasons: - Gather as many results as possible instead of failing early and not testing the rest of the cases. - Simplify logic when checking test inputs vs outputs and printing test result. Tested on: amd64, i386 --- lib/libc/tests/stdio/printfloat_test.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'lib/libc/tests') 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); -- cgit v1.1 From ad0ecc0d7e6ae464befdc0ad2954a0eb5182b0d4 Mon Sep 17 00:00:00 2001 From: ngie Date: Tue, 14 Feb 2017 04:49:24 +0000 Subject: MFC r313378,r313379: r313378: Wrap strcmp/wcscmp calls with ATF_CHECK_MSG and drop atf_tc_fail use The reasoning here was the same as what was done in r313376: - Gather as many results as possible instead of failing early and not testing the rest of the cases. - Simplify logic when checking test inputs vs outputs and printing test result. r313379: Expect :int_within_limits to fail when ptrdiff_t/*intmax_t differ in base type The %t{d,u} (ptrdiff_t) tests fail for the following reasons: - ptrdiff_t is by definition int32_t on !LP64 architectures and int64_t on LP64 architectures. - intmax_t is by definition fixed to int64_t on all architectures. - Some of the code in lib/libc/stdio/... is promoting ptrdiff_t to *intmax_t when parsing/representing the value. PR: 191674 --- lib/libc/tests/stdio/printbasic_test.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'lib/libc/tests') 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); -- cgit v1.1