From f739e9d3c1ee0c8b9693550f5a0cde078ffab3ce Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Fri, 1 May 2026 16:35:02 +0800 Subject: [PATCH 1/2] initial --- .github/scripts/windows/check-snmp-ready.ps1 | 46 ++++++++++++++++++++ .github/scripts/windows/test_task.bat | 7 ++- 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/scripts/windows/check-snmp-ready.ps1 diff --git a/.github/scripts/windows/check-snmp-ready.ps1 b/.github/scripts/windows/check-snmp-ready.ps1 new file mode 100644 index 000000000000..d19ea71369a9 --- /dev/null +++ b/.github/scripts/windows/check-snmp-ready.ps1 @@ -0,0 +1,46 @@ +param( + [Parameter(Mandatory = $true)] + [string]$PhpBuildDir +) + +$php = Join-Path $PhpBuildDir 'php.exe' +$snmpExtension = Join-Path $PhpBuildDir 'php_snmp.dll' + +if (-not (Test-Path $php)) { + Write-Error "Could not find $php" + exit 1 +} + +if (-not (Test-Path $snmpExtension)) { + Write-Error "Could not find $snmpExtension" + exit 1 +} + +$phpCode = @' +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); +} +'@ + +for ($i = 0; $i -lt 30; $i++) { + & $php -n "-dextension_dir=$PhpBuildDir" -dextension=php_snmp.dll -r $phpCode *> $null + if ($LASTEXITCODE -eq 0) { + exit 0 + } + + if (-not (Get-Process -Name snmpd -ErrorAction SilentlyContinue)) { + Write-Output 'snmpd exited before the readiness check succeeded' + exit 1 + } + + Start-Sleep -Seconds 1 +} + +Write-Output 'snmpd did not become ready within 30 seconds' + +exit 1 diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 4ce2bd96ce66..79e2172f3f2a 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -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 +powershell -NoProfile -Command "Start-Process -FilePath (Join-Path $env:DEPS_DIR 'bin\snmpd.exe') -ArgumentList '-C','-c',(Join-Path $env: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 @@ -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 +powershell -NoProfile -File .github\scripts\windows\check-snmp-ready.ps1 -PhpBuildDir %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%" From 7265f577030919bd7ab0063a04e8bdd6af695634 Mon Sep 17 00:00:00 2001 From: lamentxu <1372449351@qq.com> Date: Fri, 1 May 2026 16:53:02 +0800 Subject: [PATCH 2/2] use bat instead of ps1 --- .github/scripts/windows/check-snmp-ready.bat | 46 ++++++++++++++++++++ .github/scripts/windows/check-snmp-ready.ps1 | 46 -------------------- .github/scripts/windows/test_task.bat | 4 +- 3 files changed, 48 insertions(+), 48 deletions(-) create mode 100644 .github/scripts/windows/check-snmp-ready.bat delete mode 100644 .github/scripts/windows/check-snmp-ready.ps1 diff --git a/.github/scripts/windows/check-snmp-ready.bat b/.github/scripts/windows/check-snmp-ready.bat new file mode 100644 index 000000000000..ce2082d9edb0 --- /dev/null +++ b/.github/scripts/windows/check-snmp-ready.bat @@ -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% diff --git a/.github/scripts/windows/check-snmp-ready.ps1 b/.github/scripts/windows/check-snmp-ready.ps1 deleted file mode 100644 index d19ea71369a9..000000000000 --- a/.github/scripts/windows/check-snmp-ready.ps1 +++ /dev/null @@ -1,46 +0,0 @@ -param( - [Parameter(Mandatory = $true)] - [string]$PhpBuildDir -) - -$php = Join-Path $PhpBuildDir 'php.exe' -$snmpExtension = Join-Path $PhpBuildDir 'php_snmp.dll' - -if (-not (Test-Path $php)) { - Write-Error "Could not find $php" - exit 1 -} - -if (-not (Test-Path $snmpExtension)) { - Write-Error "Could not find $snmpExtension" - exit 1 -} - -$phpCode = @' -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); -} -'@ - -for ($i = 0; $i -lt 30; $i++) { - & $php -n "-dextension_dir=$PhpBuildDir" -dextension=php_snmp.dll -r $phpCode *> $null - if ($LASTEXITCODE -eq 0) { - exit 0 - } - - if (-not (Get-Process -Name snmpd -ErrorAction SilentlyContinue)) { - Write-Output 'snmpd exited before the readiness check succeeded' - exit 1 - } - - Start-Sleep -Seconds 1 -} - -Write-Output 'snmpd did not become ready within 30 seconds' - -exit 1 diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 79e2172f3f2a..d9a9d13a8b9f 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -109,7 +109,7 @@ 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 -powershell -NoProfile -Command "Start-Process -FilePath (Join-Path $env:DEPS_DIR 'bin\snmpd.exe') -ArgumentList '-C','-c',(Join-Path $env: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 @@ -149,7 +149,7 @@ 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 -powershell -NoProfile -File .github\scripts\windows\check-snmp-ready.ps1 -PhpBuildDir %PHP_BUILD_DIR% +.github\scripts\windows\check-snmp-ready.bat %PHP_BUILD_DIR% if %errorlevel% neq 0 exit /b 3 mkdir c:\tests_tmp