From 89963d22c7e144e063b2ded76db264b759c8ded3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 1 Apr 2025 23:03:13 +0300 Subject: initial iordata_test --- internal/flamegraph/iordata_test.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 internal/flamegraph/iordata_test.go (limited to 'internal/flamegraph') diff --git a/internal/flamegraph/iordata_test.go b/internal/flamegraph/iordata_test.go new file mode 100644 index 0000000..79fb75c --- /dev/null +++ b/internal/flamegraph/iordata_test.go @@ -0,0 +1,28 @@ +package flamegraph + +import "testing" + +func TestAddPath(t *testing.T) { + iod := newIorData() + path := pathType("testPath") + traceId := traceIdType(1) + comm := commType("testComm") + pid := pidType(1234) + tid := tidType(5678) + flags := flagsType("O_RDWR") + cnt1 := counter{count: 1, duration: 1000, durationToPrev: 100} + + iod.addPath(path, traceId, comm, pid, tid, flags, cnt1) + + if iod.paths[path][traceId][comm][pid][tid][flags] != cnt1 { + t.Errorf("Expected counter %v, got %v", cnt1, iod.paths[path][traceId][comm][pid][tid][flags]) + } + cnt2 := counter{count: 2, duration: 2000, durationToPrev: 200} + + iod.addPath(path, traceId, comm, pid, tid, flags, cnt2) + + resultCnt := cnt1.add(cnt2) + if iod.paths[path][traceId][comm][pid][tid][flags] != resultCnt { + t.Errorf("Expected counter %v, got %v", resultCnt, iod.paths[path][traceId][comm][pid][tid][flags]) + } +} -- cgit v1.2.3