1#!/bin/bash 2 3declare -i total=0 4declare -i total_xfail=0 5declare -i failed=0 6declare -i xpassed=0 7declare -a failed_tests=() 8declare -a xpassed_tests=() 9 10# Parse TRS Files 11tosort="" 12for file in $1 ; do 13 # Find number of tests run in trs file 14 ((total += $(grep ^:number-tests: "$file" | cut -d: -f3))) 15 16 # Find number of tests failed in trs file 17 numfailed=$(grep ^:number-failed-tests: "$file" | cut -d: -f3) 18 if ((numfailed != 0)) ; then 19 ((failed += numfailed)) 20 failed_tests+=($(grep ^:list-of-failed-tests: "$file" | cut -d: -f3)) 21 fi 22 23 time=$(grep ^:elapsed-time: "$file" | cut -d: -f3) 24 tosort="$tosort| $file - $time:" 25done 26((passed = total - failed)) 27 28# Parse XFAIL TRS Files 29for file in $2 ; do 30 # Find number of tests run in xfail trs file 31 xfail=$(grep ^:number-tests: "$file" | cut -d: -f3) 32 ((total_xfail += xfail)) 33 34 # Find number of tests failed in trs file 35 numfailed=$(grep ^:number-failed-tests: "$file" | cut -d: -f3) 36 if ((numfailed != xfail)) ; then 37 ((xpassed += xfail - numfailed)) 38 xpassed_tests+=($(grep ^:list-of-passed-tests: "$file" | cut -d: -f3)) 39 fi 40 41 time=$(grep ^:elapsed-time: "$file" | cut -d: -f3) 42 tosort="$tosort| $file - $time:" 43done 44((xfailed = total_xfail - xpassed)) 45((total += total_xfail)) 46 47timing=$(echo "$tosort" | tr ":" "\n" | sort -rn -k4 | sed -e 's/$/:/' | head -n10) 48 49# Determine if we are parsing Matlab or Octave trs files 50if (($(grep -c '.m.trs' <<< "$1") == 0)); then 51 prg=OCTAVE 52 outfile=run_test_octave_output.txt 53else 54 prg=MATLAB 55 outfile=run_test_matlab_output.txt 56fi 57 58# Print Output (to stdout and to a file) 59{ 60 echo '================================' 61 echo "DYNARE MAKE CHECK $prg RESULTS" 62 echo '================================' 63 echo "| TOTAL: $total" 64 echo "| PASS: $passed" 65 echo "| FAIL: $failed" 66 echo "| XFAIL: $xfailed" 67 echo "| XPASS: $xpassed" 68 if ((failed > 0)) ; then 69 echo '|' 70 echo '| LIST OF FAILED TESTS:' 71 for file in "${failed_tests[@]}" ; do 72 echo "| * $file" 73 done 74 fi 75 if ((xpassed > 0)) ; then 76 echo '|' 77 echo '| LIST OF XPASSED TESTS:' 78 for file in "${xpassed_tests[@]}" ; do 79 echo "| * $file" 80 done 81 fi 82 echo '|' 83 echo '| LIST OF 10 SLOWEST TESTS:' 84 if [[ $prg == MATLAB ]]; then 85 timing=$(sed 's/\.m\.trs/\.mod/g' <<< "$timing") 86 else 87 timing=$(sed 's/\.o\.trs/\.mod/g' <<< "$timing") 88 fi 89 echo "$timing" | tr ':' '\n' | sed -e 's/^[ \t]*//;/^$/d;s/^|[ ]/| * /' 90 echo 91} | tee $outfile 92 93# Exit with error code if some tests failed 94((failed + xpassed == 0)) 95