Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/lib/libc/c063 Fix off by one in static array acces, us...



details:   https://anonhg.NetBSD.org/src/rev/aa294f8537da
branches:  trunk
changeset: 782838:aa294f8537da
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Nov 22 14:51:19 2012 +0000

description:
Fix off by one in static array acces, use valid timestamps (ns part < 1e9),
just in case a filesystem would need to convert this to some other
representation.

diffstat:

 tests/lib/libc/c063/t_utimensat.c |  32 ++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)

diffs (74 lines):

diff -r 6df175c4ac61 -r aa294f8537da tests/lib/libc/c063/t_utimensat.c
--- a/tests/lib/libc/c063/t_utimensat.c Thu Nov 22 14:27:32 2012 +0000
+++ b/tests/lib/libc/c063/t_utimensat.c Thu Nov 22 14:51:19 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_utimensat.c,v 1.2 2012/11/19 16:07:56 martin Exp $ */
+/*     $NetBSD: t_utimensat.c,v 1.3 2012/11/22 14:51:19 martin Exp $ */
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -29,7 +29,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: t_utimensat.c,v 1.2 2012/11/19 16:07:56 martin Exp $");
+__RCSID("$NetBSD: t_utimensat.c,v 1.3 2012/11/22 14:51:19 martin Exp $");
 
 #include <atf-c.h>
 #include <errno.h>
@@ -50,8 +50,8 @@
 #define FILEERR "dir/symlink"
 
 const struct timespec tptr[] = { 
-       { 0x12345678, 0x87654321 },
-       { 0x15263748, 0x84736251 },
+       { 0x12345678, 987654321 },
+       { 0x15263748, 123456789 },
 };
 
 ATF_TC_WITH_CLEANUP(utimensat_fd);
@@ -75,10 +75,10 @@
        ATF_REQUIRE(close(dfd) == 0);
 
        ATF_REQUIRE(stat(FILE, &st) == 0);
-       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[1].tv_sec);
-       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[1].tv_nsec);
-       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[2].tv_sec);
-       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[2].tv_nsec);
+       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[0].tv_sec);
+       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[0].tv_nsec);
+       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[1].tv_sec);
+       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[1].tv_nsec);
 }
 
 ATF_TC_CLEANUP(utimensat_fd, tc)
@@ -108,10 +108,10 @@
        ATF_REQUIRE(utimensat(AT_FDCWD, BASEFILE, tptr, 0) == 0);
 
        ATF_REQUIRE(stat(BASEFILE, &st) == 0);
-       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[1].tv_sec);
-       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[1].tv_nsec);
-       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[2].tv_sec);
-       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[2].tv_nsec);
+       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[0].tv_sec);
+       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[0].tv_nsec);
+       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[1].tv_sec);
+       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[1].tv_nsec);
 }
 
 ATF_TC_CLEANUP(utimensat_fdcwd, tc)
@@ -240,10 +240,10 @@
        ATF_REQUIRE(close(dfd) == 0);
 
        ATF_REQUIRE(lstat(LINK, &st) == 0);
-       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[1].tv_sec);
-       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[1].tv_nsec);
-       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[2].tv_sec);
-       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[2].tv_nsec);
+       ATF_REQUIRE(st.st_atimespec.tv_sec == tptr[0].tv_sec);
+       ATF_REQUIRE(st.st_atimespec.tv_nsec == tptr[0].tv_nsec);
+       ATF_REQUIRE(st.st_ctimespec.tv_sec == tptr[1].tv_sec);
+       ATF_REQUIRE(st.st_ctimespec.tv_nsec == tptr[1].tv_nsec);
 }
 
 ATF_TC_CLEANUP(utimensat_fdlink, tc)



Home | Main Index | Thread Index | Old Index