|
| 1 | +<?php |
| 2 | + |
| 3 | +function requireWindowsCondition(bool $condition, string $message): void |
| 4 | +{ |
| 5 | + if (!$condition) { |
| 6 | + throw new RuntimeException($message); |
| 7 | + } |
| 8 | +} |
| 9 | + |
| 10 | +function main(int $argc, array $argv): void |
| 11 | +{ |
| 12 | + requireWindowsCondition($argc === 2, 'Expected the thread-safety mode argument'); |
| 13 | + |
| 14 | + $expectedZts = $argv[1] === 'zts'; |
| 15 | + requireWindowsCondition(PHP_OS_FAMILY === 'Windows', 'Expected PHP_OS_FAMILY=Windows'); |
| 16 | + requireWindowsCondition(DIRECTORY_SEPARATOR === '\\', 'Expected the Windows directory separator'); |
| 17 | + requireWindowsCondition((PHP_ZTS === 1) === $expectedZts, 'PHP_ZTS does not match the CI matrix'); |
| 18 | + requireWindowsCondition(windows_php_is_zts() === $expectedZts, 'The native ZTS macro does not match PHP_ZTS'); |
| 19 | + requireWindowsCondition(windows_current_process_id() > 0, 'GetCurrentProcessId() failed'); |
| 20 | + requireWindowsCondition(windows_has_module_handle(), 'GetModuleHandleW() failed'); |
| 21 | + requireWindowsCondition(windows_logical_processor_count() > 0, 'GetNativeSystemInfo() returned no processors'); |
| 22 | + |
| 23 | + $path = sys_get_temp_dir() . DIRECTORY_SEPARATOR |
| 24 | + . 'typephp-windows-smoke-' . windows_current_process_id() . '.txt'; |
| 25 | + requireWindowsCondition(file_put_contents($path, 'windows-file-api') === 16, 'Windows file write failed'); |
| 26 | + requireWindowsCondition(file_get_contents($path) === 'windows-file-api', 'Windows file read failed'); |
| 27 | + requireWindowsCondition(unlink($path), 'Windows file cleanup failed'); |
| 28 | + |
| 29 | + echo 'windows-smoke-ok:', $expectedZts ? 'zts' : 'nts'; |
| 30 | +} |
0 commit comments