提交 4238ab5b 编写于 作者: O openeuler-ci-bot 提交者: Gitee

!10 add param for not checking the mapping between suite and case during debugging.

Merge pull request !10 from lemon.higgins/master
...@@ -136,11 +136,13 @@ function CHECK_RESULT() { ...@@ -136,11 +136,13 @@ function CHECK_RESULT() {
} }
function CASE_RESULT() { function CASE_RESULT() {
test $1 -ne 0 && ret_c=1
[[ -z $exec_result ]] && { [[ -z $exec_result ]] && {
LOG_INFO "The case execute succeed." LOG_INFO "The case execute succeed."
exec_result=0 exec_result=0
all_result=0 all_result=0
return 0 return $ret_c
} }
for ret in "${all_result[@]}"; do for ret in "${all_result[@]}"; do
...@@ -148,7 +150,7 @@ function CASE_RESULT() { ...@@ -148,7 +150,7 @@ function CASE_RESULT() {
done done
exec_result=0 exec_result=0
all_result=0 all_result=0
return 1 return $ret
} }
function SSH_CMD() { function SSH_CMD() {
...@@ -202,7 +204,6 @@ function main() { ...@@ -202,7 +204,6 @@ function main() {
fi fi
run_test run_test
CASE_RESULT $?
CASE_RESULT
test $? -eq 0 || exit 1 test $? -eq 0 || exit 1
} }
...@@ -28,6 +28,7 @@ function usage() { ...@@ -28,6 +28,7 @@ function usage() {
-f:designated test suite\n -f:designated test suite\n
-r:designated test case\n -r:designated test case\n
-x:the shell script is executed in debug mode\n -x:the shell script is executed in debug mode\n
-C: the mapping in suite2case does not need to be checked.
\n \n
Example: bash runoet.sh -f test_suite -r test_case -x\n" Example: bash runoet.sh -f test_suite -r test_case -x\n"
} }
...@@ -86,44 +87,21 @@ function run_test_case() { ...@@ -86,44 +87,21 @@ function run_test_case() {
test_suite=$1 test_suite=$1
test_case=$2 test_case=$2
LOG_INFO "start to run testcase:${test_case}"
log_path=${OET_PATH}/logs/${test_suite}/${test_case} log_path=${OET_PATH}/logs/${test_suite}/${test_case}
mkdir -p ${log_path} mkdir -p ${log_path}
[ "$isCheck"x == "yes"x ] && check_case $test_suite $test_case
LOG_INFO "start to run testcase:${test_case}"
exec 6>&1 exec 6>&1
exec 7>&2 exec 7>&2
exec >${log_path}/"$(date +%Y-%m-%d-%T)".log 2>&1 exec >${log_path}/"$(date +%Y-%m-%d-%T)".log 2>&1
((case_num++)) ((case_num++))
if ! find ${OET_PATH}/suite2cases -type f -name ${test_suite} >/dev/null 2>&1; then case_path=$(find ${OET_PATH}/testcases/${test_suite} -type f -name "${test_case}\.*" | sed -e "s/${test_case}\..*//g")
LOG_ERROR "In the suite2cases directory, Can't find the file of testsuite:${test_suite}."
end_test_case 1
return 1
elif ! find ${OET_PATH}/testcases -type d -name ${test_suite} >/dev/null 2>&1; then
LOG_ERROR "Can't find the dir of testsuite:${test_suite}."
end_test_case 1
return 1
fi
if ! grep -w ${test_case} ${OET_PATH}/suite2cases/${test_suite} >/dev/null 2>&1; then
LOG_ERROR "In the suite2cases directory, no testcase:${test_case} is found inside the ${test_suite} file."
end_test_case 1
return 1
elif ! find ${OET_PATH}/testcases -type d -name ${test_suite} >/dev/null 2>&1; then
LOG_ERROR "Can't find the dir of testcase:${test_case}."
end_test_case 1
return 1
elif ! find ${OET_PATH}/testcases/${test_suite} -type f -name "${test_case}*" >/dev/null 2>&1; then
LOG_ERROR "Can't find the script of testcase:${test_case}."
end_test_case 1
return 1
fi
case_path=$(find ${OET_PATH}/testcases/${test_suite} -type f -name "${test_case}*" | sed -e "s/${test_case}\..*//g")
cd ${case_path} || exit 1 cd ${case_path} || exit 1
script_type=$(ls ${test_case}* | awk -F '.' '{print $NF}') script_type=$(ls ${test_case}* | awk -F '.' '{print $NF}')
if [[ "$script_type"x == "sh"x ]] || [[ "$script_type"x == "bash"x ]]; then if [[ "$script_type"x == "sh"x ]] || [[ "$script_type"x == "bash"x ]]; then
...@@ -154,6 +132,40 @@ function run_test_case() { ...@@ -154,6 +132,40 @@ function run_test_case() {
} }
} }
function check_case() {
test_suite=$1
test_case=$2
case_path=$(find ${OET_PATH}/testcases/${test_suite} -type f -name "${test_case}\.*" | sed -e "s/${test_case}\..*//g")
LOG_INFO "start to check testcase:${test_case}"
test -d ${OET_PATH}/testcases/${test_suite} || {
LOG_ERROR "Can't find the dir of testsuite:${test_suite}."
end_test_case 1
return 1
}
test -f ${OET_PATH}/suite2cases/${test_suite} || {
LOG_ERROR "In the suite2cases directory, Can't find the file of testsuite:${test_suite}."
end_test_case 1
return 1
}
if echo "$@" | grep -e '-C' >/dev/null 2>&1; then
if ! grep -w ${test_case} ${OET_PATH}/suite2cases/${test_suite} >/dev/null 2>&1; then
LOG_ERROR "In the suite2cases directory, no testcase:${test_case} is found inside the ${test_suite} file."
end_test_case 1
return 1
fi
fi
test -f ${case_path}/${test_case}\.* || {
LOG_ERROR "Can't find testcase. please check whether the case name is correct."
exit 1
}
}
function run_test() { function run_test() {
test_suite=$1 test_suite=$1
test_case=$2 test_case=$2
...@@ -185,8 +197,9 @@ function run_test() { ...@@ -185,8 +197,9 @@ function run_test() {
} }
export command_x="no" export command_x="no"
while getopts ":xachr:f:" arg; do export isCheck="yes"
case $arg in while getopts ":caxf:Cr:h" opt; do
case $opt in
x) x)
command_x="yes" command_x="yes"
;; ;;
...@@ -210,6 +223,9 @@ while getopts ":xachr:f:" arg; do ...@@ -210,6 +223,9 @@ while getopts ":xachr:f:" arg; do
exit 1 exit 1
} }
;; ;;
C)
isCheck="no"
;;
h) h)
usage usage
;; ;;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册