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