X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=run_tests.sh;h=dda760218260c7d5c2fd654ed12a2a64daa75b3d;hb=29476ed0317dcc635dff67d2fc9fd68233aa6656;hp=1f985b6c18acfc46bc859d593343440fd2ca3a79;hpb=03d764791eeb708ade47b5e2196b18ce04552dd1;p=yardstick.git diff --git a/run_tests.sh b/run_tests.sh index 1f985b6c1..dda760218 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -9,56 +9,22 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## -# Run yardstick's flake8, unit, coverage, functional test +# Run yardstick's unit, coverage, functional test getopts ":f" FILE_OPTION +opts=$@ # get other args -run_flake8() { - echo "Running flake8 ... " - logfile=test_results.log - if [ $FILE_OPTION == "f" ]; then - flake8 yardstick > $logfile - else - flake8 yardstick - fi +# don't write .pyc files this can cause odd unittest results +export PYTHONDONTWRITEBYTECODE=1 - if [ $? -ne 0 ]; then - echo "FAILED" - if [ $FILE_OPTION == "f" ]; then - echo "Results in $logfile" - fi - exit 1 - else - echo "OK" - fi -} +PY_VER="py$( python --version | sed 's/[^[:digit:]]//g' | cut -c-2 )" +export PY_VER -get_external_libs() { - cd $(dirname ${BASH_SOURCE[0]}) - TREX_DOWNLOAD="https://trex-tgn.cisco.com/trex/release/v2.05.tar.gz" - TREX_DIR=$PWD/trex/scripts - if [ ! -d "$TREX_DIR" ]; then - rm -rf ${TREX_DOWNLOAD##*/} - if [ ! -e ${TREX_DOWNLOAD##*/} ] ; then - wget -nv $TREX_DOWNLOAD - fi - tar xf ${TREX_DOWNLOAD##*/} - pushd . - rm -rf trex && mkdir -p trex - mv v2.05 trex/scripts - rm -rf v2.05.tar.gz - touch "$PWD/trex/scripts/automation/trex_control_plane/stl/__init__.py" - popd - fi - echo "Done." - export PYTHONPATH=$PYTHONPATH:"$PWD/trex/scripts/automation/trex_control_plane" - export PYTHONPATH=$PYTHONPATH:"$PWD/trex/scripts/automation/trex_control_plane/stl" - echo $PYTHONPATH -} +COVER_DIR_NAME="./tests/ci/" +export COVER_DIR_NAME run_tests() { echo "Get external libs needed for unit test" - get_external_libs echo "Running unittest ... " if [ $FILE_OPTION == "f" ]; then @@ -80,7 +46,7 @@ run_tests() { } run_coverage() { - source tests/ci/cover.sh + source $COVER_DIR_NAME/cover.sh run_coverage_test } @@ -100,9 +66,20 @@ run_functional_test() { fi } -export PYTHONPATH='yardstick/vTC/apexlake' +if [[ $opts =~ "--unit" ]]; then + run_tests +fi + +if [[ $opts =~ "--coverage" ]]; then + run_coverage +fi + +if [[ $opts =~ "--functional" ]]; then + run_functional_test +fi -run_flake8 -run_tests -run_coverage -run_functional_test +if [[ -z $opts ]]; then + echo "No tests to run!!" + echo "Usage: run_tests.sh [--unit] [--coverage] [--functional]" + exit 1 +fi