summaryrefslogtreecommitdiffhomepage
path: root/runsc/config/flags.go
diff options
context:
space:
mode:
authorDean Deng <deandeng@google.com>2021-04-16 17:52:12 -0700
committergVisor bot <gvisor-bot@google.com>2021-04-16 17:56:16 -0700
commit0c3e8daf503e011f0ef3e2a1c6d8b6ffd946acab (patch)
tree31e2eb139d91d463a0468f24d24832783bca698e /runsc/config/flags.go
parentee45334f147c9d5ff75d10c619c9c99ce4ba51ca (diff)
Allow runsc to generate coverage reports.
Add a coverage-report flag that will cause the sandbox to generate a coverage report (with suffix .cov) in the debug log directory upon exiting. For the report to be generated, runsc must have been built with the following Bazel flags: `--collect_code_coverage --instrumentation_filter=...`. With coverage reports, we should be able to aggregate results across all tests to surface code coverage statistics for the project as a whole. The report is simply a text file with each line representing a covered block as `file:start_line.start_col,end_line.end_col`. Note that this is similar to the format of coverage reports generated with `go test -coverprofile`, although we omit the count and number of statements, which are not useful for us. Some simple ways of getting coverage reports: bazel test <some_test> --collect_code_coverage \ --instrumentation_filter=//pkg/... bazel build //runsc --collect_code_coverage \ --instrumentation_filter=//pkg/... runsc -coverage-report=dir/ <other_flags> do ... PiperOrigin-RevId: 368952911
Diffstat (limited to 'runsc/config/flags.go')
-rw-r--r--runsc/config/flags.go3
1 files changed, 2 insertions, 1 deletions
diff --git a/runsc/config/flags.go b/runsc/config/flags.go
index 13a1a0163..c3dca2352 100644
--- a/runsc/config/flags.go
+++ b/runsc/config/flags.go
@@ -44,7 +44,8 @@ func RegisterFlags() {
// Debugging flags.
flag.String("debug-log", "", "additional location for logs. If it ends with '/', log files are created inside the directory with default names. The following variables are available: %TIMESTAMP%, %COMMAND%.")
- flag.String("panic-log", "", "file path were panic reports and other Go's runtime messages are written.")
+ flag.String("panic-log", "", "file path where panic reports and other Go's runtime messages are written.")
+ flag.String("coverage-report", "", "file path where Go coverage reports are written. Reports will only be generated if runsc is built with --collect_code_coverage and --instrumentation_filter Bazel flags.")
flag.Bool("log-packets", false, "enable network packet logging.")
flag.String("debug-log-format", "text", "log format: text (default), json, or json-k8s.")
flag.Bool("alsologtostderr", false, "send log messages to stderr.")