]> granicus.if.org Git - strace/blob - tests/utime.c
tests: convert several tests from match_grep to match_diff
[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         puts("]) = -1 ENOENT (No such file or directory)");
26         puts("+++ exited with 0 +++");
27
28         return utime("utime\nfilename", &u) == -1 && errno == ENOENT ? 0 : 77;
29 }