[Ocfs2-test-devel] [PATCH] Compress dirs checks v2

tristan.ye tristan.ye at oracle.com
Wed Aug 26 19:50:43 PDT 2009


It looks nice to me except some minor issues.

Tristan.

Goldwyn Rodrigues Wrote:
> This patch incorporates review comments by Tristan.
>
> The test sequence is:
> 1.  Create files under directories
> 2.  Remove alternate files from the directories
> 3.  Get recursive directory listing and store in listing1
> 4.  Perform fsck -D
> 5.  Get recursive directory listing and store in listing2
> 6.  Compare listing1 and listing2 to check if any files are missing.
>
> Signed-off-by: Goldwyn Rodrigues <rgoldwyn at suse.de>
>
> ---
> diff --git a/programs/fsck-tests/fsck-test.sh b/programs/fsck-tests/fsck-test.sh
> index 2edbd7b..e11e0b6 100755
> --- a/programs/fsck-tests/fsck-test.sh
> +++ b/programs/fsck-tests/fsck-test.sh
> @@ -130,6 +130,8 @@ function internal_setup()
>   	BASE_DIR=${O2TDIR}
>  	TMP_DIR="/tmp/${0##*/}-$$"
>  	mkdir -p "$TMP_DIR"
> +	MOUNT_POINT="/tmp/mp.$$"
> +	mkdir -p "$MOUNT_POINT"
>
>  	check_exec_or_exit cat mktemp wc yes
>  }
> @@ -148,6 +150,10 @@ function internal_cleanup()
>  		rm -rf "$TMP_DIR"
>  		unset TMP_DIR
>  	fi
> +	if [ -d "$MOUNT_POINT" ]; then
> +		rm -rf "$MOUNT_POINT"
> +		unset MOUNT_POINT
> +	fi
>  }
>
>  #
> @@ -169,6 +175,7 @@ function usage()
>  	      --with-fswreck=PROGRAM        use the PROGRAM as fswreck
>  	      --with-mkfs=PROGRAM           use the PROGRAM as mkfs.ocfs2
>  	      --with-corrupt=CORRUPTS       use specified fswreck corrupt code
> +	      --with-mount=PROGRAM       use the PROGRAM as mount.ocfs2
>
>  	Examples:
>
> @@ -185,6 +192,8 @@ DEVICE=""
>  MKFS_BIN=""
>  FSCK_BIN=""
>  FSWRECK_BIN=""
> +MOUNT_BIN=""
> +UMOUNT_BIN=""
>  declare -i NUM_OF_TESTS=0
>  declare -i NUM_OF_PASS=0
>  declare -i NUM_OF_FAIL=0
> @@ -214,6 +223,12 @@ function ext_setup()
>  	[ -z "$MKFS_BIN" ] && MKFS_BIN="$(which mkfs.ocfs2 2>/dev/null)"
>  	[ -x "$MKFS_BIN" ]
>  	exit_if_bad "$?" "Command \"mkfs.ocfs2\" not found"
> +	[ -z "$MOUNT_BIN" ] && MOUNT_BIN="$(which mount.ocfs2 2>/dev/null)"
> +	[ -x "$MOUNT_BIN" ]
> +	exit_if_bad "$?" "Command \"mount.ocfs2\" not found"
> +	[ -z "$UMOUNT_BIN" ] && UMOUNT_BIN="$(which umount 2>/dev/null)"
> +	[ -x "$UMOUNT_BIN" ]
> +	exit_if_bad "$?" "Command \"umount\" not found"
>  }
>
>  CURRENT_TEST=""
> @@ -372,6 +387,159 @@ function gen_fs_features()
>
>  }
>
> +# $1 number of directories
> +# $2 number of files in each directory
> +
> +function create_files()
> +{
> +	local RETVAL=0
> +	if [[ "$#" -ne "2" ]]; then
> +		echo "Not enough arguments for create_files"
> +		return 1
> +	fi
> +
> +	local numdirs=$1
> +	local numfiles=$2
> +	for i in `seq 1 $numdirs`; do
> +		mkdir $MOUNT_POINT/d.$i 2>"$STDERR"
> +		RETVAL=$?
> +		test_fail_if_bad "$RETVAL" "mkdir d.$i failed" || return $RETVAL
> +		
> +		for j in `seq 1 $numfiles`; do
> +			touch $MOUNT_POINT/d.$i/f.$j 2>"$STDERR"
> +			RETVAL=$?
> +			test_fail_if_bad "$RETVAL" "touch d.$i/f.$j failed" || return $RETVAL
> +		done
> +	done
> +	return 0
> +}
> +
> +# $1 interval for directories to delete
> +# $2 total number of directories
> +function rm_files()
> +{
> +	local RETVAL=0
> +	if [[ "$#" -ne "2" ]]; then
> +		echo "Not enough arguments for create_files"
> +		return 1
> +	fi
> +	local interval=$1
> +	local numdirs=$2
> +	for i in `seq 1 $interval $numdirs`; do
> +		rm -Rf $MOUNT_POINT/d.$i 2>"$STDERR"
> +		RETVAL=$?
> +		test_fail_if_bad "$RETVAL" "dir d.$i rm failed" || return $RETVAL
> +	done
> +	for i in `ls $MOUNT_POINT | grep -v "lost+found"`; do
>   
should be:

`ls -1 $MOUNT_POINT | grep -v "lost+found"`

otherwise you may miss files at the same line of "lost+found"

> +		for j in `seq 1 2 100`; do
>   
Also will be better if the file number and interval here are arguments.
> +			rm $MOUNT_POINT/$i/f.$j 2>"$STDERR"
> +			RETVAL=$?
> +			test_fail_if_bad "$RETVAL" "file rm $i/f.$j failed" || return $RETVAL
> +		done
> +	done
> +	return 0
> +}
> +
> +
> +#	$1	Disk size, should be ``small'', ``medium'' or ``large''.
> +function compress_dirs_test()
> +{
> +	local disk_size="$1"
> +
> +	# Small disk
> +	local -a mkfs_profile_small=(
> +		1024		# block size
> +		4096		# cluster size
> +		4		# number of node solts
> +		"4M"		# journal
> +		262144		# blocks count
> +	);
> +	# Medium disk
> +	local -a mkfs_profile_medium=(
> +		4096		# block size
> +		4096		# cluster size
> +		4		# number of node solts
> +		"16M"		# journal
> +		1048576		# blocks count
> +	);
> +	# Large disk
> +	local -a mkfs_profile_large=(
> +		4096		# block size
> +		131072		# cluster size
> +		4		# number of node solts
> +		"64M"		# journal
> +		16777216	# blocks count
> +	);
> +
> +	local v="mkfs_profile_${disk_size}[@]"
> +	local -a mkfs_profile=("${!v}")
> +
> +	test_setup "Compress dirs test"
> +
> +	if [ 0 -eq "${#mkfs_profile[@]}" ]
> +	then
> +		test_broken "Unknown disk size"
> +		return
> +	fi
> +
> +	dd if=/dev/zero of=$DEVICE bs=1M count=4 &>"$STDOUT"
> +	test_info "dd if=/dev/zero of=$DEVICE bs=1M count=4"
> +	test_fail_if_bad "$?" "dd failed" || return
> +
> +	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" ${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_info "mount $DEVICE $MOUNT_POINT"
> +	"$MOUNT_BIN" $DEVICE $MOUNT_POINT &>"$STDOUT"
> +	test_fail_if_bad "$?" "mount failed" || return
> +	
> +	local num_dirs=20
> +	local num_files=100
> +	local interval=2
> +	if [[ "disk_size" == "large" ]]; then
> +		num_dirs=100
> +		num_files=5000
> +	elif [[ "$disk_size" == "medium" ]]; then
> +		num_dirs=50
> +		num_files=1000
> +	fi
> +	test_info "Creating files num_dirs=$num_dirs num_files=$unm_files"
> +	create_files $num_dirs $num_files
> +	test_fail_if_bad "$?" "creating files failed" || return
> +	test_info "Removing files num_dirs=$num_dirs interval=$interval"
> +	rm_files $interval $num_dirs
> +	test_fail_if_bad "$?" "removing files/dirs failed" || return
> +		
> +
> +	ls -R $MOUNT_POINT > $TMP_DIR/listing1
> +
> +	test_info "umount $DEVICE $MOUNT_POINT"
> +	"$UMOUNT_BIN" $DEVICE &>"$STDOUT"
> +	test_fail_if_bad "$?" "umount failed" || return
> +
> +	test_info "fsck.ocfs2 -Dfy $DEVICE"
> +	"$FSCK_BIN" -fy "$DEVICE" >"$STDOUT"
> +	test_fail_if_bad "$?" "fsck failed" || return
> +
> +	test_info "mount $DEVICE $MOUNT_POINT"
> +	"$MOUNT_BIN" $DEVICE $MOUNT_POINT &>"$STDOUT"
> +	test_fail_if_bad "$?" "mount failed" || return
> +
> +	ls -R $MOUNT_POINT > $TMP_DIR/listing2
> +	cmp $TMP_DIR/listing1 $TMP_DIR/listing2 &>/dev/null
> +	test_fail_if_bad "$?" "files are different" || return
> +
> +	test_info "umount $DEVICE $MOUNT_POINT"
> +	"$UMOUNT_BIN" $DEVICE &>"$STDOUT"
> +	test_fail_if_bad "$?" "umount failed" || return
> +
> +	test_pass
> +}
> +
>  #	$2	Disk size, should be ``small'', ``medium'' or ``large''.
>  function corrupt_test()
>  {
> @@ -530,6 +698,9 @@ do
>  	"--with-corrupt="*)
>  		CORRUPT="${1#--with-corrupt=}"
>  		;;
> +	"--with-mount="*)
> +		MOUNT_BIN="${1#--with-mount=}"
> +		;;
>  	*)
>  		DEVICE="$1"
>  		;;
> @@ -540,14 +711,14 @@ done
>  if [ ! -d ${LOG_DIR} ]; then
>  	mkdir -p ${LOG_DIR}
>  	if [ $? -ne 0 ]; then
> -		echo -e "Failed to create directory ${LOG_DIR}\n";
> -		exit(1);
> -	fi;
> -fi;
> +		echo -e "Failed to create directory ${LOG_DIR}\n"
> +		exit 1
> +	fi
> +fi
>  LOGFILE=${LOG_DIR}/fsck-test.log
>  if [ -f ${LOGFILE} ]; then
>  	mv ${LOGFILE} `dirname ${LOGFILE}`/`date +%F-%H-%M-%S`-`basename ${LOGFILE}`
> -fi;
> +fi
>  #
>  if [ "" = "$CORRUPT" ]
>  then
> @@ -561,5 +732,6 @@ check_root_or_exit
>  ext_setup
>  smoke_test
>  basic_test
> +compress_dirs_test $DISK_SIZE
>  #corrupt_test 22
>  #corrupt_test 36
>
> _______________________________________________
> Ocfs2-test-devel mailing list
> Ocfs2-test-devel at oss.oracle.com
> http://oss.oracle.com/mailman/listinfo/ocfs2-test-devel
>   




More information about the Ocfs2-test-devel mailing list