diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-05-04 08:58:32 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-05-04 20:56:20 +0200 |
| commit | a4d38b39a8e23244bea7a53e9d7a759474f85dae (patch) | |
| tree | 6bdb1f795fc5b670c9d2bad96599820cdb1eea85 /prog/prio_test.go | |
| parent | 58ae5e18624eaaac79cab00e63d6f32c9bd64ee0 (diff) | |
prog: support disabled attribute
Update #477
Update #502
Diffstat (limited to 'prog/prio_test.go')
| -rw-r--r-- | prog/prio_test.go | 36 |
1 files changed, 2 insertions, 34 deletions
diff --git a/prog/prio_test.go b/prog/prio_test.go index 2fd059910..29ffa26d7 100644 --- a/prog/prio_test.go +++ b/prog/prio_test.go @@ -7,8 +7,6 @@ import ( "math/rand" "reflect" "testing" - - "github.com/google/go-cmp/cmp" ) func TestNormalizePrio(t *testing.T) { @@ -30,36 +28,6 @@ func TestNormalizePrio(t *testing.T) { } } -// TestPrioChoice tests that we select all syscalls with equal probability. -func TestPrioChoice(t *testing.T) { - t.Parallel() - target := &Target{ - Syscalls: []*Syscall{ - {ID: 0}, - {ID: 1}, - {ID: 2}, - {ID: 3}, - }, - } - prios := [][]float32{ - {1, 1, 1, 1}, - {1, 1, 1, 1}, - {1, 1, 1, 1}, - {1, 1, 1, 1}, - } - ct := target.BuildChoiceTable(prios, nil) - r := rand.New(rand.NewSource(0)) - var res [4]int - for i := 0; i < 10000; i++ { - res[ct.Choose(r, 0)]++ - } - // If this fails too frequently we can do some ranges, but for now it's just hardcoded. - want := [4]int{2552, 2459, 2491, 2498} - if diff := cmp.Diff(res, want); diff != "" { - t.Fatal(diff) - } -} - // Test static priorities assigned based on argument direction. func TestStaticPriorities(t *testing.T) { target, rs, iters := initTest(t) @@ -73,7 +41,7 @@ func TestStaticPriorities(t *testing.T) { {"open", "read", "write", "mmap"}, {"socket", "listen", "setsockopt"}, } - ct := target.BuildChoiceTable(target.CalculatePriorities(nil), nil) + ct := target.DefaultChoiceTable() r := rand.New(rs) for _, syscalls := range tests { // Counts the number of times a call is chosen after a call that creates a resource (referenceCall). @@ -82,7 +50,7 @@ func TestStaticPriorities(t *testing.T) { for _, call := range syscalls { count := 0 for it := 0; it < iters*10000; it++ { - chosenCall := target.Syscalls[ct.Choose(r, target.SyscallMap[call].ID)].Name + chosenCall := target.Syscalls[ct.choose(r, target.SyscallMap[call].ID)].Name if call == referenceCall { counter[chosenCall]++ } else if chosenCall == referenceCall { |
