From ed3d9b6e75a3c3f3a397e3adb892f9b3e6d4de06 Mon Sep 17 00:00:00 2001 From: Pawel Jakub Dawidek Date: Thu, 19 Apr 2007 06:01:08 +0000 Subject: [PATCH] Add more tests to verify last sendfile(2) breakage: test sending more than a page size and nbytes=0. --- tools/regression/sockets/sendfile/sendfile.c | 41 ++++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/tools/regression/sockets/sendfile/sendfile.c b/tools/regression/sockets/sendfile/sendfile.c index cc7b48bfaf83..f76e705206df 100644 --- a/tools/regression/sockets/sendfile/sendfile.c +++ b/tools/regression/sockets/sendfile/sendfile.c @@ -28,6 +28,7 @@ #include #include +#include #include @@ -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); }