| // 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 fidl.test.llcpp.dirent; |
| |
| using zx; |
| |
| const TEST_MAX_PATH uint32 = 10; |
| |
| /// Fake dirent structure to exercise linearization codepaths. |
| type DirEnt = struct { |
| is_dir bool; |
| name string:TEST_MAX_PATH; |
| some_flags int32; |
| }; |
| |
| const SMALL_DIR_VECTOR_SIZE uint32 = 3; |
| |
| /// Test interface implemented by LLCPP, with a manually written server, |
| /// since types with more than one level of indirections are not handled by the C binding. |
| protocol DirEntTestInterface { |
| /// Iterate over the dirents and return the number of directories within them. |
| CountNumDirectories(struct { |
| dirents vector<DirEnt>:1000; |
| }) -> (struct { |
| num_dir int64; |
| }); |
| |
| /// Return a vector of dirents. Empty request. Response may stack-allocate. |
| ReadDir() -> (struct { |
| dirents vector<DirEnt>:SMALL_DIR_VECTOR_SIZE; |
| }); |
| |
| /// Consume dirents. Empty response. Request may stack-allocate. |
| ConsumeDirectories(struct { |
| dirents vector<DirEnt>:SMALL_DIR_VECTOR_SIZE; |
| }) -> (); |
| |
| /// Event |
| -> OnDirents(struct { |
| dirents vector<DirEnt>:1000; |
| }); |
| |
| /// Binding will not wait for response. |
| /// But here we send an eventpair which the server will signal upon receipt of message. |
| OneWayDirents(resource struct { |
| dirents vector<DirEnt>:1000; |
| ep zx.handle:EVENTPAIR; |
| }); |
| }; |