From a4129b5c87bcf6be0da534588784433cb9548511 Mon Sep 17 00:00:00 2001 From: Matthieu Napoli Date: Thu, 22 Jan 2026 11:32:39 +0100 Subject: [PATCH] Fix ARM build --- tests/test_4_function_invocation.php | 2 ++ tests/test_5_fpm_invocation.php | 2 ++ tests/test_6_console_invocation.php | 2 ++ tests/test_7_custom_ini_scan_dir.php | 2 ++ tests/utils.php | 19 +++++++++++++++++++ 5 files changed, 27 insertions(+) diff --git a/tests/test_4_function_invocation.php b/tests/test_4_function_invocation.php index 423ece7a..ed8fed59 100644 --- a/tests/test_4_function_invocation.php +++ b/tests/test_4_function_invocation.php @@ -27,6 +27,8 @@ function post(string $url, array $params) $body = ['Hello' => 'From Bref!']; +waitForPort('127.0.0.1', 8080); + try { $response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body); $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); diff --git a/tests/test_5_fpm_invocation.php b/tests/test_5_fpm_invocation.php index 7f817c33..8c21967b 100644 --- a/tests/test_5_fpm_invocation.php +++ b/tests/test_5_fpm_invocation.php @@ -25,6 +25,8 @@ function post(string $url, string $body) $body = file_get_contents(__DIR__ . '/test_5_event.json'); +waitForPort('127.0.0.1', 8080); + try { $response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body); $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); diff --git a/tests/test_6_console_invocation.php b/tests/test_6_console_invocation.php index c7aff09c..548fa9de 100644 --- a/tests/test_6_console_invocation.php +++ b/tests/test_6_console_invocation.php @@ -27,6 +27,8 @@ function post(string $url, string $param) $body = '"From Bref"'; +waitForPort('127.0.0.1', 8080); + try { $response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body); $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); diff --git a/tests/test_7_custom_ini_scan_dir.php b/tests/test_7_custom_ini_scan_dir.php index 9df6719b..9e4344bb 100644 --- a/tests/test_7_custom_ini_scan_dir.php +++ b/tests/test_7_custom_ini_scan_dir.php @@ -27,6 +27,8 @@ function post(string $url, string $params) $body = 'list_extensions'; +waitForPort('127.0.0.1', 8080); + try { $response = post('http://127.0.0.1:8080/2015-03-31/functions/function/invocations', $body); $response = json_decode($response, true, 512, JSON_THROW_ON_ERROR); diff --git a/tests/utils.php b/tests/utils.php index 1dba63bf..5fc8a047 100644 --- a/tests/utils.php +++ b/tests/utils.php @@ -25,3 +25,22 @@ function success(string $message): void } exit(1); } + +/** + * Wait for a port to be available (useful for QEMU-emulated containers that start slowly). + */ +function waitForPort(string $host, int $port, int $timeoutSeconds = 5): void +{ + $start = time(); + while (true) { + $socket = @fsockopen($host, $port, $errno, $errstr, 1); + if ($socket !== false) { + fclose($socket); + return; + } + if (time() - $start >= $timeoutSeconds) { + error("Timeout waiting for $host:$port to be available"); + } + usleep(100000); // 100ms + } +}