Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 additions & 0 deletions .github/scripts/windows/check-snmp-ready.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
@echo off
setlocal

set "PHP_BUILD_DIR=%~1"
if "%PHP_BUILD_DIR%"=="" (
echo Usage: %~nx0 PHP_BUILD_DIR
exit /b 1
)

set "PHP_EXE=%PHP_BUILD_DIR%\php.exe"
set "PHP_SNMP_DLL=%PHP_BUILD_DIR%\php_snmp.dll"
set "PHP_CODE=snmp_set_valueretrieval(SNMP_VALUE_PLAIN); $oid='.1.3.6.1.2.1.1.1.0'; if (@snmpget('127.0.0.1', 'public', $oid, 1000000, 0) === false) exit(1); if (@snmp3_get('127.0.0.1', 'adminMD5AES', 'authPriv', 'MD5', 'test1234', 'AES', 'test1234', $oid, 1000000, 0) === false) exit(1);"

if not exist "%PHP_EXE%" (
echo Could not find "%PHP_EXE%"
exit /b 1
)

if not exist "%PHP_SNMP_DLL%" (
echo Could not find "%PHP_SNMP_DLL%"
exit /b 1
)

for /l %%i in (1,1,30) do (
call :probe
if not errorlevel 1 goto ready
tasklist /fi "IMAGENAME eq snmpd.exe" | findstr /i "snmpd.exe" >nul
if errorlevel 1 (
echo snmpd exited before the readiness check succeeded
goto fail
)
timeout /t 1 /nobreak >nul
)

echo snmpd did not become ready within 30 seconds
goto fail

:ready
exit /b 0

:fail
exit /b 1

:probe
"%PHP_EXE%" -n -dextension_dir=%PHP_BUILD_DIR% -dextension=php_snmp.dll -r "%PHP_CODE%" >nul 2>&1
exit /b %errorlevel%
7 changes: 6 additions & 1 deletion .github/scripts/windows/test_task.bat
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ popd
rem prepare for snmp
set MIBDIRS=%DEPS_DIR%\share\mibs
sed -i "s/exec HexTest .*/exec HexTest cscript\.exe \/nologo %GITHUB_WORKSPACE:\=\/%\/ext\/snmp\/tests\/bigtest\.js/g" %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf
start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln
start "" /b "%DEPS_DIR%\bin\snmpd.exe" -C -c "%GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf" -Ln
if %errorlevel% neq 0 exit /b 3

set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release
if "%THREAD_SAFE%" equ "1" set PHP_BUILD_DIR=%PHP_BUILD_DIR%_TS
Expand Down Expand Up @@ -147,6 +148,10 @@ copy /-y %DEPS_DIR%\bin\*.dll %PHP_BUILD_DIR%\*

if "%ASAN%" equ "1" set ASAN_OPTS=--asan

rem wait until snmpd is fully ready to serve v2c and v3/authPriv requests
.github\scripts\windows\check-snmp-ready.bat %PHP_BUILD_DIR%
if %errorlevel% neq 0 exit /b 3

mkdir c:\tests_tmp

nmake test TESTS="%OPCACHE_OPTS% -g FAIL,BORK,LEAK,XLEAK %ASAN_OPTS% --no-progress -q --offline --show-diff --show-slow 1000 --set-timeout 120 --temp-source c:\tests_tmp --temp-target c:\tests_tmp %PARALLEL%"
Expand Down