diff mbox series

[f2fs-dev,RFC,10/24] tests: add fsck testcase of fixing errors recorded in sb

Message ID 20241029120956.4186731-11-shengyong@oppo.com (mailing list archive)
State New
Headers show
Series f2fs-tools: add testcases | expand

Commit Message

Sheng Yong Oct. 29, 2024, 12:09 p.m. UTC
Signed-off-by: Sheng Yong <shengyong@oppo.com>
---
 tests/f_sb_errors/README    |  5 ++++
 tests/f_sb_errors/expect.in | 59 +++++++++++++++++++++++++++++++++++++
 tests/f_sb_errors/script    | 23 +++++++++++++++
 3 files changed, 87 insertions(+)
 create mode 100644 tests/f_sb_errors/README
 create mode 100644 tests/f_sb_errors/expect.in
 create mode 100644 tests/f_sb_errors/script
diff mbox series

Patch

diff --git a/tests/f_sb_errors/README b/tests/f_sb_errors/README
new file mode 100644
index 000000000000..df118e825aac
--- /dev/null
+++ b/tests/f_sb_errors/README
@@ -0,0 +1,5 @@ 
+1. create f2fs image
+2. inject s_stop_reason in super block
+3. fsck -a detects error and clear the error
+4. inject s_errors in super block
+5. fsck -a detects error and clear the error
diff --git a/tests/f_sb_errors/expect.in b/tests/f_sb_errors/expect.in
new file mode 100644
index 000000000000..ea93e95c8192
--- /dev/null
+++ b/tests/f_sb_errors/expect.in
@@ -0,0 +1,59 @@ 
+Info: Automatic fix mode enabled.
+Info: checkpoint stop reason: fault_inject(1) 
+Info: Write valid nat_bits in checkpoint
+Info: checkpoint state = x :  nat_bits compacted_summary unmount
+
+[FSCK] Unreachable nat entries                        [Ok..] [x]
+[FSCK] SIT valid block bitmap checking                [Ok..]
+[FSCK] Hard link checking for regular file            [Ok..] [x]
+[FSCK] valid_block_count matching with CP             [Ok..] [x]
+[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [x]
+[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x]
+[FSCK] valid_inode_count matched with CP              [Ok..] [x]
+[FSCK] free segment_count matched with CP             [Ok..] [x]
+[FSCK] next block offset is free                      [Ok..]
+[FSCK] fixing SIT types
+[FSCK] other corrupted bugs                           [Ok..]
+Info: Duplicate valid checkpoint to mirror position x -> x
+Info: Write valid nat_bits in checkpoint
+Info: write_checkpoint() cur_cp:x
+Info: Write valid nat_bits in checkpoint
+Info: fix_checkpoint() cur_cp:x
+[update_superblock: x] Info: Done to update superblock
+
+Info: Automatic fix mode enabled.
+Info: fs errors: fail_decompression 
+Info: checkpoint state = x :  allow_nocrc nat_bits unmount
+
+[FSCK] Unreachable nat entries                        [Ok..] [x]
+[FSCK] SIT valid block bitmap checking                [Ok..]
+[FSCK] Hard link checking for regular file            [Ok..] [x]
+[FSCK] valid_block_count matching with CP             [Ok..] [x]
+[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [x]
+[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x]
+[FSCK] valid_inode_count matched with CP              [Ok..] [x]
+[FSCK] free segment_count matched with CP             [Ok..] [x]
+[FSCK] next block offset is free                      [Ok..]
+[FSCK] fixing SIT types
+[FSCK] other corrupted bugs                           [Ok..]
+[update_superblock: x] Info: Done to update superblock
+
+Info: Automatic fix mode enabled.
+Info: checkpoint state = x :  allow_nocrc nat_bits unmount
+Info: No error was reported
+
+Info: Force to fix corruption
+Info: checkpoint state = x :  allow_nocrc nat_bits unmount
+
+[FSCK] Unreachable nat entries                        [Ok..] [x]
+[FSCK] SIT valid block bitmap checking                [Ok..]
+[FSCK] Hard link checking for regular file            [Ok..] [x]
+[FSCK] valid_block_count matching with CP             [Ok..] [x]
+[FSCK] valid_node_count matching with CP (de lookup)  [Ok..] [x]
+[FSCK] valid_node_count matching with CP (nat lookup) [Ok..] [x]
+[FSCK] valid_inode_count matched with CP              [Ok..] [x]
+[FSCK] free segment_count matched with CP             [Ok..] [x]
+[FSCK] next block offset is free                      [Ok..]
+[FSCK] fixing SIT types
+[FSCK] other corrupted bugs                           [Ok..]
+
diff --git a/tests/f_sb_errors/script b/tests/f_sb_errors/script
new file mode 100644
index 000000000000..664e4f6f49fc
--- /dev/null
+++ b/tests/f_sb_errors/script
@@ -0,0 +1,23 @@ 
+#!/bin/bash
+
+DESC="superblock[1] with s_stop_reason and s_errors"
+
+. $TOPDIR/tests/helpers
+
+cleanup pre > $LOG 2>&1
+make_f2fs >> $LOG 2>&1
+
+$INJECT --sb 1 --mb s_stop_reason --idx 1 --val 1 $META >> $LOG 2>&1
+$FSCK $FSCK_OPTS -a $META > $OUT 2>&1
+
+$INJECT --sb 1 --mb s_errors --idx 0 --val 2 $META >> $LOG 2>&1
+$FSCK $FSCK_OPTS -a $META >> $OUT 2>&1
+
+# both -a and -f cannot detect errors
+$FSCK $FSCK_OPTS -a $META >> $OUT 2>&1
+echo "" >> $OUT
+$FSCK $FSCK_OPTS -f $META >> $OUT 2>&1
+cat $OUT >> $LOG
+
+check_result
+cleanup post >> $LOG 2>&1