diff options
| author | Michael Pratt <mpratt@google.com> | 2018-12-21 07:58:27 -0800 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2018-12-21 18:08:49 +0100 |
| commit | 2fc01104d0081e0178522d3aa59938b7c3e0de57 (patch) | |
| tree | 8180b0801987ffe7241c4b492740d1d2ed0c7da8 /vm/vm_test.go | |
| parent | 588075e659832f8685d0c9dc9c75c461e023e77f (diff) | |
vm: allow Diagnose to directly return diagnosis
Rather than writing the diagnosis to the kernel console, Diagnose can
now directly return the extra debugging info, which will be appended ot
the kernel console log.
Diffstat (limited to 'vm/vm_test.go')
| -rw-r--r-- | vm/vm_test.go | 47 |
1 files changed, 35 insertions, 12 deletions
diff --git a/vm/vm_test.go b/vm/vm_test.go index 626ad62cb..ac86ad9c5 100644 --- a/vm/vm_test.go +++ b/vm/vm_test.go @@ -31,9 +31,10 @@ func (pool *testPool) Create(workdir string, index int) (vmimpl.Instance, error) } type testInstance struct { - outc chan []byte - errc chan error - diagnoseBug bool + outc chan []byte + errc chan error + diagnoseBug bool + diagnoseNoWait bool } func (inst *testInstance) Copy(hostSrc string) (string, error) { @@ -49,13 +50,20 @@ func (inst *testInstance) Run(timeout time.Duration, stop <-chan bool, command s return inst.outc, inst.errc, nil } -func (inst *testInstance) Diagnose() bool { +func (inst *testInstance) Diagnose() ([]byte, bool) { + var diag []byte if inst.diagnoseBug { - inst.outc <- []byte("BUG: DIAGNOSE\n") + diag = []byte("BUG: DIAGNOSE\n") } else { - inst.outc <- []byte("DIAGNOSE\n") + diag = []byte("DIAGNOSE\n") } - return true + + if inst.diagnoseNoWait { + return diag, false + } + + inst.outc <- diag + return nil, true } func (inst *testInstance) Close() { @@ -74,11 +82,12 @@ func init() { } type Test struct { - Name string - CanExit bool // if the program is allowed to exit normally - DiagnoseBug bool // Diagnose produces output that is detected as kernel crash - Body func(outc chan []byte, errc chan error) - Report *report.Report + Name string + CanExit bool // if the program is allowed to exit normally + DiagnoseBug bool // Diagnose produces output that is detected as kernel crash + DiagnoseNoWait bool // Diagnose returns output directly rather than to console + Body func(outc chan []byte, errc chan error) + Report *report.Report } var tests = []*Test{ @@ -121,6 +130,19 @@ var tests = []*Test{ }, }, { + Name: "diagnose-no-wait", + Body: func(outc chan []byte, errc chan error) { + errc <- nil + }, + DiagnoseNoWait: true, + Report: &report.Report{ + Title: lostConnectionCrash, + Output: []byte( + "DIAGNOSIS:\nDIAGNOSE\n", + ), + }, + }, + { Name: "kernel-crashes", Body: func(outc chan []byte, errc chan error) { outc <- []byte("BUG: bad\n") @@ -280,6 +302,7 @@ func testMonitorExecution(t *testing.T, test *Test) { } testInst := inst.impl.(*testInstance) testInst.diagnoseBug = test.DiagnoseBug + testInst.diagnoseNoWait = test.DiagnoseNoWait done := make(chan bool) go func() { test.Body(testInst.outc, testInst.errc) |
