aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--syz-verifier/exectask.go14
-rw-r--r--syz-verifier/exectask_test.go71
2 files changed, 1 insertions, 84 deletions
diff --git a/syz-verifier/exectask.go b/syz-verifier/exectask.go
index db947cbcd..052469ed7 100644
--- a/syz-verifier/exectask.go
+++ b/syz-verifier/exectask.go
@@ -66,12 +66,6 @@ func MakeExecTask(prog *prog.Prog) *ExecTask {
return task
}
-func ExecTasksQueued() int {
- ChanMapMutex.Lock()
- defer ChanMapMutex.Unlock()
- return len(TaskIDToExecResultChan)
-}
-
func DeleteExecTask(task *ExecTask) {
ChanMapMutex.Lock()
defer ChanMapMutex.Unlock()
@@ -94,28 +88,22 @@ func MakeExecTaskQueue() *ExecTaskQueue {
// ExecTaskQueue respects the pq.priority. Internally it is a thread-safe PQ.
type ExecTaskQueue struct {
pq ExecTaskPriorityQueue
- mu sync.Mutex
}
// PopTask return false if no tasks are available.
func (q *ExecTaskQueue) PopTask() (*ExecTask, bool) {
- q.mu.Lock()
- defer q.mu.Unlock()
if q.pq.Len() == 0 {
return nil, false
}
+
return heap.Pop(&q.pq).(*ExecTask), true
}
func (q *ExecTaskQueue) PushTask(task *ExecTask) {
- q.mu.Lock()
- defer q.mu.Unlock()
heap.Push(&q.pq, task)
}
func (q *ExecTaskQueue) Len() int {
- q.mu.Lock()
- defer q.mu.Unlock()
return q.pq.Len()
}
diff --git a/syz-verifier/exectask_test.go b/syz-verifier/exectask_test.go
deleted file mode 100644
index af7825bda..000000000
--- a/syz-verifier/exectask_test.go
+++ /dev/null
@@ -1,71 +0,0 @@
-// Copyright 2022 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 main
-
-import (
- "testing"
-)
-
-func TestExecTask_MakeDelete(t *testing.T) {
- program := getTestProgram(t)
- if l := ExecTasksQueued(); l != 0 {
- t.Errorf("expected to see empty map, current size is %v", l)
- }
- task := MakeExecTask(program)
- if l := ExecTasksQueued(); l != 1 {
- t.Errorf("expected map len is 0, current size is %v", l)
- }
- DeleteExecTask(task)
- if l := ExecTasksQueued(); l != 0 {
- t.Errorf("expected map len is 0, current size is %v", l)
- }
-}
-
-func TestExecTask_ToRPC(t *testing.T) {
- program := getTestProgram(t)
- task := MakeExecTask(program)
- if task.ToRPC() == nil {
- t.Errorf("rpcView generation failed")
- }
-}
-
-func TestGetExecResultChan(t *testing.T) {
- if l := ExecTasksQueued(); l != 0 {
- t.Errorf("expected to see empty map, current size is %v", l)
- }
- ch := GetExecResultChan(100)
- if l := ExecTasksQueued(); l != 0 {
- t.Errorf("expected to see empty map, current size is %v", l)
- }
- if ch != nil {
- t.Errorf("expected to see nil channel")
- }
-}
-
-func TestExecTaskQueue_PushTask(t *testing.T) {
- q := MakeExecTaskQueue()
- if l := q.Len(); l != 0 {
- t.Errorf("expected to see zero len, current is %v", l)
- }
- q.PushTask(MakeExecTask(getTestProgram(t)))
- if l := q.Len(); l != 1 {
- t.Errorf("expected to see single element, current size is %v", l)
- }
-}
-
-func TestExecTaskQueue_PopTask(t *testing.T) {
- q := MakeExecTaskQueue()
- task, gotResult := q.PopTask()
- if task != nil || gotResult != false {
- t.Errorf("empty queue operation error")
- }
- program := getTestProgram(t)
- q.PushTask(MakeExecTask(program))
- q.PushTask(MakeExecTask(program))
- q.PushTask(MakeExecTask(program))
- task, gotResult = q.PopTask()
- if task == nil || gotResult == false {
- t.Errorf("non-empty task or error was expected")
- }
-}