3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Apache License, Version 2.0
8 # which accompanies this distribution, and is available at
9 # http://www.apache.org/licenses/LICENSE-2.0
10 ##############################################################################
12 # Run yardstick's unit, coverage, functional test
14 getopts ":f" FILE_OPTION
15 opts=$@ # get other args
17 # don't write .pyc files this can cause odd unittest results
18 export PYTHONDONTWRITEBYTECODE=1
20 PY_VER="py$( python --version | sed 's/[^[:digit:]]//g' | cut -c-2 )"
23 COVER_DIR_NAME="./tools/"
27 echo "Get external libs needed for unit test"
29 echo "Running unittest ... "
30 if [ $FILE_OPTION == "f" ]; then
31 python -m unittest discover -v -s tests/unit > $logfile 2>&1
33 echo "FAILED, results in $logfile"
36 python -m unittest discover -v -s yardstick/tests/unit >> $logfile 2>&1
38 python -m unittest discover -v -s tests/unit
42 python -m unittest discover -v -s yardstick/tests/unit
46 if [ $FILE_OPTION == "f" ]; then
47 echo "FAILED, results in $logfile"
51 if [ $FILE_OPTION == "f" ]; then
52 echo "OK, results in $logfile"
58 source $COVER_DIR_NAME/cover.sh
62 run_functional_test() {
64 mkdir -p .testrepository
65 python -m subunit.run discover yardstick/tests/functional > .testrepository/subunit.log
67 subunit2pyunit < .testrepository/subunit.log
69 subunit-stats < .testrepository/subunit.log
71 if [ $EXIT_CODE -ne 0 ]; then
78 if [[ $opts =~ "--unit" ]]; then
82 if [[ $opts =~ "--coverage" ]]; then
86 if [[ $opts =~ "--functional" ]]; then
90 if [[ -z $opts ]]; then
91 echo "No tests to run!!"
92 echo "Usage: run_tests.sh [--unit] [--coverage] [--functional]"