]> git.ipfire.org Git - thirdparty/wireguard-go.git/commitdiff
device: run fewer trials in TestWaitPool when race detector enabled
authorJosh Bleecher Snyder <josh@tailscale.com>
Tue, 9 Feb 2021 16:18:47 +0000 (08:18 -0800)
committerJason A. Donenfeld <Jason@zx2c4.com>
Tue, 9 Feb 2021 17:28:58 +0000 (18:28 +0100)
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>
device/pools_test.go
device/race_disabled_test.go [new file with mode: 0644]
device/race_enabled_test.go [new file with mode: 0644]

index a27ccc0e0ff8707971ac5642542b3294c43a83e1..717072f69c65001728ebdf3d2d7041190fd4dafd 100644 (file)
@@ -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 (file)
index 0000000..65fac7e
--- /dev/null
@@ -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 (file)
index 0000000..f8ccac3
--- /dev/null
@@ -0,0 +1,10 @@
+//+build race
+
+/* SPDX-License-Identifier: MIT
+ *
+ * Copyright (C) 2017-2021 WireGuard LLC. All Rights Reserved.
+ */
+
+package device
+
+const raceEnabled = true