aboutsummaryrefslogtreecommitdiffstats
path: root/pkg
diff options
context:
space:
mode:
Diffstat (limited to 'pkg')
-rw-r--r--pkg/csource/csource_test.go14
-rw-r--r--pkg/csource/race_test.go24
-rw-r--r--pkg/testutil/norace.go9
-rw-r--r--pkg/testutil/race.go9
4 files changed, 32 insertions, 24 deletions
diff --git a/pkg/csource/csource_test.go b/pkg/csource/csource_test.go
index fc3b21573..91bd2cccf 100644
--- a/pkg/csource/csource_test.go
+++ b/pkg/csource/csource_test.go
@@ -14,11 +14,25 @@ import (
"testing"
"time"
+ "github.com/google/syzkaller/pkg/testutil"
"github.com/google/syzkaller/prog"
_ "github.com/google/syzkaller/sys"
"github.com/google/syzkaller/sys/targets"
)
+func init() {
+ // csource tests consume too much memory under race detector (>1GB),
+ // and periodically timeout on Travis. So we skip them.
+ if testutil.RaceEnabled {
+ for _, arg := range os.Args[1:] {
+ if strings.Contains(arg, "-test.short") {
+ fmt.Printf("skipping race testing in short mode\n")
+ os.Exit(0)
+ }
+ }
+ }
+}
+
func TestGenerate(t *testing.T) {
t.Parallel()
checked := make(map[string]bool)
diff --git a/pkg/csource/race_test.go b/pkg/csource/race_test.go
deleted file mode 100644
index c41cef5d3..000000000
--- a/pkg/csource/race_test.go
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2018 syzkaller project authors. All rights reserved.
-// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
-
-//go:build race
-// +build race
-
-package csource
-
-import (
- "fmt"
- "os"
- "strings"
-)
-
-func init() {
- // csource tests consume too much memory under race detector (>1GB),
- // and periodically timeout on Travis. So we skip them.
- for _, arg := range os.Args[1:] {
- if strings.Contains(arg, "-test.short") {
- fmt.Printf("skipping race testing in short mode\n")
- os.Exit(0)
- }
- }
-}
diff --git a/pkg/testutil/norace.go b/pkg/testutil/norace.go
new file mode 100644
index 000000000..ceb03928f
--- /dev/null
+++ b/pkg/testutil/norace.go
@@ -0,0 +1,9 @@
+// Copyright 2018 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+//go:build !race
+// +build !race
+
+package testutil
+
+const RaceEnabled = false
diff --git a/pkg/testutil/race.go b/pkg/testutil/race.go
new file mode 100644
index 000000000..96a9043bb
--- /dev/null
+++ b/pkg/testutil/race.go
@@ -0,0 +1,9 @@
+// Copyright 2018 syzkaller project authors. All rights reserved.
+// Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
+
+//go:build race
+// +build race
+
+package testutil
+
+const RaceEnabled = true