Skip to content

Commit 5804353

Browse files
authored
Support bug64159.phpt on Windows CI (phpGH-15895)
This test queries `extOutput` for the first line of output of the command which was executed when snmpd started (`HexTest` in snmpd.conf). Since there is no `/bin/sh` on Windows, no command would be run, and as such we received an empty string. We fix that by dynamically adjusting snmpd.conf to run a JScript which has the same output as bigtest. We also make the test diff more helpful in case of failures, where so far we only would have known that the output had a different message digest.
1 parent 64d959e commit 5804353

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

.github/scripts/windows/test_task.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ popd
103103

104104
rem prepare for snmp
105105
set MIBDIRS=%DEPS_DIR%\share\mibs
106+
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
106107
start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln
107108

108109
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release

ext/snmp/tests/bigtest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
for (var i = 0; i < 32; i++) {
2+
WScript.StdOut.Write("\x03\x02\x04\x09\x12\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17");
3+
}

ext/snmp/tests/bug64159.phpt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ snmp
77
--SKIPIF--
88
<?php
99
require_once(__DIR__.'/skipif.inc');
10-
if (PHP_OS_FAMILY === "Windows") die("xfail fails on Windows for unknown reasons");
1110
?>
1211
--ENV--
1312
MIBS=noneXistent
@@ -18,10 +17,15 @@ require_once(__DIR__.'/snmp_include.inc');
1817
snmp_set_quick_print(false);
1918
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
2019

21-
var_dump(("ab8283f948419b2d24d22f44a80b17d3" === md5(snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.1'))));
22-
20+
$ext_output = snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.1');
21+
$md5 = md5($ext_output);
22+
if ($md5 === "ab8283f948419b2d24d22f44a80b17d3") {
23+
echo "okay\n";
24+
} else {
25+
echo $ext_output;
26+
}
2327
?>
2428
--EXPECTF--
2529
MIB search path: %s
2630
Cannot find module (noneXistent): At line %d in (%s)
27-
bool(true)
31+
okay

0 commit comments

Comments
 (0)