opnsense-src/lib/libc/tests/sys/Makefile
Enji Cooper b29e142648 Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile
These testcases exercise a number of functional requirements for sendfile(2).

The testcases use IPv4 and IPv6 domain sockets with TCP, and were confirmed
functional on UFS and ZFS. UDP address family sockets cannot be used per the
sendfile(2) contract, thus using UDP sockets is outside the scope of
testing the syscall in positive cases. As seen in
`:s_negative_udp_socket_test`, UDP is used to test the sendfile(2) contract
to ensure that EINVAL is returned by sendfile(2).

The testcases added explicitly avoid testing out `SF_SYNC` due to the
complexity of verifying that support. However, this is a good next logical
item to verify.

The `hdtr_positive*` testcases work to a certain degree (the header
testcases pass), but the trailer testcases do not work (it is an expected
failure). In particular, the value received by the mock server doesn't match
the expected value, and instead looks something like the following (using
python array notation):

`trailer[:]message[1:]`

instead of:

`message[:]trailer[:]`

This makes me think there's a buffer overrun issue or problem with the
offset somewhere in the sendfile(2) system call, but I need to do some
other testing first to verify that the code is indeed sane, and my
assumptions/code isn't buggy.

The `sbytes_negative` testcases that check `sbytes` being set to an
invalid value resulting in `EFAULT` fails today as the other change
(which checks `copyout(9)`) has not been committed [1]. Thus, it
should remain an expected failure (see bug 232210 for more details
on this item).

Next steps for testing sendfile(2):
1. Fix the header/trailer testcases so that they pass.
2. Setup if_tap interface and test with it, instead of using "localhost", per
   @asomers's suggestion.
3. Handle short recv(2)'s in `server_cat(..)`.
4. Add `SF_SYNC` support.
5. Add some more negative tests outside the scope of the functional contract.

MFC after:	1 month
Reviewed by:	asomers
Approved by:	emaste (mentor)
PR: 		232210
Sponsored by:   Netflix, Inc
Differential Revision: https://reviews.freebsd.org/D18625
2019-01-23 22:00:17 +00:00

102 lines
2.9 KiB
Makefile

# $FreeBSD$
PACKAGE= tests
.include <bsd.own.mk>
.if ${MACHINE_CPUARCH} != "aarch64" && ${MACHINE_CPUARCH} != "riscv"
ATF_TESTS_C+= brk_test
.endif
ATF_TESTS_C+= queue_test
ATF_TESTS_C+= sendfile_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+= clock_nanosleep_test
NETBSD_ATF_TESTS_C+= connect_test
NETBSD_ATF_TESTS_C+= dup_test
NETBSD_ATF_TESTS_C+= fsync_test
NETBSD_ATF_TESTS_C+= getcontext_test
NETBSD_ATF_TESTS_C+= getgroups_test
NETBSD_ATF_TESTS_C+= getitimer_test
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
NETBSD_ATF_TESTS_C+= kill_test
NETBSD_ATF_TESTS_C+= link_test
NETBSD_ATF_TESTS_C+= listen_test
NETBSD_ATF_TESTS_C+= mincore_test
NETBSD_ATF_TESTS_C+= mkdir_test
NETBSD_ATF_TESTS_C+= mkfifo_test
NETBSD_ATF_TESTS_C+= mknod_test
NETBSD_ATF_TESTS_C+= mlock_test
NETBSD_ATF_TESTS_C+= mmap_test
NETBSD_ATF_TESTS_C+= mprotect_test
NETBSD_ATF_TESTS_C+= msgctl_test
NETBSD_ATF_TESTS_C+= msgget_test
NETBSD_ATF_TESTS_C+= msgrcv_test
NETBSD_ATF_TESTS_C+= msgsnd_test
NETBSD_ATF_TESTS_C+= msync_test
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
NETBSD_ATF_TESTS_C+= setuid_test
NETBSD_ATF_TESTS_C+= sigaction_test
NETBSD_ATF_TESTS_C+= sigqueue_test
NETBSD_ATF_TESTS_C+= sigtimedwait_test
NETBSD_ATF_TESTS_C+= socketpair_test
NETBSD_ATF_TESTS_C+= stat_test
NETBSD_ATF_TESTS_C+= timer_create_test
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
CSTD?= c99
LIBADD.getpid_test+= pthread
LIBADD.timer_create_test+= rt
.include "../Makefile.netbsd-tests"
SRCS.mlock_test+= mlock_helper.c
SRCS.setrlimit_test+= mlock_helper.c
.if ${COMPILER_TYPE} == "gcc"
WARNS?= 3
.else
WARNS?= 4
.endif
FILESGROUPS+= truncate_test_FILES
truncate_test_FILES= truncate_test.root_owned
truncate_test_FILESDIR= ${TESTSDIR}
truncate_test_FILESMODE= 0600
truncate_test_FILESOWN= root
truncate_test_FILESGRP= wheel
truncate_test_FILESPACKAGE= ${PACKAGE}
CLEANFILES= truncate_test.root_owned
truncate_test.root_owned:
dd if=/dev/null bs=1 count=1 of=${.TARGET} status=none
.include <bsd.test.mk>