fuzz.go
func (fc *FuzzedConnection) fuzz() bool {
	if !fc.shouldFuzz() {
		return false
	}

	switch fc.config.Mode {
	case FuzzModeDrop:
		// randomly drop the r/w, drop the conn, or sleep
		r := rand.Float64()
		if r <= fc.config.ProbDropRW {
			return true
		} else if r < fc.config.ProbDropRW+fc.config.ProbDropConn {
			// XXX: can't this fail because machine precision?
			// XXX: do we need an error?
			fc.Close()
			return true
		} else if r < fc.config.ProbDropRW+fc.config.ProbDropConn+fc.config.ProbSleep {
			time.Sleep(fc.randomDuration())
		}
	case FuzzModeDelay:
		// sleep a bit
		time.Sleep(fc.randomDuration())
	}
	return false
}
func (fc *FuzzedConnection) fuzz() bool {
	if !fc.shouldFuzz() {
		return false
	}

	switch fc.config.Mode {
	case FuzzModeDrop:
		// randomly drop the r/w, drop the conn, or sleep
		r := rand.Float64()
		if r <= fc.config.ProbDropRW {
			return true
		} else if r < fc.config.ProbDropRW+fc.config.ProbDropConn {
			// XXX: can't this fail because machine precision?
			// XXX: do we need an error?
			fc.Close()
			return true
		} else if r < fc.config.ProbDropRW+fc.config.ProbDropConn+fc.config.ProbSleep {
			time.Sleep(fc.randomDuration())
		}
	case FuzzModeDelay:
		// sleep a bit
		time.Sleep(fc.randomDuration())
	}
	return false
}
func ( fc * FuzzedConnection ) fuzz ( ) bool { if ! fc . shouldFuzz ( ) { return false } switch fc . config . Mode { case FuzzModeDrop : // randomly drop the r/w, drop the conn, or sleep r := rand . Float64 ( ) if r <= fc . config . ProbDropRW { return true } else if r < fc . config . ProbDropRW + fc . config . ProbDropConn { // XXX: can't this fail because machine precision? // XXX: do we need an error? fc . Close ( ) return true } else if r < fc . config . ProbDropRW + fc . config . ProbDropConn + fc . config . ProbSleep { time . Sleep ( fc . randomDuration ( ) ) } case FuzzModeDelay : // sleep a bit time . Sleep ( fc . randomDuration ( ) ) } return false }
// implements the fuzz (delay, kill conn)
// and returns whether or not the read/write should be ignored
implements the fuzz ( delay kill conn ) and returns whether or not the read / write should be ignored