Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/fs/vfs Start adding some I/O tests. This one does a s...
details: https://anonhg.NetBSD.org/src/rev/f49f0a6aca9a
branches: trunk
changeset: 757204:f49f0a6aca9a
user: pooka <pooka%NetBSD.org@localhost>
date: Thu Aug 19 02:36:02 2010 +0000
description:
Start adding some I/O tests. This one does a sparse write to the
second page on a file, then writes the first, and finally checks
it can read something expected. Adapted the from program supplied
by yamt in PR kern/36429.
diffstat:
tests/fs/vfs/Makefile | 3 +-
tests/fs/vfs/t_io.c | 85 +++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 87 insertions(+), 1 deletions(-)
diffs (106 lines):
diff -r e3d5457b45b1 -r f49f0a6aca9a tests/fs/vfs/Makefile
--- a/tests/fs/vfs/Makefile Thu Aug 19 02:10:02 2010 +0000
+++ b/tests/fs/vfs/Makefile Thu Aug 19 02:36:02 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.10 2010/08/17 11:46:16 pooka Exp $
+# $NetBSD: Makefile,v 1.11 2010/08/19 02:36:02 pooka Exp $
#
.include <bsd.own.mk>
@@ -7,6 +7,7 @@
WARNS= 4
TESTS_C+= t_full
+TESTS_C+= t_io
TESTS_C+= t_renamerace
TESTS_C+= t_rmdirrace
TESTS_C+= t_vfsops
diff -r e3d5457b45b1 -r f49f0a6aca9a tests/fs/vfs/t_io.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/vfs/t_io.c Thu Aug 19 02:36:02 2010 +0000
@@ -0,0 +1,85 @@
+/* $NetBSD: t_io.c,v 1.1 2010/08/19 02:36:02 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 <fcntl.h>
+#include <libgen.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <rump/rump_syscalls.h>
+#include <rump/rump.h>
+
+#include "../common/h_fsmacros.h"
+#include "../../h_macros.h"
+
+static void
+holywrite(const atf_tc_t *tc, const char *mp)
+{
+ char buf[1024];
+ char *b2, *b3;
+ size_t therange = getpagesize()+1;
+ int fd;
+
+ RL(rump_sys_chdir(mp));
+
+ RL(fd = rump_sys_open("file", O_RDWR|O_CREAT|O_TRUNC, 0666));
+
+ memset(buf, 'A', sizeof(buf));
+ RL(rump_sys_pwrite(fd, buf, 1, getpagesize()));
+
+ memset(buf, 'B', sizeof(buf));
+ RL(rump_sys_pwrite(fd, buf, 2, 0xfff));
+
+ REQUIRE_LIBC(b2 = malloc(2 * getpagesize()), NULL);
+ REQUIRE_LIBC(b3 = malloc(2 * getpagesize()), NULL);
+
+ RL(rump_sys_pread(fd, b2, therange, 0));
+
+ memset(b3, 0, therange);
+ memset(b3 + getpagesize() - 1, 'B', 2);
+
+ if (memcmp(b2, b3, therange) != 0)
+ abort();
+
+ rump_sys_close(fd);
+ rump_sys_chdir("/");
+}
+
+ATF_TC_FSAPPLY(holywrite, "create a sparse file and fill hole");
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_FSAPPLY(holywrite);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index