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