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.
This commit is contained in:
parent
25e685524c
commit
13981c9510
@ -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 @@ __RCSID("$NetBSD: t_utimensat.c,v 1.2 2012/11/19 16:07:56 martin Exp $");
|
||||
#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_TC_BODY(utimensat_fd, tc)
|
||||
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_TC_BODY(utimensat_fdcwd, tc)
|
||||
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_TC_BODY(utimensat_fdlink, tc)
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user