#include <stdio.h>
#include <err.h>
#include <stdlib.h>
#include <sys/sysmacros.h>
int
main(void)
{
FILE *f;
size_t i;
int ret = EXIT_SUCCESS;
static off_t offsets[] = {
23,
0xa0000,
0x100000,
0x7fffffffULL,
0xc0000000ULL,
0x200005432ULL
};
f = tmpfile();
if (f == NULL) {
err(EXIT_FAILURE, "TEST FAILED: failed to create "
"temporary file");
}
for (i = 0; i < ARRAY_SIZE(offsets); i++) {
off_t ftret;
if (fseeko(f, offsets[i], SEEK_SET) != 0) {
warn("TEST FAILED: failed to seek to %lld",
(long long)offsets[i]);
ret = EXIT_FAILURE;
}
ftret = ftello(f);
if (ftret == -1) {
warn("TEST FAILED: failed to get stream position at "
"%lld", (long long)offsets[i]);
ret = EXIT_FAILURE;
}
if (ftret != offsets[i]) {
warnx("TEST FAILED: stream position mismatch: expected "
"%lld, found %lld", (long long)offsets[i],
(long long)ftret);
ret = EXIT_FAILURE;
}
}
return (ret);
}