github.com/n00py/Slackor@v0.0.0-20200610224921-d007fcea1740/impacket/tests/runall.sh (about) 1 #!/bin/sh 2 if [ $# -gt 0 ] 3 then 4 SUFFIX=$1 5 # Only run coverage when called by tox 6 RUN="python -m coverage run --append --rcfile=../coveragerc " 7 RUNLOCAL="python -m coverage run --append --rcfile=./coveragerc " 8 COVERAGE=true 9 else 10 SUFFIX=XX 11 RUN=python 12 RUNLOCAL=python 13 COVERAGE= 14 fi 15 16 export PYTHONPATH=../:$PYTHONPATH 17 18 OUTPUTFILE=/tmp/impacketoutput$SUFFIX.txt 19 # Let's remove the OUTPUTFILE in case it exists 20 rm -f $OUTPUTFILE 21 22 # Start running the tests 23 24 echo Python Version 25 python -V 26 27 echo Walking modules 28 $RUNLOCAL ./walkmodules.py 29 30 echo Testing ImpactPacket 31 cd ImpactPacket 32 ./runalltestcases.sh $COVERAGE 2>&1 1>/dev/null | tee -a $OUTPUTFILE 33 34 echo Testing dot11 35 cd ../dot11 36 ./runalltestcases.sh $COVERAGE 2>&1 1>/dev/null | tee -a $OUTPUTFILE 37 38 # In some environments we don't have a Windows 2012 R2 Domain Controller, 39 # so skip these tests. 40 cd ../SMB_RPC 41 echo test_spnego.py 42 $RUN test_spnego.py 2>&1 1>/dev/null | tee -a $OUTPUTFILE 43 echo test_ntlm.py 44 $RUN test_ntlm.py 2>&1 1>/dev/null | tee -a $OUTPUTFILE 45 46 if [ -z "$NO_REMOTE" ]; then 47 echo Testing SMB RPC/LDAP 48 export PYTHONPATH=../../:$PYTHONPATH 49 echo test_smb.py 50 $RUN test_smb.py 2>&1 1>/dev/null | tee -a $OUTPUTFILE 51 echo test_ldap.py 52 $RUN test_ldap.py 2>&1 1>/dev/null | tee -a $OUTPUTFILE 53 echo test_nmb.py 54 $RUN test_nmb.py 2>&1 1>/dev/null | tee -a $OUTPUTFILE 55 ./rundce.sh $COVERAGE 2>&1 1>/dev/null | tee -a $OUTPUTFILE 56 fi 57 58 echo Testing misc 59 cd ../misc 60 ./runalltestcases.sh $COVERAGE 2>&1 1>/dev/null | tee -a $OUTPUTFILE 61 62 cd .. 63 64 if [ $COVERAGE ] 65 then 66 # Combine coverage and produce report 67 echo "Combining coverage data" 68 mv .coverage .coveragetmp 69 coverage combine .coveragetmp ImpactPacket/.coverage dot11/.coverage SMB_RPC/.coverage misc/.coverage 70 coverage html -i 71 coverage erase 72 rm -f ImpactPacket/.coverage dot11/.coverage SMB_RPC/.coverage misc/.coverage 73 fi 74 75 if grep -q ERROR $OUTPUTFILE; 76 then 77 echo "ERRORS found, look at $OUTPUTFILE" 78 exit 1 79 else 80 echo "NO ERRORS found, congrats!" 81 rm $OUTPUTFILE 82 exit 0 83 fi 84 85 echo ================================================================================ 86 echo IMPORTANT: Dont forget to remove all the .coverage files from tests/* and subdirs 87 echo if you want newly freshed coverage stats 88 echo ================================================================================