Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/tests/rump Add simple etfs test which almost tests for bug f...
details: https://anonhg.NetBSD.org/src/rev/7e3eeecc089c
branches: trunk
changeset: 755695:7e3eeecc089c
user: pooka <pooka%NetBSD.org@localhost>
date: Wed Jun 16 19:29:33 2010 +0000
description:
Add simple etfs test which almost tests for bug fixed yesterday
(the yesterday bug was against an emulated block device, so slighlty
different). But at least this test uncovered a few bugs already.
diffstat:
tests/rump/Atffile | 4 +-
tests/rump/Makefile | 4 +-
tests/rump/rumpvfs/Atffile | 6 ++
tests/rump/rumpvfs/Makefile | 13 ++++
tests/rump/rumpvfs/t_etfs.c | 115 ++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 138 insertions(+), 4 deletions(-)
diffs (176 lines):
diff -r 395c8fd5391a -r 7e3eeecc089c tests/rump/Atffile
--- a/tests/rump/Atffile Wed Jun 16 19:26:58 2010 +0000
+++ b/tests/rump/Atffile Wed Jun 16 19:29:33 2010 +0000
@@ -1,7 +1,7 @@
Content-Type: application/X-atf-atffile; version="1"
-X-NetBSD-Id: "$NetBSD: Atffile,v 1.3 2010/06/09 12:35:45 pooka Exp $"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.4 2010/06/16 19:29:33 pooka Exp $"
prop: test-suite = "NetBSD"
tp: modautoload
-tp: rumpkern
+tp_glob: rump*
diff -r 395c8fd5391a -r 7e3eeecc089c tests/rump/Makefile
--- a/tests/rump/Makefile Wed Jun 16 19:26:58 2010 +0000
+++ b/tests/rump/Makefile Wed Jun 16 19:29:33 2010 +0000
@@ -1,11 +1,11 @@
-# $NetBSD: Makefile,v 1.3 2010/06/09 12:35:45 pooka Exp $
+# $NetBSD: Makefile,v 1.4 2010/06/16 19:29:33 pooka Exp $
#
.include <bsd.own.mk>
TESTSDIR= ${TESTSBASE}/rump
-SUBDIR= kernspace .WAIT rumpkern modautoload
+SUBDIR= kernspace .WAIT rumpkern rumpvfs modautoload
.include <bsd.test.mk>
.include <bsd.subdir.mk>
diff -r 395c8fd5391a -r 7e3eeecc089c tests/rump/rumpvfs/Atffile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rump/rumpvfs/Atffile Wed Jun 16 19:29:33 2010 +0000
@@ -0,0 +1,6 @@
+Content-Type: application/X-atf-atffile; version="1"
+X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2010/06/16 19:29:33 pooka Exp $"
+
+prop: test-suite = "NetBSD"
+
+tp-glob: t_*
diff -r 395c8fd5391a -r 7e3eeecc089c tests/rump/rumpvfs/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rump/rumpvfs/Makefile Wed Jun 16 19:29:33 2010 +0000
@@ -0,0 +1,13 @@
+# $NetBSD: Makefile,v 1.1 2010/06/16 19:29:33 pooka Exp $
+
+.include <bsd.own.mk>
+
+TESTSDIR= ${TESTSBASE}/rump/rumpvfs
+
+TESTS_C= t_etfs
+
+LDADD= -lrumpvfs -lrump -lrumpuser -lpthread
+
+WARNS= 4
+
+.include <bsd.test.mk>
diff -r 395c8fd5391a -r 7e3eeecc089c tests/rump/rumpvfs/t_etfs.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/rump/rumpvfs/t_etfs.c Wed Jun 16 19:29:33 2010 +0000
@@ -0,0 +1,115 @@
+/* $NetBSD: t_etfs.c,v 1.1 2010/06/16 19:29:33 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/types.h>
+#include <sys/mount.h>
+#include <sys/sysctl.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include <atf-c.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+#include "../../h_macros.h"
+
+ATF_TC(reregister_reg);
+ATF_TC_HEAD(reregister_reg, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "Tests register/unregister/register "
+ "for a regular file");
+ atf_tc_set_md_var(tc, "use.fs", "true");
+}
+
+#define TESTSTR1 "hi, it's me again!"
+#define TESTSTR1SZ (sizeof(TESTSTR1)-1)
+
+#define TESTSTR2 "what about the old vulcan proverb?"
+#define TESTSTR2SZ (sizeof(TESTSTR2)-1)
+
+#define TESTPATH1 "/trip/to/the/moon"
+#define TESTPATH2 "/but/not/the/dark/size"
+ATF_TC_BODY(reregister_reg, tc)
+{
+ char buf[1024];
+ int localfd, etcfd;
+ ssize_t n;
+ int tfd;
+
+ etcfd = open("/etc/passwd", O_RDONLY);
+ ATF_REQUIRE(etcfd != -1);
+
+ localfd = open("./testfile", O_RDWR | O_CREAT, 0666);
+ ATF_REQUIRE(localfd != -1);
+
+ ATF_REQUIRE_EQ(write(localfd, TESTSTR1, TESTSTR1SZ), TESTSTR1SZ);
+ /* testfile now contains test string */
+
+ rump_init();
+
+ ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "/etc/passwd",
+ RUMP_ETFS_REG), 0);
+ tfd = rump_sys_open(TESTPATH1, O_RDONLY);
+ ATF_REQUIRE(tfd != -1);
+ ATF_REQUIRE(rump_sys_read(tfd, buf, sizeof(buf)) > 0);
+ rump_sys_close(tfd);
+ rump_pub_etfs_remove(TESTPATH1);
+
+ ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./testfile",
+ RUMP_ETFS_REG), 0);
+ tfd = rump_sys_open(TESTPATH2, O_RDWR);
+ ATF_REQUIRE(tfd != -1);
+ memset(buf, 0, sizeof(buf));
+ ATF_REQUIRE((n = rump_sys_read(tfd, buf, sizeof(buf))) > 0);
+
+ /* check that we have what we expected */
+ ATF_REQUIRE_STREQ(buf, TESTSTR1);
+
+ /* ... while here, check that writing works too */
+ ATF_REQUIRE_EQ(rump_sys_lseek(tfd, 0, SEEK_SET), 0);
+ ATF_REQUIRE(TESTSTR1SZ <= TESTSTR2SZ);
+ ATF_REQUIRE_EQ(rump_sys_write(tfd, TESTSTR2, TESTSTR2SZ), TESTSTR2SZ);
+
+ memset(buf, 0, sizeof(buf));
+ ATF_REQUIRE_EQ(lseek(localfd, 0, SEEK_SET), 0);
+ ATF_REQUIRE(read(localfd, buf, sizeof(buf)) > 0);
+ ATF_REQUIRE_STREQ(buf, TESTSTR2);
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+
+ ATF_TP_ADD_TC(tp, reregister_reg);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index