From 66fcb0a84fcd55ad8e1444cdd0bc0ad6592f7329 Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 1 Jul 2024 14:26:05 +0200 Subject: pkg/fuzzer: try to triage on different VMs Distribute triage requests to different VMs. --- pkg/fuzzer/queue/distributor_test.go | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 pkg/fuzzer/queue/distributor_test.go (limited to 'pkg/fuzzer/queue/distributor_test.go') 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)) +} -- cgit mrf-deployment