您的位置:首页 > 运维架构 > Shell

一个shell脚本写的测试框架

2017-07-03 22:12 639 查看
这是我进实验室进项目组写的第一程序,shell脚本写的用在项目中测试例的自动化测试测试。

#!/bin/bash

str1="Success"

str2="Failed"

str3="No_test"

num_failure=0

num_success=0

num_no_test=0

loop_cnt=1

test_port="$1"

for((k=0;k<${loop_cnt};k++)) ; do

while read
test_tcl_name
cycle_time
do

if [ "$test_tcl_name" == "" ];then

continue
fi
for ((j=0;j<"$cycle_time";j++)) ; do

echo "---------------------------------------------"

logfile=$(date +"%Y-%m-%d%H%M%S")
start_time=$(date +"%s")
#echo "logFile:$logfile" >>autotest_notes.log

echo "admin" |sudo -s ./parser_testcase_script.tcl "$test_port" $test_tcl_name >autotest_notes.log

./parser_testcase_script.tcl $test_port $test_tcl_name
grep "Test Scripts Success" autotest_notes.log

result_test=$?
echo "$result_test"

if [ "$result_test" == "0" ];then

let "num_success+=1"
echo $test_tcl_name $str1 >>autotest_result.txt

else
let "num_failure+=1"

echo $test_tcl_name $str2 >>autotest_result.txt
echo "$test_tcl_name">>autotest_result.bug
grep "Matched Failed" autotest_notes.log >>autotest_result.bug
echo "-----------------------------------------------" >>autotest_result.bug

fi
done

done <$2

done

echo "------------------------------------------">>autotest_result.txt
let "total=num_success+num_failure"
echo total $total Success $num_success Failed $num_failure >>autotest_resilt.txt
echo "total: $total , Success :$num_success, Failed: $num_failure"
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: