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.
This commit is contained in:
Greg V 2018-07-10 13:57:12 +03:00
parent 63a2180b40
commit 8cc4de5fc9
2 changed files with 9 additions and 2 deletions

View 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);

View 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