Module Name: src Committed By: pooka Date: Thu Aug 19 02:36:03 UTC 2010
Modified Files: src/tests/fs/vfs: Makefile Added Files: src/tests/fs/vfs: t_io.c Log Message: 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. To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/tests/fs/vfs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/fs/vfs/t_io.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/fs/vfs/Makefile diff -u src/tests/fs/vfs/Makefile:1.10 src/tests/fs/vfs/Makefile:1.11 --- src/tests/fs/vfs/Makefile:1.10 Tue Aug 17 11:46:16 2010 +++ src/tests/fs/vfs/Makefile Thu Aug 19 02:36:02 2010 @@ -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 Added files: Index: src/tests/fs/vfs/t_io.c diff -u /dev/null src/tests/fs/vfs/t_io.c:1.1 --- /dev/null Thu Aug 19 02:36:03 2010 +++ src/tests/fs/vfs/t_io.c Thu Aug 19 02:36:02 2010 @@ -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(); +}