cmd/dist: drop 3 minute timeout for a few packages that get close

This change drops the constant timeout from two packages where it's
been observed to be unhelpful. Applying this more widely is left to
subsequent changes.

For #79970.
Fixes #78392.

Change-Id: I2553fc959167acc1af2e55bb4649a724ebd0c5c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/789885
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@google.com>
diff --git a/src/cmd/dist/test.go b/src/cmd/dist/test.go
index 1d258fe..43ac003 100644
--- a/src/cmd/dist/test.go
+++ b/src/cmd/dist/test.go
@@ -78,7 +78,7 @@
 
 	tests        []distTest // use addTest to extend
 	testNames    map[string]bool
-	timeoutScale int
+	timeoutScale int // a non-negative integer factor to scale test timeout by; defaults to 1
 
 	worklist []*work
 }
@@ -573,9 +573,20 @@
 
 		timeoutSec := 180 * time.Second
 		for _, pkg := range stdMatches {
-			if pkg == "cmd/go" {
+			switch pkg {
+			case "cmd/go":
 				timeoutSec *= 3
-				break
+			case "cmd/cgo/internal/testshared":
+				// This package can take 2-3 minutes to test, so 3 min timeout causes
+				// flaky failures, like https://ci.chromium.org/b/8679277370961616529.
+				// Use the default timeout for it rather than the custom 3 minute one.
+				timeoutSec = 0
+			case "internal/godebugs":
+				// This package can take 5-6 minutes to test when the asan mode is on.
+				// The asan modifier scales the timeout by 2, but even 3*2 minutes is
+				// sometimes not enough. See go.dev/issue/78392.
+				// Use the default timeout for it rather than the custom 3 minute one.
+				timeoutSec = 0
 			}
 		}
 		return (&goTest{