summaryrefslogtreecommitdiffhomepage
path: root/runsc/cli
diff options
context:
space:
mode:
authorgVisor bot <gvisor-bot@google.com>2021-04-17 01:00:38 +0000
committergVisor bot <gvisor-bot@google.com>2021-04-17 01:00:38 +0000
commitce460ce2f19e4b8c63f846d6258a0948a0766578 (patch)
treee029fa98ad0b419efa5ac5827746e6dc522f463f /runsc/cli
parented4ffd6b8cc12ae502d8077843d53a630f5cf519 (diff)
parent0c3e8daf503e011f0ef3e2a1c6d8b6ffd946acab (diff)
Merge release-20210408.0-46-g0c3e8daf5 (automated)
Diffstat (limited to 'runsc/cli')
-rw-r--r--runsc/cli/main.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/runsc/cli/main.go b/runsc/cli/main.go
index 6db6614cc..79eb85cff 100644
--- a/runsc/cli/main.go
+++ b/runsc/cli/main.go
@@ -27,6 +27,7 @@ import (
"github.com/google/subcommands"
"golang.org/x/sys/unix"
+ "gvisor.dev/gvisor/pkg/coverage"
"gvisor.dev/gvisor/pkg/log"
"gvisor.dev/gvisor/pkg/refs"
"gvisor.dev/gvisor/pkg/sentry/platform"
@@ -50,6 +51,7 @@ var (
logFD = flag.Int("log-fd", -1, "file descriptor to log to. If set, the 'log' flag is ignored.")
debugLogFD = flag.Int("debug-log-fd", -1, "file descriptor to write debug logs to. If set, the 'debug-log-dir' flag is ignored.")
panicLogFD = flag.Int("panic-log-fd", -1, "file descriptor to write Go's runtime messages.")
+ coverageFD = flag.Int("coverage-fd", -1, "file descriptor to write Go coverage output.")
)
// Main is the main entrypoint.
@@ -205,6 +207,10 @@ func Main(version string) {
} else if conf.AlsoLogToStderr {
e = &log.MultiEmitter{e, newEmitter(conf.DebugLogFormat, os.Stderr)}
}
+ if *coverageFD >= 0 {
+ f := os.NewFile(uintptr(*coverageFD), "coverage file")
+ coverage.EnableReport(f)
+ }
log.SetTarget(e)
@@ -234,6 +240,8 @@ func Main(version string) {
// Call the subcommand and pass in the configuration.
var ws unix.WaitStatus
subcmdCode := subcommands.Execute(context.Background(), conf, &ws)
+ // Write coverage report before os.Exit().
+ coverage.Report()
if subcmdCode == subcommands.ExitSuccess {
log.Infof("Exiting with status: %v", ws)
if ws.Signaled() {