CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: christos Date: Mon May 12 15:33:12 UTC 2014 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: CID 978337: Fix resource leak To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.9 src/tests/rump/rumpvfs/t_etfs.c:1.10 --- src/tests/rump/rumpvfs/t_etfs.c:1.9 Tue Nov 30 13:19:47 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Mon May 12 11:33:12 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.9 2010/11/30 18:19:47 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.10 2014/05/12 15:33:12 christos Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -103,6 +103,8 @@ ATF_TC_BODY(reregister_reg, tc) ATF_REQUIRE_EQ(lseek(localfd, 0, SEEK_SET), 0); ATF_REQUIRE(read(localfd, buf, sizeof(buf)) > 0); ATF_REQUIRE_STREQ(buf, TESTSTR2); + close(etcfd); + close(localfd); } ATF_TC(reregister_blk);
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Feb 22 13:25:18 UTC 2011 Modified Files: src/tests/rump/rumpvfs: t_basic.c Log Message: One more lseek test case: in case of an error, check rv == -1 (so that it's not e.g UINT_MAX). To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/rump/rumpvfs/t_basic.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/rumpvfs/t_basic.c diff -u src/tests/rump/rumpvfs/t_basic.c:1.1 src/tests/rump/rumpvfs/t_basic.c:1.2 --- src/tests/rump/rumpvfs/t_basic.c:1.1 Tue Feb 22 10:36:13 2011 +++ src/tests/rump/rumpvfs/t_basic.c Tue Feb 22 13:25:18 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: t_basic.c,v 1.1 2011/02/22 10:36:13 pooka Exp $ */ +/* $NetBSD: t_basic.c,v 1.2 2011/02/22 13:25:18 pooka Exp $ */ /*- * Copyright (c) 2011 The NetBSD Foundation, Inc. @@ -62,6 +62,9 @@ RZ(rump_init()); RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0777)); + rv = rump_sys_lseek(37, FIVE_MEGS, SEEK_SET); + ATF_REQUIRE_ERRNO(EBADF, rv == -1); + rv = rump_sys_lseek(fd, FIVE_MEGS, SEEK_SET); ATF_REQUIRE_EQ(rv, FIVE_MEGS);
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Feb 22 10:36:14 UTC 2011 Modified Files: src/tests/rump/rumpvfs: Makefile Added Files: src/tests/rump/rumpvfs: t_basic.c Log Message: test lseek return value (off_t, might be >register_t) To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/tests/rump/rumpvfs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/rump/rumpvfs/t_basic.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/rumpvfs/Makefile diff -u src/tests/rump/rumpvfs/Makefile:1.2 src/tests/rump/rumpvfs/Makefile:1.3 --- src/tests/rump/rumpvfs/Makefile:1.2 Tue Nov 30 16:16:33 2010 +++ src/tests/rump/rumpvfs/Makefile Tue Feb 22 10:36:14 2011 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.2 2010/11/30 16:16:33 pooka Exp $ +# $NetBSD: Makefile,v 1.3 2011/02/22 10:36:14 pooka Exp $ .include TESTSDIR= ${TESTSBASE}/rump/rumpvfs -TESTS_C= t_etfs +TESTS_C= t_basic +TESTS_C+= t_etfs TESTS_C+= t_p2kifs LDADD= -lrumpvfs -lrump -lrumpuser -lpthread Added files: Index: src/tests/rump/rumpvfs/t_basic.c diff -u /dev/null src/tests/rump/rumpvfs/t_basic.c:1.1 --- /dev/null Tue Feb 22 10:36:14 2011 +++ src/tests/rump/rumpvfs/t_basic.c Tue Feb 22 10:36:13 2011 @@ -0,0 +1,78 @@ +/* $NetBSD: t_basic.c,v 1.1 2011/02/22 10:36:13 pooka Exp $ */ + +/*- + * Copyright (c) 2011 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 +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include "../../h_macros.h" + +ATF_TC(lseekrv); +ATF_TC_HEAD(lseekrv, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Test lseek return values"); +} + +#define TESTFILE "testi" + +#define FIVE_MEGS (5*1024*1024) +#define FIVE_GIGS (5*1024*1024*1024LL) + +ATF_TC_BODY(lseekrv, tc) +{ + off_t rv; + int fd; + + RZ(rump_init()); + RL(fd = rump_sys_open(TESTFILE, O_RDWR | O_CREAT, 0777)); + + rv = rump_sys_lseek(fd, FIVE_MEGS, SEEK_SET); + ATF_REQUIRE_EQ(rv, FIVE_MEGS); + + rv = rump_sys_lseek(fd, FIVE_GIGS, SEEK_SET); + ATF_REQUIRE_EQ(rv, FIVE_GIGS); +} + +ATF_TP_ADD_TCS(tp) +{ + + ATF_TP_ADD_TC(tp, lseekrv); + + return atf_no_error(); +}
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Dec 14 20:09:43 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_p2kifs.c Log Message: Use a larger array to avoid overflow. from Piotr Meyer To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/tests/rump/rumpvfs/t_p2kifs.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/rumpvfs/t_p2kifs.c diff -u src/tests/rump/rumpvfs/t_p2kifs.c:1.1 src/tests/rump/rumpvfs/t_p2kifs.c:1.2 --- src/tests/rump/rumpvfs/t_p2kifs.c:1.1 Tue Nov 30 16:16:33 2010 +++ src/tests/rump/rumpvfs/t_p2kifs.c Tue Dec 14 20:09:43 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_p2kifs.c,v 1.1 2010/11/30 16:16:33 pooka Exp $ */ +/* $NetBSD: t_p2kifs.c,v 1.2 2010/12/14 20:09:43 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -54,7 +54,7 @@ ATF_TC_BODY(makecn, tc) { struct componentname *cn; - char pathstr[] = TESTFILE; + char pathstr[MAXPATHLEN] = TESTFILE; struct vnode *vp; extern struct vnode *rumpns_rootvnode;
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Nov 30 18:19:47 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: one more test To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.8 src/tests/rump/rumpvfs/t_etfs.c:1.9 --- src/tests/rump/rumpvfs/t_etfs.c:1.8 Tue Nov 30 18:14:38 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Tue Nov 30 18:19:47 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.8 2010/11/30 18:14:38 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.9 2010/11/30 18:19:47 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -279,9 +279,12 @@ RL(rump_sys_open("/key//with/slashes", O_RDONLY)); RL(rump_sys_open("key//with/slashes", O_RDONLY)); - ATF_REQUIRE_ERRNO(ENOENT, rump_sys_open("/key/with/slashes", O_RDONLY) == -1); + + RL(rump_sys_mkdir("/a", 0777)); + ATF_REQUIRE_ERRNO(ENOENT, + rump_sys_open("/a/key//with/slashes", O_RDONLY) == -1); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Tue Nov 30 18:14:38 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: check etfs key rules To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.7 src/tests/rump/rumpvfs/t_etfs.c:1.8 --- src/tests/rump/rumpvfs/t_etfs.c:1.7 Sun Nov 7 17:51:21 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Tue Nov 30 18:14:38 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.7 2010/11/07 17:51:21 jmmv Exp $ */ +/* $NetBSD: t_etfs.c,v 1.8 2010/11/30 18:14:38 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -253,6 +253,37 @@ ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, sizeof(buf)), 0); } +ATF_TC(key); +ATF_TC_HEAD(key, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Checks key format"); +} + +ATF_TC_BODY(key, tc) +{ + + RZ(rump_init()); + + RL(open("hostfile", O_RDWR | O_CREAT, 0777)); + + RZ(rump_pub_etfs_register("/key", "hostfile", RUMP_ETFS_REG)); + ATF_REQUIRE_EQ(rump_pub_etfs_register("key", "hostfile", RUMP_ETFS_REG), + EINVAL); + + RL(rump_sys_open("/key", O_RDONLY)); + RL(rump_sys_open("key", O_RDONLY)); + + RZ(rump_pub_etfs_register("key//with/slashes", "hostfile", + RUMP_ETFS_REG)); + + RL(rump_sys_open("/key//with/slashes", O_RDONLY)); + RL(rump_sys_open("key//with/slashes", O_RDONLY)); + + ATF_REQUIRE_ERRNO(ENOENT, + rump_sys_open("/key/with/slashes", O_RDONLY) == -1); +} + ATF_TP_ADD_TCS(tp) { @@ -260,6 +291,7 @@ ATF_TP_ADD_TC(tp, reregister_blk); ATF_TP_ADD_TC(tp, large_blk); ATF_TP_ADD_TC(tp, range_blk); + ATF_TP_ADD_TC(tp, key); return atf_no_error(); }
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Mon Jun 21 14:39:36 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: check etfs mappings with offsets To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.5 src/tests/rump/rumpvfs/t_etfs.c:1.6 --- src/tests/rump/rumpvfs/t_etfs.c:1.5 Sun Jun 20 17:43:33 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Mon Jun 21 14:39:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.5 2010/06/20 17:43:33 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.6 2010/06/21 14:39:35 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -218,12 +218,52 @@ system("umount mfsdir"); } +ATF_TC(range_blk); +ATF_TC_HEAD(range_blk, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Checks ranged (offset,size) mappings"); + atf_tc_set_md_var(tc, "use.fs", "true"); +} + +ATF_TC_BODY(range_blk, tc) +{ + char buf[32000]; + char cmpbuf[32000]; + ssize_t n; + int rv, tfd; + + /* create a 64000 byte file with 16 1's at offset = 32000 */ + rv = system("dd if=/dev/zero of=disk.img bs=1000 count=64"); + ATF_REQUIRE_EQ(rv, 0); + rv = system("yes | tr '\\ny' '\\1' " + "| dd of=disk.img conv=notrunc bs=1 count=16 seek=32000"); + ATF_REQUIRE_EQ(rv, 0); + + /* map the file at [16000,48000]. this puts our 1's at offset 16000 */ + rump_init(); + ATF_REQUIRE_EQ(rump_pub_etfs_register_withsize(TESTPATH1, "disk.img", + RUMP_ETFS_BLK, 16000, 32000), 0); + tfd = rump_sys_open(TESTPATH1, O_RDWR); + ATF_REQUIRE(tfd != -1); + n = rump_sys_read(tfd, buf, sizeof(buf)); + ATF_REQUIRE_EQ(n, sizeof(buf)); + ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); + ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); + + /* check that we got what is expected */ + memset(cmpbuf, 0, sizeof(cmpbuf)); + memset(cmpbuf+16000, 1, 16); + ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, sizeof(buf)), 0); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, reregister_reg); ATF_TP_ADD_TC(tp, reregister_blk); ATF_TP_ADD_TC(tp, large_blk); + ATF_TP_ADD_TC(tp, range_blk); return atf_no_error(); }
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Sun Jun 20 17:43:33 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: Check that etfs block mapping works for >2TB devices. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.4 src/tests/rump/rumpvfs/t_etfs.c:1.5 --- src/tests/rump/rumpvfs/t_etfs.c:1.4 Sat Jun 19 13:44:11 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Sun Jun 20 17:43:33 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.4 2010/06/19 13:44:11 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.5 2010/06/20 17:43:33 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -153,11 +153,77 @@ ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH2), 0); } +ATF_TC_WITH_CLEANUP(large_blk); +ATF_TC_HEAD(large_blk, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Check etfs block devices work for " + ">2TB images"); + atf_tc_set_md_var(tc, "use.fs", "true"); +} + +#define IMG_ON_MFS "mfsdir/disk.img" +ATF_TC_BODY(large_blk, tc) +{ + char buf[128]; + char cmpbuf[128]; + ssize_t n; + int rv, tfd; + + /* + * mount mfs. it would be nice if this would not be required, + * but a) tmpfs doesn't "support" sparse files b) we don't really + * know what fs atf workdir is on anyway. + */ + if (mkdir("mfsdir", 0777) == -1) + atf_tc_fail_errno("mkdir failed"); + if (system("mount_mfs -s 64m -o nosuid,nodev mfs mfsdir") != 0) + atf_tc_skip("could not mount mfs"); + + /* create a 8TB sparse file */ + rv = system("dd if=/dev/zero of=" IMG_ON_MFS " bs=1 count=1 seek=8t"); + ATF_REQUIRE_EQ(rv, 0); + + /* + * map it and issue write at 6TB, then unmap+remap and check + * we get the same stuff back + */ + + rump_init(); + ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, IMG_ON_MFS, + RUMP_ETFS_BLK), 0); + tfd = rump_sys_open(TESTPATH1, O_RDWR); + ATF_REQUIRE(tfd != -1); + memset(buf, 12, sizeof(buf)); + n = rump_sys_pwrite(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); + ATF_REQUIRE_EQ(n, sizeof(buf)); + ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); + ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); + + ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, IMG_ON_MFS, + RUMP_ETFS_BLK), 0); + tfd = rump_sys_open(TESTPATH2, O_RDWR); + ATF_REQUIRE(tfd != -1); + memset(buf, 0, sizeof(buf)); + n = rump_sys_pread(tfd, buf, sizeof(buf), 6*1024*1024*1024ULL*1024ULL); + ATF_REQUIRE_EQ(n, sizeof(buf)); + + memset(cmpbuf, 12, sizeof(cmpbuf)); + ATF_REQUIRE_EQ(memcmp(cmpbuf, buf, 128), 0); +} + +ATF_TC_CLEANUP(large_blk, tc) +{ + + system("umount mfsdir"); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, reregister_reg); ATF_TP_ADD_TC(tp, reregister_blk); + ATF_TP_ADD_TC(tp, large_blk); return atf_no_error(); }
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Sat Jun 19 13:44:11 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: ... and remove the not-supposed-to-be-committed call to rump_sys_reboot() To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.3 src/tests/rump/rumpvfs/t_etfs.c:1.4 --- src/tests/rump/rumpvfs/t_etfs.c:1.3 Sat Jun 19 13:43:29 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Sat Jun 19 13:44:11 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.3 2010/06/19 13:43:29 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.4 2010/06/19 13:44:11 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -151,8 +151,6 @@ ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 128*512), 0); ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH2), 0); - - rump_sys_reboot(RUMP_RB_DUMP, NULL); } ATF_TP_ADD_TCS(tp)
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Sat Jun 19 13:43:29 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: fix pasto, sprinkle ATF_REQUIRE_EQ() ATF_REQUIRE_ERRNO, oh ATF_REQUIRE_ERRNO, wherefore art thou ATF_REQUIRE_ERRNO? To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.2 src/tests/rump/rumpvfs/t_etfs.c:1.3 --- src/tests/rump/rumpvfs/t_etfs.c:1.2 Sat Jun 19 13:40:09 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Sat Jun 19 13:43:29 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.2 2010/06/19 13:40:09 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.3 2010/06/19 13:43:29 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -139,8 +139,8 @@ ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 64*512); memset(cmpbuf, 1, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 64*512), 0); - rump_sys_close(tfd); - rump_pub_etfs_remove(TESTPATH1); + ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); + ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH1), 0); ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./disk2.img", RUMP_ETFS_BLK), 0); @@ -149,8 +149,8 @@ ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 128*512); memset(cmpbuf, 2, sizeof(cmpbuf)); ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 128*512), 0); - rump_sys_close(tfd); - rump_pub_etfs_remove(TESTPATH1); + ATF_REQUIRE_EQ(rump_sys_close(tfd), 0); + ATF_REQUIRE_EQ(rump_pub_etfs_remove(TESTPATH2), 0); rump_sys_reboot(RUMP_RB_DUMP, NULL); }
CVS commit: src/tests/rump/rumpvfs
Module Name:src Committed By: pooka Date: Sat Jun 19 13:40:09 UTC 2010 Modified Files: src/tests/rump/rumpvfs: t_etfs.c Log Message: add test for block device support To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 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/rumpvfs/t_etfs.c diff -u src/tests/rump/rumpvfs/t_etfs.c:1.1 src/tests/rump/rumpvfs/t_etfs.c:1.2 --- src/tests/rump/rumpvfs/t_etfs.c:1.1 Wed Jun 16 19:29:33 2010 +++ src/tests/rump/rumpvfs/t_etfs.c Sat Jun 19 13:40:09 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: t_etfs.c,v 1.1 2010/06/16 19:29:33 pooka Exp $ */ +/* $NetBSD: t_etfs.c,v 1.2 2010/06/19 13:40:09 pooka Exp $ */ /*- * Copyright (c) 2010 The NetBSD Foundation, Inc. @@ -106,10 +106,60 @@ ATF_REQUIRE_STREQ(buf, TESTSTR2); } +ATF_TC(reregister_blk); +ATF_TC_HEAD(reregister_blk, tc) +{ + + atf_tc_set_md_var(tc, "descr", "Tests register/unregister/register " + "for a block device"); + atf_tc_set_md_var(tc, "use.fs", "true"); +} + +ATF_TC_BODY(reregister_blk, tc) +{ + char buf[512 * 128]; + char cmpbuf[512 * 128]; + int rv, tfd; + + /* first, create some image files */ + rv = system("dd if=/dev/zero bs=512 count=64 " + "| tr '\\0' '\\1' > disk1.img"); + ATF_REQUIRE_EQ(rv, 0); + + rv = system("dd if=/dev/zero bs=512 count=128 " + "| tr '\\0' '\\2' > disk2.img"); + ATF_REQUIRE_EQ(rv, 0); + + rump_init(); + + ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH1, "./disk1.img", + RUMP_ETFS_BLK), 0); + tfd = rump_sys_open(TESTPATH1, O_RDONLY); + ATF_REQUIRE(tfd != -1); + ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 64*512); + memset(cmpbuf, 1, sizeof(cmpbuf)); + ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 64*512), 0); + rump_sys_close(tfd); + rump_pub_etfs_remove(TESTPATH1); + + ATF_REQUIRE_EQ(rump_pub_etfs_register(TESTPATH2, "./disk2.img", + RUMP_ETFS_BLK), 0); + tfd = rump_sys_open(TESTPATH2, O_RDONLY); + ATF_REQUIRE(tfd != -1); + ATF_REQUIRE_EQ(rump_sys_read(tfd, buf, sizeof(buf)), 128*512); + memset(cmpbuf, 2, sizeof(cmpbuf)); + ATF_REQUIRE_EQ(memcmp(buf, cmpbuf, 128*512), 0); + rump_sys_close(tfd); + rump_pub_etfs_remove(TESTPATH1); + + rump_sys_reboot(RUMP_RB_DUMP, NULL); +} + ATF_TP_ADD_TCS(tp) { ATF_TP_ADD_TC(tp, reregister_reg); + ATF_TP_ADD_TC(tp, reregister_blk); return atf_no_error(); }