From 52a33fd516102a98d3753bf69417235b655a68dc Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Thu, 14 Sep 2017 19:25:01 +0200 Subject: 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. --- prog/encoding_test.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'prog/encoding_test.go') 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) -- cgit mrf-deployment