Merge branch 'rebase-p-first-parent' into devel
[git/mingw/j6t.git] / test-fstat.c
blob9af9653dbaa1195a55707141fb69ca3257661bd4
1 #include "git-compat-util.h"
2 #include <stdio.h>
3 #include <string.h>
4 #include <unistd.h>
5 #include <sys/types.h>
6 #include <sys/stat.h>
7 #include <fcntl.h>
8 #include <windows.h>
10 #define FILENAME "stat-test.tmp"
12 int main(int argc, char**argv)
14 struct stat st1, st2;
16 memset(&st1, 0, sizeof(st1));
17 memset(&st2, 0, sizeof(st2));
19 unlink(FILENAME);
20 int fd = open(FILENAME, O_CREAT|O_RDWR|O_TRUNC, S_IRWXU);
21 if (fd == -1)
23 perror("Cannot open " FILENAME);
24 return -1;
26 Sleep(1000); /* It is IMPORTANT! */
27 write(fd, "test\n", 5);
28 fstat(fd, &st1);
29 close(fd);
30 stat(FILENAME, &st2);
31 if (st1.st_mtime == st2.st_mtime)
32 printf("fstat is OK\n");
33 else
34 printf("fstat is broken\n");
35 return 0;