From: Andrew Price <anprice@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [PATCH 4/5] gfs2-utils: Make the tool tests script more useful
Date: Tue, 26 Feb 2013 14:04:25 +0000	[thread overview]
Message-ID: <1361887466-20763-5-git-send-email-anprice@redhat.com> (raw)
In-Reply-To: <1361887466-20763-1-git-send-email-anprice@redhat.com>
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 <anprice@redhat.com>
---
 .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
next prev parent reply	other threads:[~2013-02-26 14:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-26 14:04 [Cluster-devel] [PATCH 0/5] mkfs.gfs2 improvements (groundwork) Andrew Price
2013-02-26 14:04 ` [Cluster-devel] [PATCH 1/5] libgfs2: Rework blk_alloc_i Andrew Price
2013-02-26 14:04 ` [Cluster-devel] [PATCH 2/5] libgfs2: Make gfs2_rgrp_out accept char buffers Andrew Price
2013-02-26 14:04 ` [Cluster-devel] [PATCH 3/5] mkfs.gfs2: Reduce memory usage Andrew Price
2013-02-26 14:04 ` Andrew Price [this message]
2013-02-26 14:04 ` [Cluster-devel] [PATCH 5/5] mkfs.gfs2: Separate user options from file system params Andrew Price
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox
  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):
  git send-email \
    --in-reply-to=1361887466-20763-5-git-send-email-anprice@redhat.com \
    --to=anprice@redhat.com \
    /path/to/YOUR_REPLY
  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
  Be sure your reply has a Subject: header at the top and a blank line
  before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).