aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/rpcserver/mocks
diff options
context:
space:
mode:
authorSabyrzhan Tasbolatov <snovitoll@gmail.com>2024-09-04 21:33:28 +0500
committerAleksandr Nogikh <nogikh@google.com>2024-09-09 16:49:28 +0000
commitcb2d8b3aef0920cbb5521f948e262598efc3fc1c (patch)
treea5dd2e30ebaa63b2835fa6656e8e7078054829a0 /pkg/rpcserver/mocks
parent10df4c09063bf091d9d003880e4d1044b0ec163d (diff)
pkg/rpcserver: add unit tests, Manager mocks
Added more test coverage of the package and created an interface of rpcserver to use it as the dependency (for syz-manager). Also tried to cover with tests a private method handleConn(), though it calls handleRunnerConn which has a separate logic in Handshake(), which within handleConn() unit test we should've mocked. This will require a refactoring of `runners map[int]*Runner` and runner.go in general with a separate interface which we can mock as well. General idea is to have interfaces of Server (rpc), Runner etc. and mock a compound logic like Handshake during a separate public (or private if it has callable, if-else logic) method unit-testing.
Diffstat (limited to 'pkg/rpcserver/mocks')
-rw-r--r--pkg/rpcserver/mocks/Manager.go127
1 files changed, 127 insertions, 0 deletions
diff --git a/pkg/rpcserver/mocks/Manager.go b/pkg/rpcserver/mocks/Manager.go
new file mode 100644
index 000000000..a5662ad89
--- /dev/null
+++ b/pkg/rpcserver/mocks/Manager.go
@@ -0,0 +1,127 @@
+// Code generated by mockery v2.40.3. DO NOT EDIT.
+
+package mocks
+
+import (
+ flatrpc "github.com/google/syzkaller/pkg/flatrpc"
+ mock "github.com/stretchr/testify/mock"
+
+ prog "github.com/google/syzkaller/prog"
+
+ queue "github.com/google/syzkaller/pkg/fuzzer/queue"
+
+ signal "github.com/google/syzkaller/pkg/signal"
+
+ vminfo "github.com/google/syzkaller/pkg/vminfo"
+)
+
+// Manager is an autogenerated mock type for the Manager type
+type Manager struct {
+ mock.Mock
+}
+
+// BugFrames provides a mock function with given fields:
+func (_m *Manager) BugFrames() ([]string, []string) {
+ ret := _m.Called()
+
+ if len(ret) == 0 {
+ panic("no return value specified for BugFrames")
+ }
+
+ var r0 []string
+ var r1 []string
+ if rf, ok := ret.Get(0).(func() ([]string, []string)); ok {
+ return rf()
+ }
+ if rf, ok := ret.Get(0).(func() []string); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]string)
+ }
+ }
+
+ if rf, ok := ret.Get(1).(func() []string); ok {
+ r1 = rf()
+ } else {
+ if ret.Get(1) != nil {
+ r1 = ret.Get(1).([]string)
+ }
+ }
+
+ return r0, r1
+}
+
+// CoverageFilter provides a mock function with given fields: modules
+func (_m *Manager) CoverageFilter(modules []*vminfo.KernelModule) []uint64 {
+ ret := _m.Called(modules)
+
+ if len(ret) == 0 {
+ panic("no return value specified for CoverageFilter")
+ }
+
+ var r0 []uint64
+ if rf, ok := ret.Get(0).(func([]*vminfo.KernelModule) []uint64); ok {
+ r0 = rf(modules)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).([]uint64)
+ }
+ }
+
+ return r0
+}
+
+// MachineChecked provides a mock function with given fields: features, syscalls
+func (_m *Manager) MachineChecked(features flatrpc.Feature, syscalls map[*prog.Syscall]bool) queue.Source {
+ ret := _m.Called(features, syscalls)
+
+ if len(ret) == 0 {
+ panic("no return value specified for MachineChecked")
+ }
+
+ var r0 queue.Source
+ if rf, ok := ret.Get(0).(func(flatrpc.Feature, map[*prog.Syscall]bool) queue.Source); ok {
+ r0 = rf(features, syscalls)
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(queue.Source)
+ }
+ }
+
+ return r0
+}
+
+// MaxSignal provides a mock function with given fields:
+func (_m *Manager) MaxSignal() signal.Signal {
+ ret := _m.Called()
+
+ if len(ret) == 0 {
+ panic("no return value specified for MaxSignal")
+ }
+
+ var r0 signal.Signal
+ if rf, ok := ret.Get(0).(func() signal.Signal); ok {
+ r0 = rf()
+ } else {
+ if ret.Get(0) != nil {
+ r0 = ret.Get(0).(signal.Signal)
+ }
+ }
+
+ return r0
+}
+
+// NewManager creates a new instance of Manager. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.
+// The first argument is typically a *testing.T value.
+func NewManager(t interface {
+ mock.TestingT
+ Cleanup(func())
+}) *Manager {
+ mock := &Manager{}
+ mock.Mock.Test(t)
+
+ t.Cleanup(func() { mock.AssertExpectations(t) })
+
+ return mock
+}