diff options
| author | Aleksandr Nogikh <nogikh@google.com> | 2024-05-03 13:12:00 +0200 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2024-05-16 15:38:27 +0000 |
| commit | 03820adaef911ce08278d95f034f134c3c0c852e (patch) | |
| tree | 57f87ce0f3dedda459fb1771d3b79ff96e0853bb /pkg/fuzzer/prio_queue_test.go | |
| parent | ef5d53ed7e3c7d30481a88301f680e37a5cc4775 (diff) | |
pkg/fuzzer: use queue layers
Instead of relying on a fuzzer-internal priority queue, utilize
stackable layers of request-generating steps.
Move the functionality to a separate pkg/fuzzer/queue package.
The pkg/fuzzer/queue package can be reused to add extra processing
layers on top of the fuzzing and to combine machine checking and fuzzing
execution pipelines.
Diffstat (limited to 'pkg/fuzzer/prio_queue_test.go')
| -rw-r--r-- | pkg/fuzzer/prio_queue_test.go | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/pkg/fuzzer/prio_queue_test.go b/pkg/fuzzer/prio_queue_test.go deleted file mode 100644 index 3b5b87105..000000000 --- a/pkg/fuzzer/prio_queue_test.go +++ /dev/null @@ -1,59 +0,0 @@ -// 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 fuzzer - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "golang.org/x/sync/errgroup" -) - -func TestPriority(t *testing.T) { - assert.True(t, priority{1, 2}.greaterThan(priority{1, 1})) - assert.True(t, priority{3, 2}.greaterThan(priority{2, 3})) - assert.True(t, priority{1, -5}.greaterThan(priority{1, -10})) - assert.True(t, priority{1}.greaterThan(priority{1, -1})) - assert.False(t, priority{1}.greaterThan(priority{1, 1})) -} - -func TestPrioQueueOrder(t *testing.T) { - pq := makePriorityQueue[int]() - assert.Nil(t, pq.tryPop()) - - pq.push(&priorityQueueItem[int]{value: 1, prio: priority{1}}) - pq.push(&priorityQueueItem[int]{value: 3, prio: priority{3}}) - pq.push(&priorityQueueItem[int]{value: 2, prio: priority{2}}) - - assert.Equal(t, 3, pq.tryPop().value) - assert.Equal(t, 2, pq.tryPop().value) - assert.Equal(t, 1, pq.tryPop().value) - assert.Nil(t, pq.tryPop()) - assert.Zero(t, pq.Len()) -} - -func TestPrioQueueRace(t *testing.T) { - var eg errgroup.Group - pq := makePriorityQueue[int]() - - // Two writers. - for writer := 0; writer < 2; writer++ { - eg.Go(func() error { - for i := 0; i < 1000; i++ { - pq.push(&priorityQueueItem[int]{value: 10, prio: priority{1}}) - } - return nil - }) - } - // Two readers. - for reader := 0; reader < 2; reader++ { - eg.Go(func() error { - for i := 0; i < 1000; i++ { - pq.tryPop() - } - return nil - }) - } - eg.Wait() -} |
