[Ocfs2-test-devel] [PATCH 03/59] ocfs2-test: fix mkfs-test.sh

Junxiao Bi junxiao.bi at oracle.com
Sun Sep 13 19:43:49 PDT 2015


From: Tiger Yang <tiger.yang at oracle.com>

This patch fixes problems in mkfs-test.sh when doing single_run-WIP.sh
testing, add new option about mount point, add output to the log file,
and fixes permission problems about mount, umount, mkdir and rm.

Signed-off-by: Tiger Yang <tiger.yang at oracle.com>
Signed-off-by: Junxiao Bi <junxiao.bi at oracle.com>
---
 programs/mkfs-tests/mkfs-test.sh         |  133 ++++++++++++++++--------------
 programs/python_common/single_run-WIP.sh |    5 +-
 2 files changed, 76 insertions(+), 62 deletions(-)

diff --git a/programs/mkfs-tests/mkfs-test.sh b/programs/mkfs-tests/mkfs-test.sh
index ef37aec..5d99f86 100755
--- a/programs/mkfs-tests/mkfs-test.sh
+++ b/programs/mkfs-tests/mkfs-test.sh
@@ -3,9 +3,10 @@
 # mkfs_test -o <outdir> -d <device>
 #
 usage() {
-    echo "usage: ${MKFS_TEST} -o <outdir> -d <device>"
+    echo "usage: ${MKFS_TEST} -o <outdir> -d <device> -m <mountpoint>"
     echo "       -o output directory for the logs"
     echo "       -d device"
+    echo "       -m mountpoint"
     exit 1
 }
 
@@ -121,8 +122,8 @@ do_mkfs() {
 
 do_mount() {
 	# mount the device on mntdir
-	echo -n "mount " |tee -a ${LOGFILE}
-	mount -t ocfs2 ${device} ${mntdir} 2>/dev/null
+	echo -n "mount ${device} ${mntdir} " |tee -a ${LOGFILE}
+	${MOUNT} -t ocfs2 ${device} ${mntdir} 2>/dev/null
 	if [ $? -ne 0 ]
 	then
 		echo -n "FAILED. Check dmesg for errors." 2>&1  |tee -a ${LOGFILE}
@@ -134,8 +135,8 @@ do_mount() {
 
 do_umount() {
 	# umount the volume
-	echo -n "umount "  |tee -a ${LOGFILE}
-	umount ${mntdir} 2>/dev/null
+	echo -n "umount ${mntdir} "  |tee -a ${LOGFILE}
+	${UMOUNT} ${mntdir} 2>/dev/null
 	if [ $? -ne 0 ]
 	then
 		echo "FAILED. Check dmesg for errors." 2>&1  |tee -a ${LOGFILE}
@@ -157,10 +158,10 @@ do_consume() {
 
 	if [ $file_type -eq 0 ]
 	then
-		echo -n "create ${freespace} files "
+		echo -n "create ${freespace} files " |tee -a ${LOGFILE}
 	else
 		freespace=$[${freespace}/2]
-		echo -n "create 2 large files "
+		echo -n "create 2 large files " |tee -a ${LOGFILE}
 	fi
 
 	j=0
@@ -170,10 +171,10 @@ do_consume() {
 		then
 			if [ $j -eq 10 ]
 			then
-				echo -ne "\b\b\b\b\b\b\b\b\b\b          \b\b\b\b\b\b\b\b\b\b"
+				echo -ne "\b\b\b\b\b\b\b\b\b\b          \b\b\b\b\b\b\b\b\b\b" |tee -a ${LOGFILE}
 				j=0
 			else
-				echo -n "."
+				echo "." |tee -a ${LOGFILE}
 				j=$[$j+1]
 			fi
 		fi
@@ -201,15 +202,12 @@ do_consume() {
 do_consume_and_delete() {
 	file_type=$1
 
-	mntdir=/tmp/`${DATE} +%Y%m%d_%H%M%S`
-	echo "create mntdir ${mntdir}"
-	mkdir -p ${mntdir}
-
 	do_mount
 
 	# add files to fill up (not necessarily full)
 	usedir=${mntdir}/`${DATE} +%Y%m%d_%H%M%S`
-	mkdir -p ${usedir}
+	echo "create testdir ${usedir}" |tee -a ${LOGFILE}
+	${MKDIR} -p ${usedir}
 
 	do_consume $file_type
 
@@ -220,7 +218,8 @@ do_consume_and_delete() {
 	#delete all the files.
 	do_mount
 	
-	rm -rf ${usedir}
+	${RM} -rf ${usedir}
+	echo "delete all test files" |tee -a ${LOGFILE}
 
 	do_umount
 
@@ -238,6 +237,10 @@ do_bitmap_test() {
 MKFS="`which sudo` -u root `which mkfs.ocfs2`"
 FSCK="`which sudo` -u root `which fsck.ocfs2`"
 DEBUGFS="`which sudo` -u root `which debugfs.ocfs2`"
+MOUNT="`which sudo` -u root `which mount.ocfs2`"
+UMOUNT="`which sudo` -u root `which umount`"
+MKDIR="`which sudo` -u root `which mkdir`"
+RM="`which sudo` -u root `which rm`"
 GREP=`which grep`
 DATE=`which date`
 AWK=`which awk`
@@ -247,12 +250,14 @@ MKFS_TEST=`basename $0`
 bindir=`basename ${0}`
 outdir=`basename ${bindir}`
 device=
+mntdir=
 OPTIND=1
-while getopts "d:i:o:c" args
+while getopts "d:i:o:m:c" args
 do
   case "$args" in
     o) outdir="$OPTARG";;
     d) device="$OPTARG";;
+    m) mntdir="$OPTARG";;
   esac
 done
 LOGFILE=${outdir}/mkfs-test.log
@@ -270,6 +275,11 @@ if [ ! -b "${device}" ]; then
     usage ;
 fi
 
+if [ -z "${mntdir}" ]; then
+    echo "invalid mount point: ${mntdir}" |tee -a ${LOGFILE}
+    usage ;
+fi
+
 echo "create logdir ${outdir}" |tee -a ${LOGFILE}
 mkdir -p ${outdir}
 
@@ -309,19 +319,19 @@ OUT=${outdir}/${TAG}.log
 if [ -f ${OUT} ]; then
 	rm -f ${OUT};
 fi;
-echo "Test ${testnum}: -T mail"
-echo -n "mkfs ..... "
+echo "Test ${testnum}: -T mail" |tee -a ${LOGFILE}
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
 ${MKFS} -x -F -b 4K -C 4K -N 2 -T mail ${device} 262144 >${OUT} 2>&1
-echo "OK"
-echo -n "verify ..... "
+echo "OK" |tee -a ${LOGFILE}
+echo -n "verify ..... " |tee -a ${LOGFILE}
 ${DEBUGFS} -R "ls -l //" ${device} >>${OUT} 2>&1
 num=`${AWK} '/journal:0000/ {print $6;}' ${OUT}`
 if [ $num -ne 134217728 ]; then
     echo "ERROR: Journal size too small for type mail" >> ${OUT}
     echo "" >> ${OUT}
-    echo "FAILED. Errors in ${OUT}"
+    echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
 else
-    echo "OK"
+    echo "OK" |tee -a ${LOGFILE}
 fi
 do_fsck ${OUT}
 testnum=$[$testnum+1]
@@ -333,19 +343,19 @@ OUT=${outdir}/${TAG}.log
 if [ -f ${OUT} ]; then
 	rm -f ${OUT};
 fi;
-echo "Test ${testnum}: -T datafiles"
-echo -n "mkfs ..... "
+echo "Test ${testnum}: -T datafiles" |tee -a ${LOGFILE}
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
 ${MKFS} -x -F -b 4K -C 4K -N 2 -T datafiles ${device} 262144 >${OUT} 2>&1
-echo "OK"
-echo -n "verify ..... "
+echo "OK" |tee -a ${LOGFILE}
+echo -n "verify ..... " |tee -a ${LOGFILE}
 ${DEBUGFS} -R "ls -l //" ${device} >>${OUT} 2>&1
 num=`${AWK} '/journal:0000/ {print $6;}' ${OUT}`
 if [ $num -ne 33554432 ]; then
     echo "ERROR: Journal size too small for type datafiles" >> ${OUT}
     echo "" >> ${OUT}
-    echo "FAILED. Errors in ${OUT}"
+    echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
 else
-    echo "OK"
+    echo "OK" |tee -a ${LOGFILE}
 fi
 do_fsck ${OUT}
 testnum=$[$testnum+1]
@@ -360,20 +370,20 @@ do
     if [ -f ${OUT} ]; then
 	rm -f ${OUT};
     fi;
-    echo "Test ${testnum}: -J size=${jrnlsz}M"
-    echo -n "mkfs ..... "
+    echo "Test ${testnum}: -J size=${jrnlsz}M" |tee -a ${LOGFILE}
+    echo -n "mkfs ..... " |tee -a ${LOGFILE}
     ${MKFS} -x -F -b 4K -C 4K -N 2 -J size=${jrnlsz}M ${device} 262144 >${OUT} 2>&1
-    echo "OK"
-    echo -n "verify ..... "
+    echo "OK" |tee -a ${LOGFILE}
+    echo -n "verify ..... " |tee -a ${LOGFILE}
     ${DEBUGFS} -R "ls -l //" ${device} >>${OUT} 2>&1
     num=`${AWK} '/journal:0000/ {print $6;}' ${OUT}`
     inbytes=$[$jrnlsz*1024*1024]
     if [ $num -ne ${inbytes} ]; then
         echo "ERROR: Journal size expected ${inbytes} but found ${num}" >> ${OUT}
         echo "" >> ${OUT}
-        echo "FAILED. Errors in ${OUT}"
+        echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
     else
-        echo "OK"
+        echo "OK" |tee -a ${LOGFILE}
     fi
     do_fsck ${OUT}
     testnum=$[$testnum+1]
@@ -389,19 +399,19 @@ do
     if [ -f ${OUT} ]; then
 	rm -f ${OUT};
     fi;
-    echo "Test ${testnum}: -N ${slots}"
-    echo -n "mkfs ..... "
+    echo "Test ${testnum}: -N ${slots}" |tee -a ${LOGFILE}
+    echo -n "mkfs ..... " |tee -a ${LOGFILE}
     ${MKFS} -x -F -b 4K -C 4K -N ${slots} -J size=4M ${device} 262144 >${OUT} 2>&1
-    echo "OK"
-    echo -n "verify ..... "
+    echo "OK" |tee -a ${LOGFILE}
+    echo -n "verify ..... " |tee -a ${LOGFILE}
     ${DEBUGFS} -R "stats" ${device} >>${OUT} 2>&1
     num=`${AWK} '/Max Node Slots:/ {print $4;}' ${OUT}`
     if [ $num -ne ${slots} ]; then
         echo "ERROR: Node slots expected ${slots} but found ${num}" >> ${OUT}
         echo "" >> ${OUT}
-        echo "FAILED. Errors in ${OUT}"
+        echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
     else
-        echo "OK"
+        echo "OK" |tee -a ${LOGFILE}
     fi
     do_fsck ${OUT}
     testnum=$[$testnum+1]
@@ -414,20 +424,20 @@ OUT=${outdir}/${TAG}.log
 if [ -f ${OUT} ]; then
 	rm -f ${OUT};
 fi;
-echo "Test ${testnum}: -L mylabel"
+echo "Test ${testnum}: -L mylabel" |tee -a ${LOGFILE}
 label="my_label_is_very_very_very_long_to_the_point_of_being_useless"
-echo -n "mkfs ..... "
-${MKFS} -x -F -b 4K -C 4K -N 1 -L ${label} ${device} 262144 >${OUT} 2>&1
-echo "OK"
-echo -n "verify ..... "
-${DEBUGFS} -R "stats" ${device} >>${OUT} 2>&1
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
+${MKFS} -x -F -b 4K -C 4K -N 1 -L ${label} ${device} 262144 >{OUt} 2>&1
+echo "OK" |tee -a ${LOGFILE}
+echo -n "verify ..... " |tee -a ${LOGFILE}
+${DEBUGFS} -R "stats" ${device} >${OUT} 2>&1
 dsklab=`${AWK} '/Label:/ {print $2;}' ${OUT}`
 if [ ${label} != ${dsklab} ]; then
     echo "ERROR: Label found \"${dsklab}\" expected \"${label}\"" >> ${OUT}
     echo "" >> ${OUT}
-    echo "FAILED. Errors in ${OUT}"
+    echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
 else
-    echo "OK"
+    echo "OK" |tee -a ${LOGFILE}
 fi
 do_fsck ${OUT}
 testnum=$[$testnum+1]
@@ -439,21 +449,21 @@ OUT=${outdir}/${TAG}.log
 if [ -f ${OUT} ]; then
         rm -f ${OUT};
 fi;
-echo "Test ${testnum}: --fs-features=inline-data"
+echo "Test ${testnum}: --fs-features=inline-data" |tee -a ${LOGFILE}
 label="Oracle_Home"
-echo -n "mkfs ..... "
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
 ${MKFS} --fs-features=inline-data -x -F -b 4K -C 4K -N 2 -L ${label} ${device} 262144 >>${OUT} 2>&1
-echo "OK"
-echo -n "verify ..... "
+echo "OK" |tee -a ${LOGFILE}
+echo -n "verify ..... " |tee -a ${LOGFILE}
 ${DEBUGFS} -R "stats" ${device} >>${OUT} 2>&1
 ${DEBUGFS} -R "stats" ${device}|${GREP} -i "Feature Incompat"|${GREP} -q "inline-data"
 RC=$?
 if [ "${RC}" != "0" ]; then
     echo "ERROR: Did not find InlineData Flag on superblock " >> ${OUT}
     echo "" >> ${OUT}
-    echo "FAILED. Errors in ${OUT}"
+    echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
 else
-    echo "OK"
+    echo "OK" |tee -a ${LOGFILE}
 fi
 do_fsck ${OUT}
 testnum=$[$testnum+1]
@@ -465,21 +475,21 @@ OUT=${outdir}/${TAG}.log
 if [ -f ${OUT} ]; then
         rm -f ${OUT};
 fi;
-echo "Test ${testnum}: Default option for sparse file support"
+echo "Test ${testnum}: Default option for sparse file support" |tee -a ${LOGFILE}
 label="Oracle_Home"
-echo -n "mkfs ..... "
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
 ${MKFS} -x -F -b 4K -C 4K -N 2 -L ${label} ${device} 262144 >>${OUT} 2>&1
-echo "OK"
-echo -n "verify ..... "
+echo "OK" |tee -a ${LOGFILE}
+echo -n "verify ..... " |tee -a ${LOGFILE}
 ${DEBUGFS} -R "stats" ${device} >>${OUT} 2>&1
 ${DEBUGFS} -R "stats" ${device}|${GREP} -i "Feature Incompat"|${GREP} -q "sparse"
 RC=$?
 if [ "${RC}" != "0" ]; then
     echo "ERROR: Did not find Sparse Flag on superblock " >> ${OUT}
     echo "" >> ${OUT}
-    echo "FAILED. Errors in ${OUT}"
+    echo "FAILED. Errors in ${OUT}" |tee -a ${LOGFILE}
 else
-    echo "OK"
+    echo "OK" |tee -a ${LOGFILE}
 fi
 do_fsck ${OUT}
 testnum=$[$testnum+1]
@@ -500,7 +510,10 @@ if [ $blkcount -gt $total_block ];
 then
 	blkcount=$total_block
 fi
+echo "Test ${testnum}: bitmap_cpg change" |tee -a ${LOGFILE}
+echo -n "mkfs ..... " |tee -a ${LOGFILE}
 ${MKFS} -x -F -b ${blocksz} -C ${clustsz} -N 2 ${device} ${blkcount} >${OUT} 2>&1
+echo "OK" |tee -a ${LOGFILE}
 
 #consume the whole volume and then delete all the files.
 do_bitmap_test
diff --git a/programs/python_common/single_run-WIP.sh b/programs/python_common/single_run-WIP.sh
index 5120493..ac70118 100755
--- a/programs/python_common/single_run-WIP.sh
+++ b/programs/python_common/single_run-WIP.sh
@@ -880,9 +880,10 @@ run_mkfs()
 
 	logdir=$1
 	device=$2
+	mountpoint=$3
 
 	log_start "mkfs_test"
-	mkfs-test.sh -o ${logdir} -d ${device}
+	mkfs-test.sh -o ${logdir} -d ${device} -m ${mountpoint}
 	RC=$?
 	log_end ${RC}
 }
@@ -1019,7 +1020,7 @@ run_reflink_test ${LOGDIR} ${DEVICE} ${MOUNTPOINT}
 
 # For tools test.
 
-run_mkfs ${LOGDIR} ${DEVICE}
+run_mkfs ${LOGDIR} ${DEVICE} ${MOUNTPOINT}
 
 run_tunefs ${LOGDIR} ${DEVICE}
 
-- 
1.7.9.5




More information about the Ocfs2-test-devel mailing list