Skip to content

Commit e9f686a

Browse files
committed
test(php): make smoke test bounded via pcntl alarm
1 parent 115545e commit e9f686a

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

php/tests/smoke.php

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,29 @@
88
$secret = getenv('CODE_BRIDGE_SECRET') ?: 'dev-secret';
99

1010
$client = new Client(new BridgeConfig($url, $secret, 'php-test'));
11-
$client->start();
1211
$client->sendConsole('smoke test console');
1312
$client->sendError('smoke test error');
14-
$client->stop();
13+
14+
if (!function_exists('pcntl_fork')) {
15+
echo "pcntl not available; skipping php smoke\n";
16+
exit(0);
17+
}
18+
19+
$pid = pcntl_fork();
20+
if ($pid === -1) {
21+
fwrite(STDERR, "fork failed\n");
22+
exit(1);
23+
}
24+
25+
if ($pid === 0) {
26+
pcntl_async_signals(true);
27+
pcntl_signal(SIGALRM, function () use ($client) {
28+
$client->stop();
29+
});
30+
pcntl_alarm(4);
31+
$client->start();
32+
exit(0);
33+
}
34+
35+
pcntl_waitpid($pid, $status);
1536
echo "php smoke ok\n";

0 commit comments

Comments
 (0)