aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2015-11-10 13:38:08 +0100
committerDmitry Vyukov <dvyukov@google.com>2015-11-10 13:38:08 +0100
commit18220dd54e8954f49a6fd00bf7a3dca864ea7ea7 (patch)
treefa2f1f6c25dc6e183c8421adabecea8ab9fbf2e7 /tools
parentd2c7f41bb04f921a8ce226b7ffae3bf0ef95fc3d (diff)
support parallel execution in stress utility
Diffstat (limited to 'tools')
-rw-r--r--tools/stress/stress.go46
1 files changed, 27 insertions, 19 deletions
diff --git a/tools/stress/stress.go b/tools/stress/stress.go
index ed2e19f6f..50ee04a61 100644
--- a/tools/stress/stress.go
+++ b/tools/stress/stress.go
@@ -12,6 +12,7 @@ import (
"math/rand"
"os"
"regexp"
+ "runtime"
"time"
"github.com/google/syzkaller/ipc"
@@ -23,6 +24,7 @@ var (
flagExecutor = flag.String("executor", "", "path to executor binary")
flagOutput = flag.Bool("output", false, "print executor output to console")
flagDebug = flag.Bool("debug", false, "executor debug output")
+ flagProcs = flag.Int("procs", runtime.NumCPU(), "number of parallel processes")
failedRe = regexp.MustCompile("runtime error: |panic: |Panic: ")
)
@@ -30,29 +32,35 @@ var (
func main() {
flag.Parse()
corpus := readCorpus()
- flags := ipc.FlagThreaded
+ flags := ipc.FlagThreaded | ipc.FlagCollide | ipc.FlagDropPrivs
if *flagDebug {
flags |= ipc.FlagDebug
}
- env, err := ipc.MakeEnv(*flagExecutor, 4*time.Second, flags)
- if err != nil {
- failf("failed to create execution environment: %v", err)
- }
- rs := rand.NewSource(time.Now().UnixNano())
- rnd := rand.New(rs)
- for i := 0; ; i++ {
- var p *prog.Prog
- if len(corpus) == 0 || i%10 != 0 {
- p = prog.Generate(rs, 50, nil)
- execute(env, p)
- p.Mutate(rs, 50, nil)
- execute(env, p)
- } else {
- p = corpus[rnd.Intn(len(corpus))].Clone()
- p.Mutate(rs, 50, nil)
- execute(env, p)
- }
+
+ for p := 0; p < *flagProcs; p++ {
+ go func() {
+ env, err := ipc.MakeEnv(*flagExecutor, 4*time.Second, flags)
+ if err != nil {
+ failf("failed to create execution environment: %v", err)
+ }
+ rs := rand.NewSource(time.Now().UnixNano())
+ rnd := rand.New(rs)
+ for i := 0; ; i++ {
+ var p *prog.Prog
+ if len(corpus) == 0 || i%10 != 0 {
+ p = prog.Generate(rs, 50, nil)
+ execute(env, p)
+ p.Mutate(rs, 50, nil)
+ execute(env, p)
+ } else {
+ p = corpus[rnd.Intn(len(corpus))].Clone()
+ p.Mutate(rs, 50, nil)
+ execute(env, p)
+ }
+ }
+ }()
}
+ select{}
}
func execute(env *ipc.Env, p *prog.Prog) {