From e51b8571bc192e7122f25a3d05a6407dfa8a6998 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 21 Feb 2026 20:16:19 +0200 Subject: Add ior crash/timeout harness tests (task 343) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add waitBoth unit tests: ior exit error, ior timeout, both timeout, both succeed — using real processes (true/false/sleep) - Add TestIorCrashReportsError: full harness test with fake ior binary that exits with error, verifying error mentions 'ior' and workload PID is returned - Add TestIorStartFailureCleansUpWorkload: verifies workload process is killed when ior binary doesn't exist, checking with signal 0 - Refactor waitBoth to accept grace duration parameter for testability (production code passes iorShutdownGrace, tests use 500ms) - Fix pipe drain in startWorkload: drain remaining stdout after reading PID so cmd.Wait() doesn't block on pending I/O - Add writeScript helper to helpers_test.go for creating fake binaries Co-authored-by: Amp Amp-Thread-ID: https://ampcode.com/threads/T-019c8162-c1cf-7612-b8f5-84c61e3d2021 --- integrationtests/helpers_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'integrationtests/helpers_test.go') diff --git a/integrationtests/helpers_test.go b/integrationtests/helpers_test.go index edf57b9..7db54b2 100644 --- a/integrationtests/helpers_test.go +++ b/integrationtests/helpers_test.go @@ -36,6 +36,16 @@ func absPath(t *testing.T, rel string) string { return p } +// writeScript creates an executable shell script in dir and returns its path. +func writeScript(t *testing.T, dir, name, content string) string { + t.Helper() + path := filepath.Join(dir, name) + if err := os.WriteFile(path, []byte("#!/bin/sh\n"+content+"\n"), 0o755); err != nil { + t.Fatalf("write script %s: %v", name, err) + } + return path +} + func runScenario(t *testing.T, scenario string, expected []ExpectedEvent) { t.Helper() h := newTestHarness(t) -- cgit v1.2.3