3 TEMP=`getopt -o dhsSmfqp: --long debug,help,failnorerun,quiet,serial,tct,modules,prefix: -n 'execute.sh' -- "$@"`
5 if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
7 # Note the quotes around `$TEMP': they are essential!
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 -p <prefix>\tExecute all testcases named with <prefix>"
17 echo -e " execute.sh [module]\tExecute test cases from the given module in parallel"
18 echo -e " execute.sh -s [module]\t\tExecute test cases in serial using Testkit-Lite"
19 echo -e " execute.sh -S [module]\t\tExecute test cases in serial"
20 echo -e " execute.sh -q|--quiet ...\tExecute test cases, but don't write output"
21 echo -e " execute.sh <testcase>\tFind and execute the given test case"
35 -d|--debug) opt_debug=1 ; shift ;;
36 -s|--tct) opt_tct=1 ; shift ;;
37 -f|--nofailedrerun) opt_noFailedRerun="-f" ; shift ;;
38 -S|--serial) opt_serial="-s" ; shift ;;
39 -q|--quiet) opt_quiet="-q" ; shift ;;
40 -p|--prefix) opt_match="-m $2" ; shift 2;;
41 -m|--modules) opt_modules=1 ; shift ;;
43 *) echo "Internal error $1!" ; exit 1 ;;
49 scripts/tctestsgen.sh $1 `pwd` desktop $2
50 testkit-lite -f `pwd`/tests.xml -o tct-${1}-core-tests.xml -A --comm localhost
51 scripts/add_style.pl $1
54 function summary_start
56 start=`date +"%Y-%m-%d_%H_%M_%S"`
57 cat > summary.xml <<EOF
58 <?xml version="1.0" encoding="UTF-8"?>
59 <?xml-stylesheet type="text/xsl" href="./style/summary.xsl"?>
60 <result_summary plan_name="Core">
61 <other xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string" />
62 <summary test_plan_name="Dali">
63 <start_at>$start</start_at>
64 <end_at>$start</end_at>
71 cat >> summary.xml <<EOF
78 start=`date +"%Y-%m-%d_%H_%M_%S"`
79 cat > tct-${1}-core-tests.xml <<EOF
80 <?xml version="1.0" encoding="UTF-8"?>
81 <?xml-stylesheet type="text/xsl" href="./style/testresult.xsl"?>
83 <environment build_id="" device_id="localhost" device_model="" device_name="N/A" host="Ubuntu" manufacturer="" resolution="N/A" screen_size="N/A"><other /></environment>
84 <summary test_plan_name="Empty test_plan_name"><start_at>$start</start_at><end_at>$start</end_at></summary>
85 <suite category="Core APIs" name="tct-$1-core-tests">
86 <set name="default" set_debug_msg="automated-tests.auto.suite_1_set_1.dlog">
93 cat >> tct-${1}-core-tests.xml <<EOF
100 modules=`ls -1 build/src | grep -v CMakeFiles | grep -v cmake_install.cmake`
102 if [ $opt_modules == 1 ] ; then
107 # Clean up old test results
108 rm -f tct*core-tests.xml
110 # Clean up old coverage data
111 [ -d ../build/tizen ] && rm -f ../build/tizen/dali/.libs/*.gcda
112 [ -d ../build/tizen-cmake ] && find ../build/tizen-cmake/ -name \*.gcda -exec rm {} \;
114 find build \( -name "*.gcda" \) -exec rm '{}' \;
119 if [ -f summary.xml ] ; then unlink summary.xml ; fi
121 if [ $opt_tct == 1 ] ; then
123 # Run all test case executables serially, create XML output
124 if [ -n "$1" ] ; then
129 if [ $mod != 'common' ] && [ $mod != 'manual' ]; then
131 echo -ne "$ASCII_BOLD"
132 echo -e "Executing $mod$ASCII_RESET"
141 # Execute test cases using own test harness
143 if [ -z "$1" ] ; then
145 # Execute each test executable in turn (by default, runs tests in parallel)
149 echo -e "$ASCII_BOLD"
150 echo -e "Executing $mod$ASCII_RESET"
152 dbus-launch build/src/$mod/tct-$mod-core $opt_serial $opt_noFailedRerun $opt_quiet $opt_match
157 elif [ -f "build/src/$1/tct-$1-core" ] ; then
158 # First argument is an executable filename - execute only that with any
159 # remaining arguments
163 output_start ${module}
164 dbus-launch build/src/$module/tct-$module-core $opt_serial $opt_noFailedRerun $opt_quiet $opt_match $*
169 # First argument is not an executable. Is it a test case name?
170 # Try executing each executable with the test case name until success/known failure
173 output=`build/src/$mod/tct-$mod-core $1`
175 if [ $ret -ne 6 ] ; then
176 if [ $opt_debug -ne 0 ] ; then
178 dbus-launch gdb --args build/src/$mod/tct-$mod-core $1
182 if [ $ret -eq 0 ] ; then echo -e "\nPassed" ; fi
190 # Kill off any dangling or sleeping dbus sessions that we would have created
191 cgroup=$(awk -F ':' '$2 == "name=systemd" { print $3 }' /proc/self/cgroup)
192 if [ -n "$cgroup" ] ; then
193 for pid in $(cat /sys/fs/cgroup/systemd/$cgroup/tasks 2>/dev/null); do
194 comm=$(cat /proc/$pid/comm 2>/dev/null)
196 dbus-daemon|dbus-launch)
204 if [ -f summary.xml ] ; then
205 scripts/output_summary.pl