test: disable leakcheck after the first failure (#2563)

diff --git a/grpc_test.go b/grpc_test.go
index 30eac9a..5c132dd 100644
--- a/grpc_test.go
+++ b/grpc_test.go
@@ -19,6 +19,7 @@
 package grpc
 
 import (
+	"sync/atomic"
 	"testing"
 
 	"google.golang.org/grpc/internal/grpctest"
@@ -27,8 +28,25 @@
 
 type s struct{}
 
+var lcFailed uint32
+
+type errorer struct {
+	t *testing.T
+}
+
+func (e errorer) Errorf(format string, args ...interface{}) {
+	atomic.StoreUint32(&lcFailed, 1)
+	e.t.Errorf(format, args...)
+}
+
 func (s) Teardown(t *testing.T) {
-	leakcheck.Check(t)
+	if atomic.LoadUint32(&lcFailed) == 1 {
+		return
+	}
+	leakcheck.Check(errorer{t: t})
+	if atomic.LoadUint32(&lcFailed) == 1 {
+		t.Log("Leak check disabled for future tests")
+	}
 }
 
 func Test(t *testing.T) {
diff --git a/test/end2end_test.go b/test/end2end_test.go
index 4a8b57c..21479e7 100644
--- a/test/end2end_test.go
+++ b/test/end2end_test.go
@@ -80,8 +80,25 @@
 
 type s struct{}
 
+var lcFailed uint32
+
+type errorer struct {
+	t *testing.T
+}
+
+func (e errorer) Errorf(format string, args ...interface{}) {
+	atomic.StoreUint32(&lcFailed, 1)
+	e.t.Errorf(format, args...)
+}
+
 func (s) Teardown(t *testing.T) {
-	leakcheck.Check(t)
+	if atomic.LoadUint32(&lcFailed) == 1 {
+		return
+	}
+	leakcheck.Check(errorer{t: t})
+	if atomic.LoadUint32(&lcFailed) == 1 {
+		t.Log("Leak check disabled for future tests")
+	}
 }
 
 func Test(t *testing.T) {