2016-12-26 13:46:13 +01:00
|
|
|
@echo off
|
|
|
|
chcp 65001
|
|
|
|
REM #-------------------------------------------------------------------------
|
|
|
|
REM # VGMSTREAM REGRESSION TESTING SCRIPT
|
|
|
|
REM #
|
|
|
|
REM # Searches for files in a directory (or optionally subdirs) and compares
|
|
|
|
REM # the output of two test.exe versions, both wav and stdout, for regression
|
|
|
|
REM # testing. This creates and deletes temp files, trying to process all
|
|
|
|
REM # extensions found unless specified (except a few).
|
|
|
|
REM #
|
|
|
|
REM # Options: see below.
|
|
|
|
REM #-------------------------------------------------------------------------
|
|
|
|
REM #TODO: escape & ! % in file/folder names
|
|
|
|
|
|
|
|
setlocal enableDelayedExpansion
|
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
REM #-------------------------------------------------------------------------
|
2016-12-26 13:46:13 +01:00
|
|
|
REM #options
|
2017-11-10 23:17:01 +01:00
|
|
|
REM #-------------------------------------------------------------------------
|
2016-12-26 13:46:13 +01:00
|
|
|
REM # -vo <exe> -vn <exe>: path to old/new exe
|
|
|
|
set OP_CMD_OLD=test_old.exe
|
|
|
|
set OP_CMD_NEW=test.exe
|
|
|
|
REM # -f <filename>: search wildcard (ex. -f "*.adx")
|
|
|
|
set OP_SEARCH="*.*"
|
|
|
|
REM # -r: recursive subfolders
|
|
|
|
set OP_RECURSIVE=
|
|
|
|
REM # -nd: don't delete compared files
|
|
|
|
set OP_NODELETE=
|
|
|
|
REM # -nc: don't report correct files
|
|
|
|
set OP_NOCORRECT=
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # -p: performance test (decode with new exe and no comparison done)
|
|
|
|
set OP_PERFORMANCE=
|
2018-08-25 09:55:42 +02:00
|
|
|
REM # -fc <exe>: file comparer (Windows's FC is slow)
|
|
|
|
set OP_CMD_FC=fc /a /b
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
|
|
|
|
REM # parse options
|
|
|
|
:set_options
|
|
|
|
if "%~1"=="" goto end_options
|
|
|
|
if "%~1"=="-vo" set OP_CMD_OLD=%2
|
|
|
|
if "%~1"=="-vn" set OP_CMD_NEW=%2
|
|
|
|
if "%~1"=="-f" set OP_SEARCH=%2
|
|
|
|
if "%~1"=="-r" set OP_RECURSIVE=/s
|
|
|
|
if "%~1"=="-nd" set OP_NODELETE=true
|
|
|
|
if "%~1"=="-nc" set OP_NOCORRECT=true
|
2017-11-10 23:17:01 +01:00
|
|
|
if "%~1"=="-p" set OP_PERFORMANCE=true
|
2018-08-25 09:55:42 +02:00
|
|
|
if "%~1"=="-fc" set OP_CMD_FC=%2
|
2016-12-26 13:46:13 +01:00
|
|
|
shift
|
|
|
|
goto set_options
|
|
|
|
:end_options
|
|
|
|
|
|
|
|
REM # output color defs
|
|
|
|
set C_W=0e
|
|
|
|
set C_E=0c
|
|
|
|
set C_O=0f
|
|
|
|
|
|
|
|
|
|
|
|
REM # check exe
|
|
|
|
set CMD_CHECK=where "%OP_CMD_OLD%" "%OP_CMD_NEW%"
|
|
|
|
%CMD_CHECK% > nul
|
|
|
|
if %ERRORLEVEL% NEQ 0 (
|
|
|
|
echo Old/new exe not found
|
|
|
|
goto error
|
|
|
|
)
|
|
|
|
if %OP_SEARCH%=="" (
|
|
|
|
echo Search wildcard not specified
|
|
|
|
goto error
|
|
|
|
)
|
|
|
|
|
|
|
|
REM # process start
|
2017-11-10 23:17:01 +01:00
|
|
|
set TIME_START=%time%
|
2018-06-09 17:33:31 +02:00
|
|
|
set FILES_OK=0
|
|
|
|
set FILES_KO=0
|
2017-11-10 23:17:01 +01:00
|
|
|
echo VRTS: start @%TIME_START%
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
REM # search for files
|
|
|
|
set CMD_DIR=dir /a:-d /b %OP_RECURSIVE% %OP_SEARCH%
|
|
|
|
set CMD_FIND=findstr /i /v "\.exe$ \.dll$ \.zip$ \.7z$ \.rar$ \.bat$ \.sh$ \.txt$ \.lnk$ \.wav$"
|
|
|
|
|
|
|
|
REM # process files
|
|
|
|
for /f "delims=" %%x in ('%CMD_DIR% ^| %CMD_FIND%') do (
|
|
|
|
set CMD_FILE=%%x
|
2017-11-10 23:17:01 +01:00
|
|
|
|
|
|
|
if "%OP_PERFORMANCE%" == "" (
|
|
|
|
call :process_file "!CMD_FILE!"
|
|
|
|
) else (
|
|
|
|
call :performance_file "!CMD_FILE!"
|
2018-06-09 17:33:31 +02:00
|
|
|
)
|
2017-11-10 23:17:01 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
REM # find time elapsed
|
|
|
|
set TIME_END=%time%
|
|
|
|
for /F "tokens=1-4 delims=:.," %%a in ("%TIME_START%") do (
|
|
|
|
set /A "TIME_START_S=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
2016-12-26 13:46:13 +01:00
|
|
|
)
|
2017-11-10 23:17:01 +01:00
|
|
|
for /F "tokens=1-4 delims=:.," %%a in ("%TIME_END%") do (
|
|
|
|
set /A "TIME_END_S=(((%%a*60)+1%%b %% 100)*60+1%%c %% 100)*100+1%%d %% 100"
|
|
|
|
)
|
|
|
|
set /A TIME_ELAPSED_S=(TIME_END_S-TIME_START_S)/100
|
|
|
|
set /A TIME_ELAPSED_C=(TIME_END_S-TIME_START_S)%%100
|
2016-12-26 13:46:13 +01:00
|
|
|
|
2018-06-09 17:33:31 +02:00
|
|
|
|
2016-12-26 13:46:13 +01:00
|
|
|
REM # process end (ok)
|
2017-11-10 23:17:01 +01:00
|
|
|
echo VRTS: done @%TIME_END% (%TIME_ELAPSED_S%,%TIME_ELAPSED_C%s)
|
2018-06-09 17:33:31 +02:00
|
|
|
echo VRTS: ok=%FILES_OK%, ko=%FILES_KO%
|
2017-11-10 23:17:01 +01:00
|
|
|
|
|
|
|
goto exit
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # ########################################################################
|
2016-12-26 13:46:13 +01:00
|
|
|
REM # test a single file
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # ########################################################################
|
2016-12-26 13:46:13 +01:00
|
|
|
:process_file outer
|
|
|
|
REM # ignore files starting with dot (no filename)
|
|
|
|
set CMD_SHORTNAME=%~n1
|
2017-11-10 23:17:01 +01:00
|
|
|
if "%CMD_SHORTNAME%" == "" goto process_file_continue
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
REM # get file
|
|
|
|
set CMD_FILE=%1
|
|
|
|
set CMD_FILE=%CMD_FILE:"=%
|
|
|
|
REM echo VTRS: file %CMD_FILE%
|
2018-06-09 17:33:31 +02:00
|
|
|
|
2016-12-26 13:46:13 +01:00
|
|
|
REM # old/new temp output
|
|
|
|
set WAV_OLD=%CMD_FILE%.old.wav
|
|
|
|
set TXT_OLD=%CMD_FILE%.old.txt
|
|
|
|
set CMD_VGM_OLD="%OP_CMD_OLD%" -o "%WAV_OLD%" "%CMD_FILE%"
|
|
|
|
%CMD_VGM_OLD% 1> "%TXT_OLD%" 2>&1 & REM || goto error
|
|
|
|
|
|
|
|
set WAV_NEW=%CMD_FILE%.new.wav
|
|
|
|
set TXT_NEW=%CMD_FILE%.new.txt
|
|
|
|
set CMD_VGM_NEW="%OP_CMD_NEW%" -o "%WAV_NEW%" "%CMD_FILE%"
|
|
|
|
%CMD_VGM_NEW% 1> "%TXT_NEW%" 2>&1 & REM || goto error
|
|
|
|
|
|
|
|
REM # ignore if no files are created (unsupported formats)
|
|
|
|
if not exist "%WAV_NEW%" (
|
|
|
|
if not exist "%WAV_OLD%" (
|
|
|
|
REM echo VRTS: nothing created for file %CMD_FILE%
|
|
|
|
if exist "%TXT_NEW%" del /a:a "%TXT_NEW%"
|
|
|
|
if exist "%TXT_OLD%" del /a:a "%TXT_OLD%"
|
2017-11-10 23:17:01 +01:00
|
|
|
goto process_file_continue
|
2016-12-26 13:46:13 +01:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2018-08-24 20:08:44 +02:00
|
|
|
REM # compare files (without /b may to be faster for small files?)
|
2018-08-25 09:55:42 +02:00
|
|
|
set CMP_WAV=%OP_CMD_FC% "%WAV_OLD%" "%WAV_NEW%"
|
|
|
|
set CMP_TXT=%OP_CMD_FC% "%TXT_OLD%" "%TXT_NEW%"
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
%CMP_WAV% 1> nul 2>&1
|
|
|
|
set CMP_WAV_ERROR=0
|
|
|
|
if %ERRORLEVEL% NEQ 0 set CMP_WAV_ERROR=1
|
2018-06-09 17:33:31 +02:00
|
|
|
|
2016-12-26 13:46:13 +01:00
|
|
|
%CMP_TXT% 1> nul 2>&1
|
|
|
|
set CMP_TXT_ERROR=0
|
|
|
|
if %ERRORLEVEL% NEQ 0 set CMP_TXT_ERROR=1
|
|
|
|
|
|
|
|
REM # print output
|
|
|
|
if %CMP_WAV_ERROR% EQU 1 (
|
|
|
|
if %CMP_TXT_ERROR% EQU 1 (
|
|
|
|
call :echo_color %C_E% "%CMD_FILE%" "wav and txt diffs"
|
|
|
|
) else (
|
|
|
|
call :echo_color %C_E% "%CMD_FILE%" "wav diffs"
|
|
|
|
)
|
2018-06-09 17:33:31 +02:00
|
|
|
set /a "FILES_KO+=1"
|
2016-12-26 13:46:13 +01:00
|
|
|
) else (
|
|
|
|
if %CMP_TXT_ERROR% EQU 1 (
|
|
|
|
call :echo_color %C_W% "%CMD_FILE%" "txt diffs"
|
|
|
|
) else (
|
|
|
|
if "%OP_NOCORRECT%" == "" (
|
|
|
|
call :echo_color %C_O% "%CMD_FILE%" "no diffs"
|
|
|
|
)
|
|
|
|
)
|
2018-06-09 17:33:31 +02:00
|
|
|
set /a "FILES_OK+=1"
|
2016-12-26 13:46:13 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
REM # delete temp files
|
|
|
|
if "%OP_NODELETE%" == "" (
|
|
|
|
if exist "%WAV_OLD%" del /a:a "%WAV_OLD%"
|
|
|
|
if exist "%TXT_OLD%" del /a:a "%TXT_OLD%"
|
|
|
|
if exist "%WAV_NEW%" del /a:a "%WAV_NEW%"
|
|
|
|
if exist "%TXT_NEW%" del /a:a "%TXT_NEW%"
|
|
|
|
)
|
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
:process_file_continue
|
2016-12-26 13:46:13 +01:00
|
|
|
exit /B
|
|
|
|
REM :process_file end, continue from last call
|
|
|
|
|
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # ########################################################################
|
|
|
|
REM # decode only (no comparisons done), for performance testing
|
|
|
|
REM # ########################################################################
|
|
|
|
:performance_file
|
|
|
|
REM # ignore files starting with dot (no filename)
|
|
|
|
set CMD_SHORTNAME=%~n1
|
|
|
|
if "%CMD_SHORTNAME%" == "" goto performance_file_continue
|
|
|
|
|
|
|
|
REM # get file
|
|
|
|
set CMD_FILE=%1
|
|
|
|
set CMD_FILE=%CMD_FILE:"=%
|
|
|
|
REM echo VTRS: file %CMD_FILE%
|
2018-06-09 17:33:31 +02:00
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # new temp output
|
|
|
|
set WAV_NEW=%CMD_FILE%.test.wav
|
|
|
|
set CMD_VGM_NEW="%OP_CMD_NEW%" -o "%WAV_NEW%" "%CMD_FILE%"
|
|
|
|
%CMD_VGM_NEW% 1> nul 2>&1 & REM || goto error
|
|
|
|
|
|
|
|
call :echo_color %C_O% "%CMD_FILE%" "done"
|
|
|
|
|
|
|
|
REM # ignore output
|
|
|
|
if exist "%WAV_NEW%" del /a:a "%WAV_NEW%"
|
|
|
|
|
|
|
|
:performance_file_continue
|
|
|
|
exit /B
|
|
|
|
REM :performance_file end, continue from last call
|
|
|
|
|
|
|
|
|
|
|
|
REM # ########################################################################
|
2016-12-26 13:46:13 +01:00
|
|
|
REM # hack to get colored output in Windows CMD using findstr + temp file
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # ########################################################################
|
2016-12-26 13:46:13 +01:00
|
|
|
:echo_color
|
|
|
|
set TEMP_FILE=%2-result
|
|
|
|
set TEMP_FILE=%TEMP_FILE:"=%
|
|
|
|
set TEMP_TEXT=%3
|
|
|
|
set TEMP_TEXT=%TEMP_TEXT:"=%
|
|
|
|
echo %TEMP_TEXT% > "%TEMP_FILE%"
|
|
|
|
REM # show colored filename + any text in temp file
|
|
|
|
findstr /v /a:%1 /r "^$" "%TEMP_FILE%" nul
|
|
|
|
del "%TEMP_FILE%"
|
|
|
|
exit /B
|
|
|
|
REM :echo_color end, continue from last call
|
|
|
|
|
|
|
|
|
2017-11-10 23:17:01 +01:00
|
|
|
REM # ########################################################################
|
2016-12-26 13:46:13 +01:00
|
|
|
|
|
|
|
:error
|
2017-11-10 23:17:01 +01:00
|
|
|
echo VRTS: error
|
2016-12-26 13:46:13 +01:00
|
|
|
goto exit
|
|
|
|
|
|
|
|
:exit
|