diff --git a/info_test.go b/info_test.go index 5aa26a9bb..0effb4c4f 100644 --- a/info_test.go +++ b/info_test.go @@ -130,6 +130,34 @@ func TestProgramInfo(t *testing.T) { qt.Assert(t, qt.IsTrue(ok)) qt.Assert(t, qt.IsTrue(verifiedInsns > 0)) } + + if addrs, ok := info.KsymAddrs(); testutils.IsKernelLessThan(t, "4.18") { + qt.Assert(t, qt.IsFalse(ok)) + } else { + qt.Assert(t, qt.IsTrue(ok)) + qt.Assert(t, qt.IsTrue(len(addrs) > 0)) + } + + if insns, ok := info.JitedInsns(); testutils.IsKernelLessThan(t, "4.13") { + qt.Assert(t, qt.IsFalse(ok)) + } else { + qt.Assert(t, qt.IsTrue(ok)) + qt.Assert(t, qt.IsTrue(len(insns) > 0)) + } + + if infos, ok := info.JitedLineInfos(); testutils.IsKernelLessThan(t, "5.0") { + qt.Assert(t, qt.IsFalse(ok)) + } else { + qt.Assert(t, qt.IsTrue(ok)) + qt.Assert(t, qt.IsTrue(len(infos) > 0)) + } + + if lens, ok := info.JitedFuncLens(); testutils.IsKernelLessThan(t, "4.18") { + qt.Assert(t, qt.IsFalse(ok)) + } else { + qt.Assert(t, qt.IsTrue(ok)) + qt.Assert(t, qt.IsTrue(len(lens) > 0)) + } } func TestProgramInfoProc(t *testing.T) { @@ -521,8 +549,8 @@ func TestProgInfoKsym(t *testing.T) { } } -func TestProgInfoFuncInfos(t *testing.T) { - testutils.SkipOnOldKernel(t, "5.0", "Program func info") +func TestProgInfoFuncLineInfos(t *testing.T) { + testutils.SkipOnOldKernel(t, "5.0", "Program func and line info") spec, err := LoadCollectionSpec(testutils.NativeFile(t, "testdata/loader-%s.elf")) qt.Assert(t, qt.IsNil(err)) @@ -546,4 +574,13 @@ func TestProgInfoFuncInfos(t *testing.T) { qt.Assert(t, qt.IsNotNil(fo.Func)) qt.Assert(t, qt.Not(qt.Equals(fo.Func.Name, ""))) } + + lines, err := info.LineInfos() + qt.Assert(t, qt.IsNil(err)) + + qt.Assert(t, qt.HasLen(lines, 28)) + for _, lo := range lines { + qt.Assert(t, qt.IsNotNil(lo.Line)) + qt.Assert(t, qt.Not(qt.Equals(lo.Line.Line(), ""))) + } } diff --git a/prog_test.go b/prog_test.go index 5fcddc065..a46545a69 100644 --- a/prog_test.go +++ b/prog_test.go @@ -1035,7 +1035,7 @@ var socketFilterSpec = &ProgramSpec{ Name: "test", Type: SocketFilter, Instructions: asm.Instructions{ - asm.LoadImm(asm.R0, 2, asm.DWord), + asm.LoadImm(asm.R0, 2, asm.DWord).WithSource(asm.Comment("line info")), asm.Return(), }, License: "MIT",