Module Name:src
Committed By: perseant
Date: Sun Aug 23 16:03:54 UTC 2020
Modified Files:
src/tests/fs/lfs: t_rfw.c
Log Message:
Expand test to cover more failure cases. Change from skipped to expect fail
in anticipation of working roll-forward code.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/tests/fs/lfs/t_rfw.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/lfs/t_rfw.c
diff -u src/tests/fs/lfs/t_rfw.c:1.1 src/tests/fs/lfs/t_rfw.c:1.2
--- src/tests/fs/lfs/t_rfw.c:1.1 Tue Aug 18 03:02:50 2020
+++ src/tests/fs/lfs/t_rfw.c Sun Aug 23 16:03:54 2020
@@ -1,11 +1,11 @@
-/* $NetBSD: t_rfw.c,v 1.1 2020/08/18 03:02:50 perseant Exp $ */
+/* $NetBSD: t_rfw.c,v 1.2 2020/08/23 16:03:54 perseant Exp $ */
#include
#include
-#include
#include
#include
+#include
#include
#include
#include
@@ -25,7 +25,6 @@
/* Debugging conditions */
/* #define FORCE_SUCCESS */ /* Don't actually revert, everything worked */
-/* #define FORCE_SYSCTL */ /* Don't check - necessary for FORCE_SUCCESS */
/* Write a well-known byte pattern into a file, appending if it exists */
int write_file(const char *, int);
@@ -33,6 +32,12 @@ int write_file(const char *, int);
/* Check the byte pattern and size of the file */
int check_file(const char *, int);
+/* Check the file system for consistency */
+int fsck(void);
+
+/* Actually run the test, differentiating the orphaned delete problem */
+void test(int);
+
ATF_TC(rfw);
ATF_TC_HEAD(rfw, tc)
{
@@ -41,42 +46,39 @@ ATF_TC_HEAD(rfw, tc)
atf_tc_set_md_var(tc, "timeout", "20");
}
+#define MAXLINE 132
+#define CHUNKSIZE 300
+
#define IMGNAME "disk.img"
#define FAKEBLK "/dev/blk"
#define LOGFILE "newfs.log"
#define SBLOCK0_COPY "sb0.dd"
#define SBLOCK1_COPY "sb1.dd"
-#define MAXLINE 132
-#define CHUNKSIZE 300
+
+#define MP "/mp"
+#define UNCHANGED_CONTROL MP "/3-unchanged-control"
+#define TO_BE_DELETED MP "/4-to-be-deleted"
+#define TO_BE_APPENDEDMP "/5-to-be-appended"
+#define NEWLY_CREATED MP "/6-newly-created"
+
+long long sbaddr[2] = { -1, -1 };
+const char *sblock[2] = { SBLOCK0_COPY, SBLOCK1_COPY };
+
ATF_TC_BODY(rfw, tc)
{
struct ufs_args args;
FILE *pipe;
-#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
- int o_sysctl_rfw;
- int n_sysctl_rfw;
- int mib[3];
- size_t len;
-#endif
char buf[MAXLINE];
- long long sb0addr = -1, sb1addr = -1;
+ int i;
+
+ setvbuf(stdout, NULL, _IONBF, 0);
/*
* Initialize.
*/
-#if (!defined FORCE_SUCCESS && !defined FORCE_SYSCTL)
- /* Set sysctl to allow roll-forward */
- fprintf(stderr, "* Set sysctl\n");
- mib[0] = CTL_VFS;
- mib[1] = 5; /* LFS */
- mib[2] = LFS_DO_RFW;
- len = sizeof(o_sysctl_rfw);
- if (sysctl(mib, 3, _sysctl_rfw, ,
- _sysctl_rfw, sizeof(n_sysctl_rfw)) < 0)
- atf_tc_skip("roll-forward not enabled in kernel");
-#endif /* !FORCE_SUCCESS && !FORCE_SYSCTL */
+ atf_tc_expect_fail("roll-forward not yet implemented");
- /* Create filesystem */
+ /* Create filesystem, note superblock locations */
fprintf(stderr, "* Create file system\n");
if (system("newfs_lfs -D -F -s 1 ./" IMGNAME " > " LOGFILE) == -1)
atf_tc_fail_errno("newfs failed");
@@ -84,20 +86,20 @@ ATF_TC_BODY(rfw, tc)
if (pipe == NULL)
atf_tc_fail_errno("newfs failed to execute");
while (fgets(buf, MAXLINE, pipe) != NULL) {
- if (sscanf(buf, "%lld,%lld", , ) == 2)
+ if (sscanf(buf, "%lld,%lld", sbaddr, sbaddr + 1) == 2)
break;
}
while (fgets(buf, MAXLINE, pipe) != NULL)
;
fclose(pipe);
- if (sb0addr < 0 || sb1addr < 0)
+ if (sbaddr[0] < 0 || sbaddr[1] < 0)
atf_tc_fail("superblock not found");
fprintf(stderr, "* Superblocks at %lld and %lld\n",
- sb0addr, sb1addr);
+ sbaddr[0], sbaddr[1]);
/* Set up rump */
rump_init();
- if (rump_sys_mkdir("/mp", 0777) == -1)
+ if (rump_sys_mkdir(MP, 0777) == -1)
atf_tc_fail_errno("cannot create mountpoint");
rump_pub_etfs_register(FAKEBLK, IMGNAME, RUMP_ETFS_BLK);
@@ -107,61 +109,63 @@ ATF_TC_BODY(rfw, tc)
*/
/* Mount filesystem */
- fprintf(stderr, "* Mount fs [1]\n");
+ fprintf(stderr, "* Mount fs [1, initial]\n");
memset(, 0, sizeof(args));
args.fspec = __UNCONST(FAKEBLK);
- if (rump_sys_mount(MOUNT_LFS, "/mp", 0, , sizeof(args)) == -1)
+ if (rump_sys_mount(MOUNT_LFS, MP, 0, , sizeof(args)) == -1)
atf_tc_fail_errno("rump_sys_mount failed");
/* Payload */
fprintf(stderr, "* Initial payload\n");
- write_file("/mp/to_be_deleted", CHUNKSIZE);
- write_file("/mp/to_be_appended", CHUNKSIZE);
-
- /* Unmount */
- rump_sys_unmount("/mp", 0);
+ write_file(UNCHANGED_CONTROL, CHUNKSIZE);
+ write_file(TO_BE_DELETED, CHUNKSIZE);
+ write_file(TO_BE_APPENDED, CHUNKSIZE);
+ rump_sys_sync();
+ rump_sys_sync();
+ sleep(1); /* XXX yuck - but we need the superblocks dirty */
/* Make copies of superblocks */
- sprintf(buf, "dd if=%s of=%s bs=512 iseek=%lld count=16 conv=sync",