From 1ec250c1f65f1e44b2ee099d9dbff40920c61c2a Mon Sep 17 00:00:00 2001 From: Fabio Falzoi Date: Fri, 17 Sep 2021 11:14:56 +0200 Subject: [PATCH] btf: additional checks for btf.Spec.FindType Signed-off-by: Fabio Falzoi --- internal/btf/btf_test.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/btf/btf_test.go b/internal/btf/btf_test.go index 7cffc58fd..34514d93b 100644 --- a/internal/btf/btf_test.go +++ b/internal/btf/btf_test.go @@ -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) } }