diff options
author | Jay Zhuang <jayzhuang@google.com> | 2020-07-17 11:17:20 -0700 |
---|---|---|
committer | gVisor bot <gvisor-bot@google.com> | 2020-07-17 11:18:40 -0700 |
commit | 40826b0557fc3af642236c427863d25239e7c620 (patch) | |
tree | c032951954b6392e96afbd256e55508acd5002f9 /test/packetimpact/runner | |
parent | c0ee95198ae4753d02e26e9fbf5341c1d047d9c1 (diff) |
DUT logs in test failure messages in packetimpact
DUT logs will include logs from the posix server and gVisor, which
provides a way to instrument the DUT during test failures.
PiperOrigin-RevId: 321816647
Diffstat (limited to 'test/packetimpact/runner')
-rw-r--r-- | test/packetimpact/runner/packetimpact_test.go | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/test/packetimpact/runner/packetimpact_test.go b/test/packetimpact/runner/packetimpact_test.go index 1a99719c2..ff5f5c7f1 100644 --- a/test/packetimpact/runner/packetimpact_test.go +++ b/test/packetimpact/runner/packetimpact_test.go @@ -308,12 +308,29 @@ func TestOne(t *testing.T) { "--device", testNetDev, "--dut_type", *dutPlatform, ) - logs, err := testbench.Exec(ctx, dockerutil.ExecOpts{}, testArgs...) - if !*expectFailure && err != nil { - t.Fatalf("test failed: %v, logs from testbench:\n%s", err, logs) - } - if *expectFailure && err == nil { - t.Fatalf("test failure expected but the test succeeded, enable the test and mark the corresponding bug as fixed, logs from testbench:\n%s", logs) + testbenchLogs, err := testbench.Exec(ctx, dockerutil.ExecOpts{}, testArgs...) + if (err != nil) != *expectFailure { + var dutLogs string + if logs, err := dut.Logs(ctx); err != nil { + dutLogs = fmt.Sprintf("failed to fetch DUT logs: %s", err) + } else { + dutLogs = logs + } + + t.Errorf(`test error: %v, expect failure: %t + +====== Begin of DUT Logs ====== + +%s + +====== End of DUT Logs ====== + +====== Begin of Testbench Logs ====== + +%s + +====== End of Testbench Logs ======`, + err, *expectFailure, dutLogs, testbenchLogs) } } |