diff options
| author | Paul Buetow <paul@buetow.org> | 2025-04-01 23:03:13 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2025-04-01 23:03:13 +0300 |
| commit | 89963d22c7e144e063b2ded76db264b759c8ded3 (patch) | |
| tree | 83fe07cdfe176485ccf52072c8c23f4df8da63f8 /internal/flamegraph/iordata_test.go | |
| parent | 1e2281b92863bf90a9be8769b8809ab300158a5d (diff) | |
initial iordata_test
Diffstat (limited to 'internal/flamegraph/iordata_test.go')
| -rw-r--r-- | internal/flamegraph/iordata_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
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]) + } +} |
