summaryrefslogtreecommitdiff
path: root/test/time
diff options
context:
space:
mode:
authorAustin Foxley <austinf@cetoncorp.com>2009-11-28 22:00:53 -0800
committerAustin Foxley <austinf@cetoncorp.com>2009-11-28 22:40:05 -0800
commit8359f22a288236613e64f2b3e96ef6e2ac2de097 (patch)
tree04967bfdadf913d1f8a70ddf5769446d963546dd /test/time
parent5418ef694ee17c698270702d927f04836706e60b (diff)
parent8739ed0a9b6597e7106f878ec159a19fe0848f23 (diff)
Merge remote branch 'origin/master' into nptl
Signed-off-by: Austin Foxley <austinf@cetoncorp.com>
Diffstat (limited to 'test/time')
-rw-r--r--test/time/Makefile.in1
-rw-r--r--test/time/tst-futimens1.c55
2 files changed, 36 insertions, 20 deletions
diff --git a/test/time/Makefile.in b/test/time/Makefile.in
index 65d814a71..05f73a45d 100644
--- a/test/time/Makefile.in
+++ b/test/time/Makefile.in
@@ -9,3 +9,4 @@ TESTS_DISABLED += tst-ftime_l
endif
CFLAGS_tst-strptime2 := -std=c99
+DODIFF_futimens1 := 1
diff --git a/test/time/tst-futimens1.c b/test/time/tst-futimens1.c
index a452de2c7..ed7f44feb 100644
--- a/test/time/tst-futimens1.c
+++ b/test/time/tst-futimens1.c
@@ -1,5 +1,5 @@
/* vi: set sw=4 ts=4: */
-/* testcase
+/* testcase for futimens(2)
* Copyright (C) 2009 Bernhard Reutner-Fischer <uClibc@uClibc.org>
* Licensed under the LGPL v2.1, see the file COPYING.LIB in this tarball.
*/
@@ -30,7 +30,16 @@ int do_test(int argc, char **argv) {
char *name;
int i, errors;
errors = argc - argc + 0;
-
+ unsigned has_stat_nsec = 0;
+ {
+ struct stat probe;
+ /* Let's attempt an educated guess if this filesystem supports
+ * nanosecond mtime. */
+ if ((!stat(".", &probe)) && probe.st_mtim.tv_nsec)
+ has_stat_nsec = 1;
+ else if ((!stat(argv[0], &probe)) && probe.st_mtim.tv_nsec)
+ has_stat_nsec = 1;
+ }
for (i=0; i < (int) (sizeof(tests)/sizeof(tests[0])); ++i) {
int err, fd;
struct stat sb;
@@ -44,19 +53,18 @@ int do_test(int argc, char **argv) {
err = futimens(fd, tests[i].ts);
if ((errno && !err) || (!errno && err)) {
err = errno;
- printf("%s: FAILED test %d (errno and return value disagree)\n",
- argv[0], i);
+ printf("FAILED test %d (errno and return value disagree)\n", i);
++errors;
} else
err = errno;
if (err != tests[i].err) {
- printf("%s: FAILED test %d (expected errno %d, got %d)\n",
- argv[0], i, tests[i].err, err);
+ printf("FAILED test %d (expected errno %d, got %d)\n",
+ i, tests[i].err, err);
++errors;
continue;
}
if (stat(name, &sb) < 0) {
- printf("%s: FAILED test %d (verification)\n", argv[0], i);
+ printf("FAILED test %d (verification)\n", i);
++errors;
continue;
} else {
@@ -65,20 +73,27 @@ int do_test(int argc, char **argv) {
tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec ||
tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec;
if (wrong) {
- ++errors;
- if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec)
- printf("%s: FAILED test %d (access time, sec: expected %ld, got %ld)\n",
- argv[0], i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec);
- if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec)
- printf("%s: FAILED test %d (access time, nsec: expected %ld, got %ld)\n",
- argv[0], i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec);
+ if (tests[i].ts[0].tv_sec != sb.st_atim.tv_sec) {
+ printf("FAILED test %d (access time, sec: expected %ld, got %ld)\n",
+ i, tests[i].ts[0].tv_sec, sb.st_atim.tv_sec);
+ ++errors;
+ }
+ if (tests[i].ts[0].tv_nsec != sb.st_atim.tv_nsec) {
+ printf("FAILED test %d (access time, nsec: expected %ld, got %ld)\n",
+ i, tests[i].ts[0].tv_nsec, sb.st_atim.tv_nsec);
+ errors += has_stat_nsec;
+ }
- if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec)
- printf("%s: FAILED test %d (modification time, sec: expected %ld, got %ld)\n",
- argv[0], i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec);
- if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec)
- printf("%s: FAILED test %d (modification time, nsec: expected %ld, got %ld)\n",
- argv[0], i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec);
+ if (tests[i].ts[1].tv_sec != sb.st_mtim.tv_sec) {
+ printf("FAILED test %d (modification time, sec: expected %ld, got %ld)\n",
+ i, tests[i].ts[1].tv_sec, sb.st_mtim.tv_sec);
+ ++errors;
+ }
+ if (tests[i].ts[1].tv_nsec != sb.st_mtim.tv_nsec) {
+ printf("FAILED test %d (modification time, nsec: expected %ld, got %ld)\n",
+ i, tests[i].ts[1].tv_nsec, sb.st_mtim.tv_nsec);
+ errors += has_stat_nsec;
+ }
}
}
}