From 0b1e401f2c864d3edf47d9524a657c6f5eb82c93 Mon Sep 17 00:00:00 2001 From: "Christoph M. Becker" Date: Sun, 25 Aug 2024 13:53:39 +0200 Subject: [PATCH] Skip tests calling wmic if it is not available The WMIC utitlity is deprecated as of Windows 10 21H1, and a feature on demand which is enabled by default in Windows 11 22H2 and 23H2, but will be disabled by default in the next release of Windows.[1] Therefore, we ensure that tests which rely on wmic.exe are properly skipped if it is not available. [1] Closes GH-15583. --- Zend/tests/bug55509.phpt | 7 +++++-- .../tests/general_functions/proc_nice_basic-win.phpt | 4 ++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Zend/tests/bug55509.phpt b/Zend/tests/bug55509.phpt index 1ae5b04f8a0..b45150a4979 100644 --- a/Zend/tests/bug55509.phpt +++ b/Zend/tests/bug55509.phpt @@ -49,8 +49,11 @@ elseif (PHP_OS == 'FreeBSD') { die('skip Not enough memory.'); } } elseif (PHP_OS == "WINNT") { - $s = trim(shell_exec("wmic OS get FreeVirtualMemory /Value 2>nul")); - $freeMemory = explode('=', $s)[1]*1; + $s = shell_exec("wmic OS get FreeVirtualMemory /Value 2>nul"); + if (!$s) { + die('skip wmic not available'); + } + $freeMemory = explode('=', trim($s))[1]*1; if ($freeMemory < 2.1*1024*1024) { die('skip Not enough memory.'); diff --git a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt index 20e8454f8b5..0aee620c89b 100644 --- a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt +++ b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt @@ -11,6 +11,10 @@ if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { if (getenv('SKIP_SLOW_TESTS')) { die('skip: Slow test'); } + +if (!shell_exec("where wmic 2>nul")) { + die('skip wmic not available'); +} ?> --FILE--