diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2020-03-22 14:23:35 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2020-03-24 08:43:00 +0100 |
| commit | 2ab437bb1e9f9f34d2e080ad11c944464a8bd944 (patch) | |
| tree | 568bcf0cdf14d2df812018ab48277eaff0f21632 /prog/encoding_test.go | |
| parent | ef871b2e4ff7b6a8f84a6a0a0fd3e9c3ed8e67b4 (diff) | |
prog: improve TestDeserializeHelper
1. Allow to not provide Out if it's the same as In.
2. Always check Out.
Diffstat (limited to 'prog/encoding_test.go')
| -rw-r--r-- | prog/encoding_test.go | 33 |
1 files changed, 16 insertions, 17 deletions
diff --git a/prog/encoding_test.go b/prog/encoding_test.go index ed079a37c..b5d17d007 100644 --- a/prog/encoding_test.go +++ b/prog/encoding_test.go @@ -141,7 +141,8 @@ func TestCallSetRandom(t *testing.T) { func TestDeserialize(t *testing.T) { TestDeserializeHelper(t, "test", "64", nil, []DeserializeTest{ { - In: `test$struct(&(0x7f0000000000)={0x0, {0x0}})`, + In: `test$struct(&(0x7f0000000000)={0x0, {0x0}})`, + Out: `test$struct(&(0x7f0000000000))`, }, { In: `test$struct(&(0x7f0000000000)=0x0)`, @@ -149,34 +150,40 @@ func TestDeserialize(t *testing.T) { StrictErr: "wrong int arg", }, { - In: `test$regression1(&(0x7f0000000000)=[{"000000"}, {"0000000000"}])`, + In: `test$regression1(&(0x7f0000000000)=[{"000000"}, {"0000000000"}])`, + Out: `test$regression1(&(0x7f0000000000)=[{}, {}])`, }, { - In: `test$regression2(&(0x7f0000000000)=[0x1, 0x2, 0x3, 0x4, 0x5, 0x6])`, + In: `test$regression2(&(0x7f0000000000)=[0x1, 0x2, 0x3, 0x4, 0x5, 0x6])`, + Out: `test$regression2(&(0x7f0000000000)=[0x1, 0x2, 0x3, 0x4])`, }, { In: `test_excessive_args1(0x0, 0x1, {0x1, &(0x7f0000000000)=[0x1, 0x2]})`, + Out: `test_excessive_args1()`, StrictErr: "excessive syscall arguments", }, { In: `test_excessive_args2(0x0, 0x1, {0x1, &(0x7f0000000000)={0x1, 0x2}})`, + Out: `test_excessive_args2(0x0)`, StrictErr: "excessive syscall arguments", }, { In: `test_excessive_args2(0x0, 0x1, {0x1, &(0x7f0000000000)=nil})`, + Out: `test_excessive_args2(0x0)`, StrictErr: "excessive syscall arguments", }, { In: `test_excessive_args2(0x0, &(0x7f0000000000), 0x0)`, + Out: `test_excessive_args2(0x0)`, StrictErr: "excessive syscall arguments", }, { In: `test$excessive_fields1(&(0x7f0000000000)={0x1, &(0x7f0000000000)=[{0x0}, 0x2]}, {0x1, 0x2, [0x1, 0x2]})`, + Out: `test$excessive_fields1(&(0x7f0000000000)={0x1})`, StrictErr: "excessive struct excessive_fields fields", }, { - In: `test$excessive_fields1(0x0)`, - Out: `test$excessive_fields1(0x0)`, + In: `test$excessive_fields1(0x0)`, }, { In: `test$excessive_fields1(r0)`, @@ -233,16 +240,10 @@ func TestDeserialize(t *testing.T) { StrictErr: "wrong int arg", }, { - In: `test$excessive_fields1(0x0)`, - Out: `test$excessive_fields1(0x0)`, - }, - { - In: `test$excessive_fields1(0xffffffffffffffff)`, - Out: `test$excessive_fields1(0xffffffffffffffff)`, + In: `test$excessive_fields1(0xffffffffffffffff)`, }, { - In: `test$excessive_fields1(0xfffffffffffffffe)`, - Out: `test$excessive_fields1(0xfffffffffffffffe)`, + In: `test$excessive_fields1(0xfffffffffffffffe)`, }, { In: `test$excessive_fields1(0xfffffffffffffffd)`, @@ -278,8 +279,7 @@ func TestDeserialize(t *testing.T) { StrictErr: `out arg const[1, const] has non-default value: 2`, }, { - In: `test$str1(&(0x7f0000000000)='foo\x00')`, - Out: `test$str1(&(0x7f0000000000)='foo\x00')`, + In: `test$str1(&(0x7f0000000000)='foo\x00')`, }, { In: `test$str1(&(0x7f0000000000)='bar\x00')`, @@ -287,8 +287,7 @@ func TestDeserialize(t *testing.T) { StrictErr: `bad string value "bar\x00", expect ["foo\x00"]`, }, { - In: `test$str2(&(0x7f0000000000)='bar\x00')`, - Out: `test$str2(&(0x7f0000000000)='bar\x00')`, + In: `test$str2(&(0x7f0000000000)='bar\x00')`, }, { In: `test$str2(&(0x7f0000000000)='baz\x00')`, |
