1 // commit 3af2edee150484940916eba1984f78c3b965dd05 2014-02-07
2 // fix ftello result for append streams with unflushed output
11 #define ASSERT(c) do { \
14 t_error("%s failed (errno: %s)\n", #c, strerror(errno)); \
19 char tmp
[] = "/tmp/testsuite-XXXXXX";
24 ASSERT((fd
= mkstemp(tmp
)) > 2);
25 ASSERT(write(fd
, "abcd", 4) == 4);
26 ASSERT(close(fd
) == 0);
28 ASSERT((fd
= open(tmp
, O_WRONLY
)) > 2);
29 ASSERT(f
= fdopen(fd
, "a"));
31 ASSERT(fwrite("efg", 1, 3, f
) == 3);
32 ASSERT((off
= ftello(f
)) != -1);
34 t_error("ftello is broken before flush: got %lld, want 7\n", (long long)off
);
35 ASSERT(fflush(f
) == 0);
36 ASSERT((off
= ftello(f
)) != -1);
38 t_error("ftello is broken after flush: got %lld, want 7\n", (long long)off
);
39 ASSERT(fclose(f
) == 0);
42 ASSERT(unlink(tmp
) == 0);