xref: /relibc/tests/unistd/fsync.c (revision be35961d82cd98f2a2e61c4f1869271b9f4af571)
1 #include <unistd.h>
2 #include <fcntl.h>
3 #include <stdio.h>
4 #include <stdlib.h>
5 
6 #include "test_helpers.h"
7 
8 int main(void) {
9     int fd = open("example_dir/1-never-gonna-give-you-up", O_RDWR);
10     ERROR_IF(open, fd, == -1);
11     UNEXP_IF(open, fd, < 0);
12 
13     int status = fsync(fd);
14     ERROR_IF(fsync, status, == -1);
15     UNEXP_IF(fsync, status, != 0);
16 
17     int c = close(fd);
18     ERROR_IF(close, c, == -1);
19     UNEXP_IF(close, c, != 0);
20 }
21