aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/build/build_test.go
diff options
context:
space:
mode:
authorGreg Steuck <blackgnezdo@gmail.com>2019-02-11 02:09:05 -0800
committerDmitry Vyukov <dvyukov@google.com>2019-02-11 11:09:05 +0100
commit5e5bb28ebfd9b28ed8fcdc9def45ee0b1d8a5d4a (patch)
tree4c94f8155f108687bdbb8fa3e14fca13252590b6 /pkg/build/build_test.go
parentb4f792e401f416ff9fc75716d2500971ba63d1db (diff)
pkg/build: share extractRootCause with openbsd
* pkg/build: share extractRootCause with openbsd This should get kernel build errors reported in syz-ci console. * Add a test * lint
Diffstat (limited to 'pkg/build/build_test.go')
-rw-r--r--pkg/build/build_test.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/pkg/build/build_test.go b/pkg/build/build_test.go
index 1698d3bd8..830c4f39c 100644
--- a/pkg/build/build_test.go
+++ b/pkg/build/build_test.go
@@ -4,6 +4,7 @@
package build
import (
+ "bytes"
"os/exec"
"strings"
"testing"
@@ -34,3 +35,26 @@ func TestCompilerIdentity(t *testing.T) {
})
}
}
+
+func TestExtractRootCause(t *testing.T) {
+ for _, s := range []struct{ e, expect string }{
+ {`
+cc -g -Werror db_break.c
+sys/dev/kcov.c:93:6: error: use of undeclared identifier 'kcov_cold123'; did you mean 'kcov_cold'?
+ if (kcov_cold123)
+ ^~~~~~~~~~~~
+ kcov_cold
+sys/dev/kcov.c:65:5: note: 'kcov_cold' declared here
+int kcov_cold = 1;
+ ^
+1 error generated.
+`,
+ "sys/dev/kcov.c:93:6: error: use of undeclared identifier 'kcov_cold123'; did you mean 'kcov_cold'?",
+ },
+ } {
+ got := extractCauseInner([]byte(s.e))
+ if !bytes.Equal([]byte(s.expect), got) {
+ t.Errorf("Expected %s, got %s", s.expect, got)
+ }
+ }
+}