This makes the tool test script log command output to a file and only remove the test file (now named testvol by default) on success so that we can analyze it on failure.
Also adds some tests to create and check file systems with various resource group sizes. Signed-off-by: Andrew Price <[email protected]> --- .gitignore | 2 ++ tests/tool_tests.sh | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index bd47927..a1eadd0 100644 --- a/.gitignore +++ b/.gitignore @@ -41,6 +41,8 @@ gfs2/fsck/fsck.gfs2 gfs2/mkfs/mkfs.gfs2 gfs2/tune/tunegfs2 tests/check_libgfs2 +tests/testvol +tests/tests.log group/gfs_control/gfs_control group/gfs_controld/gfs_controld ABOUT-NLS diff --git a/tests/tool_tests.sh b/tests/tool_tests.sh index 791b071..50be31a 100755 --- a/tests/tool_tests.sh +++ b/tests/tool_tests.sh @@ -11,7 +11,10 @@ MKFS="${TOPBUILDDIR}/gfs2/mkfs/mkfs.gfs2 -qO" FSCK="${TOPBUILDDIR}/gfs2/fsck/fsck.gfs2 -qn" # Name of the sparse file we'll use for testing -TEST_TARGET=${TEST_TARGET:-test_sparse} +TEST_TARGET=${TEST_TARGET:-testvol} +# Log of test output +TEST_LOG=${TEST_LOG:-tests.log} +truncate -cs0 "${TEST_LOG}" # Size, in GB, of the sparse file we'll create to run the tests TEST_TARGET_SZ=${TEST_TARGET_SZ:-10} [ $TEST_TARGET_SZ -gt 0 ] || { echo "Target size (in GB) must be greater than 0" >&2; exit 1; } @@ -22,17 +25,17 @@ fn_test() { local expected="$1" local cmd="$2" - echo -n "Running '$cmd' - (Exp: $expected Got: " - $cmd &> /dev/null; + echo -n "** Test '$cmd'" | tee -a "${TEST_LOG}" + $cmd &>> "${TEST_LOG}"; local ret=$? - echo -n "$ret) " + echo -n " (exp: $expected got: $ret) " | tee -a "${TEST_LOG}" if [ "$ret" != "$expected" ]; then - echo "FAIL" + echo "FAIL" | tee -a "${TEST_LOG}" TEST_RET=1 TEST_GRP_RET=1 else - echo "PASS" + echo "PASS" | tee -a "${TEST_LOG}" fi } @@ -44,7 +47,7 @@ fn_rm_target() fn_recreate_target() { fn_rm_target - fn_test 0 "dd if=/dev/null of=$TEST_TARGET bs=1 count=0 seek=${TEST_TARGET_SZ}G" + fn_test 0 "truncate -s ${TEST_TARGET_SZ}G ${TEST_TARGET}" } @@ -54,9 +57,16 @@ fn_test 0 "$MKFS -p lock_nolock $TEST_TARGET" fn_test 0 "$MKFS -p lock_dlm -t foo:bar $TEST_TARGET" fn_test 255 "$MKFS -p badprotocol $TEST_TARGET" fn_test 0 "$FSCK $TEST_TARGET" +fn_test 255 "$MKFS -p lock_nolock -r 31 $TEST_TARGET" +fn_test 255 "$MKFS -p lock_nolock -r 2049 $TEST_TARGET" +fn_test 0 "$MKFS -p lock_nolock -r 32 $TEST_TARGET" +fn_test 0 "$FSCK $TEST_TARGET" +fn_test 0 "$MKFS -p lock_nolock -r 2048 $TEST_TARGET" +fn_test 0 "$FSCK $TEST_TARGET" # Tests end here -# Clean up -fn_test 0 "rm -f $TEST_TARGET" +# Only remove the test file on success +[ "$TEST_RET" = "0" ] && fn_test 0 "rm -f $TEST_TARGET" +echo "Tool test output written to ${TEST_LOG}" exit $TEST_RET -- 1.8.1.2
