Fuzz testing callbacks

This commit is contained in:
Thomas Jager 2015-07-31 08:30:21 +02:00
parent 8b3e6a50ac
commit c47f9d8e3d

13
irc.go
View File

@ -89,8 +89,10 @@ func (irc *Connection) readLoop() {
// +build gofuzz // +build gofuzz
func Fuzz(data []byte) int { func Fuzz(data []byte) int {
b := bytes.NewBuffer(data) b := bytes.NewBuffer(data)
err, _ := parseToEvent(b.String()) event, err := parseToEvent(b.String())
if err == nil { if err == nil {
irc := IRC("go-eventirc", "go-eventirc")
irc.RunCallbacks(event)
return 1 return 1
} }
return 0 return 0
@ -351,9 +353,12 @@ func (irc *Connection) Disconnect() {
for event := range irc.events { for event := range irc.events {
irc.ClearCallback(event) irc.ClearCallback(event)
} }
if irc.end != nil {
close(irc.end) close(irc.end)
close(irc.pwrite) }
if irc.pwrite != nil {
close(irc.pwrite)
}
irc.Wait() irc.Wait()
irc.socket.Close() irc.socket.Close()