aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2022-12-17 13:09:15 +0100
committerDmitry Vyukov <dvyukov@google.com>2022-12-22 10:11:08 +0100
commit71d483814b0f74e465d40e0059c0d733f0017cad (patch)
treef797746ee6c449a77f314084663fc45a03b0f8ce
parent4067838e6b16173af08e062ce434ecfc46d45bda (diff)
pkg/testutil: move iterCount from prog package
-rw-r--r--pkg/testutil/testutil.go11
-rw-r--r--prog/compression_test.go2
-rw-r--r--prog/export_test.go15
-rw-r--r--prog/heatmap_test.go2
-rw-r--r--prog/mutation_test.go2
5 files changed, 16 insertions, 16 deletions
diff --git a/pkg/testutil/testutil.go b/pkg/testutil/testutil.go
index 566d728ef..67dee7ddf 100644
--- a/pkg/testutil/testutil.go
+++ b/pkg/testutil/testutil.go
@@ -11,6 +11,17 @@ import (
"time"
)
+func IterCount() int {
+ iters := 1000
+ if testing.Short() {
+ iters /= 10
+ }
+ if RaceEnabled {
+ iters /= 10
+ }
+ return iters
+}
+
func RandSource(t *testing.T) rand.Source {
seed := time.Now().UnixNano()
if fixed := os.Getenv("SYZ_SEED"); fixed != "" {
diff --git a/prog/compression_test.go b/prog/compression_test.go
index 351d06500..db5d95070 100644
--- a/prog/compression_test.go
+++ b/prog/compression_test.go
@@ -29,7 +29,7 @@ func TestEncode(t *testing.T) {
}
func testRoundTrip(r *rand.Rand, transform func([]byte) []byte, inverse func([]byte) ([]byte, error)) error {
- for i := 0; i < iterCount(); i++ {
+ for i := 0; i < testutil.IterCount(); i++ {
randBytes := testutil.RandMountImage(r)
resultBytes := transform(randBytes)
resultBytes, err := inverse(resultBytes)
diff --git a/prog/export_test.go b/prog/export_test.go
index e544103c1..54992dba1 100644
--- a/prog/export_test.go
+++ b/prog/export_test.go
@@ -23,20 +23,9 @@ var (
initTargetTest = InitTargetTest
)
-func iterCount() int {
- iters := 1000
- if testing.Short() {
- iters /= 10
- }
- if testutil.RaceEnabled {
- iters /= 10
- }
- return iters
-}
-
func initRandomTargetTest(t *testing.T, os, arch string) (*Target, rand.Source, int) {
target := initTargetTest(t, os, arch)
- return target, testutil.RandSource(t), iterCount()
+ return target, testutil.RandSource(t), testutil.IterCount()
}
func initTest(t *testing.T) (*Target, rand.Source, int) {
@@ -58,7 +47,7 @@ func testEachTarget(t *testing.T, fn func(t *testing.T, target *Target)) {
func testEachTargetRandom(t *testing.T, fn func(t *testing.T, target *Target, rs rand.Source, iters int)) {
t.Parallel()
targets := AllTargets()
- iters := iterCount()
+ iters := testutil.IterCount()
iters /= len(targets)
if iters < 3 {
iters = 3
diff --git a/prog/heatmap_test.go b/prog/heatmap_test.go
index 9c891f258..a981945ea 100644
--- a/prog/heatmap_test.go
+++ b/prog/heatmap_test.go
@@ -48,7 +48,7 @@ func TestGenericHeatmap(t *testing.T) {
}
const tries = 10
- iters := iterCount() / tries
+ iters := testutil.IterCount() / tries
r := rand.New(testutil.RandSource(t))
for _, test := range testData {
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 0c084d1fe..11e3a4933 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -416,7 +416,7 @@ func runMutationTests(t *testing.T, tests [][2]string, valid bool) {
t.Fatalf("failed to deserialize the program: %v", err)
}
want := goal.Serialize()
- iters := iterCount()
+ iters := testutil.IterCount()
if valid {
iters = 1e6 // it will stop after reaching the goal
}