(Vector) Drop frames when the animation is delayed
[platform/core/uifw/dali-toolkit.git] / automated-tests / execute.sh
1 #!/bin/bash
2
3 TEMP=`getopt -o dhsSmfq --long debug,help,failnorerun,quiet,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][-q] [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 -q|--quiet ...\tExecute test cases, but don't write output"
20     echo -e "       execute.sh <testcase>\tFind and execute the given test case"
21     exit 2
22 }
23
24 opt_tct=0
25 opt_serial=""
26 opt_modules=0
27 opt_debug=0
28 opt_noFailedRerun="";
29 opt_quiet="";
30 while true ; do
31     case "$1" in
32         -h|--help)     usage ;;
33         -d|--debug)    opt_debug=1 ; shift ;;
34         -s|--tct)      opt_tct=1 ; shift ;;
35         -f|--nofailedrerun) opt_noFailedRerun="-f" ; shift ;;
36         -S|--serial)   opt_serial="-s" ; shift ;;
37         -q|--quiet)    opt_quiet="-q" ; shift ;;
38         -m|--modules)  opt_modules=1 ; shift ;;
39         --) shift; break;;
40         *) echo "Internal error $1!" ; exit 1 ;;
41     esac
42 done
43
44 function execute_tct
45 {
46     scripts/tctestsgen.sh $1 `pwd` desktop $2
47     testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml  -A --comm localhost
48     scripts/add_style.pl $1
49 }
50
51 function summary_start
52 {
53     start=`date +"%Y-%m-%d_%H_%M_%S"`
54     cat > summary.xml <<EOF
55 <?xml version="1.0" encoding="UTF-8"?>
56 <?xml-stylesheet type="text/xsl" href="./style/summary.xsl"?>
57 <result_summary plan_name="Core">
58   <other xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" />
59   <summary test_plan_name="Dali">
60     <start_at>$start</start_at>
61     <end_at>$start</end_at>
62   </summary>
63 EOF
64 }
65
66 function summary_end
67 {
68     cat >> summary.xml <<EOF
69 </result_summary>
70 EOF
71 }
72
73 function output_start
74 {
75     start=`date +"%Y-%m-%d_%H_%M_%S"`
76     cat > tct-${1}-core-tests.xml <<EOF
77 <?xml version="1.0" encoding="UTF-8"?>
78 <?xml-stylesheet type="text/xsl" href="./style/testresult.xsl"?>
79 <test_definition>
80 <environment build_id="" device_id="localhost" device_model="" device_name="N/A" host="Ubuntu" manufacturer="" resolution="N/A" screen_size="N/A"><other /></environment>
81 <summary test_plan_name="Empty test_plan_name"><start_at>$start</start_at><end_at>$start</end_at></summary>
82   <suite category="Core APIs" name="tct-$1-core-tests">
83     <set name="default" set_debug_msg="automated-tests.auto.suite_1_set_1.dlog">
84 EOF
85 }
86
87
88 function output_end
89 {
90     cat >> tct-${1}-core-tests.xml <<EOF
91     </set>
92   </suite>
93 </test_definition>
94 EOF
95 }
96
97
98 if [ $opt_modules == 1 ] ; then
99     modules= get_modules
100     echo $modules
101     exit 0
102 fi
103
104 # Clean up old test results
105 rm -f tct*core-tests.xml
106
107 # Clean up old coverage data
108 [ -d ../build/tizen ] && rm -f ../build/tizen/dali/.libs/*.gcda
109 [ -d ../build/tizen-cmake ] && find ../build/tizen-cmake/ -name \*.gcda -exec rm {} \;
110
111 find build \( -name "*.gcda" \) -exec rm '{}' \;
112
113 ASCII_BOLD="\e[1m"
114 ASCII_RESET="\e[0m"
115
116 modules=`ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
117 if [ -f summary.xml ] ; then unlink summary.xml ; fi
118
119 if [ $opt_tct == 1 ] ; then
120     # Use Test-kit lite
121     # Run all test case executables serially, create XML output
122     if [ -n "$1" ] ; then
123         execute_tct $1 $*
124     else
125         for mod in $modules
126         do
127             if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
128
129                 echo -ne "$ASCII_BOLD"
130                 echo -e "Executing $mod$ASCII_RESET"
131                 execute_tct $mod $*
132             fi
133         done
134     fi
135
136     scripts/summarize.pl
137
138 else
139     # Execute test cases using own test harness
140
141     if [ -z "$1" ] ; then
142         # No arguments:
143         # Execute each test executable in turn (by default, runs tests in parallel)
144         summary_start
145         for mod in $modules
146         do
147             echo -e "$ASCII_BOLD"
148             echo -e "Executing $mod$ASCII_RESET"
149             output_start $mod
150             dbus-launch build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun $opt_quiet
151             output_end $mod
152         done
153         summary_end
154
155     elif [ -f "build/src/$1/tct-$1-core" ] ; then
156         # First argument is an executable filename - execute only that with any
157         # remaining arguments
158         summary_start
159         module=$1
160         shift;
161         output_start ${module}
162         dbus-launch build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $opt_quiet $*
163         output_end ${module}
164         summary_end
165
166     else
167         # First argument is not an executable. Is it a test case name?
168         # Try executing each executable with the test case name until success/known failure
169         for mod in $modules
170         do
171             output=`build/src/$mod/tct-$mod-core $1`
172             ret=$?
173             if [ $ret -ne 6 ] ; then
174                 if [ $opt_debug -ne 0 ] ; then
175                     echo DEBUGGING:
176                     dbus-launch gdb --args build/src/$mod/tct-$mod-core $1
177
178                 else
179                     echo $output
180                     if [ $ret -eq 0 ] ; then echo -e "\nPassed" ; fi
181                 fi
182                 exit $ret
183             fi
184         done
185         echo $1 not found
186     fi
187 fi
188
189 if [ -f summary.xml ] ; then
190     scripts/output_summary.pl
191 fi
192
193 exit $?