aboutsummaryrefslogtreecommitdiffstats
path: root/prog
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2021-12-21 14:23:50 +0100
committerDmitry Vyukov <dvyukov@google.com>2021-12-21 18:52:46 +0100
commitad097c94a04025c865b3956566ea5da7670ed437 (patch)
tree12a7efa8c65fa8fef91f33fb12d34d8f8f2023d7 /prog
parentc6f13480f3e562921f700b3e4f878ca5d54d958f (diff)
pkg/testutil: add package
Add package with RaceEnabled const that can be used in test to skip long tests in race mode. Switch existing tests to use the new package. Update #2886
Diffstat (limited to 'prog')
-rw-r--r--prog/decl_test.go4
-rw-r--r--prog/export_test.go6
-rw-r--r--prog/mutation_test.go6
-rw-r--r--prog/norace_test.go9
-rw-r--r--prog/prio_test.go4
-rw-r--r--prog/prog_test.go4
-rw-r--r--prog/race_test.go9
7 files changed, 17 insertions, 25 deletions
diff --git a/prog/decl_test.go b/prog/decl_test.go
index 6cec10e27..b041bf8e9 100644
--- a/prog/decl_test.go
+++ b/prog/decl_test.go
@@ -6,10 +6,12 @@ package prog
import (
"strings"
"testing"
+
+ "github.com/google/syzkaller/pkg/testutil"
)
func TestResourceCtors(t *testing.T) {
- if testing.Short() && raceEnabled {
+ if testing.Short() && testutil.RaceEnabled {
t.Skip("too slow")
}
testEachTarget(t, func(t *testing.T, target *Target) {
diff --git a/prog/export_test.go b/prog/export_test.go
index a007ed3ce..415b03047 100644
--- a/prog/export_test.go
+++ b/prog/export_test.go
@@ -9,6 +9,8 @@ import (
"os"
"testing"
"time"
+
+ "github.com/google/syzkaller/pkg/testutil"
)
// Export guts for testing.
@@ -37,7 +39,7 @@ func iterCount() int {
if testing.Short() {
iters /= 10
}
- if raceEnabled {
+ if testutil.RaceEnabled {
iters /= 10
}
return iters
@@ -88,7 +90,7 @@ func skipTargetRace(t *testing.T, target *Target) {
// Race execution is slow and we are getting timeouts on CI.
// For tests that run for all targets, leave only 2 targets,
// this should be enough to detect some races.
- if raceEnabled && (target.OS != "test" || target.Arch != "64" && target.Arch != "32") {
+ if testutil.RaceEnabled && (target.OS != "test" || target.Arch != "64" && target.Arch != "32") {
t.Skip("skipping all but test/64 targets in race mode")
}
}
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 6dfa15d63..a14719065 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -8,6 +8,8 @@ import (
"fmt"
"math/rand"
"testing"
+
+ "github.com/google/syzkaller/pkg/testutil"
)
func TestMutationFlags(t *testing.T) {
@@ -81,7 +83,7 @@ mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
}
func TestMutateArgument(t *testing.T) {
- if raceEnabled {
+ if testutil.RaceEnabled {
t.Skip("skipping in race mode, too slow")
}
tests := [][2]string{
@@ -391,7 +393,7 @@ func BenchmarkGenerate(b *testing.B) {
}
func runMutationTests(t *testing.T, tests [][2]string, valid bool) {
- if raceEnabled {
+ if testutil.RaceEnabled {
t.Skip("skipping in race mode, too slow")
}
target := initTargetTest(t, "test", "64")
diff --git a/prog/norace_test.go b/prog/norace_test.go
deleted file mode 100644
index 02b461925..000000000
--- a/prog/norace_test.go
+++ /dev/null
@@ -1,9 +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 prog
-
-const raceEnabled = false
diff --git a/prog/prio_test.go b/prog/prio_test.go
index 21eb7f147..3f2fbc2ce 100644
--- a/prog/prio_test.go
+++ b/prog/prio_test.go
@@ -7,6 +7,8 @@ import (
"math/rand"
"reflect"
"testing"
+
+ "github.com/google/syzkaller/pkg/testutil"
)
func TestNormalizePrio(t *testing.T) {
@@ -69,7 +71,7 @@ func TestStaticPriorities(t *testing.T) {
}
func TestPrioDeterminism(t *testing.T) {
- if raceEnabled {
+ if testutil.RaceEnabled {
t.Skip("skipping in race mode, too slow")
}
target, rs, iters := initTest(t)
diff --git a/prog/prog_test.go b/prog/prog_test.go
index 6586d1a1d..a21c464a0 100644
--- a/prog/prog_test.go
+++ b/prog/prog_test.go
@@ -9,6 +9,8 @@ import (
"math/rand"
"strings"
"testing"
+
+ "github.com/google/syzkaller/pkg/testutil"
)
func TestGeneration(t *testing.T) {
@@ -142,7 +144,7 @@ func TestVmaType(t *testing.T) {
// deserialized for another arch. This happens when managers exchange
// programs via hub.
func TestCrossTarget(t *testing.T) {
- if raceEnabled {
+ if testutil.RaceEnabled {
t.Skip("skipping in race mode, too slow")
}
t.Parallel()
diff --git a/prog/race_test.go b/prog/race_test.go
deleted file mode 100644
index 0c41a94f2..000000000
--- a/prog/race_test.go
+++ /dev/null
@@ -1,9 +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 prog
-
-const raceEnabled = true