aboutsummaryrefslogtreecommitdiffstats
path: root/vm
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2024-06-28 13:46:53 +0200
committerAleksandr Nogikh <nogikh@google.com>2024-07-01 09:13:47 +0000
commita7b22031cdbe8555ef6d4a086bd11dbc9feea4fd (patch)
treeb678f59c9f269de3f5330a1d8ddf38c6afbb7656 /vm
parentce1ad06980f78675067a2519a76601cb6cdc692b (diff)
vmimpl: add a delay after an error from the tracked process
It usually means a kernel crash, in which case we want to give the kernel some more time to print the whole coverage report to the console.
Diffstat (limited to 'vm')
-rw-r--r--vm/vm.go5
-rw-r--r--vm/vm_test.go2
-rw-r--r--vm/vmimpl/vmimpl.go5
3 files changed, 8 insertions, 4 deletions
diff --git a/vm/vm.go b/vm/vm.go
index 6f66f8a37..879fc8feb 100644
--- a/vm/vm.go
+++ b/vm/vm.go
@@ -437,7 +437,7 @@ func (mon *monitor) createReport(defaultError string) *report.Report {
}
func (mon *monitor) waitForOutput() {
- timer := time.NewTimer(waitForOutputTimeout * mon.inst.pool.timeouts.Scale)
+ timer := time.NewTimer(vmimpl.WaitForOutputTimeout * mon.inst.pool.timeouts.Scale)
defer timer.Stop()
for {
select {
@@ -470,6 +470,5 @@ var (
beforeContextDefault = 128 << 10
afterContext = 128 << 10
- tickerPeriod = 10 * time.Second
- waitForOutputTimeout = 10 * time.Second
+ tickerPeriod = 10 * time.Second
)
diff --git a/vm/vm_test.go b/vm/vm_test.go
index afb8634bd..357f037d5 100644
--- a/vm/vm_test.go
+++ b/vm/vm_test.go
@@ -75,7 +75,7 @@ func (inst *testInstance) Close() {
func init() {
beforeContextDefault = maxErrorLength + 100
tickerPeriod = 1 * time.Second
- waitForOutputTimeout = 3 * time.Second
+ vmimpl.WaitForOutputTimeout = 3 * time.Second
ctor := func(env *vmimpl.Env) (vmimpl.Pool, error) {
return &testPool{}, nil
diff --git a/vm/vmimpl/vmimpl.go b/vm/vmimpl/vmimpl.go
index be7186889..00a815314 100644
--- a/vm/vmimpl/vmimpl.go
+++ b/vm/vmimpl/vmimpl.go
@@ -146,6 +146,8 @@ var (
Types = make(map[string]Type)
)
+var WaitForOutputTimeout = 10 * time.Second
+
func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout time.Duration,
stop, closed <-chan bool, debug bool) (<-chan []byte, <-chan error, error) {
errc := make(chan error, 1)
@@ -168,6 +170,9 @@ func Multiplex(cmd *exec.Cmd, merger *OutputMerger, console io.Closer, timeout t
signal(fmt.Errorf("instance closed"))
case err := <-merger.Err:
cmd.Process.Kill()
+ // Once the command has exited, we might want to let the full console
+ // output accumulate before we abort the console connection too.
+ time.Sleep(WaitForOutputTimeout)
if console != nil {
// Only wait for the merger if we're able to control the console stream.
console.Close()