diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2024-07-01 14:26:05 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-08-02 13:16:51 +0000 |
| commit | 66fcb0a84fcd55ad8e1444cdd0bc0ad6592f7329 (patch) | |
| tree | 998e52d5569938e0251da1eb7c54c3746186b488 /pkg/fuzzer/queue/distributor_test.go | |
| parent | 1e9c4cf3ae82ef82220af312606fffe65e124563 (diff) | |
pkg/fuzzer: try to triage on different VMs
Distribute triage requests to different VMs.
Diffstat (limited to 'pkg/fuzzer/queue/distributor_test.go')
| -rw-r--r-- | pkg/fuzzer/queue/distributor_test.go | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/pkg/fuzzer/queue/distributor_test.go b/pkg/fuzzer/queue/distributor_test.go new file mode 100644 index 000000000..7bbf9c2e7 --- /dev/null +++ b/pkg/fuzzer/queue/distributor_test.go @@ -0,0 +1,48 @@ +// Copyright 2024 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 queue + +import ( + "testing" + + "github.com/stretchr/testify/assert" +) + +func TestDistributor(t *testing.T) { + q := Plain() + dist := Distribute(q) + + req := &Request{} + q.Submit(req) + assert.Equal(t, req, dist.Next(0)) + + q.Submit(req) + assert.Equal(t, req, dist.Next(1)) + + // Avoid VM 0. + req.Avoid = []ExecutorID{{VM: 0}} + q.Submit(req) + var noReq *Request + assert.Equal(t, noReq, dist.Next(0)) + assert.Equal(t, noReq, dist.Next(0)) + assert.Equal(t, req, dist.Next(1)) + + // If only VM 0 queries requests, it should eventually got it. + q.Submit(req) + assert.Equal(t, noReq, dist.Next(0)) + for { + got := dist.Next(0) + if got == req { + break + } + assert.Equal(t, noReq, got) + } + + // If all active VMs are in the avoid set, then they should get + // the request immidiatly. + assert.Equal(t, noReq, dist.Next(1)) + req.Avoid = []ExecutorID{{VM: 0}, {VM: 1}} + q.Submit(req) + assert.Equal(t, req, dist.Next(1)) +} |
