diff options
author | ngie <ngie@FreeBSD.org> | 2017-02-12 09:24:18 +0000 |
---|---|---|
committer | ngie <ngie@FreeBSD.org> | 2017-02-12 09:24:18 +0000 |
commit | 78e3a559e196fc51e69e57f5434cd3ca9bd767c7 (patch) | |
tree | fb4cbb88c546d7782a163e272dfc13fb5f0f726c /contrib/netbsd-tests/fs/vfs/t_vnops.c | |
parent | 3f18b64fed139907ee6e58712c75b95adb2173ee (diff) | |
download | FreeBSD-src-78e3a559e196fc51e69e57f5434cd3ca9bd767c7.zip FreeBSD-src-78e3a559e196fc51e69e57f5434cd3ca9bd767c7.tar.gz |
MFC r312008:
Upgrade NetBSD tests to 01.11.2017_23.20 snapshot
This contains some new testcases in /usr/tests/...:
- .../lib/libc
- .../lib/libthr
- .../lib/msun
- .../sys/kern
Tested on: amd64, i386
Diffstat (limited to 'contrib/netbsd-tests/fs/vfs/t_vnops.c')
-rw-r--r-- | contrib/netbsd-tests/fs/vfs/t_vnops.c | 100 |
1 files changed, 57 insertions, 43 deletions
diff --git a/contrib/netbsd-tests/fs/vfs/t_vnops.c b/contrib/netbsd-tests/fs/vfs/t_vnops.c index 08203dd..978fadb 100644 --- a/contrib/netbsd-tests/fs/vfs/t_vnops.c +++ b/contrib/netbsd-tests/fs/vfs/t_vnops.c @@ -1,4 +1,4 @@ -/* $NetBSD: t_vnops.c,v 1.55 2016/01/28 10:10:09 martin Exp $ */ +/* $NetBSD: t_vnops.c,v 1.58 2016/08/29 02:31:46 kre Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -28,6 +28,7 @@ #include <sys/stat.h> #include <sys/statvfs.h> +#include <sys/time.h> #include <assert.h> #include <atf-c.h> @@ -55,10 +56,10 @@ atf_tc_skip("symlinks not supported by file system") static char * -md(char *buf, const char *base, const char *tail) +md(char *buf, size_t buflen, const char *base, const char *tail) { - sprintf(buf, "%s/%s", base, tail); + snprintf(buf, buflen, "%s/%s", base, tail); return buf; } @@ -69,11 +70,11 @@ lookup_simple(const atf_tc_t *tc, const char *mountpath) struct stat sb1, sb2; strcpy(final, mountpath); - sprintf(pb, "%s/../%s", mountpath, basename(final)); + snprintf(pb, sizeof(pb), "%s/../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); - sprintf(pb, "%s/./../%s", mountpath, basename(final)); + snprintf(pb, sizeof(pb), "%s/./../%s", mountpath, basename(final)); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); @@ -85,22 +86,38 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath) { char pb[MAXPATHLEN]; struct stat sb1, sb2; + struct timespec atplus1, onesec; USES_DIRS; - if (FSTYPE_UDF(tc)) - atf_tc_expect_fail("PR kern/49033"); - - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb1) == -1) atf_tc_fail_errno("stat 1"); - sprintf(pb, "%s/./dir/../././dir/.", mountpath); + snprintf(pb, sizeof(pb), "%s/./dir/../././dir/.", mountpath); if (rump_sys_stat(pb, &sb2) == -1) atf_tc_fail_errno("stat 2"); + /* + * The lookup is permitted to modify the access time of + * any directories searched - such a directory is the + * subject of this test. Any difference should cause + * the 2nd lookup atime tp be >= the first, if it is ==, all is + * OK (atime is not required to be modified by the search, or + * both references may happen within the came clock tick), if the + * 2nd lookup atime is > the first, but not "too much" greater, + * just set it back, so the memcmp just below succeeds + * (assuming all else is OK). + */ + onesec.tv_sec = 1; + onesec.tv_nsec = 0; + timespecadd(&sb1.st_atimespec, &onesec, &atplus1); + if (timespeccmp(&sb2.st_atimespec, &sb1.st_atimespec, >) && + timespeccmp(&sb2.st_atimespec, &atplus1, <)) + sb2.st_atimespec = sb1.st_atimespec; + if (memcmp(&sb1, &sb2, sizeof(sb1)) != 0) { printf("what\tsb1\t\tsb2\n"); @@ -133,9 +150,6 @@ lookup_complex(const atf_tc_t *tc, const char *mountpath) atf_tc_fail("stat results differ, see ouput for more details"); } - if (FSTYPE_UDF(tc)) - atf_tc_fail("random failure of PR kern/49033 " - "did not happen this time"); } static void @@ -147,7 +161,7 @@ dir_simple(const atf_tc_t *tc, const char *mountpath) USES_DIRS; /* check we can create directories */ - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); if (rump_sys_stat(pb, &sb) == -1) @@ -169,11 +183,11 @@ dir_notempty(const atf_tc_t *tc, const char *mountpath) USES_DIRS; /* check we can create directories */ - sprintf(pb, "%s/dir", mountpath); + snprintf(pb, sizeof(pb), "%s/dir", mountpath); if (rump_sys_mkdir(pb, 0777) == -1) atf_tc_fail_errno("mkdir"); - sprintf(pb2, "%s/dir/file", mountpath); + snprintf(pb2, sizeof(pb2), "%s/dir/file", mountpath); fd = rump_sys_open(pb2, O_RDWR | O_CREAT, 0777); if (fd == -1) atf_tc_fail_errno("create file"); @@ -205,9 +219,9 @@ dir_rmdirdotdot(const atf_tc_t *tc, const char *mp) RL(rump_sys_mkdir("subtest", 0777)); RL(rump_sys_chdir("subtest")); - md(pb, mp, "test/subtest"); + md(pb, sizeof(pb), mp, "test/subtest"); RL(rump_sys_rmdir(pb)); - md(pb, mp, "test"); + md(pb, sizeof(pb), mp, "test"); RL(rump_sys_rmdir(pb)); if (FSTYPE_NFS(tc)) @@ -225,7 +239,7 @@ checkfile(const char *path, struct stat *refp) struct stat sb; static int n = 1; - md(buf, path, "file"); + md(buf, sizeof(buf), path, "file"); if (rump_sys_stat(buf, &sb) == -1) atf_tc_fail_errno("cannot stat file %d (%s)", n, buf); if (memcmp(&sb, refp, sizeof(sb)) != 0) @@ -244,18 +258,18 @@ rename_dir(const atf_tc_t *tc, const char *mp) USES_DIRS; - md(pb1, mp, "dir1"); + md(pb1, sizeof(pb1), mp, "dir1"); if (rump_sys_mkdir(pb1, 0777) == -1) atf_tc_fail_errno("mkdir 1"); - md(pb2, mp, "dir2"); + md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 2"); - md(pb2, mp, "dir2/subdir"); + md(pb2, sizeof(pb2), mp, "dir2/subdir"); if (rump_sys_mkdir(pb2, 0777) == -1) atf_tc_fail_errno("mkdir 3"); - md(pb3, mp, "dir1/file"); + md(pb3, sizeof(pb3), mp, "dir1/file"); if (rump_sys_mknod(pb3, S_IFREG | 0777, -1) == -1) atf_tc_fail_errno("create file"); if (rump_sys_stat(pb3, &ref) == -1) @@ -266,13 +280,13 @@ rename_dir(const atf_tc_t *tc, const char *mp) */ /* rename within directory */ - md(pb3, mp, "dir3"); + md(pb3, sizeof(pb3), mp, "dir3"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 1"); checkfile(pb3, &ref); /* rename directory onto itself (two ways, should fail) */ - md(pb1, mp, "dir3/."); + md(pb1, sizeof(pb1), mp, "dir3/."); if (rump_sys_rename(pb1, pb3) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 2"); if (rump_sys_rename(pb3, pb1) != -1 || errno != EISDIR) @@ -281,13 +295,13 @@ rename_dir(const atf_tc_t *tc, const char *mp) checkfile(pb3, &ref); /* rename father of directory into directory */ - md(pb1, mp, "dir2/dir"); - md(pb2, mp, "dir2"); + md(pb1, sizeof(pb1), mp, "dir2/dir"); + md(pb2, sizeof(pb2), mp, "dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail_errno("rename 4"); /* same for grandfather */ - md(pb1, mp, "dir2/subdir/dir2"); + md(pb1, sizeof(pb1), mp, "dir2/subdir/dir2"); if (rump_sys_rename(pb2, pb1) != -1 || errno != EINVAL) atf_tc_fail("rename 5"); @@ -298,29 +312,29 @@ rename_dir(const atf_tc_t *tc, const char *mp) atf_tc_fail("rename 6"); /* cross-directory rename */ - md(pb1, mp, "dir3"); - md(pb2, mp, "dir2/somedir"); + md(pb1, sizeof(pb1), mp, "dir3"); + md(pb2, sizeof(pb2), mp, "dir2/somedir"); if (rump_sys_rename(pb1, pb2) == -1) atf_tc_fail_errno("rename 7"); checkfile(pb2, &ref); /* move to parent directory */ - md(pb1, mp, "dir2/somedir/../../dir3"); + md(pb1, sizeof(pb1), mp, "dir2/somedir/../../dir3"); if (rump_sys_rename(pb2, pb1) == -1) atf_tc_fail_errno("rename 8"); - md(pb1, mp, "dir2/../dir3"); + md(pb1, sizeof(pb1), mp, "dir2/../dir3"); checkfile(pb1, &ref); /* atomic cross-directory rename */ - md(pb3, mp, "dir2/subdir"); + md(pb3, sizeof(pb3), mp, "dir2/subdir"); if (rump_sys_rename(pb1, pb3) == -1) atf_tc_fail_errno("rename 9"); checkfile(pb3, &ref); /* rename directory over an empty directory */ - md(pb1, mp, "parent"); - md(pb2, mp, "parent/dir1"); - md(pb3, mp, "parent/dir2"); + md(pb1, sizeof(pb1), mp, "parent"); + md(pb2, sizeof(pb2), mp, "parent/dir1"); + md(pb3, sizeof(pb3), mp, "parent/dir2"); RL(rump_sys_mkdir(pb1, 0777)); RL(rump_sys_mkdir(pb2, 0777)); RL(rump_sys_mkdir(pb3, 0777)); @@ -467,15 +481,15 @@ create_many(const atf_tc_t *tc, const char *mp) for (i = 0; i < nfiles; i++) { int fd; - sprintf(buf, TESTFN "%d", i); + snprintf(buf, sizeof(buf), TESTFN "%d", i); RL(fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666)); RL(rump_sys_close(fd)); } /* wipe them out */ for (i = 0; i < nfiles; i++) { - sprintf(buf, TESTFN "%d", i); - RL(rump_sys_unlink(buf)); + snprintf(buf, sizeof(buf), TESTFN "%d", i); + RLF(rump_sys_unlink(buf), "%s", buf); } #undef TESTFN @@ -499,12 +513,12 @@ create_nonalphanum(const atf_tc_t *tc, const char *mp) for (i = 0; i < 256; i++) { int fd; - sprintf(buf, "%c", i); + snprintf(buf, sizeof(buf), "%c", i); fd = rump_sys_open(buf, O_RDWR|O_CREAT|O_EXCL, 0666); if (fd == -1) continue; - RL(rump_sys_close(fd)); - RL(rump_sys_unlink(buf)); + RLF(rump_sys_close(fd), "%d", fd); + RLF(rump_sys_unlink(buf), "%s", buf); } printf("\n"); @@ -632,7 +646,7 @@ symlink_len(const atf_tc_t *tc, const char *mp, size_t len) USES_SYMLINKS; - RL(rump_sys_chdir(mp)); + RLF(rump_sys_chdir(mp), "%s", mp); buf = malloc(len + 1); ATF_REQUIRE(buf); |