From 5e5bb28ebfd9b28ed8fcdc9def45ee0b1d8a5d4a Mon Sep 17 00:00:00 2001 From: Greg Steuck Date: Mon, 11 Feb 2019 02:09:05 -0800 Subject: 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 --- pkg/build/build_test.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'pkg/build/build_test.go') 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) + } + } +} -- cgit mrf-deployment