| 1 |
// RUN: %clangxx -O0 -g %s -o %t && %run %t 2>&1 | FileCheck %s |
| 2 |
// |
| 3 |
// UNSUPPORTED: darwin, target={{.*(linux|solaris).*}} |
| 4 |
|
| 5 |
#include <assert.h> |
| 6 |
#include <inttypes.h> |
| 7 |
#include <stdio.h> |
| 8 |
|
| 9 |
int main(void) { |
| 10 |
printf("fseek\n"); |
| 11 |
|
| 12 |
FILE *fp = fopen("/etc/fstab", "r"); |
| 13 |
assert(fp); |
| 14 |
|
| 15 |
int rv = fseek(fp, 10, SEEK_SET); |
| 16 |
assert(!rv); |
| 17 |
|
| 18 |
printf("position: %ld\n", ftell(fp)); |
| 19 |
|
| 20 |
rewind(fp); |
| 21 |
|
| 22 |
printf("position: %ld\n", ftell(fp)); |
| 23 |
|
| 24 |
rv = fseeko(fp, 15, SEEK_SET); |
| 25 |
assert(!rv); |
| 26 |
|
| 27 |
printf("position: %" PRIuMAX "\n", (uintmax_t)ftello(fp)); |
| 28 |
|
| 29 |
fpos_t pos; |
| 30 |
rv = fgetpos(fp, &pos); |
| 31 |
assert(!rv); |
| 32 |
|
| 33 |
rewind(fp); |
| 34 |
|
| 35 |
printf("position: %" PRIuMAX "\n", (uintmax_t)ftello(fp)); |
| 36 |
|
| 37 |
rv = fsetpos(fp, &pos); |
| 38 |
assert(!rv); |
| 39 |
|
| 40 |
printf("position: %" PRIuMAX "\n", (uintmax_t)ftello(fp)); |
| 41 |
|
| 42 |
rv = fclose(fp); |
| 43 |
assert(!rv); |
| 44 |
|
| 45 |
// CHECK: fseek |
| 46 |
// CHECK: position: 10 |
| 47 |
// CHECK: position: 0 |
| 48 |
// CHECK: position: 15 |
| 49 |
// CHECK: position: 0 |
| 50 |
// CHECK: position: 15 |
| 51 |
|
| 52 |
return 0; |
| 53 |
} |