MCPcopy Index your code
hub / github.com/cloudflare/ebpf_exporter / TestKStackDecoder

Function TestKStackDecoder

decoder/kstack_test.go:12–95  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestKStackDecoder(t *testing.T) {
13 cases := []struct {
14 in []byte
15 out []byte
16 }{
17 {
18 in: []byte{
19 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
20 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
21 },
22 out: []byte(""),
23 },
24 {
25 in: []byte{
26 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
27 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
28 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
29 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
30 },
31 out: []byte("one\none\ntwo"),
32 },
33 {
34 in: []byte{
35 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
36 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
38 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
39 },
40 out: []byte("three\ntwo\ntwo"),
41 },
42 {
43 in: []byte{
44 0xab, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
45 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
46 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
47 },
48 out: []byte("three\nzero"),
49 },
50 {
51 in: []byte{
52 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
53 0xac, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
54 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
55 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
56 },
57 out: []byte("??\nthree\n??"),
58 },
59 }
60
61 fd, err := os.CreateTemp(t.TempDir(), "kallsyms")
62 if err != nil {
63 t.Fatalf("Error creating temporary file for kallsyms: %v", err)
64 }
65
66 defer os.Remove(fd.Name())
67
68 _, err = fd.WriteString("0000000000000004 T one\n0000000000000006 T two\n00000000000000aa T three\n")
69 if err != nil {

Callers

nothing calls this directly

Calls 2

DecodeMethod · 0.95
NewDecoderFunction · 0.92

Tested by

no test coverage detected