phoneengine/contacthandling2/tsrc/run_auto_tests.bat
changeset 37 ba76fc04e6c2
child 51 f39ed5e045e0
child 76 cfea66083b62
equal deleted inserted replaced
36:2eacb6118286 37:ba76fc04e6c2
       
     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\*
       
    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 
       
    43 call :finish
       
    44 goto :END
       
    45 
       
    46 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    47 :: function STARTUP
       
    48 ::
       
    49 :: Initializing script
       
    50 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
    51 :STARTUP
       
    52 
       
    53 set BUILDTESTS=TRUE
       
    54 set RUNTESTS=TRUE
       
    55 set REMOVETESTS=TRUE
       
    56 set INSTRUMENT=TRUE
       
    57 set REMOVEINSTRUMENT=TRUE
       
    58 set DOMODULESTESTS=TRUE
       
    59 set SBS_CALL=sbs --config winscw_udeb.test --keepgoing BUILD
       
    60 set PATH_TO_DLL=\epoc32\release\winscw\udeb
       
    61 set PATH_TO_MOVE_DLL=\epoc32\release\winscw\udeb\z\sys\bin
       
    62 set PATH_TO_COVERAGE_DATA=\coverage_data
       
    63 
       
    64 
       
    65 if not exist %PATH_TO_DLL%\eunitexerunner.exe  ( 
       
    66 echo EUnit not installed! 
       
    67 goto end
       
    68 )
       
    69 
       
    70 if not exist %PATH_TO_COVERAGE_DATA% (
       
    71 mkdir %PATH_TO_COVERAGE_DATA%
       
    72 )
       
    73 
       
    74 if [%1] EQU [] ( goto default )
       
    75 
       
    76 call :%1
       
    77 call :%2
       
    78 call :%3
       
    79 call :%4
       
    80 call :%5
       
    81 echo Running tests = %RUNTESTS%
       
    82 echo Instrumenting tests = %INSTRUMENT%
       
    83 goto default
       
    84 
       
    85 :/NOCLEANUP
       
    86 set REMOVEINSTRUMENT=FALSE
       
    87 set REMOVETESTS=FALSE
       
    88 goto end
       
    89 
       
    90 :/NORUN
       
    91 set RUNTESTS=FALSE
       
    92 set REMOVEINSTRUMENT=FALSE
       
    93 set REMOVETESTS=FALSE
       
    94 goto end
       
    95 
       
    96 :/NOINSTRUMENT
       
    97 set INSTRUMENT=FALSE
       
    98 goto end
       
    99 
       
   100 :/NOBUILD
       
   101 set BUILDTESTS=FALSE
       
   102 goto end
       
   103 
       
   104 :/ONLYUNITTESTS
       
   105 set DOMODULESTESTS=FALSE
       
   106 goto end
       
   107 
       
   108 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   109 :: function FINISH
       
   110 ::
       
   111 :: Finishes run_auto_tests.bat
       
   112 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   113 :FINISH
       
   114 call :move
       
   115 
       
   116 if [%RUNTESTS%] EQU [TRUE] (
       
   117 call :runtests
       
   118 )
       
   119 
       
   120 if [%REMOVETESTS%] EQU [TRUE] (
       
   121 call :removetests
       
   122 )
       
   123 
       
   124 if [%INSTRUMENT%] EQU [TRUE] (
       
   125 call :calculatecoverage
       
   126 )
       
   127 
       
   128 if [%REMOVEINSTRUMENT%] EQU [TRUE] (
       
   129 call :removecoverage
       
   130 )
       
   131 goto end
       
   132 
       
   133 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   134 :: function BUILD
       
   135 ::    param directory
       
   136 ::
       
   137 :: builds test from given directory
       
   138 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   139 :BUILD
       
   140 setlocal
       
   141 if [%BUILDTESTS%] EQU [FALSE] ( goto end )
       
   142 echo Building %1
       
   143 if not exist %1 ( 
       
   144 echo %1 Not found! 
       
   145 goto end
       
   146 )
       
   147 
       
   148 pushd .
       
   149 call cd %1\group
       
   150 call sbs --config winscw_udeb.test --keepgoing CLEAN
       
   151 if [%INSTRUMENT%] EQU [TRUE] (
       
   152 call ctcwrap -2comp -n %PATH_TO_COVERAGE_DATA%\%1 -i d -C "EXCLUDE=*" -C "NO_EXCLUDE=%TESTED_SRC%" "%SBS_CALL%"
       
   153 ) else (
       
   154 call %SBS_CALL%
       
   155 )
       
   156 
       
   157 popd
       
   158 endlocal
       
   159 goto end
       
   160 
       
   161 
       
   162 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   163 :: function MOVE
       
   164 ::
       
   165 :: moves compiled tests to eunit directory
       
   166 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   167 :MOVE
       
   168 echo Moving tests
       
   169 call move %PATH_TO_DLL%\ut_*.dll %PATH_TO_MOVE_DLL%
       
   170 call move %PATH_TO_DLL%\mt_*.dll %PATH_TO_MOVE_DLL%
       
   171 goto end
       
   172 
       
   173 
       
   174 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   175 :: function RUNTESTS
       
   176 ::
       
   177 :: Runs tests in eunit directory
       
   178 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   179 :RUNTESTS
       
   180 echo Running tests
       
   181 call %PATH_TO_DLL%\eunitexerunner.exe -dtextshell --
       
   182 copy \epoc32\winscw\c\shared\EUnit\Logs\EUnit_log.xml \lastrun_EUnit_log.xml
       
   183 goto end
       
   184 
       
   185 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   186 :: function CALCULATECOVERAGE
       
   187 ::
       
   188 :: Calculates test coverage. Generates html
       
   189 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   190 :CALCULATECOVERAGE
       
   191 echo Calculating coverage
       
   192 ctcpost %PATH_TO_COVERAGE_DATA%\*.sym | ctcmerge -i - -o profile.txt
       
   193 call ctc2html -t 70 -i profile.txt -o \coverage_result -nsb
       
   194 goto end
       
   195 
       
   196 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   197 :: function REMOVETESTS
       
   198 ::
       
   199 :: Removes tests from eunit directory
       
   200 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   201 :REMOVETESTS
       
   202 echo Removing Test dlls
       
   203 call sleep 3
       
   204 call del %PATH_TO_MOVE_DLL%\t_*.dll
       
   205 call del %PATH_TO_MOVE_DLL%\mt_*.dll
       
   206 call del %PATH_TO_MOVE_DLL%\ut_*.dll
       
   207 call del %PATH_TO_MOVE_DLL%\it_*.dll
       
   208 goto end
       
   209 
       
   210 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   211 :: function REMOVECOVERAGE
       
   212 ::
       
   213 :: Removes data from coverage directory
       
   214 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   215 :REMOVECOVERAGE
       
   216 echo Removing deleting coverage data
       
   217 call del %PATH_TO_COVERAGE_DATA%\*.sym
       
   218 call del %PATH_TO_COVERAGE_DATA%\*.dat
       
   219 call del profile.txt
       
   220 goto end
       
   221 
       
   222 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   223 :: function END
       
   224 ::
       
   225 :: Prints done
       
   226 ::::::::::::::::::::::::::::::::::::::::::::::::::::::
       
   227 :END
       
   228 echo Done!