phonesettings/cpphonesettingsplugins/divertplugin/tsrc/run_auto_tests_qt.bat
changeset 21 92ab7f8d0eab
child 22 6bb1b21d2484
equal deleted inserted replaced
4:c84cf270c54f 21:92ab7f8d0eab
       
     1 rem
       
     2 rem Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     3 rem All rights reserved.
       
     4 rem This component and the accompanying materials are made available
       
     5 rem under the terms of "Eclipse Public License v1.0"
       
     6 rem which accompanies this distribution, and is available
       
     7 rem at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 rem
       
     9 rem Initial Contributors:
       
    10 rem Nokia Corporation - initial contribution.
       
    11 rem
       
    12 rem Contributors:
       
    13 rem
       
    14 rem Description:
       
    15 rem
       
    16 
       
    17 @echo off
       
    18 setlocal
       
    19 goto :startup 
       
    20 
       
    21 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    22 :: function DEFAULT
       
    23 ::
       
    24 :: Modify this function
       
    25 ::  - TESTED_SRC can be changed to match tested code.
       
    26 ::    Specifies path from testcode group directory to
       
    27 ::    tested code
       
    28 ::  - Add test directories to be runned
       
    29 ::    ie. "call :build ut_projectdirectory" or use
       
    30 ::    "for /f %%a in ('dir /b ut_*') do call :build %%a"
       
    31 ::    which compiles, instruments and runs all test directories
       
    32 ::    starting with "ut_".
       
    33 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    34 :DEFAULT
       
    35 set TESTED_SRC=..\..\src\*.cpp
       
    36 
       
    37 for /f %%a in ('dir /b ut_*') do call :build %%a
       
    38 if [%DOMODULESTESTS%] EQU [TRUE] (
       
    39 for /f %%a in ('dir /b mt_*') do call :build %%a
       
    40 )
       
    41 
       
    42 call :finish
       
    43 goto :END
       
    44 
       
    45 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    46 :: function STARTUP
       
    47 ::
       
    48 :: Initializing script
       
    49 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    50 :STARTUP
       
    51 
       
    52 set BUILDTESTS=TRUE
       
    53 set RUNTESTS=TRUE
       
    54 set INSTRUMENT=TRUE
       
    55 set REMOVEINSTRUMENT=TRUE
       
    56 set DOMODULESTESTS=TRUE
       
    57 set ABLD_CALL=abld build winscw udeb -keepgoing
       
    58 set PATH_TO_DLL=\epoc32\release\winscw\udeb
       
    59 set PATH_TO_COVERAGE_DATA=\coverage_data
       
    60 
       
    61 if not exist %PATH_TO_COVERAGE_DATA% (
       
    62 mkdir %PATH_TO_COVERAGE_DATA%
       
    63 )
       
    64 
       
    65 if [%1] EQU [] ( goto default )
       
    66 
       
    67 call :%1
       
    68 call :%2
       
    69 call :%3
       
    70 call :%4
       
    71 call :%5
       
    72 echo Running tests = %RUNTESTS%
       
    73 echo Instrumenting tests = %INSTRUMENT%
       
    74 goto default
       
    75 
       
    76 :/NOCLEANUP
       
    77 set REMOVEINSTRUMENT=FALSE
       
    78 goto end
       
    79 
       
    80 :/NORUN
       
    81 set RUNTESTS=FALSE
       
    82 set REMOVEINSTRUMENT=FALSE
       
    83 goto end
       
    84 
       
    85 :/NOINSTRUMENT
       
    86 set INSTRUMENT=FALSE
       
    87 goto end
       
    88 
       
    89 :/NOBUILD
       
    90 set BUILDTESTS=FALSE
       
    91 goto end
       
    92 
       
    93 :/ONLYUNITTESTS
       
    94 set DOMODULESTESTS=FALSE
       
    95 goto end
       
    96 
       
    97 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    98 :: function FINISH
       
    99 ::
       
   100 :: Finishes run_auto_tests.bat
       
   101 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   102 :FINISH
       
   103 
       
   104 if [%RUNTESTS%] EQU [TRUE] (
       
   105 call :runtests
       
   106 )
       
   107 
       
   108 if [%INSTRUMENT%] EQU [TRUE] (
       
   109 call :calculatecoverage
       
   110 )
       
   111 
       
   112 if [%REMOVEINSTRUMENT%] EQU [TRUE] (
       
   113 call :removecoverage
       
   114 )
       
   115 goto end
       
   116 
       
   117 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   118 :: function BUILD
       
   119 ::    param directory
       
   120 ::
       
   121 :: builds test from given directory
       
   122 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   123 :BUILD
       
   124 setlocal
       
   125 if [%BUILDTESTS%] EQU [FALSE] ( goto end )
       
   126 echo Building %1
       
   127 if not exist %1 ( 
       
   128 echo %1 Not found! 
       
   129 goto end
       
   130 )
       
   131 
       
   132 pushd .
       
   133 call cd %1
       
   134 call qmake
       
   135 call bldmake bldfiles
       
   136 call abld clean winscw udeb
       
   137 if [%INSTRUMENT%] EQU [TRUE] (
       
   138 call ctcwrap -n %PATH_TO_COVERAGE_DATA%\%1 -i d -C "EXCLUDE=*" -C "NO_EXCLUDE=%TESTED_SRC%" %ABLD_CALL%
       
   139 ) else (
       
   140 call %ABLD_CALL%
       
   141 )
       
   142 
       
   143 popd
       
   144 endlocal
       
   145 goto end
       
   146 
       
   147 
       
   148 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   149 :: function RUNTESTS
       
   150 ::
       
   151 :: NOTE! Function assumes that test binary is named according to test directory.
       
   152 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   153 :RUNTESTS
       
   154 echo Running tests
       
   155 echo Expected user interactions!
       
   156 echo 1) User cancels
       
   157 echo 2) User selects vmb and inserts number
       
   158 echo 3) User selects one of the default numbers
       
   159 echo 4) User selects other number, inserts number and cancels
       
   160 echo 5) User selects othernumber and find
       
   161 echo 6) User selects other number and inserts number and timeout
       
   162 echo 7) User selects default number and and cancels in timeout query
       
   163 for /f %%a in ('dir /b ut_*') do call %PATH_TO_DLL%\%%a.exe -- 
       
   164 goto end
       
   165 
       
   166 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   167 :: function CALCULATECOVERAGE
       
   168 ::
       
   169 :: Calculates test coverage. Generates html
       
   170 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   171 :CALCULATECOVERAGE
       
   172 echo Calculating coverage
       
   173 ctcpost %PATH_TO_COVERAGE_DATA%\*.sym | ctcmerge -i - -o profile.txt
       
   174 call ctc2html -t 70 -i profile.txt -o \coverage_result -nsb
       
   175 goto end
       
   176 
       
   177 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   178 :: function REMOVECOVERAGE
       
   179 ::
       
   180 :: Removes data from coverage directory
       
   181 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   182 :REMOVECOVERAGE
       
   183 echo Removing deleting coverage data
       
   184 call del %PATH_TO_COVERAGE_DATA%\*.sym
       
   185 call del %PATH_TO_COVERAGE_DATA%\*.dat
       
   186 call del profile.txt
       
   187 goto end
       
   188 
       
   189 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   190 :: function END
       
   191 ::
       
   192 :: Prints done
       
   193 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   194 :END
       
   195 echo Done!