aboutsummaryrefslogtreecommitdiffstats
path: root/prog/mutation_test.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2020-03-15 21:16:13 +0100
committerDmitry Vyukov <dvyukov@google.com>2020-03-17 21:19:13 +0100
commit924f7606047a430a9b313c135b782e1e8f852bec (patch)
tree649fbf186af5268815f16884875f92d948ad57b0 /prog/mutation_test.go
parent5de34a784c610ab08888c185dd0c09f542d62d4f (diff)
pkg/compiler: ensure consistency of syscall argument types
Ensure that we don't have conflicting sizes for the same argument of the same syscall, e.g.: foo$1(a int16) foo$2(a int32) This is useful for several reasons: - we will be able avoid morphing syscalls into other syscalls - we will be able to figure out more precise sizes for args (lots of them are implicitly intptr, which is the largest type on most important arches) - found few bugs in linux descriptions Update #477 Update #502
Diffstat (limited to 'prog/mutation_test.go')
-rw-r--r--prog/mutation_test.go108
1 files changed, 54 insertions, 54 deletions
diff --git a/prog/mutation_test.go b/prog/mutation_test.go
index 0d12699fc..d4d3f6586 100644
--- a/prog/mutation_test.go
+++ b/prog/mutation_test.go
@@ -16,21 +16,21 @@ 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_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)`,
+ `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", 0x0)`,
+ `r0 = mutate_flags3(&(0x7f0000000000)="2e2f66696c653000", 0xddddddddeeeeeeee)`,
},
{
- `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0xddddddddeeeeeeee)`,
- `r0 = mutate$flags3(&(0x7f0000000000)="2e2f66696c653000", 0xaaaaaaaaaaaaaaaa)`,
+ `r0 = mutate_flags3(&(0x7f0000000000)="2e2f66696c653000", 0xddddddddeeeeeeee)`,
+ `r0 = mutate_flags3(&(0x7f0000000000)="2e2f66696c653000", 0xaaaaaaaaaaaaaaaa)`,
},
}
runMutationTests(t, tests, true)
@@ -41,42 +41,42 @@ func TestChooseCall(t *testing.T) {
// The call with many arguments has a higher mutation probability.
{
`mutate0()
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
`mutate0()
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xffffffff)
-mutate$integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xffffffff)
+mutate_integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
},
// Calls with the same probability.
{
- `mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
- `mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xff)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
+ `mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
+ `mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xff)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
},
// The call with a lower probability can be mutated.
{
`mutate7(&(0x7f0000000000)='123', 0x3)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+r0 = mutate_flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
`mutate7(&(0x7f0000000000)='123', 0x2)
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
-r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)
+r0 = mutate_flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
},
// Complex arguments.
{
`test$struct(&(0x7f0000000000)={0x0, {0x0}})
test$array0(&(0x7f0000001000)={0x1, [@f0=0x2, @f1=0x3], 0x4})
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
`test$struct(&(0x7f0000000000)={0xff, {0x0}})
test$array0(&(0x7f0000001000)={0x1, [@f0=0x2, @f1=0x3], 0x4})
-mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
+mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
},
}
runMutationTests(t, tests, true)
@@ -86,38 +86,38 @@ func TestMutateArgument(t *testing.T) {
tests := [][2]string{
// Mutate an integer with a higher priority than the boolean arguments.
{
- `mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
- `mutate$integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xffffffff)`,
+ `mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0x1)`,
+ `mutate_integer(0x0, 0x1, 0x1, 0x1, 0x0, 0x1, 0x0, 0x0, 0xffffffff)`,
},
// Mutate a boolean.
{
- `mutate$integer(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)`,
- `mutate$integer(0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)`,
+ `mutate_integer(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)`,
+ `mutate_integer(0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0)`,
},
// Mutate flags (bitmask = true).
{
- `r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
- `r0 = mutate$flags(&(0x7f0000000000)="2e2f66696c653000", 0x20, 0x1, 0x9)`,
+ `r0 = mutate_flags(&(0x7f0000000000)="2e2f66696c653000", 0x0, 0x1, 0x1)`,
+ `r0 = mutate_flags(&(0x7f0000000000)="2e2f66696c653000", 0x20, 0x1, 0x9)`,
},
// Mutate an int8 from a set of other arguments with higher priority.
{
- `mutate$integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
- `mutate$integer2(0x00, 0x00, 0x20, 0x00, 0x07)`,
+ `mutate_integer2(0x00, 0x00, 0x20, 0x00, 0x01)`,
+ `mutate_integer2(0x00, 0x00, 0x20, 0x00, 0x07)`,
},
// Mutate an array of structs
{
- `mutate$array2(&(0x7f0000000000)=[{0x0}, {0x0}, {0x0}, {0x0}, {0x0}])`,
- `mutate$array2(&(0x7f0000000000)=[{0x0}, {0x0}, {0x3}, {0x0}, {0x0}])`,
+ `mutate_array2(&(0x7f0000000000)=[{0x0}, {0x0}, {0x0}, {0x0}, {0x0}])`,
+ `mutate_array2(&(0x7f0000000000)=[{0x0}, {0x0}, {0x3}, {0x0}, {0x0}])`,
},
// Mutate a non-special union that have more than 1 option
{
- `mutate$union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0x2, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
- `mutate$union(&(0x7f0000000000)=@f0=0x2)`,
+ `mutate_union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0x2, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
+ `mutate_union(&(0x7f0000000000)=@f0=0x2)`,
},
// Mutate the value of the current option in union
{
- `mutate$union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0x2, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
- `mutate$union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0xff, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
+ `mutate_union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0x2, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
+ `mutate_union(&(0x7f0000000000)=@f1=[0x0, 0x1, 0xff, 0x3, 0x0, 0x1, 0x2, 0x3, 0x0, 0x0])`,
},
}
@@ -337,9 +337,9 @@ mutate5(&(0x7f0000001000)="2e2f66696c653100", 0x22c0)
`},
// Mutate the array.
{`
-mutate$array(0x1, 0x30, &(0x7f0000000000)=[0x1, 0x1, 0x1, 0x1, 0x1])
+mutate_array(0x1, 0x30, &(0x7f0000000000)=[0x1, 0x1, 0x1, 0x1, 0x1])
`, `
-mutate$array(0x1, 0x30, &(0x7f0000000000)=[0x1, 0x1, 0x1, 0x1])
+mutate_array(0x1, 0x30, &(0x7f0000000000)=[0x1, 0x1, 0x1, 0x1])
`},
// Extend an array.
{`
@@ -361,21 +361,21 @@ mutate8(0xffffffffffffffff)
`},
// Increase buffer length
{`
-mutate$buffer(&(0x7f0000000000)=""/100)
+mutate_buffer(&(0x7f0000000000)=""/100)
`, `
-mutate$buffer(&(0x7f0000000000)=""/200)
+mutate_buffer(&(0x7f0000000000)=""/200)
`},
// Decrease buffer length
{`
-mutate$buffer(&(0x7f0000000000)=""/800)
+mutate_buffer(&(0x7f0000000000)=""/800)
`, `
-mutate$buffer(&(0x7f0000000000)=""/4)
+mutate_buffer(&(0x7f0000000000)=""/4)
`},
// Mutate a ranged buffer
{`
-mutate$rangedbuffer(&(0x7f00000000c0)=""/10)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/10)
`, `
-mutate$rangedbuffer(&(0x7f00000000c0)=""/7)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/7)
`},
}
@@ -386,14 +386,14 @@ func TestNegativeMutations(t *testing.T) {
tests := [][2]string{
// Mutate buffer size outside the range limits
{`
-mutate$rangedbuffer(&(0x7f00000000c0)=""/7)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/7)
`, `
-mutate$rangedbuffer(&(0x7f00000000c0)=""/4)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/4)
`},
{`
-mutate$rangedbuffer(&(0x7f00000000c0)=""/7)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/7)
`, `
-mutate$rangedbuffer(&(0x7f00000000c0)=""/11)
+mutate_rangedbuffer(&(0x7f00000000c0)=""/11)
`},
}
runMutationTests(t, tests, false)