add lseek test with large offsets
authorSzabolcs Nagy <nsz@port70.net>
Tue, 16 Jul 2019 22:12:15 +0000 (22:12 +0000)
committerSzabolcs Nagy <nsz@port70.net>
Tue, 16 Jul 2019 22:12:15 +0000 (22:12 +0000)
src/regression/lseek-large.c [new file with mode: 0644]

diff --git a/src/regression/lseek-large.c b/src/regression/lseek-large.c
new file mode 100644 (file)
index 0000000..6d79b2c
--- /dev/null
@@ -0,0 +1,27 @@
+// lseek should work with >2G offset
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#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;
+}