aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-03-07 13:12:35 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-13 13:16:53 +0100
commit9b1f3e665308ee2ddd5b3f35a078219b5c509cdb (patch)
tree56e177dcb9b249381d27abacec5e59e9d2cf410f /prog/mutation_test.go
parent05359321bb37f035e55ccfad2cc36b0ea3b50998 (diff)
prog: control program length
We have _some_ limits on program length, but they are really soft. When we ask to generate a program with 10 calls, sometimes we get 100-150 calls. There are also no checks when we accept external programs from corpus/hub. Issue #1630 contains an example where this crashes VM (executor limit on number of 1000 resources is violated). Larger programs also harm the process overall (slower, consume more memory, lead to monster reproducers, etc). Add a set of measure for hard control over program length. Ensure that generated/mutated programs are not too long; drop too long programs coming from corpus/hub in manager; drop too long programs in hub. As a bonus ensure that mutation don't produce programs with 0 calls (which is currently possible and happens). Fixes #1630
Diffstat (limited to 'prog/mutation_test.go')
-rw-r--r--prog/mutation_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 89fe5473a..0d12699fc 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -136,7 +136,7 @@ func TestMutateArgument(t *testing.T) {
ctx := &mutator{
p: p1,
r: newRand(p1.Target, rs),
- ncalls: 0,
+ ncalls: 2 * len(p.Calls),
ct: ct,
corpus: nil,
}
@@ -163,7 +163,7 @@ func TestSizeMutateArg(t *testing.T) {
ctx := &mutator{
p: p1,
r: r,
- ncalls: 10,
+ ncalls: 2 * len(p.Calls),
ct: ct,
corpus: nil,
}
@@ -451,7 +451,7 @@ func runMutationTests(t *testing.T, tests [][2]string, valid bool) {
t.Fatalf("failed to deserialize the program: %v", err)
}
want := goal.Serialize()
- iters := int(1e5)
+ iters := int(1e6)
if !valid {
iters /= 10
}