summaryrefslogtreecommitdiff
path: root/integrationtests/helpers_test.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-02-21 19:28:23 +0200
committerPaul Buetow <paul@buetow.org>2026-02-21 19:28:23 +0200
commita5b711c5f221704209706b79fbf310a18e079391 (patch)
tree84615902f79a901aa9d98e3423c4756477b7cf4b /integrationtests/helpers_test.go
parent2c2cbe07f5e10fdb996e2a039cde84be44866f18 (diff)
more on integration tests
Diffstat (limited to 'integrationtests/helpers_test.go')
-rw-r--r--integrationtests/helpers_test.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/integrationtests/helpers_test.go b/integrationtests/helpers_test.go
new file mode 100644
index 0000000..edf57b9
--- /dev/null
+++ b/integrationtests/helpers_test.go
@@ -0,0 +1,50 @@
+package integrationtests
+
+import (
+ "os"
+ "path/filepath"
+ "testing"
+)
+
+const (
+ iorBinaryDefault = "../ior"
+ workloadBinaryDefault = "../ioworkload"
+ bpfObjectDefault = "../ior.bpf.o"
+ defaultDuration = 10
+)
+
+func newTestHarness(t *testing.T) TestHarness {
+ t.Helper()
+ if os.Geteuid() != 0 {
+ t.Skip("requires root for BPF")
+ }
+
+ return TestHarness{
+ IorBinary: absPath(t, iorBinaryDefault),
+ WorkloadBinary: absPath(t, workloadBinaryDefault),
+ BpfObject: absPath(t, bpfObjectDefault),
+ OutputDir: t.TempDir(),
+ }
+}
+
+func absPath(t *testing.T, rel string) string {
+ t.Helper()
+ p, err := filepath.Abs(rel)
+ if err != nil {
+ t.Fatalf("resolve path %s: %v", rel, err)
+ }
+ return p
+}
+
+func runScenario(t *testing.T, scenario string, expected []ExpectedEvent) {
+ t.Helper()
+ h := newTestHarness(t)
+ result, pid, err := h.Run(scenario, defaultDuration)
+ if err != nil {
+ t.Fatalf("run scenario %s: %v", scenario, err)
+ }
+
+ AssertNoUnexpectedPID(t, result, pid)
+ AssertNoUnexpectedComm(t, result, "ioworkload")
+ AssertEventsPresent(t, result, expected)
+}