diff options
author | Giovanni Bajo <rasky@develer.com> | 2018-03-01 01:56:07 +0100 |
---|---|---|
committer | Giovanni Bajo <rasky@develer.com> | 2018-03-01 18:15:24 +0000 |
commit | f16cc298d344d4db1b8bb3d941c83598abc6ba43 (patch) | |
tree | ae95cde6de9e87b113591acf9100c90cba99d37d /test/run.go | |
parent | 0bcf8bcd998a79f2479c2bb7096eb57a38ffee85 (diff) | |
download | go-f16cc298d344d4db1b8bb3d941c83598abc6ba43.tar.gz go-f16cc298d344d4db1b8bb3d941c83598abc6ba43.zip |
test: implement negative rules in asmcheck
Change-Id: I2b507e35cc314100eaf2ec2d1e5107cc2fc9e7cf
Reviewed-on: https://go-review.googlesource.com/97818
Reviewed-by: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/run.go')
-rw-r--r-- | test/run.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/test/run.go b/test/run.go index 8f2ec7e2f9..fd53095ab4 100644 --- a/test/run.go +++ b/test/run.go @@ -1367,27 +1367,33 @@ func (t *test) asmCheck(outStr string, fn string, arch string, fullops map[strin } } - var notfound []wantedAsmOpcode + var failed []wantedAsmOpcode for _, ops := range fullops { for _, o := range ops { - if !o.found { - notfound = append(notfound, o) + // There's a failure if a negative match was found, + // or a positive match was not found. + if o.negative == o.found { + failed = append(failed, o) } } } - if len(notfound) == 0 { + if len(failed) == 0 { return } // At least one asmcheck failed; report them - sort.Slice(notfound, func(i, j int) bool { - return notfound[i].line < notfound[j].line + sort.Slice(failed, func(i, j int) bool { + return failed[i].line < failed[j].line }) var errbuf bytes.Buffer fmt.Fprintln(&errbuf) - for _, o := range notfound { - fmt.Fprintf(&errbuf, "%s:%d: %s: no match for opcode: %q\n", t.goFileName(), o.line, arch, o.opcode.String()) + for _, o := range failed { + if o.negative { + fmt.Fprintf(&errbuf, "%s:%d: %s: wrong opcode found: %q\n", t.goFileName(), o.line, arch, o.opcode.String()) + } else { + fmt.Fprintf(&errbuf, "%s:%d: %s: opcode not found: %q\n", t.goFileName(), o.line, arch, o.opcode.String()) + } } err = errors.New(errbuf.String()) return |