blob: 6c4fa61bd52005842e9e9b39937c7aed2eb489e1 [file] [log] [blame]
// 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.
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.
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.
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.
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.
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.
-> 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.
-> 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.
-> 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.
-> 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.
protocol ReceiveStrictEnvelope {
GetBoundedXUnion() -> (struct {
xu StrictBoundedXUnion;
});
GetUnboundedXUnion() -> (struct {
xu StrictUnboundedXUnion;
});
};