aboutsummaryrefslogtreecommitdiffstats
path: root/syz-verifier
diff options
context:
space:
mode:
authorTaras Madan <tarasmadan@google.com>2022-03-30 15:47:47 +0200
committerGitHub <noreply@github.com>2022-03-30 15:47:47 +0200
commit9d49f3a7c56a414597a16f28dd8b6b2be6352ad8 (patch)
treedcba4852fbcedca01e8de47e52ba0a3a9f20c353 /syz-verifier
parent42718dd659525414aa0bf2794688ac94a32f7764 (diff)
Revert "syz-verifier/exectask.go: add tests" (#3050)
This reverts commit 42718dd659525414aa0bf2794688ac94a32f7764. Original PR had a race.
Diffstat (limited to 'syz-verifier')
-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")
- }
-}