Commit 3eaa5eac authored by Rashad Kanavath's avatar Rashad Kanavath

TEST: launch selftester.bat via script

parent 617540d9
@echo on
set CURDIR=%~dp0
set EXIT_ON_ERROR=1
set VERBOSE=0
cmd /k %CURDIR%tools\selftester.bat /q > %CURDIR%selftest_report.log 2>&1
\ No newline at end of file
@echo off @echo off
setlocal
set CURRENT_SCRIPT_DIR=%~dp0 set MY_TOOLS_DIR=%~dp0
set DIRNAME=%CURRENT_SCRIPT_DIR%.. cd %MY_TOOLS_DIR%..
cd %DIRNAME% set MY_INSTALL_DIR=%cd%
echo "MY_INSTALL_DIR=%MY_INSTALL_DIR%"
:: this is set in wrapper script
::set EXIT_ON_ERROR=0
IF %EXIT_ON_ERROR%.==. ( set EXIT_ON_ERROR=0)
IF %VERBOSE%.==. ( set VERBOSE=1)
:: if "/q" is given, hide the error dialogs (hence make the script non-interactive) :: if "/q" is given, hide the error dialogs (hence make the script non-interactive)
if /i not -%1-==-/q- ( if /i not -%1-==-/q- (
...@@ -13,7 +18,6 @@ echo Hide error dialogs ...@@ -13,7 +18,6 @@ echo Hide error dialogs
call :getDontShowUI call :getDontShowUI
if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 1 if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 1
:skip_hide_error :skip_hide_error
:: Get current PID :: Get current PID
type NUL > pid.log type NUL > pid.log
wmic PROCESS where "Name='WMIC.exe'" get ParentProcessId >pid.log 2>&1 wmic PROCESS where "Name='WMIC.exe'" get ParentProcessId >pid.log 2>&1
...@@ -22,12 +26,8 @@ for /F "TOKENS=1" %%b in ('type pid.log ^| findstr [0-9]') do set CURRENT_PID=%% ...@@ -22,12 +26,8 @@ for /F "TOKENS=1" %%b in ('type pid.log ^| findstr [0-9]') do set CURRENT_PID=%%
:: setup the otbenv :: setup the otbenv
call otbenv.bat call otbenv.bat
del selftest_report.log
type NUL > selftest_report.log
call :nb_report_lines
set REF_SIZE=%nb_report_lines_out%
:: ----------------------------------------------------------------------------------- :: -----------------------------------------------------------------------------------
rem Check 1 : check binaries REM Check 1 : check binaries
for /R %%i in (*.dll) do ( for /R %%i in (*.dll) do (
call :check_binary %%i call :check_binary %%i
) )
...@@ -36,13 +36,6 @@ for %%i in (bin\mapla.exe,bin\monteverdi.exe,bin\otbApplicationLauncherCommandLi ...@@ -36,13 +36,6 @@ for %%i in (bin\mapla.exe,bin\monteverdi.exe,bin\otbApplicationLauncherCommandLi
) )
call :check_binary lib\python\_otbApplication.pyd call :check_binary lib\python\_otbApplication.pyd
call :nb_report_lines
if %nb_report_lines_out% gtr %REF_SIZE% (
echo Check 1/3 : FAIL
) else (
echo Check 1/3 : PASS
)
set REF_SIZE=%nb_report_lines_out%
:: ----------------------------------------------------------------------------------- :: -----------------------------------------------------------------------------------
rem Check 2 : check applications and Python wrapping rem Check 2 : check applications and Python wrapping
set /a app_count=0 set /a app_count=0
...@@ -54,30 +47,17 @@ if %app_count% leq 90 ( ...@@ -54,30 +47,17 @@ if %app_count% leq 90 (
) )
call :check_python_wrapping call :check_python_wrapping
call :nb_report_lines
if %nb_report_lines_out% gtr %REF_SIZE% (
echo Check 2/3 : FAIL
) else (
echo Check 2/3 : PASS
)
set REF_SIZE=%nb_report_lines_out%
:: ----------------------------------------------------------------------------------- :: -----------------------------------------------------------------------------------
rem Check 3 : check monteverdi & mapla rem Check 3 : check monteverdi & mapla
call :check_desktop_app monteverdi call :check_desktop_app monteverdi
call :check_desktop_app mapla 20 call :check_desktop_app mapla 20
call :nb_report_lines
if %nb_report_lines_out% gtr %REF_SIZE% (
echo Check 3/3 : FAIL
) else (
echo Check 3/3 : PASS
)
if /i not -%1-==-/q- ( if /i not -%1-==-/q- (
goto :skip_restore_error goto :skip_restore_error
) )
if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 0 if %DONTSHOWUI_VALUE% equ 0 call :setDontShowUI 0
:skip_restore_error :skip_restore_error
setlocal
del pid.log del pid.log
del tmp.log del tmp.log
endlocal endlocal
...@@ -86,13 +66,14 @@ goto :eof ...@@ -86,13 +66,14 @@ goto :eof
::########################[ FUNCTIONS ]################################## ::########################[ FUNCTIONS ]##################################
:check_binary :check_binary
setlocal setlocal
if %VERBOSE% equ 1 ( echo ":check_binary %1" )
type NUL > tmp.log type NUL > tmp.log
tools\otb_loader.exe %1 > tmp.log 2>&1 tools\otb_loader.exe %1 > tmp.log 2>&1
call :nb_tmp_lines call :nb_tmp_lines
if %nb_tmp_lines_out% gtr 0 ( if %nb_tmp_lines_out% gtr 0 (
echo ERROR : otb_loader.exe %1 echo "ERROR: otb_loader.exe %1"
echo otb_loader.exe %1 >> selftest_report.log type tmp.log
type tmp.log >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
) )
endlocal endlocal
goto :eof goto :eof
...@@ -101,9 +82,10 @@ goto :eof ...@@ -101,9 +82,10 @@ goto :eof
setlocal setlocal
set dll_path=%~n1 set dll_path=%~n1
set app=%dll_path:~7% set app=%dll_path:~7%
if %VERBOSE% equ 1 ( echo ":check_application %app%" )
if not exist bin\otbcli_%app%.bat ( if not exist bin\otbcli_%app%.bat (
echo ERROR : missing cli launcher for application %app% echo ERROR : missing cli launcher for application %app%
echo ERROR : missing cli launcher for application %app% >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
goto :check_gui goto :check_gui
) )
type NUL > tmp.log type NUL > tmp.log
...@@ -111,13 +93,14 @@ cmd /C bin\otbcli_%app%.bat "-help" ^> tmp.log ^2^>^&^1 ...@@ -111,13 +93,14 @@ cmd /C bin\otbcli_%app%.bat "-help" ^> tmp.log ^2^>^&^1
call :parse_cli_output call :parse_cli_output
if %parse_cli_result% equ 0 ( if %parse_cli_result% equ 0 (
echo ERROR : error launching application otbcli_%app% echo ERROR : error launching application otbcli_%app%
echo ERROR : error launching application otbcli_%app% >> selftest_report.log type results.txt
type tmp.log >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
) )
:check_gui :check_gui
if not exist bin\otbgui_%app%.bat ( if not exist bin\otbgui_%app%.bat (
echo ERROR : missing gui launcher for application %app% echo ERROR : missing gui launcher for application %app%
echo ERROR : missing gui launcher for application %app% >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
goto :check_application_end goto :check_application_end
) )
if %app_count% geq 2 goto :check_application_end if %app_count% geq 2 goto :check_application_end
...@@ -130,20 +113,21 @@ if %child_pid% gtr 1 ( ...@@ -130,20 +113,21 @@ if %child_pid% gtr 1 (
set first_child=%child_pid% set first_child=%child_pid%
) else ( ) else (
echo ERROR : could not launch otbgui_%app% echo ERROR : could not launch otbgui_%app%
echo ERROR : could not launch otbgui_%app% >> selftest_report.log type tmp.log
type tmp.log >> selftest_report.log
goto :check_application_clean goto :check_application_clean
) )
call :get_child_pid %first_child% otbApplicationLauncherQt.exe call :get_child_pid %first_child% otbApplicationLauncherQt.exe
if not %child_pid% gtr 1 ( if not %child_pid% gtr 1 (
echo ERROR : could not launch otbApplicationLauncherQt %app% echo ERROR : could not launch otbApplicationLauncherQt %app%
echo ERROR : could not launch otbApplicationLauncherQt %app% >> selftest_report.log type tmp.log
type tmp.log >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
) )
:check_application_clean :check_application_clean
if not %first_child% == 0 ( if not %first_child% == 0 (
taskkill /PID %first_child% /F /T > NUL 2>&1 taskkill /PID %first_child% /F /T > NUL 2>&1
) )
:check_application_end :check_application_end
endlocal & set /a app_count=app_count+1 endlocal & set /a app_count=app_count+1
goto :eof goto :eof
...@@ -161,8 +145,8 @@ if %child_pid% gtr 1 ( ...@@ -161,8 +145,8 @@ if %child_pid% gtr 1 (
taskkill /PID %child_pid% /F /T > NUL 2>&1 taskkill /PID %child_pid% /F /T > NUL 2>&1
) else ( ) else (
echo ERROR : could not launch %appName%.exe echo ERROR : could not launch %appName%.exe
echo ERROR : could not launch %appName%.exe >> selftest_report.log type tmp.log
type tmp.log >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
) )
endlocal endlocal
goto :eof goto :eof
...@@ -174,8 +158,8 @@ python -c "import otbApplication" > tmp.log 2>&1 ...@@ -174,8 +158,8 @@ python -c "import otbApplication" > tmp.log 2>&1
call :nb_tmp_lines call :nb_tmp_lines
if %nb_tmp_lines_out% gtr 0 ( if %nb_tmp_lines_out% gtr 0 (
echo ERROR : failed to run python wrapping echo ERROR : failed to run python wrapping
echo ERROR : failed to run python wrapping >> selftest_report.log type tmp.log
type tmp.log >> selftest_report.log if %EXIT_ON_ERROR% equ 1 ( exit 1 )
) )
endlocal endlocal
goto :eof goto :eof
...@@ -183,39 +167,36 @@ goto :eof ...@@ -183,39 +167,36 @@ goto :eof
:parse_cli_output :parse_cli_output
setlocal setlocal
set /a ret=1 set /a ret=1
for /F %%a in ('findstr /n /r /c:"^This is the %app% application, version " tmp.log') do set output=%%a findstr /n /r /c:"^This is the *.*(%app%) application, version " tmp.log > results.txt
if not "%output%" gtr "1:" ( if %errorlevel%==1 (
set /a ret=0 set /a ret=0
goto :parse_cli_output_end echo "findstr failed 1st regex in parse_cli_output"
goto :parse_cli_output_end
) )
set output= findstr /n /r /c:"^Parameters: " tmp.log > results.txt
for /F %%a in ('findstr /n /r /c:"^Parameters:" tmp.log') do set output=%%a if %errorlevel%==1 (
if not "%output%" gtr "3:" (
set /a ret=0 set /a ret=0
goto :parse_cli_output_end echo "findstr failed 2nd regex in parse_cli_output"
goto :parse_cli_output_end
) )
set output= findstr /n /r /c:"^Examples: " tmp.log > results.txt
for /F %%a in ('findstr /n /r /c:"^Examples:" tmp.log') do set output=%%a if %errorlevel%==1 (
if not "%output%" gtr "1" (
set /a ret=0 set /a ret=0
goto :parse_cli_output_end echo "findstr failed 3rd regex in parse_cli_output"
goto :parse_cli_output_end
) )
set output= findstr /n /r /c:"FATAL" tmp.log > results.txt
for /F %%a in ('findstr /n /r /c:"FATAL" tmp.log') do set output=%%a if %errorlevel%==0 (
if "%output%" gtr "1" (
set /a ret=0 set /a ret=0
goto :parse_cli_output_end echo "findstr passed 4th regex in parse_cli_output"
goto :parse_cli_output_end
) )
:parse_cli_output_end :parse_cli_output_end
endlocal & set /a parse_cli_result=%ret% endlocal & set /a parse_cli_result=%ret%
goto :eof goto :eof
::----------------------------------------------------------------------- ::-----------------------------------------------------------------------
:nb_report_lines
setlocal
for /F "delims=" %%i in ('find /C /V "" ^< selftest_report.log') do set output=%%i
endlocal & set nb_report_lines_out=%output%
goto :eof
::-----------------------------------------------------------------------
:nb_tmp_lines :nb_tmp_lines
setlocal setlocal
for /F "delims=" %%i in ('find /C /V "" ^< tmp.log') do set output=%%i for /F "delims=" %%i in ('find /C /V "" ^< tmp.log') do set output=%%i
...@@ -245,3 +226,4 @@ setlocal ...@@ -245,3 +226,4 @@ setlocal
reg add "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d %1 /f reg add "HKCU\Software\Microsoft\Windows\Windows Error Reporting" /v DontShowUI /t REG_DWORD /d %1 /f
endlocal endlocal
goto :eof goto :eof
...@@ -73,6 +73,14 @@ macro(installer_files) ...@@ -73,6 +73,14 @@ macro(installer_files)
Files/otbenv.bash Files/otbenv.bash
DESTINATION ${PKG_STAGE_DIR} DESTINATION ${PKG_STAGE_DIR}
) )
#A script to launch selftest and
#save output to selftest_report.log
install(PROGRAMS
Files/run_selftester.bat
RENAME selftester.bat
DESTINATION ${PKG_STAGE_DIR}
)
endif() endif()
#these scripts are not auto-installed in PKG_STAGE_DIR #these scripts are not auto-installed in PKG_STAGE_DIR
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment