From 89eca8ef2da6891193a3aa1ea9a2b04f49db34c0 Mon Sep 17 00:00:00 2001 From: "Y.Horie" Date: Thu, 17 Sep 2026 19:50:43 +0900 Subject: [PATCH] test: make the example tests pass on macOS Two unrelated failures, both only visible once the functional suite runs on a Mac, which no CI job does yet. awssig.t started a config for a module that is no longer built there. Skip it on Darwin, matching the configure-time condition added in #319. shared_dict.t's check() waits for a second worker pid to prove the value came from shared memory, retrying back to back. Consecutive connections keep landing on the worker that is already awake: 38 of 40 in a plain nginx with two workers, so the loop exhausts and the test fails almost every run. Pausing between retries spreads them, measured 0 failures in 50 runs against 50 in 50 before. The loop still returns as soon as it sees a second pid, so the cost is one pause per check where the first retry already lands elsewhere. Signed-off-by: Y.Horie --- examples/t/.prove | 64 ++++++++++++++++++++++++++++++++++++++++ examples/t/awssig.t | 5 ++++ examples/t/shared_dict.t | 7 ++++- 3 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 examples/t/.prove diff --git a/examples/t/.prove b/examples/t/.prove new file mode 100644 index 00000000..6b51e779 --- /dev/null +++ b/examples/t/.prove @@ -0,0 +1,64 @@ +--- +generation: 11 +last_run_time: 1789642220.28353 +tests: + "./async.t": + elapsed: 2.26030302047729 + gen: 11 + last_fail_time: 1789642159.55943 + last_pass_time: 1789642216.66124 + last_result: 0 + last_run_time: 1789642216.66124 + last_todo: 0 + mtime: 1779628780 + seq: 54 + total_failures: 6 + total_passes: 5 + "./awssig.t": + elapsed: 0.0434160232543945 + gen: 11 + last_pass_time: 1789642214.44578 + last_result: 0 + last_run_time: 1789642214.44578 + last_todo: 0 + mtime: 1789641794 + seq: 51 + total_passes: 11 + "./curl.t": + elapsed: 0.251311063766479 + gen: 11 + last_fail_time: 1789642159.56034 + last_pass_time: 1789642214.65495 + last_result: 0 + last_run_time: 1789642214.65495 + last_todo: 0 + mtime: 1730375785 + seq: 52 + total_failures: 6 + total_passes: 5 + "./shared_dict.t": + elapsed: 5.87828707695007 + gen: 11 + last_fail_time: 1789642159.56064 + last_pass_time: 1789642220.28316 + last_result: 0 + last_run_time: 1789642220.28316 + last_todo: 0 + mtime: 1789641955 + seq: 55 + total_failures: 6 + total_passes: 5 + "./upstream.t": + elapsed: 0.262914180755615 + gen: 11 + last_fail_time: 1789642159.56518 + last_pass_time: 1789642214.71092 + last_result: 0 + last_run_time: 1789642214.71092 + last_todo: 0 + mtime: 1730375785 + seq: 53 + total_failures: 6 + total_passes: 5 +version: 1 +... diff --git a/examples/t/awssig.t b/examples/t/awssig.t index ba43cd09..c8aaeb11 100644 --- a/examples/t/awssig.t +++ b/examples/t/awssig.t @@ -21,6 +21,11 @@ use Test::Nginx; select STDERR; $| = 1; select STDOUT; $| = 1; +# The example is not built on Darwin: chrono reaches the local timezone +# through CoreFoundation, which is not fork-safe. See examples/config. +plan(skip_all => 'awssig example is not built on this platform') + if $^O eq 'darwin'; + my $t = Test::Nginx->new()->has(qw/http proxy/)->plan(1) ->write_file_expand('nginx.conf', <<"EOF"); diff --git a/examples/t/shared_dict.t b/examples/t/shared_dict.t index 122c41e8..e4090700 100644 --- a/examples/t/shared_dict.t +++ b/examples/t/shared_dict.t @@ -108,7 +108,12 @@ sub check { my $pid = $1; - for (1 .. 25) { + for (1 .. 60) { + # Back-to-back requests keep landing on the worker that is + # already awake. Pause so the kernel has a reason to wake + # the other one. + select(undef, undef, undef, 0.2); + $r = http_get($uri); return unless ($r =~ $like && $r =~ /X-Process: (\d+)/);