test: sync control child runs to the parent test deadline, not a fixed 45 s

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
pingqiuandClaude Opus 5.5 committed 2026-11-22 19:01:21 -08:00
1 parent 251d78bfa8
commit 399bc7699f
1 file changed
+7 -1
@@ -290,7 +290,13 @@ func TestSyncControlsIgnoreAmbientAllocation(t *testing.T) {
{"crash-matrix", "TestFdatasyncAcknowledgedWritesSurviveSIGKILL", "prezero"},
} {
t.Run(tc.name, func(t *testing.T) {
ctx, cancel := context.WithTimeout(context.Background(), 45*time.Second)
// The crash-matrix child is fdatasync-bound and takes 1-35 s on a
// slow disk, so it runs until the parent test's deadline rather
// than a fixed budget.
ctx, cancel := context.WithCancel(context.Background())
if d, ok := t.Deadline(); ok {
ctx, cancel = context.WithDeadline(context.Background(), d.Add(-10*time.Second))
}
defer cancel()
cmd := exec.CommandContext(ctx, os.Args[0], "-test.run=^"+tc.test+"$")
cmd.Env = append(os.Environ(), "SWBLOCK_TEST_SYNC_CRASH=", "SWBLOCK_TEST_SYNC_CHILD_FAILURE=", "SWBLOCK_ALLOCATION="+tc.allocation, "SWBLOCK_PREZERO=0")