blob: 5f0a3b87206ec144cc3a5d47af6ec3e1eea1efa8 [file] [log] [blame]
// Copyright 2021 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// TODO(https://fxbug.dev/42169694): Audit each test and merge into the regular `strings.gidl`.
// These were ported from a legacy set of manual C/C++ tests termed `walker_tests`.
decode_failure("VectorWithHugeCount") {
type = UnboundedNonnullableVectorOfUint32s,
// (2^30 + 4) * 4 (4 == sizeof(uint32_t)) overflows to 16 when stored as uint32_t.
// If a binding is written to use uint32 sizes AND also forget to check for
// overflows, it would incorrectly finish decoding the 16 byte vector payload.
bytes = {
v2 = [
num(1073741828):8, // count
repeat(0xff):8, // presence
repeat(0):16, // payload of 16 bytes
],
},
err = TOO_FEW_BYTES,
}
success("PresentNonnullableVectorOfHandles") {
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
value = UnboundedNonnullableVectorOfHandles{
vh0: [#0, #1, #2, #3],
},
bytes = {
v2 = [
// Count and presence
num(4):8, repeat(0xff):8,
// Four handles
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
}
success("PresentNullableVectorOfHandles") {
// TODO(https://fxbug.dev/42170268): generated Rust test does not compile.
bindings_denylist = [rust],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
value = UnboundedNullableVectorOfHandles{
vh0: [#0, #1, #2, #3],
},
bytes = {
v2 = [
// Count and presence
num(4):8, repeat(0xff):8,
// Four handles
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
}
decode_failure("AbsentNonnullableVectorOfHandlesError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
type = UnboundedNonnullableVectorOfHandles,
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
err = NON_NULLABLE_TYPE_WITH_NULL_VALUE,
}
decode_failure("InvalidAbsentNonnullableVectorOfHandlesError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
type = UnboundedNonnullableVectorOfHandles,
bytes = {
v2 = [
// Count of four, absent marker.
num(4):8, repeat(0):8,
// Four absent handles.
repeat(0):4,
repeat(0):4,
repeat(0):4,
repeat(0):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
err = NON_EMPTY_VECTOR_WITH_NULL_BODY,
}
success("AbsentNullableVectorOfHandles") {
value = UnboundedNullableVectorOfHandles{},
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
}
success("PresentNonnullableBoundedVectorOfHandles") {
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
value = Bounded32NonnullableVectorOfHandles{
vh0: [#0, #1, #2, #3],
},
bytes = {
v2 = [
// Count of four, present marker.
num(4):8, repeat(0xff):8,
// Four present handles.
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
}
success("PresentNullableBoundedVectorOfHandles") {
// TODO(https://fxbug.dev/42170268): generated Rust test does not compile.
bindings_denylist = [rust],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
value = Bounded32NullableVectorOfHandles{
vh0: [#0, #1, #2, #3],
},
bytes = {
v2 = [
// Count of four, present marker.
num(4):8, repeat(0xff):8,
// Four present handles.
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
}
decode_failure("AbsentNonnullableBoundedVectorOfHandlesError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
type = Bounded32NonnullableVectorOfHandles,
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
err = NON_NULLABLE_TYPE_WITH_NULL_VALUE,
}
decode_failure("InvalidAbsentNonnullableBoundedVectorOfHandlesError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
},
type = Bounded32NonnullableVectorOfHandles,
bytes = {
v2 = [
// Count of four, absent marker.
num(4):8, repeat(0):8,
// Four absent handles.
repeat(0):4,
repeat(0):4,
repeat(0):4,
repeat(0):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3,
],
},
err = NON_EMPTY_VECTOR_WITH_NULL_BODY,
}
success("AbsentNullableBoundedVectorOfHandles") {
value = Bounded32NullableVectorOfHandles{},
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
}
decode_failure("PresentNonnullableBoundedVectorOfHandlesShortError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
#4 = event(),
#5 = event(),
#6 = event(),
#7 = event(),
},
type = MultipleBoundedNonnullableVectorsOfHandles,
bytes = {
v2 = [
// vh0 count, presence
num(4):8, repeat(0xff):8,
// vh1 count, presence
num(4):8, repeat(0xff):8,
// 4 handles from vh0
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
// 4 handles from vh1
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3, #4, #5, #6, #7,
],
},
err = COUNT_EXCEEDS_LIMIT,
}
decode_failure("PresentNullableBoundedVectorOfHandlesShortError") {
// TODO(https://fxbug.dev/42136336): Close handles on encode/decode failure.
bindings_denylist = [dart],
handle_defs = {
#0 = event(),
#1 = event(),
#2 = event(),
#3 = event(),
#4 = event(),
#5 = event(),
#6 = event(),
#7 = event(),
},
type = MultipleBoundedNullableVectorsOfHandles,
bytes = {
v2 = [
// vh0 count, presence
num(4):8, repeat(0xff):8,
// vh1 count, presence
num(4):8, repeat(0xff):8,
// 4 handles from vh0
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
// 4 handles from vh1
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
repeat(0xff):4,
],
},
handles = {
v2 = [
#0, #1, #2, #3, #4, #5, #6, #7,
],
},
err = COUNT_EXCEEDS_LIMIT,
}
success("PresentNonnullableVectorOfUint32") {
value = UnboundedNonnullableVectorOfUint32s{
vu0: [1, 2, 3, 4],
},
bytes = {
v2 = [
// Count and presence
num(4):8, repeat(0xff):8,
// Vector values
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
}
success("PresentNullableVectorOfUint32") {
// TODO(https://fxbug.dev/42170268): generated Rust test does not compile.
bindings_denylist = [rust],
value = UnboundedNullableVectorOfUint32s{
vu0: [1, 2, 3, 4],
},
bytes = {
v2 = [
// Count and presence
num(4):8, repeat(0xff):8,
// Vector values
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
}
decode_failure("AbsentNonnullableVectorOfUint32Error") {
type = UnboundedNonnullableVectorOfUint32s,
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
err = NON_NULLABLE_TYPE_WITH_NULL_VALUE,
}
decode_failure("AbsentNullableVectorOfUint32NonZeroLengthError") {
type = UnboundedNullableVectorOfUint32s,
bytes = {
v2 = [
// Count of four, absent marker.
num(4):8, repeat(0):8,
],
},
err = NON_EMPTY_VECTOR_WITH_NULL_BODY,
}
success("AbsentNullableVectorOfUint32") {
value = UnboundedNullableVectorOfUint32s{},
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
}
success("PresentNonnullableBoundedVectorOfUint32") {
value = Bounded32NonnullableVectorOfUint32s{
vu0: [1, 2, 3, 4],
},
bytes = {
v2 = [
// Count of four, present marker.
num(4):8, repeat(0xff):8,
// Vector values.
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
}
success("PresentNullableBoundedVectorOfUint32") {
// TODO(https://fxbug.dev/42170268): generated Rust test does not compile.
bindings_denylist = [rust],
value = Bounded32NullableVectorOfUint32s{
vu0: [1, 2, 3, 4],
},
bytes = {
v2 = [
// Count of four, present marker.
num(4):8, repeat(0xff):8,
// Vector values
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
}
decode_failure("AbsentNonnullableBoundedVectorOfUint32Error") {
type = UnboundedNonnullableVectorOfUint32s,
bytes = {
v2 = [
// Count of four, absent marker.
num(4):8, repeat(0):8,
],
},
err = NON_EMPTY_VECTOR_WITH_NULL_BODY,
}
success("AbsentNullableBoundedVectorOfUint32") {
value = Bounded32NullableVectorOfUint32s{},
bytes = {
v2 = [
// Count of zero, absent marker.
num(0):8, repeat(0):8,
],
},
}
success("MultipleBoundedNonnullableVectorsOfUint32s_randomly_generated") {
value = MultipleBoundedNonnullableVectorsOfUint32s{
vu0: [1025582817, 2776683438],
vu1: [1151223630, 483621226, 3773133636, 3428471921, 3913167363, 3828621297, 1893799997],
},
bytes = {
v2 = [
num(2):8, repeat(0xFF):8, // vu0 length, presence
num(7):8, repeat(0xFF):8, // vu1 length, presence
// vu0
num(1025582817):4, num(2776683438):4,
// vu1
num(1151223630):4, num(483621226):4, num(3773133636):4, num(3428471921):4,
num(3913167363):4, num(3828621297):4, num(1893799997):4, padding:4,
],
},
}
decode_failure("PresentNonnullableBoundedVectorOfUint32ShortError") {
type = MultipleBoundedNonnullableVectorsOfUint32s,
bytes = {
v2 = [
// vh0 count, presence
num(4):8, repeat(0xff):8,
// vh1 count, presence
num(4):8, repeat(0xff):8,
// vh0 content
num(1):4,
num(2):4,
num(3):4,
num(4):4,
// vh1 content
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
err = COUNT_EXCEEDS_LIMIT,
}
decode_failure("PresentNullableBoundedVectorOfUint32ShortError") {
type = MultipleBoundedNullableVectorsOfUint32s,
bytes = {
v2 = [
// vh0 count, presence
num(4):8, repeat(0xff):8,
// vh1 count, presence
num(4):8, repeat(0xff):8,
// vh0 content
num(1):4,
num(2):4,
num(3):4,
num(4):4,
// vh1 content
num(1):4,
num(2):4,
num(3):4,
num(4):4,
],
},
err = COUNT_EXCEEDS_LIMIT,
}
success("MultipleNonnullableVectorsOfUint32s_randomly_generated") {
value = MultipleNonnullableVectorsOfUint32s{
vu0: [
2109779047, 1880292994, 1717719637, 310643115,
985910586, 701234169, 2618282161,
],
vu1: [
842458034, 4060234085, 845176054, 82316015,
2030863917, 140317742, 2650810212, 3263465718,
],
},
bytes = {
v2 = [
num(7):8, repeat(0xFF):8, // vu0 length, presence
num(8):8, repeat(0xFF):8, // vu1 length, presence
// vu0
num(2109779047):4, num(1880292994):4, num(1717719637):4, num(310643115):4,
num(985910586):4, num(701234169):4, num(2618282161):4, padding:4,
// vu1
num(842458034):4, num(4060234085):4, num(845176054):4, num(82316015):4,
num(2030863917):4, num(140317742):4, num(2650810212):4, num(3263465718):4,
],
},
}