aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/rpcserver/local.go
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/local.go
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/local.go')
-rw-r--r--pkg/rpcserver/local.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/pkg/rpcserver/local.go b/pkg/rpcserver/local.go
index e1522aa79..09cd1868d 100644
--- a/pkg/rpcserver/local.go
+++ b/pkg/rpcserver/local.go
@@ -47,8 +47,8 @@ func RunLocal(cfg *LocalConfig) error {
cfg: cfg,
setupDone: make(chan bool),
}
- serv, err := newImpl(cfg.Context, &cfg.Config, ctx)
- if err != nil {
+ serv := newImpl(cfg.Context, &cfg.Config, ctx)
+ if err := serv.Listen(); err != nil {
return err
}
defer serv.Close()
@@ -62,7 +62,7 @@ func RunLocal(cfg *LocalConfig) error {
defer serv.ShutdownInstance(id, true)
bin := cfg.Executor
- args := []string{"runner", fmt.Sprint(id), "localhost", fmt.Sprint(serv.Port)}
+ args := []string{"runner", fmt.Sprint(id), "localhost", fmt.Sprint(serv.Port())}
if cfg.GDB {
bin = "gdb"
args = append([]string{
@@ -107,7 +107,7 @@ func RunLocal(cfg *LocalConfig) error {
type local struct {
cfg *LocalConfig
- serv *Server
+ serv Server
setupDone chan bool
}