Disable libintl code for non glibc builds.
[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 if [ -d ../build/tizen ] ; then
81     rm -f ../build/tizen/dali/.libs/*.gcda
82 fi
83
84 find build \( -name "*.gcda" \) -exec rm '{}' \;
85
86 ASCII_BOLD="\e[1m"
87 ASCII_RESET="\e[0m"
88
89 modules=`ls -1 src/ | grep -v CMakeList | grep -v common | grep -v manual`
90 if [ -f summary.xml ] ; then unlink summary.xml ; fi
91
92 if [ $opt_tct == 1 ] ; then
93     # Use Test-kit lite
94     # Run all test case executables serially, create XML output
95     if [ -n "$1" ] ; then
96         execute_tct $1 $*
97     else
98         for mod in $modules
99         do
100             if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
101
102                 echo -ne "$ASCII_BOLD"
103                 echo -e "Executing $mod$ASCII_RESET"
104                 execute_tct $mod $*
105             fi
106         done
107     fi
108
109     scripts/summarize.pl
110
111 else
112     # Execute test cases using own test harness
113
114     if [ -z "$1" ] ; then
115         # No arguments:
116         # Execute each test executable in turn (by default, runs tests in parallel)
117         summary_start
118         for mod in $modules
119         do
120             echo -e "$ASCII_BOLD"
121             echo -e "Executing $mod$ASCII_RESET"
122             build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun
123         done
124         summary_end
125
126     elif [ -f "build/src/$1/tct-$1-core" ] ; then
127         # First argument is an executable filename - execute only that with any
128         # remaining arguments
129         summary_start
130         module=$1
131         shift;
132         build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $*
133         summary_end
134
135     else
136         # First argument is not an executable. Is it a test case name?
137         # Try executing each executable with the test case name until success/known failure
138         for mod in $modules
139         do
140             output=`build/src/$mod/tct-$mod-core $1`
141             ret=$?
142             if [ $ret -ne 6 ] ; then
143                 if [ $opt_debug -ne 0 ] ; then
144                     echo DEBUGGING:
145                     gdb --args build/src/$mod/tct-$mod-core $1
146
147                 else
148                     echo $output
149                     if [ $ret -eq 0 ] ; then echo -e "\nPassed" ; fi
150                 fi
151                 exit $ret
152             fi
153         done
154         echo $1 not found
155     fi
156 fi
157
158 if [ -f summary.xml ] ; then
159     scripts/output_summary.pl
160 fi
161
162 exit $?