From 6b52293f4defa6b45b564d037fd641be5d6d0e0e Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Wed, 10 Jan 2018 16:13:34 +0100 Subject: pkg/compiler: support type templates Netlink descriptions contain tons of code duplication, and need much more for proper descriptions. Introduce type templates to simplify writing such descriptions and remove code duplication. Note: type templates are experimental, have poor error handling and are subject to change. Type templates can be declared as follows: ``` type buffer[DIR] ptr[DIR, array[int8]] type fileoff[BASE] BASE type nlattr[TYPE, PAYLOAD] { nla_len len[parent, int16] nla_type const[TYPE, int16] payload PAYLOAD } [align_4] ``` and later used as follows: ``` syscall(a buffer[in], b fileoff[int64], c ptr[in, nlattr[FOO, int32]]) ``` --- pkg/ast/test_util.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'pkg/ast/test_util.go') diff --git a/pkg/ast/test_util.go b/pkg/ast/test_util.go index 0aed0a2dc..b9fe12152 100644 --- a/pkg/ast/test_util.go +++ b/pkg/ast/test_util.go @@ -7,6 +7,7 @@ import ( "bufio" "bytes" "io/ioutil" + "path/filepath" "strings" "testing" ) @@ -41,7 +42,7 @@ func NewErrorMatcher(t *testing.T, file string) *ErrorMatcher { break } errors = append(errors, &errorDesc{ - file: file, + file: filepath.Base(file), line: i, text: strings.TrimSpace(string(ln[pos+3:])), }) @@ -82,13 +83,13 @@ nextErr: want.matched = true continue nextErr } - t.Errorf("unexpected error: %v:%v:%v: %v", e.file, e.line, e.col, e.text) + t.Errorf("unexpected error:\n%v:%v:%v: %v", e.file, e.line, e.col, e.text) } for _, want := range em.expect { if want.matched { continue } - t.Errorf("unmatched error: %v:%v: %v", want.file, want.line, want.text) + t.Errorf("unmatched error:\n%v:%v: %v", want.file, want.line, want.text) } } -- cgit mrf-deployment