Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/tests/fs Convert "The Original" rename race test from to vfs...



details:   https://anonhg.NetBSD.org/src/rev/e049f13f041b
branches:  trunk
changeset: 756371:e049f13f041b
user:      pooka <pooka%NetBSD.org@localhost>
date:      Wed Jul 14 21:39:31 2010 +0000

description:
Convert "The Original" rename race test from to vfs and retire the
ffs/tmpfs versions.  The only difference is that the origamical
one mounted ffs with MNT_LOG (and therein actually lay the bug).

diffstat:

 tests/fs/ffs/Makefile         |    3 +-
 tests/fs/ffs/t_renamerace.c   |  135 ------------------------------------------
 tests/fs/tmpfs/t_renamerace.c |   53 +----------------
 tests/fs/vfs/Makefile         |    5 +-
 tests/fs/vfs/t_renamerace.c   |   90 ++++++++++++++++++++++++++++
 5 files changed, 95 insertions(+), 191 deletions(-)

diffs (truncated from 339 to 300 lines):

diff -r 66c03e8e4abd -r e049f13f041b tests/fs/ffs/Makefile
--- a/tests/fs/ffs/Makefile     Wed Jul 14 21:24:40 2010 +0000
+++ b/tests/fs/ffs/Makefile     Wed Jul 14 21:39:31 2010 +0000
@@ -1,10 +1,9 @@
-#      $NetBSD: Makefile,v 1.8 2010/06/30 21:54:56 njoly Exp $
+#      $NetBSD: Makefile,v 1.9 2010/07/14 21:39:31 pooka Exp $
 #
 
 TESTSDIR=      ${TESTSBASE}/fs/ffs
 WARNS=         4
 
-TESTS_C=       t_renamerace
 TESTS_C+=      t_fifos
 TESTS_C+=      t_snapshot
 TESTS_C+=      t_mount
diff -r 66c03e8e4abd -r e049f13f041b tests/fs/ffs/t_renamerace.c
--- a/tests/fs/ffs/t_renamerace.c       Wed Jul 14 21:24:40 2010 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,135 +0,0 @@
-/*     $NetBSD: t_renamerace.c,v 1.12 2010/06/30 16:37:12 pooka Exp $  */
-
-/*
- * Modified for rump and atf from a program supplied
- * by Nicolas Joly in kern/40948
- */
-
-#include <sys/types.h>
-#include <sys/mount.h>
-
-#include <atf-c.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <pthread.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-
-#include <rump/rump.h>
-#include <rump/rump_syscalls.h>
-
-#include <ufs/ufs/ufsmount.h>
-
-#include "../../h_macros.h"
-
-ATF_TC_WITH_CLEANUP(renamerace);
-ATF_TC_HEAD(renamerace, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "rename(2) race against files "
-           "unlinked mid-operation, kern/40948");
-       atf_tc_set_md_var(tc, "use.fs", "true");
-}
-
-volatile int quit;
-
-static void *
-w1(void *arg)
-{
-       int fd;
-
-       while (!quit) {
-               fd = rump_sys_open("/mp/rename.test1",
-                   O_WRONLY|O_CREAT|O_TRUNC, 0666);
-               rump_sys_unlink("/mp/rename.test1");
-               rump_sys_close(fd);
-       }
-       return NULL;
-}
-
-static void *
-w2(void *arg)
-{
-
-       while (!quit)
-               rump_sys_rename("/mp/rename.test1", "/mp/rename.test2");
-
-       return NULL;
-}
-
-/* XXX: how to do cleanup if we use mkdtemp? */
-#define IMAGENAME "/tmp/ffsatf.img"
-static char image[PATH_MAX];
-
-#define FAKEBLK "/dev/sp00ka"
-
-ATF_TC_BODY(renamerace, tc)
-{
-       struct ufs_args args;
-       char cmd[256];
-       pthread_t pt1, pt2;
-
-#if 0
-       strcpy(image, TMPPATH);
-       if (mkdtemp(image) == NULL)
-               atf_tc_fail_errno("can't create tmpdir %s", TMPPATH);
-       strcat(image, "/ffsatf.img");
-#else
-       strcpy(image, IMAGENAME);
-#endif
-
-       strcpy(cmd, "newfs -F -s 10000 ");
-       strcat(cmd, image);
-
-       if (system(cmd) == -1)
-               atf_tc_fail_errno("newfs failed");
-
-       memset(&args, 0, sizeof(args));
-       args.fspec = __UNCONST(FAKEBLK);
-
-       rump_init();
-       if (rump_sys_mkdir("/mp", 0777) == -1)
-               atf_tc_fail_errno("cannot create mountpoint");
-       rump_pub_etfs_register(FAKEBLK, image, RUMP_ETFS_BLK);
-       if (rump_sys_mount(MOUNT_FFS, "/mp", MNT_LOG, &args, sizeof(args))==-1)
-               atf_tc_fail_errno("rump_sys_mount failed");
-
-       pthread_create(&pt1, NULL, w1, NULL);
-       pthread_create(&pt2, NULL, w2, NULL);
-
-       sleep(10);
-
-       quit = 1;
-       pthread_join(pt1, NULL);
-       pthread_join(pt2, NULL);
-
-       if (rump_sys_unmount("/mp", 0) == -1)
-               atf_tc_fail_errno("unmount failed");
-}
-
-ATF_TC_CLEANUP(renamerace, tc)
-{
-#if 0
-       char *img;
-
-       img = strrchr(image, '/');
-       if (!img)
-               return;
-
-       printf("removing %s\n", img+1);
-       unlink(img+1);
-       *img = '\0';
-       rmdir(img);
-#else
-       unlink(IMAGENAME);
-#endif
-}
-
-ATF_TP_ADD_TCS(tp)
-{
-       ATF_TP_ADD_TC(tp, renamerace);
-
-       return atf_no_error();
-}
diff -r 66c03e8e4abd -r e049f13f041b tests/fs/tmpfs/t_renamerace.c
--- a/tests/fs/tmpfs/t_renamerace.c     Wed Jul 14 21:24:40 2010 +0000
+++ b/tests/fs/tmpfs/t_renamerace.c     Wed Jul 14 21:39:31 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: t_renamerace.c,v 1.7 2010/07/04 12:43:23 pooka Exp $   */
+/*     $NetBSD: t_renamerace.c,v 1.8 2010/07/14 21:39:31 pooka Exp $   */
 
 /*
  * Modified for rump and atf from a program supplied
@@ -25,56 +25,6 @@
 
 #include "../../h_macros.h"
 
-ATF_TC(renamerace);
-ATF_TC_HEAD(renamerace, tc)
-{
-       atf_tc_set_md_var(tc, "descr", "rename(2) race against files "
-           "unlinked mid-operation, kern/41128");
-}
-
-static void *
-w1(void *arg)
-{
-       int fd;
-
-       for (;;) {
-               fd = rump_sys_open("/rename.test1",
-                   O_WRONLY|O_CREAT|O_TRUNC, 0666);
-               rump_sys_unlink("/rename.test1");
-               rump_sys_close(fd);
-       }
-       return NULL;
-}
-
-static void *
-w2(void *arg)
-{
-
-       for (;;) {
-               rump_sys_rename("/rename.test1", "/rename.test2");
-       }
-       return NULL;
-}
-
-ATF_TC_BODY(renamerace, tc)
-{
-       struct tmpfs_args args;
-       pthread_t pt1, pt2;
-
-       memset(&args, 0, sizeof(args));
-       args.ta_version = TMPFS_ARGS_VERSION;
-       args.ta_root_mode = 0777;
-
-       rump_init();
-       if (rump_sys_mount(MOUNT_TMPFS, "/", 0, &args, sizeof(args)) == -1)
-               atf_tc_fail_errno("could not mount tmpfs");
-
-       pthread_create(&pt1, NULL, w1, NULL);
-       pthread_create(&pt2, NULL, w2, NULL);
-
-       sleep(10);
-}
-
 ATF_TC(renamerace2);
 ATF_TC_HEAD(renamerace2, tc)
 {
@@ -169,7 +119,6 @@
 
 ATF_TP_ADD_TCS(tp)
 {
-       ATF_TP_ADD_TC(tp, renamerace);
        ATF_TP_ADD_TC(tp, renamerace2);
 
        return atf_no_error();
diff -r 66c03e8e4abd -r e049f13f041b tests/fs/vfs/Makefile
--- a/tests/fs/vfs/Makefile     Wed Jul 14 21:24:40 2010 +0000
+++ b/tests/fs/vfs/Makefile     Wed Jul 14 21:39:31 2010 +0000
@@ -1,10 +1,11 @@
-#      $NetBSD: Makefile,v 1.5 2010/07/13 18:13:10 pooka Exp $
+#      $NetBSD: Makefile,v 1.6 2010/07/14 21:39:31 pooka Exp $
 #
 
 TESTSDIR=      ${TESTSBASE}/fs/vfs
 WARNS=         4
 
-TESTS_C=       t_rmdirrace
+TESTS_C+=      t_renamerace
+TESTS_C+=      t_rmdirrace
 TESTS_C+=      t_vfsops
 TESTS_C+=      t_vnops
 
diff -r 66c03e8e4abd -r e049f13f041b tests/fs/vfs/t_renamerace.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/vfs/t_renamerace.c       Wed Jul 14 21:39:31 2010 +0000
@@ -0,0 +1,90 @@
+/*     $NetBSD: t_renamerace.c,v 1.1 2010/07/14 21:39:31 pooka Exp $   */
+
+/*
+ * Modified for rump and atf from a program supplied
+ * by Nicolas Joly in kern/40948
+ */
+
+#include <sys/types.h>
+#include <sys/mount.h>
+#include <sys/utsname.h>
+
+#include <atf-c.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "../common/h_fsmacros.h"
+#include "../../h_macros.h"
+
+static volatile int quittingtime;
+
+static void *
+w1(void *arg)
+{
+       int fd;
+
+       rump_pub_lwp_alloc_and_switch(0, 10);
+       rump_sys_chdir(arg);
+
+       while (!quittingtime) {
+               fd = rump_sys_open("rename.test1",
+                   O_WRONLY|O_CREAT|O_TRUNC, 0666);
+               if (fd == -1)
+                       atf_tc_fail_errno("create");
+               rump_sys_unlink("rename.test1");
+               rump_sys_close(fd);
+       }
+
+       rump_sys_chdir("/");
+
+       return NULL;
+}
+
+static void *



Home | Main Index | Thread Index | Old Index