From 580435354eab63a2231cc03c24c26f211d440e3b Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sat, 21 Sep 2024 16:03:25 +0200 Subject: [PATCH] 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. --- .github/scripts/windows/test_task.bat | 1 + ext/snmp/tests/bigtest.js | 3 +++ ext/snmp/tests/bug64159.phpt | 12 ++++++++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 ext/snmp/tests/bigtest.js diff --git a/.github/scripts/windows/test_task.bat b/.github/scripts/windows/test_task.bat index 93595e3c403..b719d288e66 100644 --- a/.github/scripts/windows/test_task.bat +++ b/.github/scripts/windows/test_task.bat @@ -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 diff --git a/ext/snmp/tests/bigtest.js b/ext/snmp/tests/bigtest.js new file mode 100644 index 00000000000..d8b4fc97780 --- /dev/null +++ b/ext/snmp/tests/bigtest.js @@ -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"); +} diff --git a/ext/snmp/tests/bug64159.phpt b/ext/snmp/tests/bug64159.phpt index e7cdbd54377..622cb1ce019 100644 --- a/ext/snmp/tests/bug64159.phpt +++ b/ext/snmp/tests/bug64159.phpt @@ -7,7 +7,6 @@ snmp --SKIPIF-- --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