[dali_1.4.53] Merge branch 'devel/master'
[platform/core/uifw/dali-toolkit.git] / automated-tests / execute.sh
1 #!/bin/bash
2
3 TEMP=`getopt -o dhsSmf --long debug,help,failnorerun,serial,tct,modules -n 'execute.sh' -- "$@"`
4
5 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
6
7 # Note the quotes around `$TEMP': they are essential!
8 eval set -- "$TEMP"
9
10 function usage
11 {
12     echo -e "Usage: execute.sh [-d][-s|-S|-r] [module|testcase]"
13     echo -e "       execute.sh\t\tExecute test cases from all modules in parallel"
14     echo -e "       execute.sh -f \tExecute test cases from all modules in parallel without rerunning failed test cases"
15     echo -e "       execute.sh -d <testcase>\tDebug testcase"
16     echo -e "       execute.sh [module]\tExecute test cases from the given module in parallel"
17     echo -e "       execute.sh -s [module]\t\tExecute test cases in serial using Testkit-Lite"
18     echo -e "       execute.sh -S [module]\t\tExecute test cases in serial"
19     echo -e "       execute.sh <testcase>\tFind and execute the given test case"
20     exit 2
21 }
22
23 opt_tct=0
24 opt_serial=""
25 opt_modules=0
26 opt_debug=0
27 opt_noFailedRerun="";
28 while true ; do
29     case "$1" in
30         -h|--help)     usage ;;
31         -d|--debug)    opt_debug=1 ; shift ;;
32         -s|--tct)      opt_tct=1 ; shift ;;
33         -f|--nofailedrerun) opt_noFailedRerun="-f" ; shift ;;
34         -S|--serial)   opt_serial="-s" ; shift ;;
35         -m|--modules)  opt_modules=1 ; shift ;;
36         --) shift; break;;
37         *) echo "Internal error $1!" ; exit 1 ;;
38     esac
39 done
40
41 function execute_tct
42 {
43     scripts/tctestsgen.sh $1 `pwd` desktop $2
44     testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml  -A --comm localhost
45     scripts/add_style.pl $1
46 }
47
48 function summary_start
49 {
50     start=`date +"%Y-%m-%d_%H_%M_%S"`
51     cat > summary.xml <<EOF
52 <?xml version="1.0" encoding="UTF-8"?>
53 <?xml-stylesheet type="text/xsl" href="./style/summary.xsl"?>
54 <result_summary plan_name="Core">
55   <other xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" />
56   <summary test_plan_name="Dali">
57     <start_at>$start</start_at>
58     <end_at>$start</end_at>
59   </summary>
60 EOF
61 }
62
63 function summary_end
64 {
65     cat >> summary.xml <<EOF
66 </result_summary>
67 EOF
68 }
69
70 if [ $opt_modules == 1 ] ; then
71     modules= get_modules
72     echo $modules
73     exit 0
74 fi
75
76 # Clean up old test results
77 rm -f tct*core-tests.xml
78
79 # Clean up old coverage data
80 [ -d ../build/tizen ] && rm -f ../build/tizen/dali/.libs/*.gcda
81 [ -d ../build/tizen-cmake ] && find ../build/tizen-cmake/ -name \*.gcda -exec rm {} \;
82
83 find build \( -name "*.gcda" \) -exec rm '{}' \;
84
85 ASCII_BOLD="\e[1m"
86 ASCII_RESET="\e[0m"
87
88 modules=`ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
89 if [ -f summary.xml ] ; then unlink summary.xml ; fi
90
91 if [ $opt_tct == 1 ] ; then
92     # Use Test-kit lite
93     # Run all test case executables serially, create XML output
94     if [ -n "$1" ] ; then
95         execute_tct $1 $*
96     else
97         for mod in $modules
98         do
99             if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
100
101                 echo -ne "$ASCII_BOLD"
102                 echo -e "Executing $mod$ASCII_RESET"
103                 execute_tct $mod $*
104             fi
105         done
106     fi
107
108     scripts/summarize.pl
109
110 else
111     # Execute test cases using own test harness
112
113     if [ -z "$1" ] ; then
114         # No arguments:
115         # Execute each test executable in turn (by default, runs tests in parallel)
116         summary_start
117         for mod in $modules
118         do
119             echo -e "$ASCII_BOLD"
120             echo -e "Executing $mod$ASCII_RESET"
121             build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun
122         done
123         summary_end
124
125     elif [ -f "build/src/$1/tct-$1-core" ] ; then
126         # First argument is an executable filename - execute only that with any
127         # remaining arguments
128         summary_start
129         module=$1
130         shift;
131         build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $*
132         summary_end
133
134     else
135         # First argument is not an executable. Is it a test case name?
136         # Try executing each executable with the test case name until success/known failure
137         for mod in $modules
138         do
139             output=`build/src/$mod/tct-$mod-core $1`
140             ret=$?
141             if [ $ret -ne 6 ] ; then
142                 if [ $opt_debug -ne 0 ] ; then
143                     echo DEBUGGING:
144                     gdb --args build/src/$mod/tct-$mod-core $1
145
146                 else
147                     echo $output
148                     if [ $ret -eq 0 ] ; then echo -e "\nPassed" ; fi
149                 fi
150                 exit $ret
151             fi
152         done
153         echo $1 not found
154     fi
155 fi
156
157 if [ -f summary.xml ] ; then
158     scripts/output_summary.pl
159 fi
160
161 exit $?