c6a3baf287e1407c9a41ab90c118207480fe12bd
[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 these paths to point to correct path
16 location=$HOME/situare/repository/situare/tests/
17 FILE=$HOME/situare/repository/situare/reports/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     echo "Building tests for $component/$unittest"
38     qmake
39     echo "Running tests for $component/$unittest"
40     ./$unittest -o testreport_$component.txt
41     echo "Cleaning $unittest"
42     make clean
43     rm Makefile
44     rm $unittest
45   done
46 done
47
48 #########################################################
49 # Second part: Extraction of results                    #
50 #########################################################
51 echo "Summarizing test results....." 
52 for component in "${MODULES[@]}" #Loop through components
53 do 
54   cd $location/$component
55   CASES=(`ls`) #List all test cases uner component directory
56   for unittests in "${CASES[@]}"
57   do
58     cd $location/$component/$unittests
59     echo "############# $component/$unittests ################" >> $FILE
60     grep Totals *.txt >> $FILE
61   done
62 done
63 exit 0