Skip to content

Commit

Permalink
go-fuzz: add retrying to connect to coordinator
Browse files Browse the repository at this point in the history
  • Loading branch information
bayandin authored and dvyukov committed Aug 28, 2019
1 parent 1123d3b commit 1810d38
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 18 deletions.
17 changes: 14 additions & 3 deletions go-fuzz/hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
)

const (
syncPeriod = 3 * time.Second
syncDeadline = 100 * syncPeriod
syncPeriod = 3 * time.Second
syncDeadline = 100 * syncPeriod
connectionPollInterval = 100 * time.Millisecond

minScore = 1.0
maxScore = 1000.0
Expand Down Expand Up @@ -123,7 +124,17 @@ func newHub(metadata MetaData) *Hub {
}

func (hub *Hub) connect() error {
c, err := rpc.Dial("tcp", *flagWorker)
var c *rpc.Client
var err error

t := time.Now()
for {
c, err = rpc.Dial("tcp", *flagWorker)
if err == nil || time.Since(t) > *flagConnectionTimeout {
break
}
time.Sleep(connectionPollInterval)
}
if err != nil {
return err
}
Expand Down
31 changes: 16 additions & 15 deletions go-fuzz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,22 @@ import (
//go:generate rm go-bindata-assetfs

var (
flagWorkdir = flag.String("workdir", ".", "dir with persistent work data")
flagProcs = flag.Int("procs", runtime.NumCPU(), "parallelism level")
flagTimeout = flag.Int("timeout", 10, "test timeout, in seconds")
flagMinimize = flag.Duration("minimize", 1*time.Minute, "time limit for input minimization")
flagCoordinator = flag.String("coordinator", "", "coordinator mode (value is coordinator address)")
flagWorker = flag.String("worker", "", "worker mode (value is coordinator address)")
flagBin = flag.String("bin", "", "test binary built with go-fuzz-build")
flagFunc = flag.String("func", "", "function to fuzz")
flagDumpCover = flag.Bool("dumpcover", false, "dump coverage profile into workdir")
flagDup = flag.Bool("dup", false, "collect duplicate crashers")
flagTestOutput = flag.Bool("testoutput", false, "print test binary output to stdout (for debugging only)")
flagCoverCounters = flag.Bool("covercounters", true, "use coverage hit counters")
flagSonar = flag.Bool("sonar", true, "use sonar hints")
flagV = flag.Int("v", 0, "verbosity level")
flagHTTP = flag.String("http", "", "HTTP server listen address (coordinator mode only)")
flagWorkdir = flag.String("workdir", ".", "dir with persistent work data")
flagProcs = flag.Int("procs", runtime.NumCPU(), "parallelism level")
flagTimeout = flag.Int("timeout", 10, "test timeout, in seconds")
flagMinimize = flag.Duration("minimize", 1*time.Minute, "time limit for input minimization")
flagCoordinator = flag.String("coordinator", "", "coordinator mode (value is coordinator address)")
flagWorker = flag.String("worker", "", "worker mode (value is coordinator address)")
flagConnectionTimeout = flag.Duration("connectiontimeout", 1*time.Minute, "time limit for worker to try to connect coordinator")
flagBin = flag.String("bin", "", "test binary built with go-fuzz-build")
flagFunc = flag.String("func", "", "function to fuzz")
flagDumpCover = flag.Bool("dumpcover", false, "dump coverage profile into workdir")
flagDup = flag.Bool("dup", false, "collect duplicate crashers")
flagTestOutput = flag.Bool("testoutput", false, "print test binary output to stdout (for debugging only)")
flagCoverCounters = flag.Bool("covercounters", true, "use coverage hit counters")
flagSonar = flag.Bool("sonar", true, "use sonar hints")
flagV = flag.Int("v", 0, "verbosity level")
flagHTTP = flag.String("http", "", "HTTP server listen address (coordinator mode only)")

shutdown uint32
shutdownC = make(chan struct{})
Expand Down

0 comments on commit 1810d38

Please sign in to comment.