[Ocfs2-test-devel] [PATCH 1/9] ocfs2-test: Add testing cases for online filecheck
Gang He
ghe at suse.com
Sun Jun 19 20:14:40 PDT 2016
Reviewed-by: Gang He <ghe at suse.com>
Thanks
Gang
>>>
> This include skeleton for testing online filecheck,
> and testing cases for inode block which has been merged
> into kernel mainline.
>
> This testcase won't run with "-t all" options now unless
> "filecheck" is explicitly specified, because it's still
> under developing progress.
>
> Signed-off-by: Eric Ren <zren at suse.com>
> ---
> programs/Makefile | 3 +-
> programs/online_filecheck/Makefile | 9 +
> programs/online_filecheck/filecheck_test_run.sh | 187 +++++++++++
> programs/online_filecheck/filecheck_utils.sh | 53 +++
> programs/online_filecheck/inode_block_test.sh | 407
> ++++++++++++++++++++++++
> programs/python_common/single_run-WIP.sh | 27 +-
> 6 files changed, 684 insertions(+), 2 deletions(-)
> create mode 100644 programs/online_filecheck/Makefile
> create mode 100755 programs/online_filecheck/filecheck_test_run.sh
> create mode 100755 programs/online_filecheck/filecheck_utils.sh
> create mode 100755 programs/online_filecheck/inode_block_test.sh
>
> diff --git a/programs/Makefile b/programs/Makefile
> index 04313f9..b562995 100644
> --- a/programs/Makefile
> +++ b/programs/Makefile
> @@ -59,7 +59,8 @@ SUBDIRS = \
> reflink_tests \
> directio_test \
> discontig_bg_test \
> - verify_readonly
> + verify_readonly \
> + online_filecheck
>
> ifdef OCFS2_TEST_DX_DIRS
> SUBDIRS += dx_dirs_tests
> diff --git a/programs/online_filecheck/Makefile
> b/programs/online_filecheck/Makefile
> new file mode 100644
> index 0000000..b16a473
> --- /dev/null
> +++ b/programs/online_filecheck/Makefile
> @@ -0,0 +1,9 @@
> +TOPDIR = ../..
> +
> +include $(TOPDIR)/Preamble.make
> +
> +DIST_FILES = filecheck_test_run.sh inode_block_test.sh filecheck_utils.sh
> +
> +BIN_EXTRA = filecheck_test_run.sh inode_block_test.sh filecheck_utils.sh
> +
> +include $(TOPDIR)/Postamble.make
> diff --git a/programs/online_filecheck/filecheck_test_run.sh
> b/programs/online_filecheck/filecheck_test_run.sh
> new file mode 100755
> index 0000000..9bcfdb1
> --- /dev/null
> +++ b/programs/online_filecheck/filecheck_test_run.sh
> @@ -0,0 +1,187 @@
> +#!/bin/bash
> +#
> +# filecheck_run.sh
> +#
> +# descritpion: This script will perform a thorough single node test on
> online
> +# filecheck for OCFS2. Following testcases will be involed.
> +#
> +# 1. inode block: inode number, inode generation, block ECC
> +#
> +# Author: Eric Ren, zren at suse.com
> +# History: 22 Mar, 2016
> +#
> +# Copyright (C) 2016 SUSE. All rights reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> +# modify it under the terms of the GNU General Public
> +# License as published by the Free Software Foundation, version 2.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> +# General Public License for more details.
> +
> +###########################################################################
> #####
> +# Global Variables
> +###########################################################################
> #####
> +if [ -f `dirname ${0}`/o2tf.sh ]; then
> + . `dirname ${0}`/o2tf.sh
> +fi
> +
> +USERNAME="`id -un`"
> +GROUPNAME="`id -gn`"
> +
> +SUDO="`which sudo` -u root"
> +MKFS_BIN="`which sudo` -u root `which mkfs.ocfs2`"
> +MOUNT_BIN="`which sudo` -u root `which mount.ocfs2`"
> +UMOUNT_BIN="`which sudo` -u root `which umount`"
> +
> +LABELNAME=ocfs2-filecheck-tests
> +OCFS2_DEVICE=
> +MOUNT_POINT=
> +MOUNT_OPTS="errors=continue"
> +FEATURES="local,metaecc"
> +BLOCKSIZE=4096
> +CLUSTERSIZE=32768
> +WORKSPACE=
> +
> +DEFAULT_LOG="filecheck-test-logs"
> +LOG_OUT_DIR=
> +DETAIL_LOG_FILE=
> +
> +TEST_NO=0
> +TEST_PASS=0
> +
> +set -o pipefail
> +
> +###########################################################################
> #####
> +# Utility Functions
> +###########################################################################
> #####
> +
> +f_usage()
> +{
> + echo "usage: `basename ${0}` [-o output log dir] <-d <device>>
> <mountpoint>"
> + echo " -o output directory for logs."
> + echo " -d specify the device to be formated as an ocfs2 volume."
> + echo " <mountpoint> path of mount point where the ocfs2 volume will
> be mounted on."
> +}
> +
> +f_getoptions()
> +{
> + if [ $# -eq 0 ];then
> + f_usage
> + exit 1
> + fi
> +
> + while getopts "o:d:" options; do
> + case $options in
> + o ) LOG_OUT_DIR="$OPTARG";;
> + d ) OCFS2_DEVICE="$OPTARG";;
> + * ) f_usage
> + exit 1;;
> + esac
> + done
> + shift $(($OPTIND - 1))
> + MOUNT_POINT=${1}
> +}
> +
> +f_setup()
> +{
> + f_getoptions $*
> +
> + if [ -z "${MOUNT_POINT}" -o ! -d ${MOUNT_POINT} ];then
> + echo "Mount point ${MOUNT_POINT} does not exist."
> + f_usage
> + fi
> +
> + LOG_OUT_DIR="${LOG_OUT_DIR:-$DEFAULT_LOG}/filecheck"
> + mkdir -p ${LOG_OUT_DIR} || exit 1
> +
> + LOG_SURFIX=$(date +%Y%m%d-%H%M%S)
> + DETAIL_LOG_FILE="${LOG_OUT_DIR}/filecheck_test-${LOG_SURFIX}.log"
> + RUN_LOG_FILE="$LOG_OUT_DIR/run-filecheck-${LOG_SURFIX}.log"
> +
> + WORKSPACE="${MOUNT_POINT}/filecheck_test_place"
> +}
> +
> +f_do_mkfs_and_mount()
> +{
> + echo -n "Mkfsing device:" | tee -a ${DETAIL_LOG_FILE}
> +
> + echo y | ${MKFS_BIN} --fs-features=${FEATURES} --label ${LABELNAME} -b
> ${BLOCKSIZE} -C ${CLUSTERSIZE} ${OCFS2_DEVICE} >> ${DETAIL_LOG_FILE} 2>&1
> + RET=$?
> + f_echo_status ${RET} | tee -a ${DETAIL_LOG_FILE}
> + f_exit_or_not ${RET}
> +
> + echo -n "Mounting device to ${MOUNT_POINT}:" | tee -a
> ${DETAIL_LOG_FILE}
> + ${MOUNT_BIN} -t ocfs2 -o ${MOUNT_OPTS} ${OCFS2_DEVICE} ${MOUNT_POINT} >>
> ${DETAIL_LOG_FILE} 2>&1
> + RET=$?
> + f_echo_status ${RET} | tee -a ${DETAIL_LOG_FILE}
> + f_exit_or_not ${RET}
> +
> + ${SUDO} chown -R ${USERNAME}:${GROUPNAME} ${MOUNT_POINT}
> + ${SUDO} chmod -R 777 ${MOUNT_POINT}
> +
> + mkdir -p ${WORKSPACE} || exit 1
> +}
> +
> +f_do_umount()
> +{
> + echo -n "Umounting device to ${MOUNT_POINT}:" | tee -a ${DETAIL_LOG_FILE}
> +
> + rm -rf ${WORKSPACE} || exit 1
> +
> + ${UMOUNT_BIN} ${MOUNT_POINT} >> ${DETAIL_LOG_FILE} 2>&1
> + RET=$?
> + f_echo_status ${RET} | tee -a ${DETAIL_LOG_FILE}
> + f_exit_or_not ${RET}
> +}
> +
> +f_runtest()
> +{
> + # put testing units here
> + f_do_mkfs_and_mount
> +
> + ((TEST_NO++))
> + echo -ne "[${TEST_NO}] Inode block corrupt & check & fix:" | tee -a
> ${RUN_LOG_FILE}
> + inode_block_test.sh -d ${OCFS2_DEVICE} -m ${MOUNT_POINT} -l
> ${LOG_OUT_DIR}
> + RET=$?
> + f_echo_status ${RET} | tee -a ${RUN_LOG_FILE}
> + f_exit_or_not ${RET}
> + ((TEST_PASS++))
> +
> + f_do_umount
> +}
> +
> +function f_cleanup()
> +{
> + :
> +}
> +
> +###########################################################################
> #####
> +# Main Entry
> +###########################################################################
> #####
> +
> +#redefine the int signal hander
> +trap 'echo -ne "\n\n">>${RUN_LOG_FILE}; echo "Interrupted by Ctrl+C,Cleanuping
> \
> +... "|tee -a ${RUN_LOG_FILE}; f_cleanup; exit 1' SIGINT
> +
> +f_setup $*
> +
> +START_TIME=${SECONDS}
> +f_LogRunMsg ${RUN_LOG_FILE} "=====================Filecheck tests start:
> `date`\
> +=====================\n"
> +f_LogMsg ${DETAIL_LOG_FILE} "=====================Filecheck tests start:
> `date`\
> +====================="
> +
> +f_runtest
> +
> +END_TIME=${SECONDS}
> +f_LogRunMsg ${RUN_LOG_FILE} "=====================Filecheck tests end:
> `date`\
> +=====================\n"
> +f_LogMsg ${DETAIL_LOG_FILE} "=====================Filecheck tests end:
> `date`\
> +====================="
> +
> +f_LogRunMsg ${RUN_LOG_FILE} "Time elapsed(s):
> $((${END_TIME}-${START_TIME}))\n"
> +f_LogRunMsg ${RUN_LOG_FILE} "Tests total: ${TEST_NO}\n"
> +f_LogRunMsg ${RUN_LOG_FILE} "Tests passed: ${TEST_PASS}\n"
> diff --git a/programs/online_filecheck/filecheck_utils.sh
> b/programs/online_filecheck/filecheck_utils.sh
> new file mode 100755
> index 0000000..c63f770
> --- /dev/null
> +++ b/programs/online_filecheck/filecheck_utils.sh
> @@ -0,0 +1,53 @@
> +#!/bin/bash
> +
> +PATH=$PATH:/usr/sbin/
> +
> +DEBUGFS_BIN="`which sudo` -u root `which debugfs.ocfs2`"
> +FSWRECK_BIN="`which sudo` -u root `dirname ${0}`/fswreck"
> +SUDO_BASH="`which sudo` -u root bash -c"
> +SUDO_CAT="`which sudo` -u root `which cat`"
> +
> +f_check_file()
> +{
> + local inode=$1
> + local check_file=$2
> + local error_type=$3
> + local log_file=$4
> +
> + echo -e "${SUDO_BASH} \"echo ${inode} > ${check_file}\"" >> ${log_file} 2>&1
> + ${SUDO_BASH} "echo ${inode} > ${check_file}"
> + sleep 0.1
> + ${SUDO_CAT} ${check_file} > .tmp 2>&1
> + cat .tmp | head -n 1 >> ${log_file} 2>&1
> + LINE=`cat .tmp | tail -n 1`
> + rm -f -- .tmp
> + echo -e "${LINE}" >> ${log_file}
> + local ERROR=`echo ${LINE} | awk '{print $3}'`
> + f_LogMsg ${log_file} "Error type: ${ERROR}"
> + if [ ${ERROR} != "${error_type}" ];then
> + f_LogMsg ${log_file} "Unexpected error type, exit..."
> + false
> + fi
> +}
> +
> +f_fix_file()
> +{
> + local inode=$1
> + local fix_file=$2
> + local log_file=$3
> +
> + echo -e "${SUDO_BASH} \"echo ${inode} > ${fix_file}\"" >> ${log_file} 2>&1
> + ${SUDO_BASH} "echo ${inode} > ${fix_file}"
> + sleep 0.1
> + ${SUDO_CAT} ${fix_file} > .tmp 2>&1
> + cat .tmp | head -n 1 >> ${log_file} 2>&1
> + LINE=`cat .tmp | tail -n 1`
> + rm -f -- .tmp
> + echo -e "${LINE}" >> ${log_file}
> + local RESULT=`echo ${LINE} | awk '{print $3}'`
> + f_LogMsg ${log_file} "Fix result: ${RESULT}"
> + if [ ${RESULT} != "SUCCESS" ];then
> + f_LogMsg ${log_file} "Failed to fix! Exit..."
> + false
> + fi
> +}
> diff --git a/programs/online_filecheck/inode_block_test.sh
> b/programs/online_filecheck/inode_block_test.sh
> new file mode 100755
> index 0000000..3f39fa1
> --- /dev/null
> +++ b/programs/online_filecheck/inode_block_test.sh
> @@ -0,0 +1,407 @@
> +#!/bin/bash
> +
> +###########################################################################
> #####
> +# Global Variables
> +###########################################################################
> #####
> +if [ -f `dirname ${0}`/o2tf.sh ]; then
> + . `dirname ${0}`/o2tf.sh
> +fi
> +
> +if [ -f `dirname ${0}`/filecheck_utils.sh ]; then
> + . `dirname ${0}`/filecheck_utils.sh
> +fi
> +
> +PATH=$PATH:/usr/sbin/
> +
> +FSWRECK_BIN="`dirname ${0}`/fswreck"
> +DEBUGFS_BIN="`which debugfs.ocfs2`"
> +SUDO_DEBUGFS="`which sudo` -u root `which debugfs.ocfs2`"
> +SUDO_FSWRECK="`which sudo` -u root `dirname ${0}`/fswreck"
> +SUDO_BASH="`which sudo` -u root bash -c"
> +SUDO_CAT="`which sudo` -u root `which cat`"
> +
> +DEVICE=
> +MOUNT_POINT=
> +MOUNT_OPTS="errors=continue"
> +FEATURES="local,metaecc"
> +
> +LOG_DIR=
> +DETAIL_LOG_FILE=
> +
> +SYSDIR_OCFS2=/sys/fs/ocfs2
> +SYSDIR_DEVICE=
> +CHECK_FILE=
> +FIX_FILE=
> +SET_CACHE=
> +CACHE_MIN=10
> +CACHE_MAX=100
> +
> +TEST_NO=0
> +TEST_PASS=0
> +
> +set -o pipefail
> +
> +###########################################################################
> #####
> +# Utility Functions
> +###########################################################################
> #####
> +function f_usage()
> +{
> + echo "usage: `basename ${0}` <-d device> <-m mountpoint> <-l log-dir>"
> +}
> +
> +function f_getoptions()
> +{
> + if [ $# -eq 0 ]; then
> + f_usage;
> + exit 1
> + fi
> +
> + while getopts "d:m:l:h" options; do
> + case $options in
> + d ) DEVICE="$OPTARG";;
> + m ) MOUNT_POINT="$OPTARG";;
> + l ) LOG_DIR="$OPTARG";;
> + h ) f_usage;;
> + * ) f_usage;;
> + esac
> + done
> +}
> +
> +function f_setup()
> +{
> + f_getoptions $*
> +
> + if [ ! -x ${FSWRECK_BIN} ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Fswreck tool must be provided to
> proceed testing..."
> + exit 1
> + fi
> +
> + if [ ! -x ${DEBUGFS_BIN} ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Debugfs.ocfs2 tool must be provided to
> proceed testing..."
> + exit 1
> + fi
> +
> + LOG_SURFIX="`date +%Y-%m-%d_%H-%M-%S`"
> + DETAIL_LOG_FILE="${LOG_DIR}/inode_block_test-${LOG_SURFIX}.log"
> +
> + SYSDIR_DEVICE="${SYSDIR_OCFS2}/`basename ${DEVICE}`"
> + CHECK_FILE="${SYSDIR_DEVICE}/filecheck/check"
> + FIX_FILE="${SYSDIR_DEVICE}/filecheck/fix"
> + SET_CACHE="${SYSDIR_DEVICE}/filecheck/set"
> +}
> +
> +function f_cleanup()
> +{
> + :
> +}
> +
> +
> +###########################################################################
> #####
> +# Core Function
> +###########################################################################
> #####
> +function f_runtest()
> +{
> + local ERR_TYPE_ARRY="inode_gen inode_ecc inode_block_num cache_size"
> +
> + for type in ${ERR_TYPE_ARRY}; do
> + ((TEST_NO++))
> +
> + case "${type}" in
> + inode_gen )
> + f_inode_gen_check;;
> + inode_ecc )
> + f_inode_ecc;;
> + inode_block_num )
> + f_inode_block_num;;
> + cache_size )
> + f_cache_size;;
> + * ) echo -e "Unknown testing unit: ${type}" >> ${DETAIL_LOG_FILE}
> + false
> + esac
> +
> + if [ $? -eq 0 ];then
> + ((TEST_PASS++))
> + fi
> + done
> +}
> +
> +function f_inode_gen_check()
> +{
> + echo -e "\n[${TEST_NO}] Inode generation number:" >> ${DETAIL_LOG_FILE}
> +
> + #fswreck
> + echo -e "\n[*] Corrupt inode generation number:" >> ${DETAIL_LOG_FILE}
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_FSWRECK} -c INODE_GEN ${DEVICE}"
> + ${SUDO_FSWRECK} -c INODE_GEN ${DEVICE} > .tmp 2>&1
> + f_exit_or_not $?
> + cat .tmp >> ${DETAIL_LOG_FILE} 2>&1
> +
> + local LINE=`cat .tmp | tail -n 1`
> + echo -e "Got the last line: ${LINE}" >> ${DETAIL_LOG_FILE}
> + rm -f -- .tmp
> +
> + local TMP=${LINE#*#}
> + local INO=${TMP%,*}
> + f_LogMsg ${DETAIL_LOG_FILE} "Got inode number: ${INO}"
> + local GOOD_GEN=`echo ${LINE}|awk '{print $7}'`
> + f_LogMsg ${DETAIL_LOG_FILE} "Got good generation number: ${GOOD_GEN}"
> +
> + #check
> + echo -e "\n[*] Check inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_check_file ${INO} ${CHECK_FILE} "GENERATION" ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: FAILED"
> + fi
> +
> + #fix
> + echo -e "\n[*] Fix inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_fix_file ${INO} ${FIX_FILE} ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: FAILED"
> + fi
> +
> + #verify
> + echo -e "\n[*] Verify:" >> ${DETAIL_LOG_FILE} 2>&1
> + f_verify_inode_gen ${INO} ${GOOD_GEN} ${DEVICE} >> ${DETAIL_LOG_FILE} 2>&1
> +
> + if [ $? -ne 0 ]; then
> + echo "Fail: fix inode#${INO} generation." >> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> + echo -e "Verify: PASSED" >> ${DETAIL_LOG_FILE} 2>&1
> +}
> +
> +function f_inode_ecc()
> +{
> + echo -e "\n[${TEST_NO}] Inode ecc:" >> ${DETAIL_LOG_FILE}
> +
> + #fswreck
> + echo -e "\n[*] Corrupt inode block ecc:" >> ${DETAIL_LOG_FILE}
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_FSWRECK} -c INODE_BLOCK_ECC
> ${DEVICE}"
> + ${SUDO_FSWRECK} -c INODE_BLOCK_ECC ${DEVICE} > .tmp 2>&1
> + RET=$?
> + f_exit_or_not ${RET}
> + cat .tmp >> ${DETAIL_LOG_FILE} 2>&1
> +
> + local LINE=`cat .tmp | tail -n 1`
> + rm -f -- .tmp
> + local TMP=${LINE#*#}
> + local INO=${TMP%,*}
> + local BAD_CRC32=0x1234
> + local BAD_ECC=0x1234
> +
> + #check
> + echo -e "\n[*] Check inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_check_file ${INO} ${CHECK_FILE} "BLOCKECC" ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: FAILED"
> + fi
> +
> + #fix
> + echo -e "\n[*] Fix inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_fix_file ${INO} ${FIX_FILE} ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: FAILED"
> + fi
> +
> + #verify
> + echo -e "\n[*] Verify:" >> ${DETAIL_LOG_FILE} 2>&1
> + f_verify_inode_meta_ecc ${INO} ${BAD_CRC32} ${BAD_ECC} ${DEVICE} >>
> ${DETAIL_LOG_FILE} 2>&1
> + if [ $? -ne 0 ]; then
> + echo "Fail: fix inode#${INO} meta ecc." >> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> + echo -e "Verify: PASSED" >> ${DETAIL_LOG_FILE} 2>&1
> +}
> +
> +function f_inode_block_num()
> +{
> + echo -e "\n[${TEST_NO}] Inode block number:" >> ${DETAIL_LOG_FILE}
> +
> + #fswreck
> + echo -e "\n[*] Corrupt inode block number:" >> ${DETAIL_LOG_FILE}
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_FSWRECK} -c INODE_BLKNO ${DEVICE}"
> + ${SUDO_FSWRECK} -c INODE_BLKNO ${DEVICE} > .tmp 2>&1
> + RET=$?
> + f_exit_or_not ${RET}
> + cat .tmp >> ${DETAIL_LOG_FILE} 2>&1
> +
> + local LINE=`cat .tmp | tail -n 1`
> + rm -f -- .tmp
> + local TMP=${LINE#*#}
> + local INO=${TMP%,*}
> + local GOOD_BLOCKNUM=`echo ${LINE}|awk '{print $7}'`
> +
> + #check
> + echo -e "\n[*] Check inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_check_file ${INO} ${CHECK_FILE} "BLOCKNO" ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Check: FAILED"
> + fi
> +
> + #fix
> + echo -e "\n[*] Fix inode#${INO}:" >> ${DETAIL_LOG_FILE}
> + f_fix_file ${INO} ${FIX_FILE} ${DETAIL_LOG_FILE}
> + if [ $? -eq 0 ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: PASSED"
> + else
> + f_LogMsg ${DETAIL_LOG_FILE} "Fix: FAILED"
> + fi
> +
> + #verify
> + echo -e "\n[*] Verify:" >> ${DETAIL_LOG_FILE} 2>&1
> + f_verify_inode_block_num ${INO} ${GOOD_BLOCKNUM} ${DEVICE} >>
> ${DETAIL_LOG_FILE} 2>&1
> + if [ $? -ne 0 ]; then
> + echo "Fail: fix inode#${INO}'s block number." >> ${DETAIL_LOG_FILE}
> 2>&1
> + return 1
> + fi
> + echo -e "Verify: PASSED" >> ${DETAIL_LOG_FILE} 2>&1
> +}
> +
> +#cache size to save check records
> +function f_cache_size()
> +{
> + echo -e "\n[${TEST_NO}] Cache size setting:" >> ${DETAIL_LOG_FILE}
> +
> + #see if case size is valid
> + local SIZE=`${SUDO_BASH} "cat ${SET_CACHE}"`
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_BASH} \"cat ${SET_CACHE}\""
> + f_LogMsg ${DETAIL_LOG_FILE} "Cache size: ${SIZE}"
> + if [ ${SIZE} -gt ${CACHE_MAX} -o ${SIZE} -lt ${CACHE_MIN} ];then
> + f_LogMsg ${DETAIL_LOG_FILE} "Cache size should be in [${CACHE_MIN},
> ${CACHE_MAX}]."
> + return 1
> + fi
> +
> + #positive test case
> + echo -e "\nPositive testing:" >> ${DETAIL_LOG_FILE}
> + for size in ${CACHE_MIN} ${CACHE_MAX}; do
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_BASH} \"echo ${size} >
> ${SET_CACHE}\""
> + ${SUDO_BASH} "echo ${size} > ${SET_CACHE}" >> ${DETAIL_LOG_FILE} 2>&1
> + if [ $? -ne 0 ]; then
> + f_LogMsg ${DETAIL_LOG_FILE} "Faild to set case size to $size"
> + return 1
> + fi
> + done
> + echo -e "PASSED" >> ${DETAIL_LOG_FILE}
> +
> + #negative test case
> + echo -e "\nNegative testing:" >> ${DETAIL_LOG_FILE}
> + for size in ${CACHE_MIN}-1 ${CACHE_MAX}+1; do
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_BASH} \"echo ${size} >
> ${SET_CACHE}\""
> + ${SUDO_BASH} "echo ${size} > ${SET_CACHE}" >> ${DETAIL_LOG_FILE} 2>&1
> + if [ $? -eq 0 ]; then
> + f_LogMsg ${DETAIL_LOG_FILE} "We should *NOT* set case size to
> $size successfully."
> + return 1
> + fi
> + done
> + echo -e "PASSED" >> ${DETAIL_LOG_FILE}
> +}
> +
> +f_verify_inode_gen()
> +{
> + local -i inode=$1
> + local -i gen=$2
> + DEVICE=$3
> +
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_DEBUGFS} -R \"stat <${inode}>\"
> ${DEVICE}|grep \"FS Generation:\""
> + fix_result=`${SUDO_DEBUGFS} -R "stat <${inode}>" ${DEVICE}|grep "FS
> Generation:"`
> + f_LogMsg ${DETAIL_LOG_FILE} "echo ${fix_result} | awk '{print \$3}'"
> + fix_gen=`echo ${fix_result} | awk '{print $3}'`
> + if [ -z $fix_gen ];then
> + echo -e "Failed to get FS generation number using debugfs.ocfs2" >>
> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> +
> + echo -e "fs generation=$fix_gen, wanted=$gen" >> ${DETAIL_LOG_FILE} 2>&1
> + if [ $fix_gen -ne $gen ];then
> + echo -e "Verify: failed to fix." >> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> +}
> +
> +f_verify_inode_block_num()
> +{
> + local -i inode=$1
> + local -i block_num=$2
> + DEVICE=$3
> +
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_DEBUGFS} -R \"stat <${inode}>\"
> ${DEVICE}|grep \"Inode:\""
> + fix_result=`${SUDO_DEBUGFS} -R "stat <${inode}>" ${DEVICE}|grep "Inode:"`
> + f_LogMsg ${DETAIL_LOG_FILE} "echo ${fix_result} | awk '{print \$2}'"
> + fix_block_num=`echo ${fix_result} | awk '{print $2}'`
> + if [ -z $fix_block_num ];then
> + echo -e "Failed to get inode block number using debugfs.ocfs2" >>
> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> +
> + echo -e "inode block number=$fix_block_num, wanted=$block_num" >>
> ${DETAIL_LOG_FILE}
> + 2>&1
> + if [ $fix_block_num -ne $block_num ];then
> + echo -e "Verify: failed to fix." >> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> +}
> +
> +f_verify_inode_meta_ecc()
> +{
> + local -i inode=$1
> + local crc32=`printf "%d" $2`
> + local ecc=`printf "%d" $3`
> + DEVICE=$4
> +
> + f_LogMsg ${DETAIL_LOG_FILE} "${SUDO_DEBUGFS} -R \"stat <${inode}>\"
> ${DEVICE}|grep \"CRC32:\""
> + fix_result=`${SUDO_DEBUGFS} -R "stat <${inode}>" ${DEVICE}|grep "CRC32:"`
> + f_LogMsg ${DETAIL_LOG_FILE} "echo ${fix_result} | awk '{print \$2}'"
> + fix_crc32=`echo ${fix_result} | awk '{print $2}'`
> + if [ -z $fix_crc32 ];then
> + echo -e "Failed to get inode block crc32 using debugfs.ocfs2" >>
> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> + fix_crc32=`printf "%d" 0x${fix_crc32}`
> +
> + f_LogMsg ${DETAIL_LOG_FILE} "echo ${fix_result} | awk '{print \$4}'"
> + fix_ecc=`echo ${fix_result} | awk '{print $4}'`
> + if [ -z $fix_ecc ];then
> + echo -e "Failed to get inode block ecc using debugfs.ocfs2" >>
> ${DETAIL_LOG_FILE} 2>&1
> + return 1
> + fi
> + fix_ecc=`printf "%d" 0x${fix_ecc}`
> +
> + echo "crc32=$fix_crc32, bad crc32=$crc32; ecc=$fix_ecc, bad ecc=$ecc" >>
> ${DETAIL_LOG_FILE} 2>&1
> +}
> +
> +###########################################################################
> #####
> +# Main Entry
> +###########################################################################
> #####
> +
> +#redefine the int signal hander
> +trap 'echo -ne "\n\n">>${DETAIL_LOG_FILE};echo "Interrupted by
> Ctrl+C,Cleanuping ... "|tee
> +-a ${DETAIL_LOG_FILE}; f_cleanup; exit 1' SIGINT
> +
> +f_setup $*
> +
> +START_TIME=${SECONDS}
> +f_LogMsg ${DETAIL_LOG_FILE} "=====================Inode block testing
> start: `date`====================="
> +
> +f_runtest
> +
> +END_TIME=${SECONDS}
> +f_LogMsg ${DETAIL_LOG_FILE} "=====================Inode block testing end:
> `date`========================="
> +
> +f_LogMsg ${DETAIL_LOG_FILE} "Time elapsed(s):
> $((${END_TIME}-${START_TIME}))"
> +f_LogMsg ${DETAIL_LOG_FILE} "Tests total: ${TEST_NO}"
> +f_LogMsg ${DETAIL_LOG_FILE} "Tests passed: ${TEST_PASS}"
> +
> +if [ ${TEST_NO} -ne ${TEST_PASS} ]; then
> + false
> +fi
> diff --git a/programs/python_common/single_run-WIP.sh
> b/programs/python_common/single_run-WIP.sh
> index c6fcb77..5a8fae1 100755
> --- a/programs/python_common/single_run-WIP.sh
> +++ b/programs/python_common/single_run-WIP.sh
> @@ -870,6 +870,26 @@ run_reflink_test()
> log_end ${RC}
> }
>
> +run_filecheck_test()
> +{
> + log_message "run filecheck_test" $@
> + if [ "$#" -lt "3" ]; then
> + echo "Error in run_filecheck()"
> + exit 1
> + fi
> +
> + logdir=$1
> + device=$2
> + mountpoint=$3
> +
> + log_start "filecheck_test"
> + filecheck_test_run.sh -o ${logdir} -d ${device} ${mountpoint}
> + RC=$?
> +
> + log_end ${RC}
> +}
> +
> +
> # Following cases aim to test tools
> run_mkfs()
> {
> @@ -975,7 +995,8 @@ if [ -z ${TESTCASES} ]; then
> fi
>
> SUPPORTED_TESTCASES="all create_and_open directaio fillverifyholes
> renamewriterace aiostress\
> - filesizelimits mmaptruncate buildkernel splice sendfile mmap reserve_space
> inline xattr reflink mkfs tunefs backup_super"
> + filesizelimits mmaptruncate buildkernel splice sendfile mmap
> reserve_space inline xattr\
> + reflink mkfs tunefs backup_super filecheck"
> for cas in ${TESTCASES}; do
> echo ${SUPPORTED_TESTCASES} | grep -sqw $cas
> if [ $? -ne 0 ]; then
> @@ -1068,6 +1089,10 @@ for tc in `${ECHO} ${TESTCASES} | ${SED} "s:,: :g"`;
> do
> run_reflink_test ${LOGDIR} ${DEVICE} ${MOUNTPOINT}
> fi
>
> + if [ "$tc"X = "filecheck"X ];then
> + run_filecheck_test ${LOGDIR} ${DEVICE} ${MOUNTPOINT}
> + fi
> +
> # For tools test.
>
> if [ "$tc"X = "mkfs"X -o "$tc"X = "all"X ];then
> --
> 2.6.6
More information about the Ocfs2-test-devel
mailing list