From: Szabolcs Nagy Date: Tue, 16 Jul 2019 22:12:15 +0000 (+0000) Subject: add lseek test with large offsets X-Git-Url: http://nsz.repo.hu/git/?p=libc-test;a=commitdiff_plain;h=feee04a18f1530207297a11e76c9ed9e6f51ec45 add lseek test with large offsets --- diff --git a/src/regression/lseek-large.c b/src/regression/lseek-large.c new file mode 100644 index 0000000..6d79b2c --- /dev/null +++ b/src/regression/lseek-large.c @@ -0,0 +1,27 @@ +// lseek should work with >2G offset +#include +#include +#include +#include +#include +#include "test.h" + +#define A(c) ((c) || (t_error(#c " failed: %s\n", strerror(errno)), 0)) + +int main(void) +{ + off_t a[] = {0x7fffffff, 0x80000000, 0x80000001, 0xffffffff, 0x100000001, 0x1ffffffff, 0 }; + off_t r; + FILE *f; + int fd; + int i; + + A((f = tmpfile()) != 0); + A((fd = fileno(f)) != -1); + for (i = 0; a[i]; i++) { + r = lseek(fd, a[i], SEEK_SET); + if (r != a[i]) + t_error("lseek(fd, 0x%llx, SEEK_SET) got 0x%llx\n", (long long)a[i], (long long)r); + } + return t_status; +}