diff options
| author | Dean Deng <deandeng@google.com> | 2020-12-04 15:59:12 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-12-05 07:58:22 +0100 |
| commit | 0ef84591d219e3142621dc31dcec970300f7ec0c (patch) | |
| tree | 370075f403aad27e843810111dd746718e53f83a | |
| parent | 20366b870db78f1d58502dad9ffcf6dad618fae7 (diff) | |
pkg/build: skip coverage instrumentation on gVisor norace files
These cannot be instrumented with regular atomic operations (e.g.,
sync/atomic.AddInt32), which will happen if -race is enabled. We may be
able to re-enable coverage on them when https://golang.org/issue/43007 is
resolved.
| -rw-r--r-- | pkg/build/gvisor.go | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/pkg/build/gvisor.go b/pkg/build/gvisor.go index d0711ee70..b540d0144 100644 --- a/pkg/build/gvisor.go +++ b/pkg/build/gvisor.go @@ -24,14 +24,32 @@ func (gvisor gvisor) build(params *Params) error { config := strings.Fields(string(params.Config)) args := []string{"build", "--verbose_failures"} target := "//runsc:runsc" + race := raceEnabled(config) + if race { + args = append(args, "--features=race") + target = "//runsc:runsc-race" + } if coverageEnabled(config) { + coverageFiles := "//pkg/..." + exclusions := []string{ + "//pkg/sentry/platform/...", // Breaks kvm. + } + if race { + // These files use go:norace, which is not respected by + // coverage instrumentation. Race builds will be + // instrumented with atomic coverage (using + // sync/atomic.AddInt32), which will not work. + exclusions = append(exclusions, []string{ + "//pkg/sleep/sleep_unsafe.go", + "//pkg/syncevent/waiter_unsafe.go", + }...) + } + for _, f := range exclusions { + coverageFiles += ",-" + f + } args = append(args, []string{ "--collect_code_coverage", - "--instrumentation_filter=//pkg/...,-//pkg/sentry/platform/..."}...) - } - if raceEnabled(config) { - args = append(args, "--features=race") - target = "//runsc:runsc-race" + "--instrumentation_filter=" + coverageFiles}...) } args = append(args, target) // The 1 hour timeout is quite high. But we've seen false positives with 20 mins |
