一个shell脚本写的测试框架

来源:互联网 发布:java微服务架构有哪些 编辑:程序博客网 时间:2024/05/22 14:04

这是我进实验室进项目组写的第一程序,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  fidone 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"


原创粉丝点击