From e4edb0e20b90350779b319f60f0d7878ef423e4f Mon Sep 17 00:00:00 2001 From: Andrey Konovalov Date: Tue, 11 Oct 2016 21:01:21 +0200 Subject: Add tests for big-endian ints --- prog/encodingexec_test.go | 22 ++++++++++++++++++++++ sys/test.txt | 21 +++++++++++++++++++++ 2 files changed, 43 insertions(+) diff --git a/prog/encodingexec_test.go b/prog/encodingexec_test.go index e166e8ae8..207543705 100644 --- a/prog/encodingexec_test.go +++ b/prog/encodingexec_test.go @@ -129,6 +129,28 @@ func TestSerializeForExec(t *testing.T) { instrEOF, }, }, + { + "syz_test$end0(&(0x7f0000000000)={0x42, 0x42, 0x42, 0x42, 0x42})", + []uint64{ + instrCopyin, dataOffset + 0, argConst, 1, 0x42, + instrCopyin, dataOffset + 1, argConst, 2, 0x4200, + instrCopyin, dataOffset + 3, argConst, 4, 0x42000000, + instrCopyin, dataOffset + 7, argConst, 8, 0x4200000000000000, + instrCopyin, dataOffset + 15, argConst, 8, 0x4200000000000000, + callID("syz_test$end0"), 1, argConst, ptrSize, dataOffset, + instrEOF, + }, + }, + { + "syz_test$end1(&(0x7f0000000000)={0xe, 0x42, 0x1})", + []uint64{ + instrCopyin, dataOffset + 0, argConst, 2, 0x0e00, + instrCopyin, dataOffset + 2, argConst, 4, 0x42000000, + instrCopyin, dataOffset + 6, argConst, 8, 0x0100000000000000, + callID("syz_test$end1"), 1, argConst, ptrSize, dataOffset, + instrEOF, + }, + }, } for i, test := range tests { diff --git a/sys/test.txt b/sys/test.txt index bf66d83aa..a4381c1ad 100644 --- a/sys/test.txt +++ b/sys/test.txt @@ -166,3 +166,24 @@ syz_length_large_struct { f1 int64 f2 array[int32, 8] } + +# Big endian. + +syz_test$end0(a0 ptr[in, syz_end_int_struct]) +syz_test$end1(a0 ptr[in, syz_end_var_struct]) + +syz_end_flags = 0, 1 + +syz_end_int_struct { + f0 int8 + f1 int16be + f2 int32be + f3 int64be + f4 intptrbe +} [packed] + +syz_end_var_struct { + f0 len[parent, int16be] + f1 const[0x42, int32be] + f2 flags[syz_end_flags, int64be] +} [packed] -- cgit mrf-deployment