@echo off
REM * Copyright 2012, 2013 Broadcom Corporation -- http://www.broadcom.com
REM * This program is the proprietary software of Broadcom Corporation and/or
REM * its licensors, and may only be used, duplicated, modified or distributed
REM * pursuant to the terms and conditions of a separate, written license
REM * agreement executed between you and Broadcom (an "Authorized License").
REM * Except as set forth in an Authorized License, Broadcom grants no license
REM * (express or implied), right to use, or waiver of any kind with respect to
REM * the Software, and Broadcom expressly reserves all rights in and to the
REM * Software and all intellectual property rights therein. IF YOU HAVE NO
REM * AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE IN ANY
REM * WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE ALL USE OF
REM * THE SOFTWARE.

setlocal EnableDelayedExpansion

if not exist %~dp0..\..\Tools\SensorDiagnosticTool.exe goto MUST_HAVE_SDT

echo Validate repeatedly client can open/close
echo Ensure traceview is setup to capture into a log file
pause

set n=0

:AGAIN

set /a x=%random% %% 4
if %x%==0 set /a x=3
echo Repetition %n%, client count %x%, %date% %time%

for /l %%i in (1,1,%x%) do (
    REM echo.    Starting client %%i !time!
    start %~dp0..\..\Tools\SensorDiagnosticTool.exe
    set /a t=!random! %% 3
    ping 1.1.1.1 -n !t! -w 1000 > nul.txt
)

REM Wait for tools to execute for some number of seconds
ping 1.1.1.1 -n 3 -w 1000 > nul

REM Kill the tools
taskkill /f /im SensorDiagnosticTool.exe > nul
ping 1.1.1.1 -n 3 -w 1000 > nul
	
set /a n=%n% + 1

REM 24 hours for roughly 20 seconds each repetition: 24 * 60 * 60 / 20 = 4320
if %n% LSS 4320 goto AGAIN
goto FINISH

:MUST_HAVE_SDT
echo ================================= Error ==================================
echo Must have %~dp0..\..\Tools\SensorDiagnosticTool.exe
echo Get from http://msdn.microsoft.com/en-us/library/windows/hardware/ff547083(v=vs.85).aspx#tech_sensors
goto FINISH

:FINISH
endlocal
pause
