summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJosh Bleecher Snyder <josh@tailscale.com>2021-02-09 08:18:47 -0800
committerJason A. Donenfeld <Jason@zx2c4.com>2021-02-09 18:28:58 +0100
commitd117d42ae74d276cd986337d218bd9f4220c789e (patch)
tree004bc64db2060622314b2bcee14e818d4b62cbd5
parentecceaadd168ce682695acf1a5c004ef89e4927eb (diff)
device: run fewer trials in TestWaitPool when race detector enabled
On a many-core machine with the race detector enabled, this test can take several minutes to complete. Signed-off-by: Josh Bleecher Snyder <josh@tailscale.com>
-rw-r--r--device/pools_test.go4
-rw-r--r--device/race_disabled_test.go10
-rw-r--r--device/race_enabled_test.go10
3 files changed, 24 insertions, 0 deletions
diff --git a/device/pools_test.go b/device/pools_test.go
index a27ccc0..717072f 100644
--- a/device/pools_test.go
+++ b/device/pools_test.go
@@ -17,6 +17,10 @@ import (
func TestWaitPool(t *testing.T) {
var wg sync.WaitGroup
trials := int32(100000)
+ if raceEnabled {
+ // This test can be very slow with -race.
+ trials /= 10
+ }
workers := runtime.NumCPU() + 2
if workers-4 <= 0 {
t.Skip("Not enough cores")
diff --git a/device/race_disabled_test.go b/device/race_disabled_test.go
new file mode 100644
index 0000000..65fac7e
--- /dev/null
+++ b/device/race_disabled_test.go
@@ -0,0 +1,10 @@
+//+build !race
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package device
+
+const raceEnabled = false
diff --git a/device/race_enabled_test.go b/device/race_enabled_test.go
new file mode 100644
index 0000000..f8ccac3
--- /dev/null
+++ b/device/race_enabled_test.go
@@ -0,0 +1,10 @@
+//+build race
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package device
+
+const raceEnabled = true