Skip to content

Commit bbfb4e7

Browse files
committed
test: include Windows smoke sources
1 parent f5547ca commit bbfb4e7

2 files changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
/** Windows API smoke-test declarations implemented by winapi.cc. */
4+
function windows_current_process_id(): int {}
5+
6+
function windows_has_module_handle(): bool {}
7+
8+
function windows_logical_processor_count(): int {}
9+
10+
function windows_php_is_zts(): bool {}

tests/windows/smoke/main.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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

Comments
 (0)