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
32 python -m unittest discover -v -s yardstick/tests/unit >> $logfile 2>&1
34 python -m unittest discover -v -s tests/unit
35 python -m unittest discover -v -s yardstick/tests/unit
39 if [ $FILE_OPTION == "f" ]; then
40 echo "FAILED, results in $logfile"
44 if [ $FILE_OPTION == "f" ]; then
45 echo "OK, results in $logfile"
51 source $COVER_DIR_NAME/cover.sh
55 run_functional_test() {
57 mkdir -p .testrepository
58 python -m subunit.run discover yardstick/tests/functional > .testrepository/subunit.log
59 python -m subunit.run discover tests/functional >> .testrepository/subunit.log
61 subunit2pyunit < .testrepository/subunit.log
63 subunit-stats < .testrepository/subunit.log
65 if [ $EXIT_CODE -ne 0 ]; then
72 if [[ $opts =~ "--unit" ]]; then
76 if [[ $opts =~ "--coverage" ]]; then
80 if [[ $opts =~ "--functional" ]]; then
84 if [[ -z $opts ]]; then
85 echo "No tests to run!!"
86 echo "Usage: run_tests.sh [--unit] [--coverage] [--functional]"