Support bug64159.phpt on Windows CI (GH-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.
This commit is contained in:
Christoph M. Becker 2024-09-21 16:03:25 +02:00 committed by GitHub
parent 64d959e266
commit 580435354e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -103,6 +103,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
start %DEPS_DIR%\bin\snmpd.exe -C -c %GITHUB_WORKSPACE%\ext\snmp\tests\snmpd.conf -Ln
set PHP_BUILD_DIR=%PHP_BUILD_OBJ_DIR%\Release

View File

@ -0,0 +1,3 @@
for (var i = 0; i < 32; i++) {
WScript.StdOut.Write("\x03\x02\x04\x09\x12\x0B\x0C\x0D\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17");
}

View File

@ -7,7 +7,6 @@ snmp
--SKIPIF--
<?php
require_once(__DIR__.'/skipif.inc');
if (PHP_OS_FAMILY === "Windows") die("xfail fails on Windows for unknown reasons");
?>
--ENV--
MIBS=noneXistent
@ -18,10 +17,15 @@ require_once(__DIR__.'/snmp_include.inc');
snmp_set_quick_print(false);
snmp_set_valueretrieval(SNMP_VALUE_LIBRARY);
var_dump(("ab8283f948419b2d24d22f44a80b17d3" === md5(snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.1'))));
$ext_output = snmpget($hostname, $community, '.1.3.6.1.4.1.2021.8.1.101.1');
$md5 = md5($ext_output);
if ($md5 === "ab8283f948419b2d24d22f44a80b17d3") {
echo "okay\n";
} else {
echo $ext_output;
}
?>
--EXPECTF--
MIB search path: %s
Cannot find module (noneXistent): At line %d in (%s)
bool(true)
okay