github.com/cilium/ebpf@v0.15.1-0.20240517100537-8079b37aa138/link/raw_tracepoint_test.go (about)

     1  package link
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/cilium/ebpf"
     7  	"github.com/cilium/ebpf/internal/testutils"
     8  )
     9  
    10  func TestRawTracepoint(t *testing.T) {
    11  	testutils.SkipOnOldKernel(t, "4.17", "BPF_RAW_TRACEPOINT API")
    12  
    13  	prog := mustLoadProgram(t, ebpf.RawTracepoint, 0, "")
    14  
    15  	link, err := AttachRawTracepoint(RawTracepointOptions{
    16  		Name:    "cgroup_mkdir",
    17  		Program: prog,
    18  	})
    19  	if err != nil {
    20  		t.Fatal(err)
    21  	}
    22  
    23  	testLink(t, link, prog)
    24  }
    25  
    26  func TestRawTracepoint_writable(t *testing.T) {
    27  	testutils.SkipOnOldKernel(t, "5.2", "BPF_RAW_TRACEPOINT_WRITABLE API")
    28  
    29  	prog := mustLoadProgram(t, ebpf.RawTracepoint, 0, "")
    30  
    31  	defer prog.Close()
    32  
    33  	link, err := AttachRawTracepoint(RawTracepointOptions{
    34  		Name:    "cgroup_rmdir",
    35  		Program: prog,
    36  	})
    37  	if err != nil {
    38  		t.Fatal(err)
    39  	}
    40  
    41  	testLink(t, link, prog)
    42  }