| // Copyright 2019 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. |
| library llcpptest.flexible.test; |
| |
| using zx; |
| |
| type FlexibleXUnion = flexible resource union { |
| 1: want_more_than_30_bytes array<uint8, 30>; |
| 2: want_more_than_4_handles array<zx.Handle:optional, 4>; |
| }; |
| |
| /// Only one of the fields will be set by the server. This allows |
| /// the transaction to infer which field is present. See flexible_test.cc. |
| type FlexibleTable = resource table { |
| 1: want_more_than_30_bytes_at_ordinal_3 array<uint8, 30>; |
| 2: want_more_than_4_handles_at_ordinal_4 array<zx.Handle:optional, 4>; |
| }; |
| |
| /// The server will be implemented manually to purposefully return xunion/tables |
| /// with an unknown ordinal. |
| closed protocol ReceiveFlexibleEnvelope { |
| /// Receive a xunion with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more bytes than the current max message size. |
| strict GetUnknownXUnionMoreBytes() -> (resource struct { |
| xu FlexibleXUnion; |
| }); |
| |
| /// Receive a xunion with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more handles than the current max message handle |
| /// count. |
| strict GetUnknownXUnionMoreHandles() -> (resource struct { |
| xu FlexibleXUnion; |
| }); |
| |
| /// Receive a table with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more bytes than the current max message size. |
| strict GetUnknownTableMoreBytes() -> (resource struct { |
| t FlexibleTable; |
| }); |
| |
| /// Receive a table with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more handles than the current max message handle |
| /// count. |
| strict GetUnknownTableMoreHandles() -> (resource struct { |
| t FlexibleTable; |
| }); |
| |
| /// Receive a xunion with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more bytes than the current max message size. |
| strict -> OnUnknownXUnionMoreBytes(FlexibleXUnion); |
| |
| /// Receive a xunion with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more handles than the current max message handle |
| /// count. |
| strict -> OnUnknownXUnionMoreHandles(FlexibleXUnion); |
| |
| /// Receive a table with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more bytes than the current max message size. |
| strict -> OnUnknownTableMoreBytes(FlexibleTable); |
| |
| /// Receive a table with an unknown ordinal (suppose coming from a newer |
| /// server) which contains more handles than the current max message handle |
| /// count. |
| strict -> OnUnknownTableMoreHandles(FlexibleTable); |
| }; |
| |
| type StrictBoundedXUnion = strict union { |
| 1: v vector<uint8>:200; |
| }; |
| |
| type StrictUnboundedXUnion = strict union { |
| 1: v vector<uint8>; |
| }; |
| |
| // TODO(yifeit): Test strict tables once they are supported in fidlc. |
| |
| /// Test that the response to GetBoundedXUnion could be allocated on the stack, |
| /// while that to GetUnboundedXUnion is allocated on the heap, through |
| /// compile-time assertions. |
| closed protocol ReceiveStrictEnvelope { |
| strict GetBoundedXUnion() -> (struct { |
| xu StrictBoundedXUnion; |
| }); |
| strict GetUnboundedXUnion() -> (struct { |
| xu StrictUnboundedXUnion; |
| }); |
| }; |