Source-Changes-HG archive

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

[src/trunk]: src/tests/fs/vfs add some tests



details:   https://anonhg.NetBSD.org/src/rev/e6593b73263b
branches:  trunk
changeset: 762545:e6593b73263b
user:      yamt <yamt%NetBSD.org@localhost>
date:      Tue Feb 22 21:23:19 2011 +0000

description:
add some tests

diffstat:

 tests/fs/vfs/t_ro.c    |  50 +++++++++++++++++++++++++++++++++++++++++++++++++-
 tests/fs/vfs/t_vnops.c |  24 +++++++++++++++++++++++-
 2 files changed, 72 insertions(+), 2 deletions(-)

diffs (134 lines):

diff -r f896b8c61181 -r e6593b73263b tests/fs/vfs/t_ro.c
--- a/tests/fs/vfs/t_ro.c       Tue Feb 22 21:19:30 2011 +0000
+++ b/tests/fs/vfs/t_ro.c       Tue Feb 22 21:23:19 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_ro.c,v 1.4 2011/01/31 18:53:29 njoly Exp $   */
+/*     $NetBSD: t_ro.c,v 1.5 2011/02/22 21:23:19 yamt Exp $    */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -42,6 +42,10 @@
 #include "../../h_macros.h"
 
 #define AFILE "testfile"
+#define ADIR "testdir"
+#define AFIFO "testfifo"
+#define ASYMLINK "testsymlink"
+#define ALINK "testlink"
 #define FUNTEXT "this is some non-humppa text"
 #define FUNSIZE (sizeof(FUNTEXT)-1)
 
@@ -138,10 +142,50 @@
        FSTEST_EXIT();
 }
 
+static void
+createdir(const atf_tc_t *tc, const char *mp)
+{
+
+       FSTEST_ENTER();
+       ATF_REQUIRE_ERRNO(EROFS, rump_sys_mkdir(ADIR, 0775) == -1);
+       FSTEST_EXIT();
+}
+
+static void
+createfifo(const atf_tc_t *tc, const char *mp)
+{
+
+       FSTEST_ENTER();
+       ATF_REQUIRE_ERRNO(EROFS, rump_sys_mkfifo(AFIFO, 0775) == -1);
+       FSTEST_EXIT();
+}
+
+static void
+createsymlink(const atf_tc_t *tc, const char *mp)
+{
+
+       FSTEST_ENTER();
+       ATF_REQUIRE_ERRNO(EROFS, rump_sys_symlink("hoge", ASYMLINK) == -1);
+       FSTEST_EXIT();
+}
+
+static void
+createlink(const atf_tc_t *tc, const char *mp)
+{
+
+       FSTEST_ENTER();
+       ATF_REQUIRE_ERRNO(EROFS, rump_sys_link(AFILE, ALINK) == -1);
+       FSTEST_EXIT();
+}
+
 ATF_TC_FSAPPLY_RO(create, "create file on r/o mount", nullgen);
 ATF_TC_FSAPPLY_RO(rmfile, "remove file from r/o mount", filegen);
 ATF_TC_FSAPPLY_RO(fileio, "can read a file but not write it", filegen);
 ATF_TC_FSAPPLY_RO(attrs, "can query but not change attributes", filegen);
+ATF_TC_FSAPPLY_RO(createdir, "create directory on r/o mount", nullgen);
+ATF_TC_FSAPPLY_RO(createfifo, "create fifo on r/o mount", nullgen);
+ATF_TC_FSAPPLY_RO(createsymlink, "create symlink on r/o mount", nullgen);
+ATF_TC_FSAPPLY_RO(createlink, "create hardlink on r/o mount", filegen);
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -150,6 +194,10 @@
        ATF_TP_FSAPPLY_RO(rmfile);
        ATF_TP_FSAPPLY_RO(fileio);
        ATF_TP_FSAPPLY_RO(attrs);
+       ATF_TP_FSAPPLY_RO(createdir);
+       ATF_TP_FSAPPLY_RO(createfifo);
+       ATF_TP_FSAPPLY_RO(createsymlink);
+       ATF_TP_FSAPPLY_RO(createlink);
 
        return atf_no_error();
 }
diff -r f896b8c61181 -r e6593b73263b tests/fs/vfs/t_vnops.c
--- a/tests/fs/vfs/t_vnops.c    Tue Feb 22 21:19:30 2011 +0000
+++ b/tests/fs/vfs/t_vnops.c    Tue Feb 22 21:23:19 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_vnops.c,v 1.13 2011/01/31 10:01:26 pooka Exp $       */
+/*     $NetBSD: t_vnops.c,v 1.14 2011/02/22 21:23:19 yamt Exp $        */
 
 /*-
  * Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -409,6 +409,26 @@
 }
 
 static void
+create_exist(const atf_tc_t *tc, const char *mp)
+{
+       const char *name = "hoge";
+       int fd;
+
+       RL(rump_sys_chdir(mp));
+       RL(fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666));
+       RL(rump_sys_close(fd));
+       RL(rump_sys_unlink(name));
+       RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666));
+       RL(rump_sys_close(fd));
+       RL(fd = rump_sys_open(name, O_RDWR|O_CREAT, 0666));
+       RL(rump_sys_close(fd));
+       ATF_REQUIRE_ERRNO(EEXIST,
+           (fd = rump_sys_open(name, O_RDWR|O_CREAT|O_EXCL, 0666)));
+       RL(rump_sys_unlink(name));
+       RL(rump_sys_chdir("/"));
+}
+
+static void
 rename_nametoolong(const atf_tc_t *tc, const char *mp)
 {
        char *name;
@@ -693,6 +713,7 @@
 ATF_TC_FSAPPLY(rename_dotdot, "rename dir ..");
 ATF_TC_FSAPPLY(rename_reg_nodir, "rename regular files, no subdirectories");
 ATF_TC_FSAPPLY(create_nametoolong, "create file with name too long");
+ATF_TC_FSAPPLY(create_exist, "create with O_EXCL");
 ATF_TC_FSAPPLY(rename_nametoolong, "rename to file with name too long");
 ATF_TC_FSAPPLY(symlink_zerolen, "symlink with 0-len target");
 ATF_TC_FSAPPLY(attrs, "check setting attributes works");
@@ -710,6 +731,7 @@
        ATF_TP_FSAPPLY(rename_dotdot);
        ATF_TP_FSAPPLY(rename_reg_nodir);
        ATF_TP_FSAPPLY(create_nametoolong);
+       ATF_TP_FSAPPLY(create_exist);
        ATF_TP_FSAPPLY(rename_nametoolong);
        ATF_TP_FSAPPLY(symlink_zerolen);
        ATF_TP_FSAPPLY(attrs);



Home | Main Index | Thread Index | Old Index