| 1 | @setlocal EnableDelayedExpansion |
| 2 | @echo off |
| 3 | |
| 4 | REM We look to see if there's a debugger available in the injected sandbox folder |
| 5 | REM from the host. If there is, we'll show it as a launch option (later) for the |
| 6 | REM user. |
| 7 | REM If we do offer the debugger, we better show the IP address too, since it seems |
| 8 | REM to change for each invocation of the Sandbox environment |
| 9 | for /f "tokens=2 delims=[]" %%a in ('ping -n 1 -4 ""') do set IPAddr=%%a |
| 10 | @if %PROCESSOR_ARCHITECTURE%=="ARM64" ( |
| 11 | @if exist C:\sandbox\assets\Debugger\ARM64\msvsmon.exe ( |
| 12 | set "MsVsMonPath=C:\sandbox\assets\Debugger\ARM64\msvsmon.exe /noauth /anyuser /nosecuritywarn" |
| 13 | ) |
| 14 | ) else ( |
| 15 | @if exist C:\sandbox\assets\Debugger\x64\msvsmon.exe ( |
| 16 | set "MsVsMonPath=C:\sandbox\assets\Debugger\x64\msvsmon.exe /noauth /anyuser /nosecuritywarn" |
| 17 | ) |
| 18 | ) |
| 19 | FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -Command "[System.Net.Dns]::GetHostEntry('localhost').HostName"`) DO ( |
| 20 | SET "Hostname=%%F" |
| 21 | ) |
| 22 | |
| 23 | :TestSelect |
| 24 | cls |
| 25 | REM Show the test select menu |
| 26 | |
| 27 | REM We start with an entry for the Debugger if available |
| 28 | set index=0 |
| 29 | if not "%MsVsMonPath%"=="" ( |
| 30 | echo [!index!] Run Remote Debugger [IP=%IPAddr%] [Hostname=%Hostname%] |
| 31 | set "option[!index!]=%MsVsMonPath%" |
| 32 | ) |
| 33 | |
| 34 | REM And then for each 'runtests.cmd' file we find |
| 35 | for /f %%i in ('where /R C:\build runtests.cmd') do ( |
| 36 | set /A "index+=1" |
| 37 | echo [!index!] %%i |
| 38 | set "option[!index!]=%%i!" |
| 39 | ) |
| 40 | |
| 41 | REM and finally an option to quit the menu |
| 42 | echo [q] Quit |
| 43 | |
| 44 | set /P "SelectTest=Please Choose The Test You Want To Execute: " |
| 45 | if "%SelectTest%"=="q" Goto End |
| 46 | if defined option[%SelectTest%] Goto TestSet |
| 47 | |
| 48 | :TestError |
| 49 | cls |
| 50 | Echo ERROR: Invalid Test Selected!! |
| 51 | pause |
| 52 | goto TestSelect |
| 53 | |
| 54 | :TestSet |
| 55 | set "TestIs=!option[%SelectTest%]!" |
| 56 | if not "%SelectTest%"=="0" ( |
| 57 | REM for the non-Debugger options, we want to get the basepath |
| 58 | REM the file name, and a TestName component.. |
| 59 | for %%a in (%TestIs%) do set "FileDir=%%~dpa" |
| 60 | for %%b in (%TestIs%) do set "FileName=%%~nxb" |
| 61 | |
| 62 | REM since we start from C:\build, the 3rd token in '\' is |
| 63 | REM the 'IntegrationMsi' naming that looks good for a TestName |
| 64 | for /f "tokens=3 delims=\" %%c in ("%TestIs%") do ( |
| 65 | set "TestName=%%c" |
| 66 | ) |
| 67 | |
| 68 | REM We just start these as a separate window |
| 69 | REM and use cmd.exe /K to keep it around after execution has finished |
| 70 | start "!TestName!" /D "!FileDir!" cmd.exe /K !FileName! |
| 71 | ) else ( |
| 72 | start !TestIs! |
| 73 | ) |
| 74 | goto TestSelect |
| 75 | |
| 76 | :End |
| 77 | @endlocal |