781cfe008be47acbc9b599bd823cc42634097867
[situare] / scripts / master_test_script.sh
1 #!/bin/bash
2
3 ##########################################################
4 # This script is executed from /scripts directory        #
5 # in situare project folder                              #
6 ##########################################################
7 clear
8 echo "This is the master script for building and executing all automatic unit test."
9 echo "As a final step, it creates summary report from all tests executed."
10 ##########################################################
11 #Environment settings                                    #
12 ##########################################################
13 #Store all directory names to a list
14 MODULES=(`ls ../tests/`)
15 #Modify this path to point to correct path
16 location=$HOME/situare/repository/situare/tests/
17 FILE=$HOME/situare/repository/situare/scripts/tests_summary.txt
18 if [ ! -e $FILE ]; then
19     touch tests_summary.txt
20     echo "##########################################" >> tests_summary.txt
21     echo "# Summary of unit tests executed         #" >> tests_summary.txt
22     echo "# Date: `date`    #" >> tests_summary.txt
23     echo "# User: `whoami`                            #" >> tests_summary.txt
24     echo "##########################################" >> tests_summary.txt
25 fi  
26
27 ##########################################################
28 #First part: Execution of all tests                      #
29 ##########################################################
30 for component in "${MODULES[@]}" #Loop through components
31 do
32   cd $location/$component
33   CASES=(`ls`) #List all test cases uner component directory
34   for unittest in "${CASES[@]}"
35   do
36     cd $location/$component/$unittest
37     if [ $component = "testMap" ]; then 
38        qmake
39     else 
40        qmake -project "CONFIG+=qtestlib"
41        echo "Creating make file for $component/$unittest"
42        qmake
43     fi
44     echo "Building tests for $component/$unittest"
45     make
46     echo "Running tests for $component/$unittest"
47     ./$unittest -o testreport_$component.txt
48     echo "Cleaning $unittest"
49     make clean
50     rm Makefile
51     rm $unittest
52   done
53 done
54
55 #########################################################
56 # Second part: Extraction of results                    #
57 #########################################################
58 echo "Summarizing test results....." 
59 for component in "${MODULES[@]}" #Loop through components
60 do 
61   cd $location/$component
62   CASES=(`ls`) #List all test cases uner component directory
63   for unittests in "${CASES[@]}"
64   do
65     cd $location/$component/$unittests
66     echo "############# $component/$unittests ################" >> $FILE
67     grep Totals *.txt >> $FILE
68   done
69 done
70 exit 0