Print testbench log on packetimpact failures

These logs include flags passed to packetimpact tests (the Go tests), and test
failure messages.

PiperOrigin-RevId: 320989521
This commit is contained in:
Jay Zhuang 2020-07-13 10:56:51 -07:00 committed by gVisor bot
parent 7ff4649b3c
commit bafef1cf3a
1 changed files with 5 additions and 5 deletions

View File

@ -283,8 +283,8 @@ func TestOne(t *testing.T) {
// will issue a RST. To prevent this IPtables can be used to filter out all
// incoming packets. The raw socket that packetimpact tests use will still see
// everything.
if _, err := testbench.Exec(ctx, dockerutil.ExecOpts{}, "iptables", "-A", "INPUT", "-i", testNetDev, "-j", "DROP"); err != nil {
t.Fatalf("unable to Exec iptables on container %s: %s", testbench.Name, err)
if logs, err := testbench.Exec(ctx, dockerutil.ExecOpts{}, "iptables", "-A", "INPUT", "-i", testNetDev, "-j", "DROP"); err != nil {
t.Fatalf("unable to Exec iptables on container %s: %s, logs from testbench:\n%s", testbench.Name, err, logs)
}
// FIXME(b/156449515): Some piece of the system has a race. The old
@ -307,12 +307,12 @@ func TestOne(t *testing.T) {
"--device", testNetDev,
"--dut_type", *dutPlatform,
)
_, err = testbench.Exec(ctx, dockerutil.ExecOpts{}, testArgs...)
logs, err := testbench.Exec(ctx, dockerutil.ExecOpts{}, testArgs...)
if !*expectFailure && err != nil {
t.Fatal("test failed:", err)
t.Fatalf("test failed: %v, logs from testbench:\n%s", err, logs)
}
if *expectFailure && err == nil {
t.Fatal("test failure expected but the test succeeded, enable the test and mark the corresponding bug as fixed")
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)
}
}