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 a test case which tries to fhopen() a file ...
details: https://anonhg.NetBSD.org/src/rev/434904beab36
branches: trunk
changeset: 757147:434904beab36
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Aug 16 10:47:16 2010 +0000
description:
Add a test case which tries to fhopen() a file handle filled with
random garbage.
diffstat:
tests/fs/vfs/t_vfsops.c | 41 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 40 insertions(+), 1 deletions(-)
diffs (67 lines):
diff -r fe0f2f8194cf -r 434904beab36 tests/fs/vfs/t_vfsops.c
--- a/tests/fs/vfs/t_vfsops.c Mon Aug 16 10:46:19 2010 +0000
+++ b/tests/fs/vfs/t_vfsops.c Mon Aug 16 10:47:16 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: t_vfsops.c,v 1.6 2010/08/12 09:42:53 pooka Exp $ */
+/* $NetBSD: t_vfsops.c,v 1.7 2010/08/16 10:47:16 pooka Exp $ */
/*-
* Copyright (c) 2010 The NetBSD Foundation, Inc.
@@ -165,11 +165,49 @@
}
#undef FNAME
+/*
+ * This test only checks the file system doesn't crash. We *might*
+ * try a valid file handle.
+ */
+static void
+tfhinval(const atf_tc_t *tc, const char *path)
+{
+ size_t fhsize;
+ void *fhp;
+ unsigned long seed;
+ int fd;
+
+ if (FSTYPE_TMPFS(tc))
+ atf_tc_skip("file handles broken (PR kern/43605)");
+
+ srandom(seed = time(NULL));
+ printf("RNG seed %lu\n", seed);
+
+ RL(rump_sys_chdir(path));
+ fhsize = 0;
+ if (rump_sys_getfh(".", NULL, &fhsize) == -1) {
+ if (errno == EOPNOTSUPP) {
+ atf_tc_skip("file handles not supported");
+ } else if (errno != E2BIG) {
+ atf_tc_fail_errno("getfh size");
+ }
+ }
+
+ fhp = malloc(fhsize);
+ tests_makegarbage(fhp, fhsize);
+ fd = rump_sys_fhopen(fhp, fhsize, O_RDWR);
+ if (fd != -1)
+ rump_sys_close(fd);
+
+ RL(rump_sys_chdir("/"));
+}
+
ATF_TC_FSAPPLY(tmount, "mount/unmount");
ATF_TC_FSAPPLY(tstatvfs, "statvfs");
ATF_TC_FSAPPLY(tsync, "sync");
ATF_TC_FSAPPLY(tfilehandle, "file handles");
ATF_TC_FSAPPLY(tfhremove, "fhtovp for removed file");
+ATF_TC_FSAPPLY(tfhinval, "fhopen invalid filehandle");
ATF_TP_ADD_TCS(tp)
{
@@ -179,6 +217,7 @@
ATF_TP_FSAPPLY(tsync);
ATF_TP_FSAPPLY(tfilehandle);
ATF_TP_FSAPPLY(tfhremove);
+ ATF_TP_FSAPPLY(tfhinval);
return atf_no_error();
}
Home |
Main Index |
Thread Index |
Old Index