]> granicus.if.org Git - strace/blob - tests/utime.c
tests: add utime.test
[strace] / tests / utime.c
1 #include <time.h>
2 #include <utime.h>
3 #include <errno.h>
4 #include <stdio.h>
5
6 static void
7 print_tm(struct tm *p)
8 {
9         printf("%02d/%02d/%02d-%02d:%02d:%02d",
10                p->tm_year + 1900, p->tm_mon + 1, p->tm_mday,
11                p->tm_hour, p->tm_min, p->tm_sec);
12 }
13
14 int
15 main(void)
16 {
17         time_t t = time(NULL);
18         struct utimbuf u = { .actime = t, .modtime = t };
19         struct tm *p = localtime(&t);
20
21         printf("utime\\(\"utime\\\\nfilename\", \\[");
22         print_tm(p);
23         printf(", ");
24         print_tm(p);
25         printf("\\]\\) += -1 ENOENT .*\n");
26
27         return utime("utime\nfilename", &u) == -1 && errno == ENOENT ? 0 : 77;
28 }