aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/build/gvisor.go28
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