github.com/n00py/Slackor@v0.0.0-20200610224921-d007fcea1740/impacket/tests/misc/runalltestcases.sh (about)

     1  #!/bin/bash
     2  separator='======================================================================'
     3  
     4  export PYTHONPATH=../..:$PYTHONPATH
     5  
     6  if [ $# -gt 0 ]
     7  then
     8  	# Only run coverage when called by tox
     9  	RUN="python -m coverage run --append --rcfile=../coveragerc "
    10  else
    11  	RUN=python
    12  fi
    13  
    14  total=0
    15  ok=0
    16  failed=0
    17  for file in `ls *.py` ; do
    18  	echo $separator
    19  	echo Executing $RUN $file
    20  	latest=$(
    21  		$RUN $file 2>&1 | {
    22  		while read line; do
    23  			echo " $line" 1>&2
    24  			latest="$line"
    25  		done
    26  		echo $latest
    27  		} 
    28  	)
    29  	#echo Latest ${latest} 
    30  	result=${latest:0:6}
    31  	if [ "$result" = "FAILED" ]
    32  	then
    33  		(( failed++ ))
    34  	elif [ "$result" = "OK" ]
    35  	then
    36  		(( ok++ ))
    37  	fi
    38  
    39  	(( total++ ))
    40  done
    41  echo $separator
    42  echo Summary:
    43  echo " OK $ok/$total"
    44  echo " $failed FAILED"
    45  if [ "$failed" -gt 0 ]; then
    46      echo "ERROR" >&2
    47      exit 1
    48  fi