aboutsummaryrefslogtreecommitdiff
path: root/src/test/sandbox/runtest_menu.bat
blob: e6b64365021ac8bfbd0592574fd30e46182ecb1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
@setlocal EnableDelayedExpansion
@echo off

REM We look to see if there's a debugger available in the injected sandbox folder
REM from the host.  If there is, we'll show it as a launch option (later) for the
REM user.
REM If we do offer the debugger, we better show the IP address too, since it seems
REM to change for each invocation of the Sandbox environment
for /f "tokens=2 delims=[]" %%a in ('ping -n 1 -4 ""') do set IPAddr=%%a
@if %PROCESSOR_ARCHITECTURE%=="ARM64" (
	@if exist C:\sandbox\assets\Debugger\ARM64\msvsmon.exe (
		set "MsVsMonPath=C:\sandbox\assets\Debugger\ARM64\msvsmon.exe /noauth /anyuser /nosecuritywarn"
	)
) else (
	@if exist C:\sandbox\assets\Debugger\x64\msvsmon.exe (
		set "MsVsMonPath=C:\sandbox\assets\Debugger\x64\msvsmon.exe /noauth /anyuser /nosecuritywarn"
	)
)
FOR /F "tokens=* USEBACKQ" %%F IN (`powershell -Command "[System.Net.Dns]::GetHostEntry('localhost').HostName"`) DO (
SET "Hostname=%%F"
)

:TestSelect
cls
REM Show the test select menu

REM We start with an entry for the Debugger if available
set index=0
if not "%MsVsMonPath%"=="" (
	echo [!index!] Run Remote Debugger [IP=%IPAddr%] [Hostname=%Hostname%]
	set "option[!index!]=%MsVsMonPath%"
)

REM And then for each 'runtests.cmd' file we find
for /f %%i in ('where /R C:\build runtests.cmd') do (
  set /A "index+=1"
  echo [!index!] %%i
  set "option[!index!]=%%i!"
)

REM and finally an option to quit the menu
echo [q] Quit

set /P "SelectTest=Please Choose The Test You Want To Execute: "
if "%SelectTest%"=="q" Goto End
if defined option[%SelectTest%] Goto TestSet

:TestError
cls
Echo ERROR: Invalid Test Selected!!
pause
goto TestSelect

:TestSet
set "TestIs=!option[%SelectTest%]!"
if not "%SelectTest%"=="0" (
	REM for the non-Debugger options, we want to get the basepath
	REM the file name, and a TestName component..
	for %%a in (%TestIs%) do set "FileDir=%%~dpa"
	for %%b in (%TestIs%) do set "FileName=%%~nxb"

	REM since we start from C:\build, the 3rd token in '\' is
	REM the 'IntegrationMsi' naming that looks good for a TestName
	for /f "tokens=3 delims=\" %%c in ("%TestIs%") do (
		set "TestName=%%c"
	)

	REM We just start these as a separate window
	REM and use cmd.exe /K to keep it around after execution has finished
	start "!TestName!" /D "!FileDir!" cmd.exe /K !FileName!
) else (
	start !TestIs!
)
goto TestSelect

:End
@endlocal