[Ocfs2-test-devel] [PATCH 1/1] Ocfs2-test: Improve resize_test.sh for tunefs.ocfs2 changes.

Tristan Ye tristan.ye at oracle.com
Mon Jun 8 21:05:05 PDT 2009


As the output of new tunefs.ocfs2 changed when doing resizing(Now it
output nothing even if we turn the vebose mode on), our test tools
therefore need to be updated accordingly. from my point of view, it
would be better to both check the return code of the testing cmd and
output of debugfs.ocfs2 to see if the volume size grows correctly.

Some other improvements also included in the patches for permission and
path problems.

Signed-off-by: Tristan Ye <tristan.ye at oracle.com>
---
 programs/resize_test/resize_test.sh |   43 ++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 15 deletions(-)

diff --git a/programs/resize_test/resize_test.sh b/programs/resize_test/resize_test.sh
index 9a243ed..f5ba60c 100755
--- a/programs/resize_test/resize_test.sh
+++ b/programs/resize_test/resize_test.sh
@@ -7,7 +7,11 @@
 # blocks, where each chunk has to be greater than a cluster
 #
 
-PATH=$PATH:/sbin        # Add /sbin to the path for ocfs2 tools
+if [ -f `dirname ${0}`/config.sh ]; then
+	. `dirname ${0}`/config.sh
+fi
+
+PATH=$PATH:/sbin:${BINDIR}        # Add /sbin to the path for ocfs2 tools
 
 usage() {
     echo "usage: resize_test.sh -c -o <outdir> -d <device> -i <iters> -l <label> -m <mntdir> -n <nodelist>"
@@ -165,6 +169,7 @@ do_debugfs() {
 }
 
 do_tunefs() {
+
     if [ "$#" -lt "2" ]
     then
         echo "do_tunefs(): <out> <blk>" >&2
@@ -179,21 +184,23 @@ do_tunefs() {
     else
         echo -n "grow device to ${blk} blocks "
     fi
-    echo ${TUNEFS} -S ${device} ${blk} > ${out}
-    ${TUNEFS} -x -S ${device} ${blk} >>${out} 2>&1
-    ${GREP} "Cannot grow volume size" ${out} >/dev/null 2>&1
-    if [ $? -eq 0 ]
-    then
-         echo "OK (ENOSPC)"
-         return 1
-    fi
-
-    ${GREP} "Resized volume" ${out} >/dev/null 2>&1
-    if [ $? -ne 0 ] ;
-    then
-        echo "FAILED. Errors in ${out}"
-        exit 1
+    echo ${TUNEFS} -v -S ${device} ${blk} > ${out}
+    ${TUNEFS} -v -S ${device} ${blk} >>${out} 2>&1
+
+    if [ $? -eq 0 ]; then
+	 bs=`${DEBUGFS} -R "stats" ${device} 2>/dev/null | awk '/Block Size Bits/ {print $4;}'`
+	 cs=`${DEBUGFS} -R "stats" ${device} 2>/dev/null | awk '/Cluster Size Bits/ {print $8;}'`
+	 clusters=`${DEBUGFS} -R "stats" ${device} 2>/dev/null | awk '/Clusters:/ {print $4;}'` 
+	 blocks=`echo 2^$((${cs}-${bs}))*${clusters}|bc`
+	 if [ "${blocks}" != "${blk}" ]; then
+		echo "FAILED, wanted to grow ${blk}, but got ${blocks} instead"
+		return 1
+	 fi
+    else
+	 echo "FAILED. Errors in ${out}"
+	 exit 1
     fi
+   
     echo "OK"
     return 0
 }
@@ -361,6 +368,9 @@ DD="`which sudo` -u root `which dd`"
 MKDIR="`which sudo` -u root `which mkdir`"
 GREP=`which grep`
 DATE=`which date`
+CHOWN_BIN=`which chown`
+CHMOD_BIN=`which chmod`
+SUDO="`which sudo` -u root"
 REMOTE_MOUNT=`which remote_mount.py`
 REMOTE_UMOUNT=`which remote_umount.py`
 
@@ -405,6 +415,9 @@ fi
 echo "create logdir ${outdir}"
 ${MKDIR} -p ${outdir}
 
+${SUDO} ${CHMOD_BIN} -R 777 ${outdir}
+${SUDO} ${CHOWN_BIN} -R ${USERNAME}:${GROUPNAME} ${outdir}
+
 blocksz=0
 clustsz=0
 numclst=0
-- 
1.5.5




More information about the Ocfs2-test-devel mailing list