Page MenuHomeFreeBSD

Add a few atf tests for sendfile, with and without I/O errors.
Needs ReviewPublic

Authored by chs on Wed, Jun 24, 6:08 PM.

Details

Reviewers
markj
kib
glebius
Summary

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.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 31931
Build 29482: arc lint + arc unit

Event Timeline

chs created this revision.Wed, Jun 24, 6:08 PM
chs requested review of this revision.Wed, Jun 24, 6:08 PM
markj added a subscriber: cem.Wed, Jun 24, 6:17 PM

Thanks for doing this.

tests/sys/kern/sendfile_helper.c
43

These are not sorted properly. sys/types.h should come first, followed by the rest of sys/*, followed by user headers sorted alphabetically.

@cem is this a useful test case for D25428?

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.

cem added inline comments.Wed, Jun 24, 6:47 PM
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>