blob: c1af785bae32f69d0dd5b3b7730abb825fc5242a [file] [log] [blame]
Dmitry V. Levind27ccca2015-07-15 09:02:17 +00001#include <time.h>
2#include <utime.h>
3#include <errno.h>
4#include <stdio.h>
5
6static void
7print_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
14int
15main(void)
16{
17 time_t t = time(NULL);
18 struct utimbuf u = { .actime = t, .modtime = t };
19 struct tm *p = localtime(&t);
20
Dmitry V. Levinf14a8e12015-08-26 23:25:06 +000021 printf("utime(\"utime\\nfilename\", [");
Dmitry V. Levind27ccca2015-07-15 09:02:17 +000022 print_tm(p);
23 printf(", ");
24 print_tm(p);
Dmitry V. Levinf14a8e12015-08-26 23:25:06 +000025 puts("]) = -1 ENOENT (No such file or directory)");
26 puts("+++ exited with 0 +++");
Dmitry V. Levind27ccca2015-07-15 09:02:17 +000027
28 return utime("utime\nfilename", &u) == -1 && errno == ENOENT ? 0 : 77;
29}