Module Name:    src
Committed By:   pooka
Date:           Wed Jun 16 19:29:33 UTC 2010

Modified Files:
        src/tests/rump: Atffile Makefile
Added Files:
        src/tests/rump/rumpvfs: Atffile Makefile t_etfs.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/tests/rump/Atffile src/tests/rump/Makefile
cvs rdiff -u -r0 -r1.1 src/tests/rump/rumpvfs/Atffile \
    src/tests/rump/rumpvfs/Makefile src/tests/rump/rumpvfs/t_etfs.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/rump/Atffile
diff -u src/tests/rump/Atffile:1.3 src/tests/rump/Atffile:1.4
--- src/tests/rump/Atffile:1.3	Wed Jun  9 12:35:45 2010
+++ src/tests/rump/Atffile	Wed Jun 16 19:29:33 2010
@@ -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*
Index: src/tests/rump/Makefile
diff -u src/tests/rump/Makefile:1.3 src/tests/rump/Makefile:1.4
--- src/tests/rump/Makefile:1.3	Wed Jun  9 12:35:45 2010
+++ src/tests/rump/Makefile	Wed Jun 16 19:29:33 2010
@@ -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>

Added files:

Index: src/tests/rump/rumpvfs/Atffile
diff -u /dev/null src/tests/rump/rumpvfs/Atffile:1.1
--- /dev/null	Wed Jun 16 19:29:33 2010
+++ src/tests/rump/rumpvfs/Atffile	Wed Jun 16 19:29:33 2010
@@ -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_*
Index: src/tests/rump/rumpvfs/Makefile
diff -u /dev/null src/tests/rump/rumpvfs/Makefile:1.1
--- /dev/null	Wed Jun 16 19:29:33 2010
+++ src/tests/rump/rumpvfs/Makefile	Wed Jun 16 19:29:33 2010
@@ -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>
Index: src/tests/rump/rumpvfs/t_etfs.c
diff -u /dev/null src/tests/rump/rumpvfs/t_etfs.c:1.1
--- /dev/null	Wed Jun 16 19:29:33 2010
+++ src/tests/rump/rumpvfs/t_etfs.c	Wed Jun 16 19:29:33 2010
@@ -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();
+}

Reply via email to