aboutsummaryrefslogtreecommitdiffstats
path: root/prog/encoding_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2017-09-14 19:25:01 +0200
committerDmitry Vyukov <dvyukov@google.com>2017-09-15 16:02:37 +0200
commit52a33fd516102a98d3753bf69417235b655a68dc (patch)
tree351ab73db934d3b4e4babbe27e8801c659f2631b /prog/encoding_test.go
parent25f4fe0662f7f3b390d16b2e786f2ba0aa0293f1 (diff)
prog: remove default target and all global state
Now each prog function accepts the desired target explicitly. No global, implicit state involved. This is much cleaner and allows cross-OS/arch testing, etc.
Diffstat (limited to 'prog/encoding_test.go')
-rw-r--r--prog/encoding_test.go12
1 files changed, 5 insertions, 7 deletions
diff --git a/prog/encoding_test.go b/prog/encoding_test.go
index c58fe7dc8..8b7b84a2d 100644
--- a/prog/encoding_test.go
+++ b/prog/encoding_test.go
@@ -1,7 +1,7 @@
// Copyright 2016 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.
-package prog_test
+package prog
import (
"fmt"
@@ -9,9 +9,6 @@ import (
"regexp"
"sort"
"testing"
-
- . "github.com/google/syzkaller/prog"
- _ "github.com/google/syzkaller/sys"
)
func setToArray(s map[string]struct{}) []string {
@@ -79,9 +76,9 @@ func TestCallSet(t *testing.T) {
}
func TestCallSetRandom(t *testing.T) {
- rs, iters := InitTest(t)
+ target, rs, iters := initTest(t)
for i := 0; i < iters; i++ {
- p := Generate(rs, 10, nil)
+ p := target.Generate(rs, 10, nil)
calls0 := make(map[string]struct{})
for _, c := range p.Calls {
calls0[c.Meta.Name] = struct{}{}
@@ -99,6 +96,7 @@ func TestCallSetRandom(t *testing.T) {
}
func TestDeserialize(t *testing.T) {
+ target, _, _ := initTest(t)
tests := []struct {
data string
err *regexp.Regexp
@@ -113,7 +111,7 @@ func TestDeserialize(t *testing.T) {
},
}
for _, test := range tests {
- _, err := Deserialize([]byte(test.data))
+ _, err := target.Deserialize([]byte(test.data))
if err != nil {
if test.err == nil {
t.Fatalf("deserialization failed with\n%s\ndata:\n%s\n", err, test.data)