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