Update release note for Danube.3.2
[yardstick.git] / run_tests.sh
1 #!/bin/bash
2
3 ##############################################################################
4 # Copyright (c) 2015 Ericsson AB and others.
5 #
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 ##############################################################################
11
12 # Run yardstick's flake8, unit, coverage, functional test
13
14 getopts ":f" FILE_OPTION
15
16 run_flake8() {
17     echo "Running flake8 ... "
18     logfile=test_results.log
19     if [ $FILE_OPTION == "f" ]; then
20         flake8 yardstick > $logfile
21     else
22         flake8 yardstick
23     fi
24
25     if [ $? -ne 0 ]; then
26         echo "FAILED"
27         if [ $FILE_OPTION == "f" ]; then
28             echo "Results in $logfile"
29         fi
30         exit 1
31     else
32         echo "OK"
33     fi
34 }
35
36
37 run_tests() {
38     echo "Get external libs needed for unit test"
39
40     echo "Running unittest ... "
41     if [ $FILE_OPTION == "f" ]; then
42         python -m unittest discover -v -s tests/unit > $logfile 2>&1
43     else
44         python -m unittest discover -v -s tests/unit
45     fi
46
47     if [ $? -ne 0 ]; then
48         if [ $FILE_OPTION == "f" ]; then
49             echo "FAILED, results in $logfile"
50         fi
51         exit 1
52     else
53         if [ $FILE_OPTION == "f" ]; then
54             echo "OK, results in $logfile"
55         fi
56     fi
57 }
58
59 run_coverage() {
60     source tests/ci/cover.sh
61     run_coverage_test
62 }
63
64 run_functional_test() {
65
66     mkdir -p .testrepository
67     python -m subunit.run discover tests/functional > .testrepository/subunit.log
68
69     subunit2pyunit < .testrepository/subunit.log
70     EXIT_CODE=$?
71     subunit-stats < .testrepository/subunit.log
72
73     if [ $EXIT_CODE -ne 0 ]; then
74         exit 1
75     else
76         echo "OK"
77     fi
78 }
79
80 export PYTHONPATH='yardstick/vTC/apexlake'
81
82 run_flake8
83 run_tests
84 run_coverage
85 run_functional_test