summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/db/hash/hash_page.c13
-rw-r--r--lib/libc/gen/nice.336
-rw-r--r--lib/libc/gen/nice.c16
-rw-r--r--lib/libc/string/memmem.322
-rw-r--r--lib/libc/string/memmem.c6
-rw-r--r--lib/libc/sys/recv.255
-rw-r--r--lib/libc/tests/Makefile3
-rw-r--r--lib/libc/tests/Makefile.netbsd-tests6
-rw-r--r--lib/libc/tests/c063/Makefile5
-rw-r--r--lib/libc/tests/db/Makefile8
-rw-r--r--lib/libc/tests/gen/Makefile14
-rw-r--r--lib/libc/tests/gen/execve/Makefile6
-rw-r--r--lib/libc/tests/gen/posix_spawn/Makefile6
-rw-r--r--lib/libc/tests/hash/Makefile8
-rw-r--r--lib/libc/tests/inet/Makefile5
-rw-r--r--lib/libc/tests/locale/Makefile2
-rw-r--r--lib/libc/tests/net/Makefile2
-rw-r--r--lib/libc/tests/net/getaddrinfo/Makefile4
-rw-r--r--lib/libc/tests/regex/Makefile2
-rw-r--r--lib/libc/tests/rpc/Makefile1
-rw-r--r--lib/libc/tests/setjmp/Makefile4
-rw-r--r--lib/libc/tests/ssp/Makefile6
-rw-r--r--lib/libc/tests/stdio/Makefile5
-rw-r--r--lib/libc/tests/stdio/open_memstream2_test.c (renamed from lib/libc/tests/stdio/open_memstream_test.c)0
-rw-r--r--lib/libc/tests/stdio/printbasic_test.c22
-rw-r--r--lib/libc/tests/stdio/printfloat_test.c19
-rw-r--r--lib/libc/tests/stdlib/Makefile10
-rw-r--r--lib/libc/tests/string/Makefile2
-rw-r--r--lib/libc/tests/sys/Makefile13
-rw-r--r--lib/libc/tests/sys/mlock_helper.c114
-rw-r--r--lib/libc/tests/termios/Makefile2
-rw-r--r--lib/libc/tests/time/Makefile2
-rw-r--r--lib/libc/tests/tls/Makefile1
-rw-r--r--lib/libc/tests/tls/dso/Makefile1
-rw-r--r--lib/libc/tests/ttyio/Makefile2
35 files changed, 262 insertions, 161 deletions
diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c
index 8040419..f9a7289 100644
--- a/lib/libc/db/hash/hash_page.c
+++ b/lib/libc/db/hash/hash_page.c
@@ -572,7 +572,9 @@ __get_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_disk,
int
__put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
{
- int fd, page, size, wsize;
+ int fd, page, size;
+ ssize_t wsize;
+ char pbuf[MAX_BSIZE];
size = hashp->BSIZE;
if ((hashp->fp == -1) && open_temp(hashp))
@@ -582,15 +584,18 @@ __put_page(HTAB *hashp, char *p, u_int32_t bucket, int is_bucket, int is_bitmap)
if (hashp->LORDER != BYTE_ORDER) {
int i, max;
+ memcpy(pbuf, p, size);
if (is_bitmap) {
max = hashp->BSIZE >> 2; /* divide by 4 */
for (i = 0; i < max; i++)
- M_32_SWAP(((int *)p)[i]);
+ M_32_SWAP(((int *)pbuf)[i]);
} else {
- max = ((u_int16_t *)p)[0] + 2;
+ uint16_t *bp = (uint16_t *)(void *)pbuf;
+ max = bp[0] + 2;
for (i = 0; i <= max; i++)
- M_16_SWAP(((u_int16_t *)p)[i]);
+ M_16_SWAP(bp[i]);
}
+ p = pbuf;
}
if (is_bucket)
page = BUCKET_TO_PAGE(bucket);
diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3
index 9c39b78..8ce13af 100644
--- a/lib/libc/gen/nice.3
+++ b/lib/libc/gen/nice.3
@@ -28,7 +28,7 @@
.\" @(#)nice.3 8.1 (Berkeley) 6/4/93
.\" $FreeBSD$
.\"
-.Dd June 4, 1993
+.Dd February 28, 2015
.Dt NICE 3
.Os
.Sh NAME
@@ -48,20 +48,48 @@ This interface is obsoleted by
.Pp
The
.Fn nice
-function obtains the scheduling priority of the process
-from the system and sets it to the priority value specified in
-.Fa incr .
+function adds
+.Fa incr
+to the scheduling priority of the process.
The priority is a value in the range -20 to 20.
The default priority is 0; lower priorities cause more favorable scheduling.
Only the super-user may lower priorities.
.Pp
Children inherit the priority of their parent processes via
.Xr fork 2 .
+.Sh RETURN VALUES
+Upon successful completion,
+.Fn nice
+returns 0, and
+.Va errno
+is unchanged.
+Otherwise, \-1 is returned, the process' nice value is not changed, and
+.Va errno
+is set to indicate the error.
+.Sh ERRORS
+The
+.Fn nice
+function will fail if:
+.Bl -tag -width Er
+.It Bq Er EPERM
+The
+.Fa incr
+argument is negative and the caller does not have appropriate privileges.
+.El
.Sh SEE ALSO
.Xr nice 1 ,
.Xr fork 2 ,
.Xr setpriority 2 ,
.Xr renice 8
+.Sh STANDARDS
+The
+.Fn nice
+function conforms to
+.St -p1003.1-2008
+except for the return value.
+This implementation returns 0 upon successful completion but
+the standard requires returning the new nice value,
+which could be \-1.
.Sh HISTORY
A
.Fn nice
diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c
index e8375e8..ba9524b 100644
--- a/lib/libc/gen/nice.c
+++ b/lib/libc/gen/nice.c
@@ -43,14 +43,20 @@ __FBSDID("$FreeBSD$");
* Backwards compatible nice.
*/
int
-nice(incr)
- int incr;
+nice(int incr)
{
- int prio;
+ int saverrno, prio;
+ saverrno = errno;
errno = 0;
prio = getpriority(PRIO_PROCESS, 0);
- if (prio == -1 && errno)
+ if (prio == -1 && errno != 0)
return (-1);
- return (setpriority(PRIO_PROCESS, 0, prio + incr));
+ if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) {
+ if (errno == EACCES)
+ errno = EPERM;
+ return (-1);
+ }
+ errno = saverrno;
+ return (0);
}
diff --git a/lib/libc/string/memmem.3 b/lib/libc/string/memmem.3
index 73c267c..fb341f4 100644
--- a/lib/libc/string/memmem.3
+++ b/lib/libc/string/memmem.3
@@ -26,7 +26,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd August 24, 2005
+.Dd May 26, 2015
.Dt MEMMEM 3
.Os
.Sh NAME
@@ -51,14 +51,12 @@ in the byte string
.Fa big .
.Sh RETURN VALUES
If
-.Fa big_len
-is smaller than
-.Fa little_len ,
-if
.Fa little_len
-is 0, if
-.Fa big_len
-is 0 or if
+is zero
+.Fa big
+is returned (that is, an empty little is deemed to match at the beginning of
+big);
+if
.Fa little
occurs nowhere in
.Fa big ,
@@ -84,3 +82,11 @@ function first appeared in
.Sh BUGS
This function was broken in Linux libc up to and including version 5.0.9
and in GNU libc prior to version 2.1.
+Prior to
+.Fx 11.0
+.Nm
+returned
+.Dv NULL
+when
+.Fa little_len
+equals 0.
diff --git a/lib/libc/string/memmem.c b/lib/libc/string/memmem.c
index 72e6517..3fd05df 100644
--- a/lib/libc/string/memmem.c
+++ b/lib/libc/string/memmem.c
@@ -42,9 +42,9 @@ memmem(const void *l, size_t l_len, const void *s, size_t s_len)
const char *cl = (const char *)l;
const char *cs = (const char *)s;
- /* we need something to compare */
- if (l_len == 0 || s_len == 0)
- return NULL;
+ /* empty "s" matches the beginning of "l" */
+ if (s_len == 0)
+ return (void *)cl;
/* "s" must be smaller or equal to "l" */
if (l_len < s_len)
diff --git a/lib/libc/sys/recv.2 b/lib/libc/sys/recv.2
index e0a1f04..7ad7aa7 100644
--- a/lib/libc/sys/recv.2
+++ b/lib/libc/sys/recv.2
@@ -28,7 +28,7 @@
.\" @(#)recv.2 8.3 (Berkeley) 2/21/94
.\" $FreeBSD$
.\"
-.Dd March 19, 2013
+.Dd February 3, 2017
.Dt RECV 2
.Os
.Sh NAME
@@ -218,57 +218,10 @@ with no data buffer provided immediately after an
.Fn accept
system call.
.Pp
-Open file descriptors are now passed as ancillary data for
+With
.Dv AF_UNIX
-domain sockets, with
-.Fa cmsg_level
-set to
-.Dv SOL_SOCKET
-and
-.Fa cmsg_type
-set to
-.Dv SCM_RIGHTS .
-The close-on-exec flag on received descriptors is set according to the
-.Dv MSG_CMSG_CLOEXEC
-flag passed to
-.Fn recvmsg .
-.Pp
-Process credentials can also be passed as ancillary data for
-.Dv AF_UNIX
-domain sockets using a
-.Fa cmsg_type
-of
-.Dv SCM_CREDS .
-In this case,
-.Fa cmsg_data
-should be a structure of type
-.Fa cmsgcred ,
-which is defined in
-.In sys/socket.h
-as follows:
-.Bd -literal
-struct cmsgcred {
- pid_t cmcred_pid; /* PID of sending process */
- uid_t cmcred_uid; /* real UID of sending process */
- uid_t cmcred_euid; /* effective UID of sending process */
- gid_t cmcred_gid; /* real GID of sending process */
- short cmcred_ngroups; /* number or groups */
- gid_t cmcred_groups[CMGROUP_MAX]; /* groups */
-};
-.Ed
-.Pp
-If a sender supplies ancillary data with enough space for the above struct
-tagged as
-.Dv SCM_CREDS
-control message type to the
-.Fn sendmsg
-system call, then kernel will fill in the credential information of the
-sending process and deliver it to the receiver.
-Since receiver usually has no control over a sender, this method of retrieving
-credential information isn't reliable.
-For reliable retrieval of remote side credentials it is advised to use the
-.Dv LOCAL_CREDS
-socket option on the receiving socket.
+domain sockets, ancillary data can be used to pass file descriptors and
+process credentials.
See
.Xr unix 4
for details.
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
OpenPOWER on IntegriCloud