Module Name: src
Committed By: yamt
Date: Tue Feb 22 21:23:20 UTC 2011
Modified Files:
src/tests/fs/vfs: t_ro.c t_vnops.c
Log Message:
add some tests
To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/tests/fs/vfs/t_ro.c
cvs rdiff -u -r1.13 -r1.14 src/tests/fs/vfs/t_vnops.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/tests/fs/vfs/t_ro.c
diff -u src/tests/fs/vfs/t_ro.c:1.4 src/tests/fs/vfs/t_ro.c:1.5
--- src/tests/fs/vfs/t_ro.c:1.4 Mon Jan 31 18:53:29 2011
+++ src/tests/fs/vfs/t_ro.c Tue Feb 22 21:23:19 2011
@@ -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();
}
Index: src/tests/fs/vfs/t_vnops.c
diff -u src/tests/fs/vfs/t_vnops.c:1.13 src/tests/fs/vfs/t_vnops.c:1.14
--- src/tests/fs/vfs/t_vnops.c:1.13 Mon Jan 31 10:01:26 2011
+++ src/tests/fs/vfs/t_vnops.c Tue Feb 22 21:23:19 2011
@@ -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);