Skip to content

Commit

Permalink
btf: additional checks for btf.Spec.FindType
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Falzoi <fabio.falzoi84@gmail.com>
  • Loading branch information
Fabio Falzoi authored and lmb committed Sep 17, 2021
1 parent 8972efb commit 1ec250c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/btf/btf_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,20 @@ func TestFindType(t *testing.T) {
}

// spec.FindType MUST fail if typ is not a non-nil **T, where T satisfies btf.Type.
i := 0
p := &i
for _, typ := range []interface{}{
nil,
Struct{},
&Struct{},
[]Struct{},
&[]Struct{},
map[int]Struct{},
&map[int]Struct{},
p,
&p,
} {
if err := spec.FindType("iphdr", nil); err == nil {
if err := spec.FindType("iphdr", typ); err == nil {
t.Fatalf("FindType does not fail with type %T", typ)
}
}
Expand Down

0 comments on commit 1ec250c

Please sign in to comment.