Skip to content

Commit

Permalink
cmd/dlv: update ebpf trace test
Browse files Browse the repository at this point in the history
  • Loading branch information
derekparker committed Oct 12, 2021
1 parent 414a9c5 commit 1ad50bd
Showing 1 changed file with 1 addition and 41 deletions.
42 changes: 1 addition & 41 deletions cmd/dlv/dlv_test.go
Expand Up @@ -828,7 +828,7 @@ func TestTraceEBPF(t *testing.T) {
dlvbin, tmpdir := getDlvBinEBPF(t)
defer os.RemoveAll(tmpdir)

expected := []byte("> (1) main.foo(99, 9801)\n")
expected := []byte("> (1) main.foo(99, 9801)\n=> \"9900\"")

fixtures := protest.FindFixturesDir()
cmd := exec.Command(dlvbin, "trace", "--ebpf", "--output", filepath.Join(tmpdir, "__debug"), filepath.Join(fixtures, "issue573.go"), "foo")
Expand All @@ -847,46 +847,6 @@ func TestTraceEBPF(t *testing.T) {
cmd.Wait()
}

func TestTraceEBPFRet(t *testing.T) {
if os.Getenv("CI") == "true" {
t.Skip("cannot run test in CI, requires kernel compiled with btf support")
}
if runtime.GOOS != "linux" || runtime.GOARCH != "amd64" {
t.Skip("not implemented on non linux/amd64 systems")
}
if !goversion.VersionAfterOrEqual(runtime.Version(), 1, 16) {
t.Skip("requires at least Go 1.16 to run test")
}
usr, err := user.Current()
if err != nil {
t.Fatal(err)
}
if usr.Uid != "0" {
t.Skip("test must be run as root")
}

dlvbin, tmpdir := getDlvBinEBPF(t)
defer os.RemoveAll(tmpdir)

expected := "> (1) main.g(1000) => \"10\"\n"

fixtures := protest.FindFixturesDir()
cmd := exec.Command(dlvbin, "trace", "--ebpf", "--output", filepath.Join(tmpdir, "__debug"), filepath.Join(fixtures, "databpstack2.go"), "main.g")
rdr, err := cmd.StderrPipe()
assertNoError(err, t, "stderr pipe")
defer rdr.Close()

assertNoError(cmd.Start(), t, "running trace")

output, err := ioutil.ReadAll(rdr)
assertNoError(err, t, "ReadAll")

if !strings.Contains(string(output), expected) {
t.Fatalf("expected:\n%s\ngot:\n%s", expected, output)
}
cmd.Wait()
}

func TestDlvTestChdir(t *testing.T) {
dlvbin, tmpdir := getDlvBin(t)
defer os.RemoveAll(tmpdir)
Expand Down

0 comments on commit 1ad50bd

Please sign in to comment.