diff --git a/test/iptables/BUILD b/test/iptables/BUILD index 5f6bf600b..3de0d7549 100644 --- a/test/iptables/BUILD +++ b/test/iptables/BUILD @@ -38,6 +38,7 @@ go_test( "manual", ], deps = [ + "//pkg/log", "//pkg/test/dockerutil", "//pkg/test/testutil", ], diff --git a/test/iptables/iptables_test.go b/test/iptables/iptables_test.go index 6827314b2..7b656b708 100644 --- a/test/iptables/iptables_test.go +++ b/test/iptables/iptables_test.go @@ -23,6 +23,7 @@ import ( "sync" "testing" + "gvisor.dev/gvisor/pkg/log" "gvisor.dev/gvisor/pkg/test/dockerutil" "gvisor.dev/gvisor/pkg/test/testutil" ) @@ -50,7 +51,8 @@ func singleTest(t *testing.T, test TestCase) { func iptablesTest(t *testing.T, test TestCase, ipv6 bool) { if _, ok := Tests[test.Name()]; !ok { - t.Fatalf("no test found with name %q. Has it been registered?", test.Name()) + log.Infof("no test found with name %q. Has it been registered?", test.Name()) + t.FailNow() } // Wait for the local and container goroutines to finish. @@ -63,9 +65,9 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) { d := dockerutil.MakeContainer(ctx, t) defer func() { if logs, err := d.Logs(context.Background()); err != nil { - t.Logf("Failed to retrieve container logs.") + log.Infof("Failed to retrieve container logs.") } else { - t.Logf("=== Container logs: ===\n%s", logs) + log.Infof("=== Container logs: ===\n%s", logs) } // Use a new context, as cleanup should run even when we // timeout. @@ -83,7 +85,8 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) { args = append(args, "-ipv6") } if err := d.Spawn(ctx, opts, args...); err != nil { - t.Fatalf("docker run failed: %v", err) + log.Infof("docker run failed: %v", err) + t.FailNow() } // Get the container IP. @@ -91,14 +94,17 @@ func iptablesTest(t *testing.T, test TestCase, ipv6 bool) { if err != nil { // If ipv6 is not configured, don't fail. if ipv6 && err == dockerutil.ErrNoIP { - t.Skipf("No ipv6 address is available.") + log.Infof("No ipv6 address is available.") + t.Skip() } - t.Fatalf("failed to get container IP: %v", err) + log.Infof("failed to get container IP: %v", err) + t.FailNow() } // Give the container our IP. if err := sendIP(ip); err != nil { - t.Fatalf("failed to send IP to container: %v", err) + log.Infof("failed to send IP to container: %v", err) + t.FailNow() } // Run our side of the test.