# 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
}
run_coverage() {
- source tests/ci/cover.sh
+ source $COVER_DIR_NAME/cover.sh
run_coverage_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