Module Name: src Committed By: njoly Date: Mon Jul 5 12:53:59 UTC 2010
Modified Files: src/distrib/sets/lists/tests: mi src/etc/mtree: NetBSD.dist.base src/tests/fs: Makefile Added Files: src/tests/fs/vfs: Atffile Makefile t_rmdirrace.c Log Message: Add test program that use sample code from kern/41937, and fs rump helpers to check currently supported filesystems. t_rmdirrace (1/1): 5 test cases ext2fs_race: Passed. ffs_race: Passed. msdosfs_race: Passed. sysvbfs_race: Passed. tmpfs_race: Passed. To generate a diff of this commit: cvs rdiff -u -r1.97 -r1.98 src/distrib/sets/lists/tests/mi cvs rdiff -u -r1.29 -r1.30 src/etc/mtree/NetBSD.dist.base cvs rdiff -u -r1.11 -r1.12 src/tests/fs/Makefile cvs rdiff -u -r0 -r1.1 src/tests/fs/vfs/Atffile src/tests/fs/vfs/Makefile \ src/tests/fs/vfs/t_rmdirrace.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/distrib/sets/lists/tests/mi diff -u src/distrib/sets/lists/tests/mi:1.97 src/distrib/sets/lists/tests/mi:1.98 --- src/distrib/sets/lists/tests/mi:1.97 Sun Jul 4 19:34:44 2010 +++ src/distrib/sets/lists/tests/mi Mon Jul 5 12:53:58 2010 @@ -1,4 +1,4 @@ -# $NetBSD: mi,v 1.97 2010/07/04 19:34:44 pooka Exp $ +# $NetBSD: mi,v 1.98 2010/07/05 12:53:58 njoly Exp $ # # Note: don't delete entries from here - mark them as "obsolete" instead. # @@ -211,6 +211,8 @@ ./usr/libdata/debug/usr/tests/fs/union tests-fs-debug ./usr/libdata/debug/usr/tests/fs/union/t_basic.debug tests-fs-debug debug,atf ./usr/libdata/debug/usr/tests/fs/union/t_pr.debug tests-fs-debug debug,atf +./usr/libdata/debug/usr/tests/fs/vfs tests-fs-debug +./usr/libdata/debug/usr/tests/fs/vfs/t_rmdirrace.debug tests-fs-debug debug,atf ./usr/libdata/debug/usr/tests/ipf tests-ipf-tests ./usr/libdata/debug/usr/tests/kernel tests-kernel-tests ./usr/libdata/debug/usr/tests/kernel/kqueue tests-kernel-tests @@ -919,6 +921,9 @@ ./usr/tests/fs/union/Atffile tests-fs-tests atf ./usr/tests/fs/union/t_basic tests-fs-tests atf ./usr/tests/fs/union/t_pr tests-fs-tests atf +./usr/tests/fs/vfs tests-fs-tests +./usr/tests/fs/vfs/Atffile tests-fs-tests atf +./usr/tests/fs/vfs/t_rmdirrace tests-fs-tests atf ./usr/tests/games tests-games-tests ./usr/tests/games/Atffile tests-games-tests ./usr/tests/games/t_factor tests-games-tests Index: src/etc/mtree/NetBSD.dist.base diff -u src/etc/mtree/NetBSD.dist.base:1.29 src/etc/mtree/NetBSD.dist.base:1.30 --- src/etc/mtree/NetBSD.dist.base:1.29 Sun Jul 4 19:33:18 2010 +++ src/etc/mtree/NetBSD.dist.base Mon Jul 5 12:53:58 2010 @@ -1,4 +1,4 @@ -# $NetBSD: NetBSD.dist.base,v 1.29 2010/07/04 19:33:18 pooka Exp $ +# $NetBSD: NetBSD.dist.base,v 1.30 2010/07/05 12:53:58 njoly Exp $ # @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93 # Do not customize this file as it may be overwritten on upgrades. @@ -210,6 +210,7 @@ ./usr/libdata/debug/usr/tests/fs/tmpfs ./usr/libdata/debug/usr/tests/fs/umapfs ./usr/libdata/debug/usr/tests/fs/union +./usr/libdata/debug/usr/tests/fs/vfs ./usr/libdata/debug/usr/tests/ipf ./usr/libdata/debug/usr/tests/kernel ./usr/libdata/debug/usr/tests/kernel/kqueue @@ -1110,6 +1111,7 @@ ./usr/tests/fs/tmpfs ./usr/tests/fs/umapfs ./usr/tests/fs/union +./usr/tests/fs/vfs ./usr/tests/games ./usr/tests/ipf ./usr/tests/ipf/expected Index: src/tests/fs/Makefile diff -u src/tests/fs/Makefile:1.11 src/tests/fs/Makefile:1.12 --- src/tests/fs/Makefile:1.11 Mon Jun 28 09:45:06 2010 +++ src/tests/fs/Makefile Mon Jul 5 12:53:58 2010 @@ -1,10 +1,11 @@ -# $NetBSD: Makefile,v 1.11 2010/06/28 09:45:06 pooka Exp $ +# $NetBSD: Makefile,v 1.12 2010/07/05 12:53:58 njoly Exp $ .include <bsd.own.mk> TESTSDIR= ${TESTSBASE}/fs SUBDIR+= ffs kernfs lfs msdosfs nullfs ptyfs puffs tmpfs umapfs union +SUBDIR+= vfs FILES= h_funcs.subr FILESDIR= ${TESTSDIR} Added files: Index: src/tests/fs/vfs/Atffile diff -u /dev/null src/tests/fs/vfs/Atffile:1.1 --- /dev/null Mon Jul 5 12:53:59 2010 +++ src/tests/fs/vfs/Atffile Mon Jul 5 12:53:58 2010 @@ -0,0 +1,6 @@ +Content-Type: application/X-atf-atffile; version="1" +X-NetBSD-Id: "$NetBSD: Atffile,v 1.1 2010/07/05 12:53:58 njoly Exp $" + +prop: test-suite = "NetBSD" + +tp: t_rmdirrace Index: src/tests/fs/vfs/Makefile diff -u /dev/null src/tests/fs/vfs/Makefile:1.1 --- /dev/null Mon Jul 5 12:53:59 2010 +++ src/tests/fs/vfs/Makefile Mon Jul 5 12:53:58 2010 @@ -0,0 +1,17 @@ +# $NetBSD: Makefile,v 1.1 2010/07/05 12:53:58 njoly Exp $ +# + +TESTSDIR= ${TESTSBASE}/fs/vfs +WARNS= 4 + +TESTS_C= t_rmdirrace + +LDADD+=-lrumpfs_ext2fs # ext2fs +LDADD+=-lrumpfs_ffs # ffs +LDADD+=-lrumpfs_msdos # msdos +LDADD+=-lrumpfs_sysvbfs # sysvbfs +LDADD+=-lrumpfs_tmpfs # tmpfs +LDADD+=-lrumpdev_disk -lrumpdev # disk device +LDADD+=-lrumpvfs -lrump -lrumpuser -lpthread # base + +.include <bsd.test.mk> Index: src/tests/fs/vfs/t_rmdirrace.c diff -u /dev/null src/tests/fs/vfs/t_rmdirrace.c:1.1 --- /dev/null Mon Jul 5 12:53:59 2010 +++ src/tests/fs/vfs/t_rmdirrace.c Mon Jul 5 12:53:58 2010 @@ -0,0 +1,102 @@ +/* $NetBSD: t_rmdirrace.c,v 1.1 2010/07/05 12:53:58 njoly Exp $ */ + +/*- + * Copyright (c) 2010 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by + * + * 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 <atf-c.h> +#include <fcntl.h> +#include <pthread.h> +#include <unistd.h> + +#include <rump/rump_syscalls.h> +#include <rump/rump.h> + +#include "../common/h_fsmacros.h" + +#define DIRNAME "rmdir.test" + +static void *func1(void *arg) +{ + + while (*(int *)arg != 1) + rump_sys_mkdir(DIRNAME, 0755); + + return NULL; +} + +static void *func2(void *arg) +{ + + while (*(int *)arg != 1) + rump_sys_rmdir(DIRNAME); + + return NULL; +} + +static void +race(const char *path) +{ + int res, fd, quit; + pthread_t th1, th2; + + fd = rump_sys_open(".", O_RDONLY, 0666); + if (fd == -1) + atf_tc_fail("open failed"); + res = rump_sys_chdir(path); + if (res == -1) + atf_tc_fail("chdir failed"); + + quit = 0; + + res = pthread_create(&th1, NULL, func1, &quit); + if (res != 0) + atf_tc_fail("pthread_create1 failed"); + res = pthread_create(&th2, NULL, func2, &quit); + if (res != 0) + atf_tc_fail("pthread_create2 failed"); + + sleep(10); + + quit = 1; + + res = pthread_join(th2, NULL); + if (res != 0) + atf_tc_fail("pthread_join2 failed"); + res = pthread_join(th1, NULL); + if (res != 0) + atf_tc_fail("pthread_join1 failed"); + + res = rump_sys_fchdir(fd); + if (res == -1) + atf_tc_fail("fchdir failed"); +} + +ATF_FSAPPLY(race, "rmdir(2) race");