File: uprobe_test.go

package info (click to toggle)
golang-github-cilium-ebpf 0.17.3%2Bds1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,684 kB
  • sloc: ansic: 1,259; makefile: 127; python: 113; awk: 29; sh: 24
file content (29 lines) | stat: -rw-r--r-- 797 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package tracefs

import (
	"fmt"
	"testing"
)

func TestUprobeToken(t *testing.T) {
	tests := []struct {
		args     ProbeArgs
		expected string
	}{
		{ProbeArgs{Path: "/bin/bash"}, "/bin/bash:0x0"},
		{ProbeArgs{Path: "/bin/bash", Offset: 1}, "/bin/bash:0x1"},
		{ProbeArgs{Path: "/bin/bash", Offset: 65535}, "/bin/bash:0xffff"},
		{ProbeArgs{Path: "/bin/bash", Offset: 65536}, "/bin/bash:0x10000"},
		{ProbeArgs{Path: "/bin/bash", Offset: 1, RefCtrOffset: 1}, "/bin/bash:0x1(0x1)"},
		{ProbeArgs{Path: "/bin/bash", Offset: 1, RefCtrOffset: 65535}, "/bin/bash:0x1(0xffff)"},
	}

	for i, tt := range tests {
		t.Run(fmt.Sprint(i), func(t *testing.T) {
			po := UprobeToken(tt.args)
			if tt.expected != po {
				t.Errorf("Expected path:offset to be '%s', got '%s'", tt.expected, po)
			}
		})
	}
}