diff options
author | pjd <pjd@FreeBSD.org> | 2007-04-19 06:01:08 +0000 |
---|---|---|
committer | pjd <pjd@FreeBSD.org> | 2007-04-19 06:01:08 +0000 |
commit | f52c36ec467b54656cd520b3646dd45197cd0125 (patch) | |
tree | bb0a8392773904bf60cddf312dcbeead7c52703e /tools | |
parent | e728588aa7cb67001986ab4315f45661a326b60f (diff) | |
download | FreeBSD-src-f52c36ec467b54656cd520b3646dd45197cd0125.zip FreeBSD-src-f52c36ec467b54656cd520b3646dd45197cd0125.tar.gz |
Add more tests to verify last sendfile(2) breakage: test sending more
than a page size and nbytes=0.
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/sockets/sendfile/sendfile.c | 41 |
1 files changed, 38 insertions, 3 deletions
diff --git a/tools/regression/sockets/sendfile/sendfile.c b/tools/regression/sockets/sendfile/sendfile.c index cc7b48b..f76e705 100644 --- a/tools/regression/sockets/sendfile/sendfile.c +++ b/tools/regression/sockets/sendfile/sendfile.c @@ -28,6 +28,7 @@ #include <sys/types.h> #include <sys/socket.h> +#include <sys/stat.h> #include <netinet/in.h> @@ -47,7 +48,7 @@ #define TEST_PORT 5678 #define TEST_MAGIC 0x4440f7bb -#define TEST_PAGES 3 +#define TEST_PAGES 4 #define TEST_SECONDS 30 struct test_header { @@ -223,8 +224,18 @@ send_test(int connect_socket, u_int32_t header_length, u_int32_t offset, 0) < 0) err(-1, "sendfile"); - if (off != length) - errx(-1, "sendfile: off %llu", off); + if (length == 0) { + struct stat sb; + + if (fstat(file_fd, &sb) < 0) + err(-1, "fstat"); + length = sb.st_size; + } + + if (off != length) { + errx(-1, "sendfile: off(%llu) != length(%llu)", off, + (unsigned long long)length); + } if (header != NULL) free(header); @@ -265,6 +276,30 @@ run_parent(void) sleep(1); + connect_socket = new_test_socket(); + send_test(connect_socket, 0, 0, 2 * getpagesize()); + close(connect_socket); + + sleep(1); + + connect_socket = new_test_socket(); + send_test(connect_socket, 0, 0, 0); + close(connect_socket); + + sleep(1); + + connect_socket = new_test_socket(); + send_test(connect_socket, 0, getpagesize(), 0); + close(connect_socket); + + sleep(1); + + connect_socket = new_test_socket(); + send_test(connect_socket, 0, 2 * getpagesize(), 0); + close(connect_socket); + + sleep(1); + (void)kill(child_pid, SIGKILL); } |