diff --git a/scripts/clear_config.cmd b/scripts/clear_config.cmd new file mode 100644 index 0000000..b8d57d0 --- /dev/null +++ b/scripts/clear_config.cmd @@ -0,0 +1,12 @@ +REM Clear the saved config options (in the registry) +SET "TMPOUT=%TEMP%\set_config.out" + +REG DELETE "HKCU\SOFTWARE\codersnotes.com\Very Sleepy" /F >"%TMPOUT%" 2>&1 +if ERRORLEVEL 1 ( + rem reg.exe outputs "The operation completed successfully." on success. + rem This is nice, but is undesirable for our tests. + rem Only emit the output if something fails. + @echo %~n0: failure + @type "%TMPOUT%" + exit /b !ERRORLEVEL! +) diff --git a/scripts/clear_env.cmd b/scripts/clear_env.cmd index e855472..6b82ea5 100644 --- a/scripts/clear_env.cmd +++ b/scripts/clear_env.cmd @@ -13,3 +13,9 @@ set VC= set VS_YEAR= set CC= set MAKE= + +rem Ensure these don't interfere with tests. +rem https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/general-environment-variables +set _NT_SYMBOL_PATH= +set _NT_ALT_SYMBOL_PATH= +set _NT_SYMBOL_PROXY= diff --git a/scripts/get_config.cmd b/scripts/get_config.cmd new file mode 100644 index 0000000..baf61b5 --- /dev/null +++ b/scripts/get_config.cmd @@ -0,0 +1,13 @@ +@SETLOCAL ENABLEDELAYEDEXPANSION +@ECHO OFF + +REM Retrieve a config value from the registry and store it in the specified environment variable. +REM Usage: get_config.cmd + +SET "VALUE_NAME=%~1" +SET "VAR_NAME=%~2" + +FOR /F "usebackq tokens=*" %%v IN (`PowerShell.exe -NoProfile -ExecutionPolicy Bypass -Command "Get-ItemPropertyValue -Path 'Registry::HKEY_CURRENT_USER\SOFTWARE\codersnotes.com\Very Sleepy' -Name '!VALUE_NAME!' -ErrorAction:SilentlyContinue" ^ nul +if errorlevel 1 exit 1 + +set FOUND=0 +set STAT_VALUE=_NOT_FOUND_ +if exist "!SLEEPY_BASE!\Stats.txt" ( + for /f "tokens=1,2* delims=: " %%a in (!SLEEPY_BASE!\Stats.txt) do ( + if "%%~a"=="!STAT_DESCR!" ( + set FOUND=1 + set "STAT_VALUE=%%~b" + ) + ) +) +if %FOUND% == 0 exit /b 1 + +ENDLOCAL & set "%TARGET_ENVVAR%=%STAT_VALUE%" diff --git a/scripts/set_config.cmd b/scripts/set_config.cmd new file mode 100644 index 0000000..fcea5a9 --- /dev/null +++ b/scripts/set_config.cmd @@ -0,0 +1,19 @@ +@setlocal enabledelayedexpansion +@echo off + +rem Set a config value (that's a string/REG_SZ) in the registry. +rem Usage: set_config.cmd option_name new_value + +set "VALUE_NAME=%~1" +set "VALUE_DATA=%~2" + +SET "TMPOUT=%TEMP%\set_config.out" +reg add "HKCU\SOFTWARE\codersnotes.com\Very Sleepy" /v "!VALUE_NAME!" /t REG_SZ /d "!VALUE_DATA!" /f >"%TMPOUT%" 2>&1 +if ERRORLEVEL 1 ( + rem reg.exe outputs "The operation completed successfully." on success. + rem This is nice, but is undesirable for our tests. + rem Only emit the output if something fails. + @type "%TMPOUT%" + exit /b !ERRORLEVEL! +) + diff --git a/scripts/set_config_dword.cmd b/scripts/set_config_dword.cmd new file mode 100644 index 0000000..a7498e4 --- /dev/null +++ b/scripts/set_config_dword.cmd @@ -0,0 +1,19 @@ +@setlocal enabledelayedexpansion +@echo off + +rem Set a config value (that's a DWORD) in the registry. +rem Usage: set_config_dword.cmd + +set "VALUE_NAME=%~1" +set "VALUE_DATA=%~2" + +SET "TMPOUT=%TEMP%\set_config.out" +reg add "HKCU\SOFTWARE\codersnotes.com\Very Sleepy" /v "!VALUE_NAME!" /t REG_DWORD /d !VALUE_DATA! /f >"%TMPOUT%" 2>&1 +if ERRORLEVEL 1 ( + rem reg.exe outputs "The operation completed successfully." on success. + rem This is nice, but is undesirable for our tests. + rem Only emit the output if something fails. + @type "%TMPOUT%" + exit /b !ERRORLEVEL! +) + diff --git a/scripts/test_minidump.cmd b/scripts/test_minidump.cmd new file mode 100644 index 0000000..7a000dd --- /dev/null +++ b/scripts/test_minidump.cmd @@ -0,0 +1,12 @@ +@echo off + +rem usage: test_minidump.cmd + +if exist %1 rmdir /S /Q %1 +call %~dp0\unpack_to %1.sleepy %1 > nul +if errorlevel 1 exit /b 1 + +set FOUND=0 +if exist "%~1\minidump.dmp" set FOUND=1 + +if %FOUND% == 0 exit /b 1 diff --git a/scripts/test_symbol.cmd b/scripts/test_symbol.cmd index 7b09dd4..5e3d8d0 100644 --- a/scripts/test_symbol.cmd +++ b/scripts/test_symbol.cmd @@ -2,7 +2,7 @@ if exist %1 rmdir /S /Q %1 call %~dp0\unpack_to %1.sleepy %1 > nul -if errorlevel 1 exit 1 +if errorlevel 1 exit /b 1 set FOUND=0 for /F "tokens=3" %%a in (%1\Symbols.txt) do if "%%~a" == "%~2" set FOUND=1 diff --git a/tests/cmdline/.gitignore b/tests/cmdline/.gitignore new file mode 100644 index 0000000..e028ef4 --- /dev/null +++ b/tests/cmdline/.gitignore @@ -0,0 +1,4 @@ +*.ilk + +# custom script to build (outside of appveyor environment) +build.local.bat diff --git a/tests/cmdline/ReadMe.md b/tests/cmdline/ReadMe.md new file mode 100644 index 0000000..79ec54d --- /dev/null +++ b/tests/cmdline/ReadMe.md @@ -0,0 +1,30 @@ +# Command Line Parameter Testing + +These command line parameters are tested + + * minidump + * samplerate + * symopts + +The tests are not so much tests of functionality related to the parameters, but rather tests that the parameters are correctly honored when specified on the command line. + + + +## Overridable Options + +Some command line parameters will override what is saved in the application config. + +When you specify one of those parameters on the command line, for that instance: the application should not permit you to change the value, nor should it change the value in the saved config. + +These parameters exhibit this behavior + + * `/minidump` + * `/samplerate` + * `/symsearchpath` + * `/symcachedir` + * `/usesymserver` (specify `/usesymserver-` to turn it off) + * `/symserver` + +You can verify the behavior by specifying one or more of the parameters on the command line, then going into Tools / Options, and verify that the corresponding setting shows the override value and cannot be changed. + +You can also verify that the saved config data for that setting does not get updated with the value specified on the command line. diff --git a/tests/cmdline/build.bat b/tests/cmdline/build.bat new file mode 100644 index 0000000..9cab99a --- /dev/null +++ b/tests/cmdline/build.bat @@ -0,0 +1,21 @@ +@setlocal +@echo off +cd /d "%~dp0" +call ..\..\scripts\clear_env.cmd + +rem Build executables for two different architectures. +rem Ensure that the .pdb is _not_ in the same dir as the executable. + +SETLOCAL +call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 +cl /MD /Z7 program.c /Fe:program32.exe /link /DEBUG:FASTLINK +if not exist "%~dp0symdir32" mkdir "%~dp0symdir32" +move /y program32.pdb "%~dp0symdir32" +ENDLOCAL + +SETLOCAL +call "%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x64 +cl /MD /Z7 program.c /Fe:program64.exe /link /DEBUG:FASTLINK +if not exist "%~dp0symdir64" mkdir "%~dp0symdir64" +move /y program64.pdb "%~dp0symdir64" +ENDLOCAL diff --git a/tests/cmdline/program.c b/tests/cmdline/program.c new file mode 100644 index 0000000..f47b28e --- /dev/null +++ b/tests/cmdline/program.c @@ -0,0 +1,13 @@ +int vs_test_fun() +{ + unsigned int i, n = 17; + // This is 4x longer than the other ones because we need more time to gather samples. + for (i=0; i<4000000000u; i++) + n = n * 17 + i; + return n; +} + +int main() +{ + return vs_test_fun(); +} diff --git a/tests/cmdline/program32.exe b/tests/cmdline/program32.exe new file mode 100644 index 0000000..c914612 Binary files /dev/null and b/tests/cmdline/program32.exe differ diff --git a/tests/cmdline/program64.exe b/tests/cmdline/program64.exe new file mode 100644 index 0000000..45f3cf0 Binary files /dev/null and b/tests/cmdline/program64.exe differ diff --git a/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/program32.pdb b/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/program32.pdb new file mode 100644 index 0000000..28cab66 Binary files /dev/null and b/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/program32.pdb differ diff --git a/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/refs.ptr b/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/refs.ptr new file mode 100644 index 0000000..66cde1e --- /dev/null +++ b/tests/cmdline/symcache32/program32.pdb/9100AD1E7D7F41A595C3D1A186DA1D773/refs.ptr @@ -0,0 +1 @@ +0000000001,file,"c:\data\src\work\VerySleepy\verysleepy-mojomojomojo\tests\tests\cmdline\symdir32\program32.pdb",pri,,N,, \ No newline at end of file diff --git a/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/program64.pdb b/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/program64.pdb new file mode 100644 index 0000000..0f9e537 Binary files /dev/null and b/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/program64.pdb differ diff --git a/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/refs.ptr b/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/refs.ptr new file mode 100644 index 0000000..84397d4 --- /dev/null +++ b/tests/cmdline/symcache64/program64.pdb/EAD8BF2DA1C44033B73F323250735FE03/refs.ptr @@ -0,0 +1 @@ +0000000001,file,"c:\data\src\work\VerySleepy\verysleepy-mojomojomojo\tests\tests\cmdline\symdir64\program64.pdb",pri,,N,, \ No newline at end of file diff --git a/tests/cmdline/symdir32/program32.pdb b/tests/cmdline/symdir32/program32.pdb new file mode 100644 index 0000000..28cab66 Binary files /dev/null and b/tests/cmdline/symdir32/program32.pdb differ diff --git a/tests/cmdline/symdir64/program64.pdb b/tests/cmdline/symdir64/program64.pdb new file mode 100644 index 0000000..0f9e537 Binary files /dev/null and b/tests/cmdline/symdir64/program64.pdb differ diff --git a/tests/cmdline/test.bat b/tests/cmdline/test.bat new file mode 100644 index 0000000..55c0f8d --- /dev/null +++ b/tests/cmdline/test.bat @@ -0,0 +1,28 @@ +@echo off +setlocal enabledelayedexpansion +if not exist program32.exe call build +if not exist program64.exe call build + +rem https://github.com/VerySleepy/verysleepy/issues/28 + +rem Verify that command-line options are honored and do not override saved configuration settings. + +set SLEEPY_SILENT_CRASH=1 + +for %%b in (32 64) do ( + echo. + echo ============================================================ + echo Testing %%b + echo. + echo. + + FOR %%o in (minidump samplerate symopts) do ( + rem Discard any saved config options. + call ..\..\scripts\clear_config + + call test_cmdline_%%o.cmd %%b + if !ERRORLEVEL! neq 0 exit /b 1 + ) +) + +echo %~f0: OK diff --git a/tests/cmdline/test_cmdline_minidump.cmd b/tests/cmdline/test_cmdline_minidump.cmd new file mode 100644 index 0000000..7e087c7 --- /dev/null +++ b/tests/cmdline/test_cmdline_minidump.cmd @@ -0,0 +1,66 @@ +@echo off +setlocal enabledelayedexpansion + +set "PGMARCH=%~1" + +set "SCRIPTS_DIR=%~dps0..\..\scripts" + +call %SCRIPTS_DIR%\get_config SaveMinidump START_MINIDUMP_VALUE +IF NOT "!START_MINIDUMP_VALUE!"=="" (IF "START_MINIDUMP_VALUE"=="429496729" (set /a START_MINIDUMP_VALUE=-1) ELSE (set /a START_MINIDUMP_VALUE=START_MINIDUMP_VALUE)) + +rem +rem Test with the behavior turned OFF. +rem + +set TEST_MINIDUMP_VALUE=2 + +if "!START_MINIDUMP_VALUE!"=="!TEST_MINIDUMP_VALUE!" (set /a TEST_MINIDUMP_VALUE=TEST_MINIDUMP_VALUE+1) +@echo Test MiniDump value: !TEST_MINIDUMP_VALUE! + +if exist program-!PGMARCH!.sleepy del program-!PGMARCH!.sleepy +rem Ensure that we profile a matching-architecture executable so that the "mismatch" warning doesn't halt the test. +call %SCRIPTS_DIR%\sleepy!pgmarch! /r:program!pgmarch!.exe /o:program-!pgmarch!.sleepy /minidump:!TEST_MINIDUMP_VALUE! +if !ERRORLEVEL! neq 0 exit /b 1 + +rem Verify the capture has a dump. +call %SCRIPTS_DIR%\test_minidump program-!pgmarch! +if !ERRORLEVEL! neq 0 ( @echo Minidump not taken & exit /b 1 ) else ( @echo Minidump taken ) + +rem Verify that the config value didn't change to what we specified. +rem It will change if it wasn't set, but not to what we specified. +call %SCRIPTS_DIR%\get_config SaveMinidump FINAL_MINIDUMP_VALUE + +if "!FINAL_MINIDUMP_VALUE!"=="!TEST_MINIDUMP_VALUE!" ( + @echo ERROR: SaveMinidump value was changed to the cmdline override value. + exit /b 1 +) + + +rem +rem Test with the behavior turned OFF. +rem + +rem Anything less than 0 means "no minidump" +rem We want to use something different than what's in the saved config (often, -1). +set TEST_MINIDUMP_VALUE=-2 + +if "!START_MINIDUMP_VALUE!"=="!TEST_MINIDUMP_VALUE!" (set /a TEST_MINIDUMP_VALUE=TEST_MINIDUMP_VALUE+1) +@echo Test MiniDump value: !TEST_MINIDUMP_VALUE! + +if exist program-!PGMARCH!.sleepy del program-!PGMARCH!.sleepy +rem Ensure that we profile a matching-architecture executable so that the "mismatch" warning doesn't halt the test. +call %SCRIPTS_DIR%\sleepy!pgmarch! /r:program!pgmarch!.exe /o:program-!pgmarch!.sleepy /minidump:!TEST_MINIDUMP_VALUE! +if !ERRORLEVEL! neq 0 exit /b 1 + +rem Verify the capture does not dave a dump. +call %SCRIPTS_DIR%\test_minidump program-!pgmarch! +if !ERRORLEVEL! neq 1 ( @echo Minidump taken but should not have been & exit /b 1 ) else ( @echo Minidump not taken ) + +rem Verify that the config value didn't change to what we specified. +rem It will change if it wasn't set, but not to what we specified. +call %SCRIPTS_DIR%\get_config SaveMinidump FINAL_MINIDUMP_VALUE + +if "!FINAL_MINIDUMP_VALUE!"=="!TEST_MINIDUMP_VALUE!" ( + @echo ERROR: SaveMinidump value was changed to the cmdline override value. + exit /b 1 +) diff --git a/tests/cmdline/test_cmdline_samplerate.cmd b/tests/cmdline/test_cmdline_samplerate.cmd new file mode 100644 index 0000000..23ea305 --- /dev/null +++ b/tests/cmdline/test_cmdline_samplerate.cmd @@ -0,0 +1,87 @@ +@echo off +setlocal enabledelayedexpansion + +rem Testing Parameter: samplerate (speed throttle) +rem The test for this involves counting the number of samples taken during captures whose durations are identical. +rem Test with a number different sample rates, and verify that the number of samples decreases when the sample rate decreases. +rem Because sample rate is only a fudge-y way of reducing induced load due to sampling, choose +rem values for sample rate that _should_ clearly indicate that the rate was higher. +rem I have also observed that sample rates above 60 or so will not always effect taking more samples. + + +set "PGMARCH=%~1" +set CONFIG_PARAM=SpeedThrottle + +set "SCRIPTS_DIR=%~dps0..\..\scripts" + +set PREVIOUS_SAMPLES= +for /L %%r in (1, 40, 100) DO ( + @echo Testing Sample Rate: %%r + call :TEST_SAMPLE_RATE %%r OBSERVED_SAMPLE_COUNT + if ERRORLEVEL 1 exit /b 1 + @echo Observed samples: !OBSERVED_SAMPLE_COUNT! + if not "!PREVIOUS_SAMPLES!"=="" ( + if !PREVIOUS_SAMPLES! gtr !OBSERVED_SAMPLE_COUNT! ( + @echo ERROR: Sample count did not decrease as the sample rate increased. + exit /b 1 + ) + ) + set /a PREVIOUS_SAMPLES = OBSERVED_SAMPLE_COUNT +) + +exit /b + + + + +:TEST_SAMPLE_RATE +setlocal enabledelayedexpansion + +rem Set the parameter to a different value than what's being tested with. +rem Perform the profiling capture. +rem Expand the archive. +rem Get the number of samples taken from Stats.txt. +rem Assign that value to the passed-in environment variable name. + +SET "TEST_SAMPLERATE_VALUE=%~1" +SET "OUTPUT_VAR=%~2" + + +set /a START_SAMPLERATE_VALUE=101-!TEST_SAMPLERATE_VALUE! +call %SCRIPTS_DIR%\set_config_dword "!CONFIG_PARAM!" !START_SAMPLERATE_VALUE! +call %SCRIPTS_DIR%\get_config "!CONFIG_PARAM!" CHECK_START_SAMPLERATE_VALUE +if not "!CHECK_START_SAMPLERATE_VALUE!"=="!START_SAMPLERATE_VALUE!" ( + @echo PRECONDITION ERROR: failed to set the saved config value for !CONFIG_PARAM! + exit /b 1 +) + +@echo Test SampleRate value: !TEST_SAMPLERATE_VALUE! + +if exist "program-!PGMARCH!.sleepy" del "program-!PGMARCH!.sleepy" +if exist "program-!PGMARCH!" rmdir /s /q "program-!PGMARCH!" + +call %SCRIPTS_DIR%\sleepy!pgmarch! /r:program!pgmarch!.exe /o:program-!pgmarch!.sleepy /samplerate:!TEST_SAMPLERATE_VALUE! +if !ERRORLEVEL! neq 0 ( + @echo ERROR: Very Sleepy reports failure: !ERRORLEVEL! + exit /b 1 +) + +rem Get the number of samples. +call %SCRIPTS_DIR%\get_stat "program-!pgmarch!" Samples OBSERVED_SAMPLES +if !ERRORLEVEL! neq 0 exit /b 1 +if "!OBSERVED_SAMPLES!"=="" ( + @echo Unable to find sample count in profile stats. + exit /b 1 +) + +rem Verify that the config value didn't change to what we specified. +rem It will change if it wasn't set, but not to what we specified. +call %SCRIPTS_DIR%\get_config "!CONFIG_PARAM!" FINAL_SAMPLERATE_VALUE + +IF "!FINAL_SAMPLERATE_VALUE!"=="!TEST_SAMPLERATE_VALUE!" ( + @echo ERROR: !CONFIG_PARAM! value was changed to the cmdline override value. + exit /b 1 +) + +endlocal & set /a %OUTPUT_VAR% = %OBSERVED_SAMPLES% +exit /b diff --git a/tests/cmdline/test_cmdline_symopts.cmd b/tests/cmdline/test_cmdline_symopts.cmd new file mode 100644 index 0000000..f75f635 --- /dev/null +++ b/tests/cmdline/test_cmdline_symopts.cmd @@ -0,0 +1,153 @@ +@echo off +setlocal enabledelayedexpansion + + +rem Testing Parameter Behavior: `symsearchpath` +rem To test for this, we will profile a run of program!ARCH!.exe and verify that the expected symbol was/wasn't found. +rem 1. Run without any search path. Ensure that the target symbol is NOT found. (verify search path is meaningful) +rem 2. Run with a search path. Ensure that the target symbol IS found. (verify search path) +rem 3. Run with an empty symbol cache. Ensure that the target symbol is NOT found. (verify cache is meaningful) +rem 4. Run with a search path and a symbol cache. Ensure that the symbol IS found. (build search cache) +rem 5. Run WITHOUT a search path and WITH a symbol cache. Ensure that the symbol IS found. (search cache only) +rem Testing Parameter Ephemerality +rem 6. Run with a search path that doesn't contain the symbols. The saved search path does contain them. +rem 6. Run with a cache that doesn't contain the symbols. The saved search path does contain them. + +set "PGMARCH=%~1" +set CONFIG_SYMPATH=SymbolSearchPath +set CONFIG_SYMCACHE=SymbolCache + +set "SCRIPTS_DIR=%~dps0..\..\scripts" + +set "EMPTY_SYMDIR=%~dp0empty_symdir" +set "EMPTY_SYMCACHE=%~dp0empty_symcache" + +set "SYMDIR=%~dp0symdir!PGMARCH!" +set "SYMCACHE=%~dp0symcache!PGMARCH!" + + +:SCENARIO_1 +rem 1. run without any options: not found +@echo. +@echo scenario 1: symbol not found +call %SCRIPTS_DIR%\clear_config +call :RUN_PROFILER "" +if !SYMBOL_FOUND! neq 0 (@echo ERROR: failed scenario 1) & exit /b 1 + +:SCENARIO_2 +rem 2. run with search path: found +@echo. +@echo scenario 2: symbol found +call %SCRIPTS_DIR%\clear_config +call :RUN_PROFILER "/symsearchpath:!SYMDIR!" +if !SYMBOL_FOUND! neq 1 (@echo ERROR: failed scenario 2) & exit /b 1 + +:SCENARIO_3 +rem 3. Run with an empty symbol cache: not found +@echo. +@echo scenario 3: symbol not found +call %SCRIPTS_DIR%\clear_config +call :CLEAR_DIR "!EMPTY_SYMCACHE!" +call :RUN_PROFILER "/symcachedir:!EMPTY_SYMCACHE!" +if !SYMBOL_FOUND! neq 0 (@echo ERROR: failed scenario 3) & exit /b 1 + +:SCENARIO_4 +rem 4. run with a search path and a symbol cache: found +@echo. +@echo scenario 4: symbol found +call %SCRIPTS_DIR%\clear_config +call :RUN_PROFILER "/symsearchpath:!SYMDIR! /symcachedir:!SYMCACHE!" +if !SYMBOL_FOUND! neq 1 (@echo ERROR: failed scenario 4) & exit /b 1 + +:SCENARIO_5 +rem 5. run WITHOUT a search path and WITH a symbol cache: found +@echo. +@echo scenario 5: symbol found +call %SCRIPTS_DIR%\clear_config +call :RUN_PROFILER "/symcachedir:!SYMCACHE!" +if !SYMBOL_FOUND! neq 1 (@echo ERROR: failed scenario 5) & exit /b 1 + + +rem 6. run with a search path that doesn't contain the symbols, overriding one that contain them: not found +rem Test the config value. +:SCENARIO_6a +@echo. +@echo scenario 6a: symbol found +call %SCRIPTS_DIR%\clear_config +call %SCRIPTS_DIR%\set_config %CONFIG_SYMPATH% "!SYMDIR!" +call :RUN_PROFILER +if !SYMBOL_FOUND! neq 1 (@echo ERROR: failed scenario 6a) & exit /b 1 +:SCENARIO_6b +rem Test the override +@echo. +@echo scenario 6b: symbol not found +call :CLEAR_DIR "!EMPTY_SYMDIR!" +call %SCRIPTS_DIR%\get_config %CONFIG_SYMPATH% PRE_RUN_SYMPATH +call :RUN_PROFILER "/symsearchpath:!EMPTY_SYMDIR!" +call %SCRIPTS_DIR%\get_config %CONFIG_SYMPATH% POST_RUN_SYMPATH +if !SYMBOL_FOUND! neq 0 (@echo ERROR: failed scenario 6b) & exit /b 1 +if not "!PRE_RUN_SYMPATH!"=="!POST_RUN_SYMPATH!" ( + @echo ERROR: symbol path value was incorrectly changed to the cmdline override value. + exit /b 1 +) + + +rem 7. run with a cache that doesn't contain the symbols, overriding one that contain them: not found +rem Test the config value. +:SCENARIO_7a +@echo. +@echo scenario 7a: symbol found +call %SCRIPTS_DIR%\clear_config +call %SCRIPTS_DIR%\set_config %CONFIG_SYMCACHE% "!SYMCACHE!" +call :RUN_PROFILER +if !SYMBOL_FOUND! neq 1 (@echo ERROR: failed scenario 7a) & exit /b 1 +rem Test the override +:SCENARIO_7b +@echo. +@echo scenario 7b: symbol not found +call :CLEAR_DIR "!EMPTY_SYMCACHE!" +call %SCRIPTS_DIR%\get_config %CONFIG_SYMCACHE% PRE_RUN_SYMCACHE +call :RUN_PROFILER "/symcachedir:!EMPTY_SYMCACHE!" +call %SCRIPTS_DIR%\get_config %CONFIG_SYMCACHE% POST_RUN_SYMCACHE +if !SYMBOL_FOUND! neq 0 (@echo ERROR: failed scenario 7b) & exit /b 1 +if not "!PRE_RUN_SYMCACHE!"=="!POST_RUN_SYMCACHE!" ( + @echo ERROR: symbol cache was incorrectly changed to the cmdline override value. + exit /b 1 +) + + + +exit /b + +:SAVE_CONFIG +call %SCRIPTS_DIR%\get_config CONFIG_SYMPATH PRE_RUN_SYMPATH +call %SCRIPTS_DIR%\get_config CONFIG_SYMCACHE PRE_RUN_SYMCACHE + + + +:CLEAR_DIR +if exist "%~1" rmdir /s /q "%~1" +mkdir "%~1" +exit /B + + + +:RUN_PROFILER +SET SYMBOL_FOUND= +setlocal enabledelayedexpansion + +rem Callers should ensure that this parameter does not have/need embedded quotes. They will be lost. +set "ADDL_ARGS=%~1" + +if exist program-!PGMARCH!.sleepy del program-!PGMARCH!.sleepy +rem Ensure that we profile a matching-architecture executable so that the "mismatch" warning doesn't halt the test. +call %SCRIPTS_DIR%\sleepy!pgmarch! /r:program!pgmarch!.exe /o:program-!pgmarch!.sleepy !ADDL_ARGS! +if !ERRORLEVEL! neq 0 exit /b 1 + +rem Check for the target symbol. +call %SCRIPTS_DIR%\test_symbol program-!pgmarch! vs_test_fun +set /a IS_SYMBOL_FOUND = 1 - !ERRORLEVEL! +@echo Found Symbol: !IS_SYMBOL_FOUND! + +endlocal & set SYMBOL_FOUND=%IS_SYMBOL_FOUND% +exit /b diff --git a/tests/dmd-32mscoff/test.bat b/tests/dmd-32mscoff/test.bat index 95b2d4d..2b68620 100644 --- a/tests/dmd-32mscoff/test.bat +++ b/tests/dmd-32mscoff/test.bat @@ -6,6 +6,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (32 64) do ( echo Testing %%b + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b.sleepy del program-%%b.sleepy call ..\..\scripts\sleepy%%b /r:program.exe /o:program-%%b.sleepy if !ERRORLEVEL! neq 0 exit /b 1 diff --git a/tests/dmd-64/test.bat b/tests/dmd-64/test.bat index 43f379d..16dace7 100644 --- a/tests/dmd-64/test.bat +++ b/tests/dmd-64/test.bat @@ -6,6 +6,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (64) do ( echo Testing %%b + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b.sleepy del program-%%b.sleepy call ..\..\scripts\sleepy%%b /r:program.exe /o:program-%%b.sleepy if !ERRORLEVEL! neq 0 exit /b 1 diff --git a/tests/gcc43-wine/test.bat b/tests/gcc43-wine/test.bat index 74c673f..ecaa201 100644 --- a/tests/gcc43-wine/test.bat +++ b/tests/gcc43-wine/test.bat @@ -9,6 +9,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (32 64) do for %%d in (wine mingw) do ( echo Testing %%b-%%d + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b-%%d.sleepy del program-%%b-%%d.sleepy call ..\..\scripts\sleepy%%b --%%d /r:program.exe /o:program-%%b-%%d.sleepy if !ERRORLEVEL! neq 0 exit /b 1 diff --git a/tests/gcc49-32/test.bat b/tests/gcc49-32/test.bat index b75b9a4..80300cf 100644 --- a/tests/gcc49-32/test.bat +++ b/tests/gcc49-32/test.bat @@ -10,6 +10,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (32 64) do for %%d in (mingw) do ( echo Testing %%b-%%d + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b-%%d.sleepy del program-%%b-%%d.sleepy call ..\..\scripts\sleepy%%b --%%d /r:program.exe /o:program-%%b-%%d.sleepy if !ERRORLEVEL! neq 0 exit /b 1 diff --git a/tests/gcc49-64/test.bat b/tests/gcc49-64/test.bat index 7d9517b..ce08891 100644 --- a/tests/gcc49-64/test.bat +++ b/tests/gcc49-64/test.bat @@ -10,6 +10,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (64) do for %%d in (mingw) do ( echo Testing %%b-%%d + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b-%%d.sleepy del program-%%b-%%d.sleepy call ..\..\scripts\sleepy%%b --%%d /r:program.exe /o:program-%%b-%%d.sleepy if !ERRORLEVEL! neq 0 exit /b 1 diff --git a/tests/msvc14/test.bat b/tests/msvc14/test.bat index 7239b59..a5c0b2e 100644 --- a/tests/msvc14/test.bat +++ b/tests/msvc14/test.bat @@ -8,6 +8,10 @@ set SLEEPY_SILENT_CRASH=1 for %%b in (32 64) do ( echo Testing %%b + + rem Discard any saved config options. + call ..\..\scripts\clear_config + if exist program-%%b.sleepy del program-%%b.sleepy call ..\..\scripts\sleepy%%b /r:program.exe /o:program-%%b.sleepy if !ERRORLEVEL! neq 0 exit /b 1