aboutsummaryrefslogtreecommitdiffstats
path: root/prog/minimization.go
diff options
context:
space:
mode:
authorAleksandr Nogikh <nogikh@google.com>2021-09-03 16:20:07 +0000
committerAleksandr Nogikh <wp32pw@gmail.com>2021-09-22 15:40:02 +0200
commit1c202847db0380015a8920bfd21375c2d9f28ddb (patch)
tree6693da3a936398a9ac6678842ac181c5f0e3e429 /prog/minimization.go
parenta7ce77be27d8e3728b97122a005bc5b23298cfc3 (diff)
all: refactor fault injection into call props
Now that call properties mechanism is implemented, we can refactor fault injection. Unfortunately, it is impossible to remove all traces of the previous apprach. In reprolist and while performing syz-ci jobs, syzkaller still needs to parse the old format. Remove the old prog options-based approach whenever possible and replace it with the use of call properties.
Diffstat (limited to 'prog/minimization.go')
-rw-r--r--prog/minimization.go18
1 files changed, 17 insertions, 1 deletions
diff --git a/prog/minimization.go b/prog/minimization.go
index 5e0383bb8..71320d92e 100644
--- a/prog/minimization.go
+++ b/prog/minimization.go
@@ -28,7 +28,7 @@ func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool)
// Try to remove all calls except the last one one-by-one.
p0, callIndex0 = removeCalls(p0, callIndex0, crash, pred)
- // Try to minimize individual args.
+ // Try to minimize individual calls.
for i := 0; i < len(p0.Calls); i++ {
ctx := &minimizeArgsCtx{
target: p0.Target,
@@ -46,6 +46,7 @@ func Minimize(p0 *Prog, callIndex0 int, crash bool, pred0 func(*Prog, int) bool)
goto again
}
}
+ p0 = minimizeCallProps(p0, i, callIndex0, pred)
}
if callIndex0 != -1 {
@@ -77,6 +78,21 @@ func removeCalls(p0 *Prog, callIndex0 int, crash bool, pred func(*Prog, int) boo
return p0, callIndex0
}
+func minimizeCallProps(p0 *Prog, callIndex, callIndex0 int, pred func(*Prog, int) bool) *Prog {
+ props := p0.Calls[callIndex].Props
+
+ // Try to drop fault injection.
+ if props.FailNth > 0 {
+ p := p0.Clone()
+ p.Calls[callIndex].Props.FailNth = 0
+ if pred(p, callIndex0) {
+ p0 = p
+ }
+ }
+
+ return p0
+}
+
type minimizeArgsCtx struct {
target *Target
p0 **Prog