Skip to content

Commit 3b9af79

Browse files
authored
Merge pull request #309 from brefphp/fix-build
Fix ARM build
2 parents 248348c + a4129b5 commit 3b9af79

File tree

5 files changed

+27
-0
lines changed

5 files changed

+27
-0
lines changed

tests/test_4_function_invocation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function post(string $url, array $params)
2727

2828
$body = ['Hello' => 'From Bref!'];
2929

30+
waitForPort('127.0.0.1', 8080);
31+
3032
try {
3133
$response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body);
3234
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);

tests/test_5_fpm_invocation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ function post(string $url, string $body)
2525

2626
$body = file_get_contents(__DIR__ . '/test_5_event.json');
2727

28+
waitForPort('127.0.0.1', 8080);
29+
2830
try {
2931
$response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body);
3032
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);

tests/test_6_console_invocation.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function post(string $url, string $param)
2727

2828
$body = '"From Bref"';
2929

30+
waitForPort('127.0.0.1', 8080);
31+
3032
try {
3133
$response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body);
3234
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);

tests/test_7_custom_ini_scan_dir.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@ function post(string $url, string $params)
2727

2828
$body = 'list_extensions';
2929

30+
waitForPort('127.0.0.1', 8080);
31+
3032
try {
3133
$response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body);
3234
$response = json_decode($response, true, 512, JSON_THROW_ON_ERROR);

tests/utils.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,22 @@ function success(string $message): void
2525
}
2626
exit(1);
2727
}
28+
29+
/**
30+
* Wait for a port to be available (useful for QEMU-emulated containers that start slowly).
31+
*/
32+
function waitForPort(string $host, int $port, int $timeoutSeconds = 5): void
33+
{
34+
$start = time();
35+
while (true) {
36+
$socket = @fsockopen($host, $port, $errno, $errstr, 1);
37+
if ($socket !== false) {
38+
fclose($socket);
39+
return;
40+
}
41+
if (time() - $start >= $timeoutSeconds) {
42+
error("Timeout waiting for $host:$port to be available");
43+
}
44+
usleep(100000); // 100ms
45+
}
46+
}

0 commit comments

Comments
 (0)