aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2016-09-29 12:21:26 +0200
committerDmitry Vyukov <dvyukov@google.com>2016-09-29 12:21:26 +0200
commitbf21057e7c36c72c1b46aa71bea8dc48509d4c40 (patch)
tree81c7c3e87305b00500af94b11ebabf5816d9b824
parent11a690d2752b590cadebe982ae4b66bf5c0cccef (diff)
prog: add a test for union layout
This is a retrospect tests for the union bug fixed in: 91eb1b922fd95bfaa5d8b0aad16902a73f3fe3d1
-rw-r--r--prog/encodingexec_test.go10
-rw-r--r--sys/test.txt19
2 files changed, 27 insertions, 2 deletions
diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go
index cf259e89c..651352fd6 100644
--- a/prog/encodingexec_test.go
+++ b/prog/encodingexec_test.go
@@ -67,6 +67,7 @@ func TestSerializeForExec(t *testing.T) {
},
},
{
+ // TODO: the offsets are currently caclulated incorrectly.
"syz_test$align0(&(0x7f0000000000)={0x1, 0x2, 0x3, 0x4, 0x5})",
[]uint64{
instrCopyin, dataOffset + 0, argConst, 2, 1,
@@ -78,6 +79,15 @@ func TestSerializeForExec(t *testing.T) {
instrEOF,
},
},
+ {
+ "syz_test$union0(&(0x7f0000000000)={0x1, @f2=0x2})",
+ []uint64{
+ instrCopyin, dataOffset + 0, argConst, 8, 1,
+ instrCopyin, dataOffset + 8, argConst, 1, 2,
+ callID("syz_test$union0"), 1, argConst, ptrSize, dataOffset,
+ instrEOF,
+ },
+ },
}
for i, test := range tests {
diff --git a/sys/test.txt b/sys/test.txt
index 67e338a83..2fc41e677 100644
--- a/sys/test.txt
+++ b/sys/test.txt
@@ -14,12 +14,27 @@ syz_test$opt1(a0 ptr[in, intptr, opt])
syz_test$opt2(a0 vma[opt])
# Struct alignment.
-syz_test$align0(a0 ptr[in, align0])
+syz_test$align0(a0 ptr[in, syz_align0])
-align0 {
+syz_align0 {
f0 int16
f1 int32
f2 int8
f3 int16
f4 int64
}
+
+# Unions.
+
+syz_test$union0(a0 ptr[in, syz_union_struct])
+
+syz_union_struct {
+ f int64
+ u syz_union0
+}
+
+syz_union0 [
+ f0 int64
+ f1 array[int64, 10]
+ f2 int8
+]