diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-04-09 09:49:39 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-04-09 08:33:12 +0000 |
| commit | 56086b24bdfd822d3b227edb3064db443cd8c971 (patch) | |
| tree | fc307b5a2332cb85d0b8804e9d2645450da10853 /pkg/cover/report_test.go | |
| parent | da07505f2b87b144347aa19597979d340b134b06 (diff) | |
pkg/cover: don't duplicate broken kcov logic in the test
dwarf.go already detects if kcov is broken and need to provide this bit
for the check in report.go, so just use this bit in the test as well.
Diffstat (limited to 'pkg/cover/report_test.go')
| -rw-r--r-- | pkg/cover/report_test.go | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/pkg/cover/report_test.go b/pkg/cover/report_test.go index 729caba41..ab0be490b 100644 --- a/pkg/cover/report_test.go +++ b/pkg/cover/report_test.go @@ -40,9 +40,6 @@ type Test struct { DebugInfo bool AddCover bool AddBadPc bool - // Set by the testing environment depending on the target compiler. - // See https://github.com/google/syzkaller/issues/4447. - KcovIsBroken bool // Set to true if the test should be skipped under broken kcov. SkipIfKcovIsBroken bool // Inexact coverage generated by AddCover=true may override empty Result. @@ -135,17 +132,12 @@ func TestReportGenerator(t *testing.T) { if target.BrokenCompiler != "" { t.Skip("skipping the test due to broken cross-compiler:\n" + target.BrokenCompiler) } - kcovIsBroken := targetKcovIsBroken(t, target) for _, test := range tests { test := test - test.KcovIsBroken = kcovIsBroken t.Run(test.Name, func(t *testing.T) { if test.Supports != nil && !test.Supports(target) { t.Skip("unsupported target") } - if test.SkipIfKcovIsBroken && test.KcovIsBroken { - t.Skip("coverage testing requested, but kcov is broken") - } t.Parallel() testReportGenerator(t, target, test) }) @@ -281,14 +273,6 @@ func buildTestBinary(t *testing.T, target *targets.Target, test *Test, dir strin return bin } -// Work around https://github.com/google/syzkaller/issues/4447. Do not use for anything else. -func targetKcovIsBroken(t *testing.T, target *targets.Target) bool { - if out, err := osutil.RunCmd(time.Hour, "", target.CCompiler, "--version"); err == nil { - return backend.IsKcovBrokenInCompiler(string(out)) - } - return true -} - type reports struct { html []byte csv []byte @@ -328,6 +312,9 @@ func generateReport(t *testing.T, target *targets.Target, test *Test) (*reports, if err != nil { return nil, err } + if !rg.PreciseCoverage && test.SkipIfKcovIsBroken { + t.Skip("coverage testing requested, but kcov is broken") + } if test.AddCover { var pcs []uint64 Inexact := false @@ -363,7 +350,7 @@ func generateReport(t *testing.T, target *targets.Target, test *Test) (*reports, t.Logf("using inexact coverage range 0x%x-0x%x", main.Addr, main.Addr+uint64(main.Size)) Inexact = true } - if Inexact && test.Result == "" && !test.KcovIsBroken { + if Inexact && test.Result == "" && rg.PreciseCoverage { test.Result = fmt.Sprintf("%d out of %d PCs returned by kcov do not have matching coverage callbacks", len(pcs)-1, len(pcs)) } |
