aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation_test.go
diff options
context:
space:
mode:
authorVeronica Radu <veronicaradu@google.com>2019-08-07 18:00:46 +0200
committerDmitry Vyukov <dvyukov@google.com>2019-08-09 15:02:02 +0200
commitaff9e255cd708709adef545d1f932020ee5c0978 (patch)
tree353468cb149a587e747cfc702003946abd5130a2 /prog/mutation_test.go
parente5701ed16c822ef5a4abc4224b44c36b3489aca3 (diff)
prog: add special mutation for binary flags
Diffstat (limited to 'prog/mutation_test.go')
-rw-r--r--prog/mutation_test.go34
1 files changed, 33 insertions, 1 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 100820dd7..6b50b975e 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -11,6 +11,32 @@ import (
"testing"
)
+func TestMutationFlags(t *testing.T) {
+ tests := [][2]string{
+ // Mutate flags (bitmask = true).
+ {
+ `r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
+ `r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x20, 0x1, 0x9)`,
+ },
+ {
+ `r0 = mutate$flags2(&(0x7f0000000000)="2e2f66696c653000", 0x0)`,
+ `r0 = mutate$flags2(&(0x7f0000000000)="2e2f66696c653000", 0xd9)`,
+ },
+
+ // Mutate flags (bitmask = false).
+ {
+ `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0x0)`,
+ `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0xddddddddeeeeeeee)`,
+ },
+ {
+ `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0xddddddddeeeeeeee)`,
+ `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0xaaaaaaaaaaaaaaaa)`,
+ },
+ }
+
+ runMutationTests(t, tests)
+}
+
func TestClone(t *testing.T) {
target, rs, iters := initTest(t)
for i := 0; i < iters; i++ {
@@ -68,7 +94,6 @@ func TestMutateCorpus(t *testing.T) {
}
func TestMutateTable(t *testing.T) {
- target := initTargetTest(t, "test", "64")
tests := [][2]string{
// Insert a call.
{`
@@ -151,6 +176,13 @@ mutate8(0x2)
mutate8(0xffffffffffffffff)
`},
}
+
+ runMutationTests(t, tests)
+}
+
+func runMutationTests(t *testing.T, tests [][2]string) {
+ target := initTargetTest(t, "test", "64")
+
for ti, test := range tests {
test := test
t.Run(fmt.Sprint(ti), func(t *testing.T) {