LDRA: Automating TBRun

Most of the analysis and test runs for LDRA can be automated.

I am using the following batch file to automate TBRun:

REM Assumes the following Directory structure:
REM
REM   c:\projects\TCF-Test
REM   c:\projects\TCF-Test\Environment
REM   c:\projects\TCF-Test\TCF
REM
REM The directory `c:\projects\TCF-Test` should contain the source code, headers 
REM and any linker files.
REM 
REM The directory `c:\projects\TCF-Test\Environment` should contain the 
REM `sysearch.dat` and `sysappvar.dat` setup for the unit tests we are running.
REM
REM The directory `c:\projects\TCF-Test\TCF` should contain the stripped TCF files
REM we require for the unit tests we are running.
REM
REM The results will be in: `C:\LDRA_Workarea\TCF_TEST_SET_tbwrkfls`.
REM

REM Directory where source files are.
set ALIAS_DIR=C:\projects\TCF-Test
REM Sub-directory where stripped TCF files are
set TCF_DIR=TCF
REM Set name
set SET_NAME=TCF_TEST_SET
REM Directory where source files are
set CODE_DIR=C:\projects\TCF-Test
REM Directory where LDRA is installed
set CMD_DIR=c:\LDRA_Toolsuite
REM Out log file
set LOG_FILE=tcf_log.txt

REM Clean up previous run
del /f "%CODE_DIR%\%LOG_FILE%"
del /f "%CODE_DIR%\sysearch.dat"
del /f "%CODE_DIR%\sysppvar.dat"

REM Copy in standard setup files
REM   - syssearch.dat is used to find header files
copy /y "%CODE_DIR%\Environment\sysearch.dat" "%CODE_DIR%\sysearch.dat"
REM   - sysppvar.dat is used to specify defines for compilation and static analysis
copy /y "%CODE_DIR%\Environment\sysppvar.dat" "%CODE_DIR%\sysppvar.dat"

REM Delete any previous Set results and configuration
echo "Delete set" > %LOG_FILE%
start /B /wait %CMD_DIR%\contestbed -delete_set="%SET_NAME%" >> %LOG_FILE%
timeout /T 2

REM Create a new Set
echo "Create set" >> %LOG_FILE%
start /B /wait %CMD_DIR%\contestbed "%SET_NAME%" -create_set=system -1q^
    >> %LOG_FILE%
timeout /T 2

REM Add the source files to the set. This must include all code necessary to do
REM a clean build.
echo "set source files " >> %LOG_FILE%
start /B /wait %CMD_DIR%\\contestbed "%SET_NAME%" -add_set_file="%CODE_DIR%\code_under_test_a.c" -add_set_file="%CODE_DIR%\code_under_test_b.c" -add_set_file="%CODE_DIR%\helper_functions.c" -1q >> %LOG_FILE%
timeout /T 2

REM Force a minimal static analysis so that we can perform the dynamic test run
echo "force analysis " >> %LOG_FILE%
start /B /wait %CMD_DIR%\\contestbed "%SET_NAME%" /112n34q >> %LOG_FILE%
timeout /T 2

rem Run tests
for /r %%v in (%TCF_DIR%\*.tcf) do (
    echo "RUN %%v" >> %LOG_FILE%
    start /B /wait %CMD_DIR%\Contbrun.exe "%SET_NAME%" -tcf="%%v"^
         -alias_by_directory="%ALIAS_DIR%" -regress -tas -quit >> %LOG_FILE%
    timeout /T 2
)


Comments