test: use simple portable sendfile
authorGreg V <greg@unrelenting.technology>
Tue, 10 Jul 2018 10:57:12 +0000 (13:57 +0300)
committerGreg V <greg@unrelenting.technology>
Mon, 16 Jul 2018 10:48:54 +0000 (13:48 +0300)
There's no need for high performance in these little tests, so instead of
supporting various platform-specific sendfile() implementations, just use a local read-write function.

test/litest.c
test/litest.h

index 7c9cf00..ae4c160 100644 (file)
@@ -42,7 +42,6 @@
 #include "linux/input.h"
 #include <sys/ptrace.h>
 #include <sys/resource.h>
-#include <sys/sendfile.h>
 #include <sys/timerfd.h>
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -1229,7 +1228,7 @@ litest_copy_file(const char *dest, const char *src, const char *header)
                                 src,
                                 strerror(errno));
        /* lazy, just check for error and empty file copy */
-       litest_assert_int_gt(sendfile(out, in, NULL, 40960), 0);
+       litest_assert_int_gt(litest_send_file(out, in), 0);
        close(out);
        close(in);
 
index 9c42c03..6d332f6 100644 (file)
@@ -1077,6 +1077,14 @@ litest_touchpad_is_external(struct litest_device *dev)
        return is_external;
 }
 
+static inline int
+litest_send_file(int sock, int fd)
+{
+       char buf[40960];
+       int n = read(fd, buf, 40960);
+       return write(sock, buf, n);
+}
+
 #undef ck_assert_double_eq
 #undef ck_assert_double_ne
 #undef ck_assert_double_lt