(t *testing.T)
| 52 | } |
| 53 | |
| 54 | func TestForwardFunctionDeclaration(t *testing.T) { |
| 55 | file := testutils.NativeFile(t, "testdata/fwd_decl-%s.elf") |
| 56 | coll, err := LoadCollectionSpec(file) |
| 57 | if err != nil { |
| 58 | t.Fatal(err) |
| 59 | } |
| 60 | |
| 61 | spec := coll.Programs["call_fwd"] |
| 62 | |
| 63 | // This program calls an unimplemented forward function declaration. |
| 64 | _, err = newProgram(t, spec, nil) |
| 65 | if !errors.Is(err, asm.ErrUnsatisfiedProgramReference) { |
| 66 | t.Fatal("Expected an error wrapping ErrUnsatisfiedProgramReference, got:", err) |
| 67 | } |
| 68 | |
| 69 | // Append the implementation of fwd(). |
| 70 | spec.Instructions = append(spec.Instructions, |
| 71 | asm.Mov.Imm32(asm.R0, 23).WithSymbol("fwd"), |
| 72 | asm.Return(), |
| 73 | ) |
| 74 | |
| 75 | // The body of the subprog we appended does not come with BTF func_infos, |
| 76 | // so the verifier will reject it. Load without BTF. |
| 77 | for i, ins := range spec.Instructions { |
| 78 | if btf.FuncMetadata(&ins) != nil || ins.Source() != nil { |
| 79 | sym := ins.Symbol() |
| 80 | ref := ins.Reference() |
| 81 | ins.Metadata = asm.Metadata{} |
| 82 | spec.Instructions[i] = ins.WithSymbol(sym).WithReference(ref) |
| 83 | } |
| 84 | } |
| 85 | |
| 86 | prog, err := newProgram(t, spec, nil) |
| 87 | testutils.SkipIfNotSupported(t, err) |
| 88 | qt.Assert(t, qt.IsNil(err)) |
| 89 | |
| 90 | ret := mustRun(t, prog, nil) |
| 91 | |
| 92 | if ret != 23 { |
| 93 | t.Fatalf("Expected 23, got %d", ret) |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | func TestFlattenInstructionsAllocations(t *testing.T) { |
| 98 | name := "entrypoint" |
nothing calls this directly
no test coverage detected
searching dependent graphs…