Skip to content

Commit f739e9d

Browse files
committed
initial
1 parent 1462499 commit f739e9d

2 files changed

Lines changed: 52 additions & 1 deletion

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
param(
2+
[Parameter(Mandatory = $true)]
3+
[string]$PhpBuildDir
4+
)
5+
6+
$php = Join-Path $PhpBuildDir 'php.exe'
7+
$snmpExtension = Join-Path $PhpBuildDir 'php_snmp.dll'
8+
9+
if (-not (Test-Path $php)) {
10+
Write-Error "Could not find $php"
11+
exit 1
12+
}
13+
14+
if (-not (Test-Path $snmpExtension)) {
15+
Write-Error "Could not find $snmpExtension"
16+
exit 1
17+
}
18+
19+
$phpCode = @'
20+
snmp_set_valueretrieval(SNMP_VALUE_PLAIN);
21+
$oid = '.1.3.6.1.2.1.1.1.0';
22+
if (@snmpget('127.0.0.1', 'public', $oid, 1000000, 0) === false) {
23+
exit(1);
24+
}
25+
if (@snmp3_get('127.0.0.1', 'adminMD5AES', 'authPriv', 'MD5', 'test1234', 'AES', 'test1234', $oid, 1000000, 0) === false) {
26+
exit(1);
27+
}
28+
'@
29+
30+
for ($i = 0; $i -lt 30; $i++) {
31+
& $php -n "-dextension_dir=$PhpBuildDir" -dextension=php_snmp.dll -r $phpCode *> $null
32+
if ($LASTEXITCODE -eq 0) {
33+
exit 0
34+
}
35+
36+
if (-not (Get-Process -Name snmpd -ErrorAction SilentlyContinue)) {
37+
Write-Output 'snmpd exited before the readiness check succeeded'
38+
exit 1
39+
}
40+
41+
Start-Sleep -Seconds 1
42+
}
43+
44+
Write-Output 'snmpd did not become ready within 30 seconds'
45+
46+
exit 1

.github/scripts/windows/test_task.bat

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ popd
109109
rem prepare for snmp
110110
set MIBDIRS=%DEPS_DIR%\share\mibs
111111
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
112-
start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln
112+
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'"
113+
if %errorlevel% neq 0 exit /b 3
113114

114115
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release
115116
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%\*
147148

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

151+
rem wait until snmpd is fully ready to serve v2c and v3/authPriv requests
152+
powershell -NoProfile -File .github\scripts\windows\check-snmp-ready.ps1 -PhpBuildDir %PHP_BUILD_DIR%
153+
if %errorlevel% neq 0 exit /b 3
154+
150155
mkdir c:\tests_tmp
151156

152157
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%"

0 commit comments

Comments
 (0)