HomeFreeBSD

Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile

Description

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

Details

Provenance
ngieAuthored on
Reviewer
asomers
Differential Revision
D18625: Add [initial] functional tests for sendfile(2) as lib/libc/sys/sendfile
Parents
rS343361: MFC r343086:
Branches
Unknown
Tags
Unknown