From 28bd3e371b1f31cb243f0df56b9c7720971a89db Mon Sep 17 00:00:00 2001 From: Dmitry Vyukov Date: Mon, 10 Dec 2018 15:49:04 +0100 Subject: prog: support AUTO args in programs AUTO arguments can be used for: - consts - lens - pointers For const's and len's AUTO is replaced with the natural value, addresses for AUTO pointers are allocated linearly. This greatly simplifies writing test programs by hand as most of the time we want these natural values. Update tests to use AUTO. --- sys/test/gen/64.go | 13 ++++++++++++- sys/test/test.txt | 10 ++++++++++ sys/test/test/align0 | 6 +++--- sys/test/test/bf | 8 +++----- 4 files changed, 28 insertions(+), 9 deletions(-) (limited to 'sys/test') diff --git a/sys/test/gen/64.go b/sys/test/gen/64.go index 1abe96317..d3c24241d 100644 --- a/sys/test/gen/64.go +++ b/sys/test/gen/64.go @@ -65,6 +65,11 @@ var structDescs_64 = []*KeyedStruct{ &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int8", FldName: "i8", TypeSize: 1}}}, &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "i32", TypeSize: 4}}}, }}}, + {Key: StructKey{Name: "auto_struct0"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "auto_struct0", TypeSize: 12}, Fields: []Type{ + &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "f0", TypeSize: 4}}, Buf: "parent"}, + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "f1", TypeSize: 4}}, Val: 67}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "f2", TypeSize: 4}}}, + }}}, {Key: StructKey{Name: "compare_data"}, Desc: &StructDesc{TypeCommon: TypeCommon{TypeName: "compare_data", IsVarlen: true}, Fields: []Type{ &StructType{Key: StructKey{Name: "align0"}, FldName: "align0"}, &StructType{Key: StructKey{Name: "syz_bf_struct0"}, FldName: "bf0"}, @@ -660,6 +665,12 @@ var syscalls_64 = []*Syscall{ {Name: "test$array2", CallName: "test", Args: []Type{ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_array_blob"}}}, }}, + {Name: "test$auto0", CallName: "test", Args: []Type{ + &ConstType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "const", FldName: "a", TypeSize: 8}}, Val: 66}, + &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "b", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "auto_struct0"}}}, + &LenType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "len", FldName: "c", TypeSize: 8}}, Buf: "b"}, + &IntType{IntTypeCommon: IntTypeCommon{TypeCommon: TypeCommon{TypeName: "int32", FldName: "d", TypeSize: 4}}}, + }}, {Name: "test$bf0", CallName: "test", Args: []Type{ &PtrType{TypeCommon: TypeCommon{TypeName: "ptr", FldName: "a0", TypeSize: 8}, Type: &StructType{Key: StructKey{Name: "syz_bf_struct0"}}}, }}, @@ -929,4 +940,4 @@ var consts_64 = []ConstValue{ {Name: "SYS_unsupported"}, } -const revision_64 = "82736d421a5d52db6df0775561f1e59cc6cb9014" +const revision_64 = "ece48c7de48771745acdea340f4c52c47e058e65" diff --git a/sys/test/test.txt b/sys/test/test.txt index aadf704b4..214c42c6c 100644 --- a/sys/test/test.txt +++ b/sys/test/test.txt @@ -703,3 +703,13 @@ unsupported$1(a unsupported) unsupported fallback$0() fd fallback$1(a fd) seccomp() + +# AUTO + +test$auto0(a const[0x42], b ptr[in, auto_struct0], c len[b], d int32) + +auto_struct0 { + f0 len[parent, int32] + f1 const[0x43, int32] + f2 int32 +} diff --git a/sys/test/test/align0 b/sys/test/test/align0 index e2e5b9275..426b6e2de 100644 --- a/sys/test/test/align0 +++ b/sys/test/test/align0 @@ -1,3 +1,3 @@ -syz_compare(&(0x7f0000000000)="010000000200000003000400000000000500000000000000", 0x18, &(0x7f0000001000)=@align0={0x1, 0x2, 0x3, 0x4, 0x5}, 0x18) -syz_compare(&(0x7f0000000000)="", 0x18, &(0x7f0000001000)=@align0={0x0, 0x0, 0x0, 0x0, 0x0}, 0x17) # EBADF -syz_compare(&(0x7f0000000000)="", 0x18, &(0x7f0000001000)=@align0={0x1, 0x0, 0x0, 0x0, 0x0}, 0x18) # EINVAL +syz_compare(&AUTO="010000000200000003000400000000000500000000000000", 0x18, &AUTO=@align0={0x1, 0x2, 0x3, 0x4, 0x5}, AUTO) +syz_compare(&AUTO="", 0x18, &AUTO=@align0={0x0, 0x0, 0x0, 0x0, 0x0}, 0x17) # EBADF +syz_compare(&AUTO="", 0x18, &AUTO=@align0={0x1, 0x0, 0x0, 0x0, 0x0}, AUTO) # EINVAL diff --git a/sys/test/test/bf b/sys/test/test/bf index bc43b1fb4..4e43b989b 100644 --- a/sys/test/test/bf +++ b/sys/test/test/bf @@ -1,5 +1,3 @@ -syz_compare(&(0x7f0000000000)="ab03000000000000cdcdcdcdcdcdcdcdeb070000ff7f0000ab0303abaa000000", 0x20, &(0x7f0000001000)=@bf0={0xabab, 0xcdcdcdcdcdcdcdcd, 0xabab, 0xffff, 0xffffff, 0xabab, 0xabab, 0xaaa}, 0x20) - -syz_compare(&(0x7f0000002000)="dcfcde563422f10e", 0x8, &(0x7f0000003000)=@bf2={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, 0x8) - -syz_compare(&(0x7f0000004000)="0ef1223456defcdc", 0x8, &(0x7f0000005000)=@bf3={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, 0x8) +syz_compare(&AUTO="ab03000000000000cdcdcdcdcdcdcdcdeb070000ff7f0000ab0303abaa000000", 0x20, &AUTO=@bf0={0xabab, 0xcdcdcdcdcdcdcdcd, 0xabab, 0xffff, 0xffffff, 0xabab, 0xabab, 0xaaa}, AUTO) +syz_compare(&AUTO="dcfcde563422f10e", 0x8, &AUTO=@bf2={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, AUTO) +syz_compare(&AUTO="0ef1223456defcdc", 0x8, &AUTO=@bf3={0x0abc, 0x0bcd, 0xcdef, 0x123456, 0x78ef12}, AUTO) -- cgit mrf-deployment