From 8cc4de5fc90fbcf5675f7f5bba9a87cba19b368b Mon Sep 17 00:00:00 2001 From: Greg V Date: Tue, 10 Jul 2018 13:57:12 +0300 Subject: [PATCH] test: use simple portable sendfile 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 | 3 +-- test/litest.h | 8 ++++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/test/litest.c b/test/litest.c index 7c9cf00..ae4c160 100644 --- a/test/litest.c +++ b/test/litest.c @@ -42,7 +42,6 @@ #include "linux/input.h" #include #include -#include #include #include #include @@ -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); diff --git a/test/litest.h b/test/litest.h index 9c42c03..6d332f6 100644 --- a/test/litest.h +++ b/test/litest.h @@ -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 -- 2.7.4