From 69f53eb622e0f41d0e91debd71d6694148b52a30 Mon Sep 17 00:00:00 2001 From: Austin Clements Date: Sat, 25 Jul 2015 00:13:09 -0400 Subject: [PATCH] cmd/stress: add "-ignore regexp" flag This adds a flag for specifying a regular expression for failures that should be ignored. This is useful for filtering out known issues and provides a logical mirror to the existing -failure flag. Change-Id: Ibbacdd2125aa23fe819896e5a17664b703c4ee35 Reviewed-on: https://go-review.googlesource.com/12676 Reviewed-by: Dmitry Vyukov --- cmd/stress/stress.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/cmd/stress/stress.go b/cmd/stress/stress.go index 9aebbf6d..f02fa2a7 100644 --- a/cmd/stress/stress.go +++ b/cmd/stress/stress.go @@ -29,6 +29,7 @@ var ( flagTimeout = flag.Duration("timeout", 10*time.Minute, "timeout each process after `duration`") flagKill = flag.Bool("kill", true, "kill timed out processes if true, otherwise just print pid (to attach with gdb)") flagFailure = flag.String("failure", "", "fail only if output matches `regexp`") + flagIgnore = flag.String("ignore", "", "ignore failure if output matches `regexp`") ) func main() { @@ -37,7 +38,7 @@ func main() { flag.Usage() os.Exit(1) } - var failureRe *regexp.Regexp + var failureRe, ignoreRe *regexp.Regexp if *flagFailure != "" { var err error if failureRe, err = regexp.Compile(*flagFailure); err != nil { @@ -45,6 +46,13 @@ func main() { os.Exit(1) } } + if *flagIgnore != "" { + var err error + if ignoreRe, err = regexp.Compile(*flagIgnore); err != nil { + fmt.Println("bad ignore regexp:", err) + os.Exit(1) + } + } res := make(chan []byte) for i := 0; i < *flagP; i++ { go func() { @@ -73,7 +81,7 @@ func main() { } out, err := cmd.CombinedOutput() close(done) - if err != nil && (failureRe == nil || failureRe.Match(out)) { + if err != nil && (failureRe == nil || failureRe.Match(out)) && (ignoreRe == nil || !ignoreRe.Match(out)) { out = append(out, fmt.Sprintf("\n\nERROR: %v\n", err)...) } else { out = []byte{}