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