Some atf tests will help us to avoid breaking sendfile's handling of I/O errors,
here are a few basic tests to get us started.
Details
- Reviewers
markj kib glebius - Commits
- rS363377: add a few tests for sendfile.
Diff Detail
- Repository
- rS FreeBSD src repository - subversion
- Lint
Lint Passed - Unit
No Test Coverage - Build Status
Buildable 31931 Build 29482: arc lint + arc unit
Event Timeline
Thanks for doing this.
tests/sys/kern/sendfile_helper.c | ||
---|---|---|
43 | ||
48 | These can be declared static. The bools should probably be declared volatile as well, since they are accessed by multiple threads. | |
117 | The constant can be replaced with INADDR_LOOPBACK. | |
119 | It would be less fragile to allow the kernel to select an ephemeral port and then have the program get the bound port number using getsockname(). | |
130 | These two lines can be replaced by errc(1, error, "pthread_create"); | |
tests/sys/kern/sendfile_test.sh | ||
27 | I would suggest adding a brief header comment here summarizing what these tests are covering. |
tests/sys/kern/sendfile_helper.c | ||
---|---|---|
43 | $ clang-format -style=file testcase.c > testcase.c.new $ diff -u testcase.c{,.new} --- testcase.c 2020-06-24 11:45:15.287019000 -0700 +++ testcase.c.new 2020-06-24 11:45:32.647437000 -0700 @@ -1,14 +1,16 @@ #include <sys/types.h> -#include <err.h> -#include <fcntl.h> #include <sys/socket.h> -#include <netinet/in.h> +#include <sys/sysctl.h> #include <sys/uio.h> -#include <stdlib.h> -#include <string.h> -#include <unistd.h> + +#include <netinet/in.h> + +#include <err.h> #include <errno.h> +#include <fcntl.h> #include <pthread.h> -#include <sys/sysctl.h> #include <stdbool.h> #include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> |
Curious... is there a reason why this was added in addition to lib/libc/tests/sys/sendfile_test.c?
head/tests/sys/kern/sendfile_helper.c | ||
---|---|---|
103 ↗ | (On Diff #74716) | What about IPv6? |
I didn't learn of the existence of the sendfile test in libc until after I had written this new one.
head/tests/sys/kern/sendfile_helper.c | ||
---|---|---|
103 ↗ | (On Diff #74716) | My reason for writing this sendfile test was to exercise the disk I/O error paths in sendfile, because I have had to fix bugs in those error paths 3 times in the last 6 months. Also, the sendfile code is complete agnostic to whether the socket is IPv4 or IPv6, so it did not occur to me to that there was any reason to test both versions of IP. |