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 <dvyukov@google.com>
This commit is contained in:
parent
4d49207e6b
commit
69f53eb622
|
@ -29,6 +29,7 @@ var (
|
||||||
flagTimeout = flag.Duration("timeout", 10*time.Minute, "timeout each process after `duration`")
|
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)")
|
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`")
|
flagFailure = flag.String("failure", "", "fail only if output matches `regexp`")
|
||||||
|
flagIgnore = flag.String("ignore", "", "ignore failure if output matches `regexp`")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
@ -37,7 +38,7 @@ func main() {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
var failureRe *regexp.Regexp
|
var failureRe, ignoreRe *regexp.Regexp
|
||||||
if *flagFailure != "" {
|
if *flagFailure != "" {
|
||||||
var err error
|
var err error
|
||||||
if failureRe, err = regexp.Compile(*flagFailure); err != nil {
|
if failureRe, err = regexp.Compile(*flagFailure); err != nil {
|
||||||
|
@ -45,6 +46,13 @@ func main() {
|
||||||
os.Exit(1)
|
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)
|
res := make(chan []byte)
|
||||||
for i := 0; i < *flagP; i++ {
|
for i := 0; i < *flagP; i++ {
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -73,7 +81,7 @@ func main() {
|
||||||
}
|
}
|
||||||
out, err := cmd.CombinedOutput()
|
out, err := cmd.CombinedOutput()
|
||||||
close(done)
|
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)...)
|
out = append(out, fmt.Sprintf("\n\nERROR: %v\n", err)...)
|
||||||
} else {
|
} else {
|
||||||
out = []byte{}
|
out = []byte{}
|
||||||
|
|
Loading…
Reference in New Issue