Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src add tests for the mount update from rw to rw+log, which used...
details: https://anonhg.NetBSD.org/src/rev/c6081b571e5f
branches: trunk
changeset: 352246:c6081b571e5f
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Wed Mar 22 21:33:06 2017 +0000
description:
add tests for the mount update from rw to rw+log, which used to case the panic
reported in PR kern/52056
diffstat:
distrib/sets/lists/tests/mi | 3 +-
tests/fs/ffs/Makefile | 3 +-
tests/fs/ffs/t_update_log.c | 148 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 152 insertions(+), 2 deletions(-)
diffs (186 lines):
diff -r badf61ae9df9 -r c6081b571e5f distrib/sets/lists/tests/mi
--- a/distrib/sets/lists/tests/mi Wed Mar 22 21:30:59 2017 +0000
+++ b/distrib/sets/lists/tests/mi Wed Mar 22 21:33:06 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: mi,v 1.728 2017/03/11 04:24:52 ozaki-r Exp $
+# $NetBSD: mi,v 1.729 2017/03/22 21:33:06 jdolecek Exp $
#
# Note: don't delete entries from here - mark them as "obsolete" instead.
#
@@ -1440,6 +1440,7 @@
./usr/tests/fs/ffs/t_snapshot tests-fs-tests atf,rump
./usr/tests/fs/ffs/t_snapshot_log tests-fs-tests atf,rump
./usr/tests/fs/ffs/t_snapshot_v2 tests-fs-tests atf,rump
+./usr/tests/fs/ffs/t_update_log tests-fs-tests atf,rump
./usr/tests/fs/fifofs tests-fs-tests compattestfile,atf
./usr/tests/fs/fifofs/Atffile tests-fs-tests atf,rump
./usr/tests/fs/fifofs/Kyuafile tests-fs-tests atf,rump,kyua
diff -r badf61ae9df9 -r c6081b571e5f tests/fs/ffs/Makefile
--- a/tests/fs/ffs/Makefile Wed Mar 22 21:30:59 2017 +0000
+++ b/tests/fs/ffs/Makefile Wed Mar 22 21:33:06 2017 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.18 2015/01/07 22:24:03 pooka Exp $
+# $NetBSD: Makefile,v 1.19 2017/03/22 21:33:06 jdolecek Exp $
#
.include <bsd.own.mk>
@@ -27,6 +27,7 @@
TESTS_C+= t_mount
TESTS_C+= t_quota2_1
TESTS_C+= t_quota2_remount
+TESTS_C+= t_update_log
LDADD+=-lrumpfs_ffs # ffs
LDADD+=-lrumpdev_fss # snapshot dev
diff -r badf61ae9df9 -r c6081b571e5f tests/fs/ffs/t_update_log.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/fs/ffs/t_update_log.c Wed Mar 22 21:33:06 2017 +0000
@@ -0,0 +1,148 @@
+/* $NetBSD: t_update_log.c,v 1.1 2017/03/22 21:33:53 jdolecek Exp $ */
+
+/*
+ * Check log behaviour on mount updates
+ */
+
+#include <atf-c.h>
+
+#define FSTEST_IMGSIZE (96 * 512)
+#include "../common/h_fsmacros.h"
+
+#include <sys/types.h>
+#include <sys/mount.h>
+
+#include <stdlib.h>
+
+#include <ufs/ufs/ufsmount.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+
+#include "h_macros.h"
+
+ATF_TC(updaterwtolog);
+ATF_TC_HEAD(updaterwtolog, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "mounts file system with "
+ "rw, then rw+log");
+}
+
+/*
+ * PR kern/52056
+ * This doesn't trigger panic with old, despite same operations triggering
+ * it with live kernel.
+ * Steps:
+ * 1. boot singleuser
+ * 2. mount -u /
+ * 3. echo abc > abc
+ * 4. mount -u -o log /
+ * 5. echo abc >> abc
+ *
+ * Keeping around just in case.
+ */
+ATF_TC_BODY(updaterwtolog, tc)
+{
+ char buf[1024];
+ struct ufs_args args;
+ int n = 10, fd;
+ const char *newfs_args = "-O2";
+ const char teststring[] = "6c894efc21094525ca1f974c0189b3b0c4e1f28d";
+
+ snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d "
+ "%s %s", (n + 3), newfs_args, FSTEST_IMGNAME);
+ if (system(buf) == -1)
+ atf_tc_fail_errno("cannot create file system");
+
+ rump_init();
+ if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1)
+ atf_tc_fail_errno("mount point create");
+
+ rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK);
+
+ args.fspec = __UNCONST("/diskdev");
+
+ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_RDONLY,
+ &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME);
+
+ if (rump_sys_chdir(FSTEST_MNTNAME) == 1)
+ atf_tc_fail_errno("chdir");
+
+ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_UPDATE,
+ &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME);
+
+ RL(fd = rump_sys_open("dummy", O_CREAT | O_RDWR, 0755));
+ RL(rump_sys_write(fd, teststring, strlen(teststring)));
+ rump_sys_close(fd);
+
+ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_LOG|MNT_UPDATE,
+ &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("mount ffs rw log update %s", FSTEST_MNTNAME);
+
+ RL(fd = rump_sys_open("dummy", O_APPEND | O_RDWR, 0755));
+ RL(rump_sys_write(fd, teststring, strlen(teststring)));
+ rump_sys_close(fd);
+
+ /* otherwise we're do-ne */
+}
+
+ATF_TC(updaterwtolog_async);
+ATF_TC_HEAD(updaterwtolog_async, tc)
+{
+
+ atf_tc_set_md_var(tc, "descr", "mounts file system with "
+ "rw+async, then rw+async+log");
+}
+
+/*
+ * PR kern/52056
+ */
+ATF_TC_BODY(updaterwtolog_async, tc)
+{
+ char buf[1024];
+ struct ufs_args args;
+ int n = 10, fd;
+ const char *newfs_args = "-O2";
+
+ snprintf(buf, sizeof(buf), "newfs -q user -q group -F -s 4000 -n %d "
+ "%s %s", (n + 3), newfs_args, FSTEST_IMGNAME);
+ if (system(buf) == -1)
+ atf_tc_fail_errno("cannot create file system");
+
+ rump_init();
+ if (rump_sys_mkdir(FSTEST_MNTNAME, 0777) == -1)
+ atf_tc_fail_errno("mount point create");
+
+ rump_pub_etfs_register("/diskdev", FSTEST_IMGNAME, RUMP_ETFS_BLK);
+
+ args.fspec = __UNCONST("/diskdev");
+
+ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, 0,
+ &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("mount ffs rw %s", FSTEST_MNTNAME);
+
+ if (rump_sys_chdir(FSTEST_MNTNAME) == 1)
+ atf_tc_fail_errno("chdir");
+
+ RL(fd = rump_sys_open("dummy", O_CREAT | O_RDWR, 0755));
+ sprintf(buf, "test file");
+ RL(rump_sys_write(fd, buf, strlen(buf)));
+ rump_sys_close(fd);
+
+ if (rump_sys_mount(MOUNT_FFS, FSTEST_MNTNAME, MNT_LOG|MNT_ASYNC|MNT_UPDATE,
+ &args, sizeof(args)) == -1)
+ atf_tc_fail_errno("mount ffs rw log update %s", FSTEST_MNTNAME);
+
+ /* otherwise we're do-ne */
+}
+
+ATF_TP_ADD_TCS(tp)
+{
+ ATF_TP_ADD_TC(tp, updaterwtolog);
+ ATF_TP_ADD_TC(tp, updaterwtolog_async);
+
+ return atf_no_error();
+}
Home |
Main Index |
Thread Index |
Old Index