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 basic tests for vfsops.
details: https://anonhg.NetBSD.org/src/rev/87eece0a5e18
branches: trunk
changeset: 756333:87eece0a5e18
user: pooka <pooka%NetBSD.org@localhost>
date: Tue Jul 13 11:51:59 2010 +0000
description:
Add basic tests for vfsops.
tfilehandle is a test for PR kern/43605
diffstat:
tests/fs/vfs/Atffile | 4 +-
tests/fs/vfs/Makefile | 3 +-
tests/fs/vfs/t_vfsops.c | 134 ++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 138 insertions(+), 3 deletions(-)
diffs (166 lines):
diff -r 45e955ae2548 -r 87eece0a5e18 tests/fs/vfs/Atffile
--- a/tests/fs/vfs/Atffile Tue Jul 13 11:16:02 2010 +0000
+++ b/tests/fs/vfs/Atffile Tue Jul 13 11:51:59 2010 +0000
@@ -1,6 +1,6 @@
Content-Type: application/X-atf-atffile; version="1"
-X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2010/07/05 12:53:58 njoly Exp $"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.2 2010/07/13 11:51:59 pooka Exp $"
prop: test-suite = "NetBSD"
-tp: t_rmdirrace
+tp-glob: t_*
diff -r 45e955ae2548 -r 87eece0a5e18 tests/fs/vfs/Makefile
--- a/tests/fs/vfs/Makefile Tue Jul 13 11:16:02 2010 +0000
+++ b/tests/fs/vfs/Makefile Tue Jul 13 11:51:59 2010 +0000
@@ -1,10 +1,11 @@
-# $NetBSD: Makefile,v 1.2 2010/07/08 13:21:02 pooka Exp $
+# $NetBSD: Makefile,v 1.3 2010/07/13 11:51:59 pooka Exp $
#
TESTSDIR= ${TESTSBASE}/fs/vfs
WARNS= 4
TESTS_C= t_rmdirrace
+TESTS_C+= t_vfsops
LDADD+=-lrumpfs_ext2fs # ext2fs
LDADD+=-lrumpfs_ffs # ffs
diff -r 45e955ae2548 -r 87eece0a5e18 tests/fs/vfs/t_vfsops.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/vfs/t_vfsops.c Tue Jul 13 11:51:59 2010 +0000
@@ -0,0 +1,134 @@
+/* $NetBSD: t_vfsops.c,v 1.1 2010/07/13 11:51:59 pooka Exp $ */
+
+/*-
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/stat.h>
+#include <sys/statvfs.h>
+
+#include <atf-c.h>
+#include <unistd.h>
+
+#include <rump/rump_syscalls.h>
+#include <rump/rump.h>
+
+#include "../common/h_fsmacros.h"
+#include "../../h_macros.h"
+
+static void
+tmount(const atf_tc_t *tc, const char *path)
+{
+
+ return;
+}
+
+static void
+tstatvfs(const atf_tc_t *tc, const char *path)
+{
+ struct statvfs svb;
+
+ if (rump_sys_statvfs1(path, &svb, ST_WAIT) == -1)
+ atf_tc_fail_errno("statvfs");
+}
+
+static void
+tsync(const atf_tc_t *tc, const char *path)
+{
+
+ rump_sys_sync();
+}
+
+#define MAGICSTR "just a string, I like A"
+static void
+tfilehandle(const atf_tc_t *tc, const char *path)
+{
+ char fpath[MAXPATHLEN];
+ char buf[sizeof(MAGICSTR)];
+ size_t fhsize;
+ void *fhp;
+ int fd;
+
+ sprintf(fpath, "%s/file", path);
+ fd = rump_sys_open(fpath, O_RDWR | O_CREAT, 0777);
+ if (fd == -1)
+ atf_tc_fail_errno("open");
+
+ if (rump_sys_write(fd, MAGICSTR, sizeof(MAGICSTR)) != sizeof(MAGICSTR))
+ atf_tc_fail("write to file");
+ rump_sys_close(fd);
+
+ /*
+ * Get file handle size.
+ * This also weeds out unsupported file systems.
+ */
+ fhsize = 0;
+ if (rump_sys_getfh(fpath, 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);
+ if (rump_sys_getfh(fpath, fhp, &fhsize) == -1)
+ atf_tc_fail_errno("getfh");
+
+ /* open file based on file handle */
+ fd = rump_sys_fhopen(fhp, fhsize, O_RDONLY);
+ if (FSTYPE_TMPFS(tc)) {
+ atf_tc_expect_fail("PR kern/43605");
+ if (fd != -1 || errno != EINVAL)
+ atf_tc_expect_pass();
+ }
+ if (fd == -1) {
+ atf_tc_fail_errno("fhopen");
+ }
+
+ /* check that we got the same file */
+ if (rump_sys_read(fd, buf, sizeof(buf)) != sizeof(MAGICSTR))
+ atf_tc_fail("read fhopened file");
+
+ ATF_REQUIRE_STREQ(buf, MAGICSTR);
+
+ rump_sys_close(fd);
+}
+
+ATF_TC_FSAPPLY(tmount, "mount/unmount");
+ATF_TC_FSAPPLY(tstatvfs, "statvfs");
+ATF_TC_FSAPPLY(tsync, "sync");
+ATF_TC_FSAPPLY(tfilehandle, "file handles");
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_FSAPPLY(tmount);
+ ATF_TP_FSAPPLY(tstatvfs);
+ ATF_TP_FSAPPLY(tsync);
+ ATF_TP_FSAPPLY(tfilehandle);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index