[Ocfs2-tools-devel] [PATCH 3/3] Ocfs2-tests: Add testcases for fsck-test to verify if new corruptions for inline-data can be fixed.v2

Tristan Ye tristan.ye at oracle.com
Tue Sep 9 04:55:26 PDT 2008


Add new testcase for fsck-test to verfiy if newly added corruptions for inline-data
can be fixed by fsck.the corruptions will mess up the inline-data flag and id_count.

Btw,the newly added corruptions mentioned above in fswreck were 44,45(corrupt code).
Therefore 4 .stdout files added for comparison when fscking...

Should apply the patch for fswreck to add new corruptions first before your testing,
this patch also has been sent out.

Marcos,

I've noticed that you have added a patch to generate a single logfile for fsck-test.sh,
that sounds great,just some minor suggestions as follows:)

1.you use tee -a ${LOG_FILE} to append the logfile,but the tee always try to write the
logfile before the LOG_DIR was created.so the script always failed when the LOG_DIR we
specified did not exist. should mkdir the LOG_DIR at the very beginning.

2.I also noticed you use tee -a to capture the diff result when verfiying the output between
actual output of fsck and expected standard one as follows,

diff -u -I ..>${STDOU}|tee -a ${LOG_FILE}

test_fail_if_bad $? ...

In that case,the $?(return code) always be true as it always return the RC of second command in a pipe
operation.since the tee command always should be successful.
so we got a PASSED test here even if the fsck test failed.

you can use set -o pipefail in script to avoid this. or just remove the tee command from pipe.It seems
did not make any sense to capture a output here.

Besides that,

I'd like to add a fsck.ocfs2.$corrupt.clean.actual.stdout here,otherwise,we always only got a
clean actual output.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 programs/fsck-tests/fsck-test.sh                   |   42 ++++++++++++++++---
 .../fsck-tests/medium-disk/fsck.ocfs2.44.stdout    |   21 ++++++++++
 .../fsck-tests/medium-disk/fsck.ocfs2.45.stdout    |   25 ++++++++++++
 .../fsck-tests/small-disk/fsck.ocfs2.44.stdout     |   21 ++++++++++
 .../fsck-tests/small-disk/fsck.ocfs2.45.stdout     |   25 ++++++++++++
 5 files changed, 127 insertions(+), 7 deletions(-)
 create mode 100644 programs/fsck-tests/medium-disk/fsck.ocfs2.44.stdout
 create mode 100644 programs/fsck-tests/medium-disk/fsck.ocfs2.45.stdout
 create mode 100644 programs/fsck-tests/small-disk/fsck.ocfs2.44.stdout
 create mode 100644 programs/fsck-tests/small-disk/fsck.ocfs2.45.stdout

diff --git a/programs/fsck-tests/fsck-test.sh b/programs/fsck-tests/fsck-test.sh
index 7af55df..852b91e 100755
--- a/programs/fsck-tests/fsck-test.sh
+++ b/programs/fsck-tests/fsck-test.sh
@@ -195,6 +195,10 @@ DISK_SIZE="small"
 LOG_DIR=`dirname ${BINDIR}`
 
 
+declare -a FS_FEATURES=""
+FS_FEATURES_OPTION="--fs-features="
+FS_FEATURES_ARGS=""
+
 #
 # ext_setup		Guess the position of fsck.ocfs2, fswreck and fill
 #			FSCK_BIN, FSWRECK_BIN
@@ -350,6 +354,25 @@ function smoke_test()
 	test_pass_or_fail 0
 }
 
+#add --fs-feature support for mkfs
+function gen_fs_features()
+{
+        local corrupt="$1"
+
+	FS_FEATURES_ARGS=
+
+        case "$corrupt" in
+                "44")   FS_FEATURES="noinline-data" ;;
+                "45")   FS_FEATURES="inline-data" ;;
+                *)      ;;
+        esac
+
+        for item in $FS_FEATURES;do
+                FS_FEATURES_ARGS="${FS_FEATURES_OPTION}${item} ${FS_FEATURES_ARGS}"
+        done
+
+}
+
 #	$2	Disk size, should be ``small'', ``medium'' or ``large''.
 function corrupt_test()
 {
@@ -396,10 +419,13 @@ function corrupt_test()
 	test_info "dd if=/dev/zero of=$DEVICE bs=1M count=4"
 	test_fail_if_bad "$?" "dd failed" || return
 
-	test_info mkfs.ocfs2 -b "${mkfs_profile[0]}" -C "${mkfs_profile[1]}" \
+	#add --fs-features support for mkfs
+        gen_fs_features ${corrupt}
+
+	test_info mkfs.ocfs2 ${FS_FEATURES_ARGS} -b "${mkfs_profile[0]}" -C "${mkfs_profile[1]}" \
 		-N "${mkfs_profile[2]}" -J "size=${mkfs_profile[3]}" \
 		"$DEVICE" "${mkfs_profile[4]}"
-	yes | "$MKFS_BIN" -b "${mkfs_profile[0]}" -C "${mkfs_profile[1]}" \
+	yes | "$MKFS_BIN" ${FS_FEATURES_ARGS} -b "${mkfs_profile[0]}" -C "${mkfs_profile[1]}" \
 		-N "${mkfs_profile[2]}" -J "size=${mkfs_profile[3]}" \
 		"$DEVICE" "${mkfs_profile[4]}" &>"$STDOUT"
 	test_fail_if_bad "$?" "mkfs failed" || return
@@ -430,7 +456,7 @@ function corrupt_test()
 		-I "\[EB_GEN\] An extent block at [0-9]\+ in inode [0-9]\+ has a generation of 1234 which doesn't match the volume's generation of [0-9a-f]\{8\}.  Consider this extent block invalid? y" \
 		"$TMP_DIR/fsck.ocfs2.$corrupt.expect.stdout" \
 		"$TMP_DIR/fsck.ocfs2.$corrupt.actual.stdout" \
-		>"$STDOUT" &>"$STDOUT" |tee -a ${LOGFILE}
+		>"$STDOUT" &>"$STDOUT"
 	fi
 	test_fail_if_bad "$?" "fsck output differ with the expect one" || return
 
@@ -438,7 +464,7 @@ function corrupt_test()
 	"$FSCK_BIN" -fy "$DEVICE" >"$STDOUT" 2>"$STDERR"
 	test_fail_if_bad "$?" "fsck failed" || return
 
-	cp "$STDOUT" "$TMP_DIR/fsck.ocfs2.$corrupt.actual.stdout" &>/dev/null
+	cp "$STDOUT" "$TMP_DIR/fsck.ocfs2.$corrupt.clean.actual.stdout" &>/dev/null
 	[ -f "$TMP_DIR/fsck.ocfs2.clean.expect.stdout" ] ||
 		sed -e "s#@DEVICE@#$DEVICE#" \
 		<"$BASE_DIR/workfiles/fsck-test/${disk_size}-disk/fsck.ocfs2.clean.stdout" \
@@ -446,8 +472,8 @@ function corrupt_test()
 
 	diff -u -I "  uuid:              \( [0-9a-f][0-9a-f]\)\{16\}" \
 		"$TMP_DIR/fsck.ocfs2.clean.expect.stdout" \
-		"$TMP_DIR/fsck.ocfs2.$corrupt.actual.stdout" \
-		>"$STDOUT" &>"$STDOUT" |tee -a ${LOGFILE}
+		"$TMP_DIR/fsck.ocfs2.$corrupt.clean.actual.stdout" \
+		>"$STDOUT" &>"$STDOUT"
 	test_fail_if_bad "$?" "fsck output differ with the expect one" || return
 
 	test_pass
@@ -511,6 +537,8 @@ do
 	shift
 done
 
+mkdir -p "$LOG_DIR" || exit 1
+
 LOGFILE=${LOG_DIR}/fsck-test.log
 if [ -f ${LOGFILE} ]; then
 	mv ${LOGFILE} `dirname ${LOGFILE}`/`date +%F-%H-%M-%S`-`basename ${LOGFILE}`
@@ -518,7 +546,7 @@ fi;
 #
 if [ "" = "$CORRUPT" ]
 then
-	CORRUPT="$(seq -f "%02g" 00 43)"
+	CORRUPT="$(seq -f "%02g" 00 45)"
 fi
 
 [ -b "$DEVICE" ]
diff --git a/programs/fsck-tests/medium-disk/fsck.ocfs2.44.stdout b/programs/fsck-tests/medium-disk/fsck.ocfs2.44.stdout
new file mode 100644
index 0000000..b3bf0b7
--- /dev/null
+++ b/programs/fsck-tests/medium-disk/fsck.ocfs2.44.stdout
@@ -0,0 +1,21 @@
+Checking OCFS2 filesystem in @DEVICE@:
+  label:              <NONE>
+  uuid:               f4 54 89 d1 04 97 4b 52 a7 b6 8c 73 26 77 22 d3 
+  number of blocks:   1048576
+  bytes per block:    4096
+  number of clusters: 1048576
+  bytes per cluster:  4096
+  max slots:          4
+
+ at DEVICE@ was run with -f, check forced.
+Pass 0a: Checking cluster allocation chains
+Pass 0b: Checking inode allocation chains
+Pass 0c: Checking extent block allocation chains
+Pass 1: Checking inodes and blocks.
+[INLINE_DATA_FLAG_INVALID] Inode 16857 has inline flag set but the volume doesn't support it. Clear it? y
+[INLINE_DATA_FLAG_INVALID] Inode 16858 has inline flag set but the volume doesn't support it. Clear it? y
+Pass 2: Checking directory entries.
+Pass 3: Checking directory connectivity.
+Pass 4a: checking for orphaned inodes
+Pass 4b: Checking inodes link counts.
+All passes succeeded.
diff --git a/programs/fsck-tests/medium-disk/fsck.ocfs2.45.stdout b/programs/fsck-tests/medium-disk/fsck.ocfs2.45.stdout
new file mode 100644
index 0000000..f267219
--- /dev/null
+++ b/programs/fsck-tests/medium-disk/fsck.ocfs2.45.stdout
@@ -0,0 +1,25 @@
+Checking OCFS2 filesystem in @DEVICE@:
+  label:              <NONE>
+  uuid:               04 31 ee 61 f6 02 44 ac a1 0b be a8 c7 59 6c b8 
+  number of blocks:   1048576
+  bytes per block:    4096
+  number of clusters: 1048576
+  bytes per cluster:  4096
+  max slots:          4
+
+ at DEVICE@ was run with -f, check forced.
+Pass 0a: Checking cluster allocation chains
+Pass 0b: Checking inode allocation chains
+Pass 0c: Checking extent block allocation chains
+Pass 1: Checking inodes and blocks.
+[INLINE_DATA_COUNT_INVALID] Inode 16851 is inline file and its id_count is 0 which should be 3896. Correct this count? y
+[INODE_SIZE] Inode 16851has a size of 3897 which exceeds the max inline data size 3896. Correct the file size? y
+[INODE_CLUSTERS] Inode 16851 has 1 clusters but it has inline data flag set. Correct the number of clusters? y
+[INLINE_DATA_COUNT_INVALID] Inode 16852 is inline file and its id_count is 0 which should be 3896. Correct this count? y
+[INODE_SIZE] Inode 16852has a size of 3897 which exceeds the max inline data size 3896. Correct the file size? y
+[INODE_CLUSTERS] Inode 16852 has 1 clusters but it has inline data flag set. Correct the number of clusters? y
+Pass 2: Checking directory entries.
+Pass 3: Checking directory connectivity.
+Pass 4a: checking for orphaned inodes
+Pass 4b: Checking inodes link counts.
+All passes succeeded.
diff --git a/programs/fsck-tests/small-disk/fsck.ocfs2.44.stdout b/programs/fsck-tests/small-disk/fsck.ocfs2.44.stdout
new file mode 100644
index 0000000..1cee7df
--- /dev/null
+++ b/programs/fsck-tests/small-disk/fsck.ocfs2.44.stdout
@@ -0,0 +1,21 @@
+Checking OCFS2 filesystem in @DEVICE@:
+  label:              <NONE>
+  uuid:               b6 9a 0a bf 4f b7 45 33 a2 61 8f ab 93 f3 f0 5f 
+  number of blocks:   262144
+  bytes per block:    1024
+  number of clusters: 65536
+  bytes per cluster:  4096
+  max slots:          4
+
+ at DEVICE@ was run with -f, check forced.
+Pass 0a: Checking cluster allocation chains
+Pass 0b: Checking inode allocation chains
+Pass 0c: Checking extent block allocation chains
+Pass 1: Checking inodes and blocks.
+[INLINE_DATA_FLAG_INVALID] Inode 16883 has inline flag set but the volume doesn't support it. Clear it? y
+[INLINE_DATA_FLAG_INVALID] Inode 16884 has inline flag set but the volume doesn't support it. Clear it? y
+Pass 2: Checking directory entries.
+Pass 3: Checking directory connectivity.
+Pass 4a: checking for orphaned inodes
+Pass 4b: Checking inodes link counts.
+All passes succeeded.
diff --git a/programs/fsck-tests/small-disk/fsck.ocfs2.45.stdout b/programs/fsck-tests/small-disk/fsck.ocfs2.45.stdout
new file mode 100644
index 0000000..6b94859
--- /dev/null
+++ b/programs/fsck-tests/small-disk/fsck.ocfs2.45.stdout
@@ -0,0 +1,25 @@
+Checking OCFS2 filesystem in @DEVICE@:
+  label:              <NONE>
+  uuid:               8d a0 35 81 7e 98 4a 52 8d bd 72 92 37 2d 32 89 
+  number of blocks:   262144
+  bytes per block:    1024
+  number of clusters: 65536
+  bytes per cluster:  4096
+  max slots:          4
+
+ at DEVICE@ was run with -f, check forced.
+Pass 0a: Checking cluster allocation chains
+Pass 0b: Checking inode allocation chains
+Pass 0c: Checking extent block allocation chains
+Pass 1: Checking inodes and blocks.
+[INLINE_DATA_COUNT_INVALID] Inode 16863 is inline file and its id_count is 0 which should be 824. Correct this count? y
+[INODE_SIZE] Inode 16863has a size of 825 which exceeds the max inline data size 824. Correct the file size? y
+[INODE_CLUSTERS] Inode 16863 has 1 clusters but it has inline data flag set. Correct the number of clusters? y
+[INLINE_DATA_COUNT_INVALID] Inode 16864 is inline file and its id_count is 0 which should be 824. Correct this count? y
+[INODE_SIZE] Inode 16864has a size of 825 which exceeds the max inline data size 824. Correct the file size? y
+[INODE_CLUSTERS] Inode 16864 has 1 clusters but it has inline data flag set. Correct the number of clusters? y
+Pass 2: Checking directory entries.
+Pass 3: Checking directory connectivity.
+Pass 4a: checking for orphaned inodes
+Pass 4b: Checking inodes link counts.
+All passes succeeded.
-- 
1.5.5




More information about the Ocfs2-tools-devel mailing list