diff options
Diffstat (limited to 'ext/standard/tests/general_functions/proc_nice_basic-win.phpt')
-rw-r--r-- | ext/standard/tests/general_functions/proc_nice_basic-win.phpt | 92 |
1 files changed, 44 insertions, 48 deletions
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 87a4545501..6bf3b2c0a6 100644 --- a/ext/standard/tests/general_functions/proc_nice_basic-win.phpt +++ b/ext/standard/tests/general_functions/proc_nice_basic-win.phpt @@ -8,10 +8,6 @@ if (!defined('PHP_WINDOWS_VERSION_MAJOR')) { die('skip: Only for Windows'); } -if (PHP_SAPI != 'cli') { - die('skip: Only for CLI'); -} - if (getenv('SKIP_SLOW_TESTS')) { doe('skip: Slow test'); } @@ -19,71 +15,71 @@ if (getenv('SKIP_SLOW_TESTS')) { --FILE-- <?php function get_priority_from_wmic() { - static $bin, $pid; + static $bin, $pid; - if (!$bin) { - $t = explode('\\', PHP_BINARY); + if (!$bin) { + $t = explode('\\', PHP_BINARY); - $bin = end($t); - $pid = getmypid(); - } + $bin = end($t); + $pid = getmypid(); + } - $t = ''; - $p = popen('wmic process where name="' . $bin . '"', 'r'); + $t = ''; + $p = popen('wmic process where name="' . $bin . '"', 'r'); - if (!$p) { - return false; - } + if (!$p) { + return false; + } - while(!feof($p)) { - $t .= fread($p, 1024); - } + while(!feof($p)) { + $t .= fread($p, 1024); + } - pclose($p); + pclose($p); - $t = explode(PHP_EOL, $t); + $t = explode(PHP_EOL, $t); - $f = false; - $m = [ - strpos($t[0], ' ProcessId' ), - strpos($t[0], ' Priority ') - ]; + $f = false; + $m = [ + strpos($t[0], ' ProcessId' ), + strpos($t[0], ' Priority ') + ]; - foreach ($t as $n => $l) { - if (!$n || empty($l)) { - continue; - } + foreach ($t as $n => $l) { + if (!$n || empty($l)) { + continue; + } - $d = []; + $d = []; - foreach ($m as $c) { - $d[] = (int) substr($l, $c + 1, strpos($l, ' ', $c + 2) - ($c + 1)); - } + foreach ($m as $c) { + $d[] = (int) substr($l, $c + 1, strpos($l, ' ', $c + 2) - ($c + 1)); + } - if ($d[0] === $pid) { - return $d[1]; - } - } + if ($d[0] === $pid) { + return $d[1]; + } + } - return false; + return false; } $p = [ - /* '<verbose name>' => ['<wmic value>', '<proc_nice value>'] */ + /* '<verbose name>' => ['<wmic value>', '<proc_nice value>'] */ - 'Idle' => [4, 10], - 'Below normal' => [6, 5], - 'Normal' => [8, 0], - 'Above normal' => [10, -5], - 'High priority' => [13, -10] - ]; + 'Idle' => [4, 10], + 'Below normal' => [6, 5], + 'Normal' => [8, 0], + 'Above normal' => [10, -5], + 'High priority' => [13, -10] + ]; foreach ($p as $test => $data) { - printf('Testing \'%s\' (%d): ', $test, $data[1]); + printf('Testing \'%s\' (%d): ', $test, $data[1]); - proc_nice($data[1]); + proc_nice($data[1]); - print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; + print (($wp = get_priority_from_wmic()) === $data[0] ? 'Passed' : 'Failed (' . $wp . ')') . PHP_EOL; } ?> --EXPECT-- |