1 /* 2 * Copyright 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 /* 18 * Generated mock file from original source file 19 * Functions generated:11 20 * 21 * mockcify.pl ver 0.3.0 22 */ 23 24 #include <functional> 25 26 // Original included files, if any 27 #include "osi/include/reactor.h" 28 #include "osi/include/socket.h" 29 30 // Mocked compile conditionals, if any 31 32 namespace test { 33 namespace mock { 34 namespace osi_socket { 35 36 // Shared state between mocked functions and tests 37 // Name: socket_accept 38 // Params: const socket_t* socket 39 // Return: socket_t* 40 struct socket_accept { 41 socket_t* return_value{0}; 42 std::function<socket_t*(const socket_t* socket)> body{ 43 [this](const socket_t* /* socket */) { return return_value; }}; operatorsocket_accept44 socket_t* operator()(const socket_t* socket) { return body(socket); } 45 }; 46 extern struct socket_accept socket_accept; 47 48 // Name: socket_bytes_available 49 // Params: const socket_t* socket 50 // Return: ssize_t 51 struct socket_bytes_available { 52 ssize_t return_value{0}; 53 std::function<ssize_t(const socket_t* socket)> body{ 54 [this](const socket_t* /* socket */) { return return_value; }}; operatorsocket_bytes_available55 ssize_t operator()(const socket_t* socket) { return body(socket); } 56 }; 57 extern struct socket_bytes_available socket_bytes_available; 58 59 // Name: socket_free 60 // Params: socket_t* socket 61 // Return: void 62 struct socket_free { 63 std::function<void(socket_t* socket)> body{[](socket_t* /* socket */) {}}; operatorsocket_free64 void operator()(socket_t* socket) { body(socket); } 65 }; 66 extern struct socket_free socket_free; 67 68 // Name: socket_listen 69 // Params: const socket_t* socket, port_t port 70 // Return: bool 71 struct socket_listen { 72 bool return_value{false}; 73 std::function<bool(const socket_t* socket, port_t port)> body{ 74 [this](const socket_t* /* socket */, port_t /* port */) { return return_value; }}; operatorsocket_listen75 bool operator()(const socket_t* socket, port_t port) { return body(socket, port); } 76 }; 77 extern struct socket_listen socket_listen; 78 79 // Name: socket_new 80 // Params: void 81 // Return: socket_t* 82 struct socket_new { 83 socket_t* return_value{0}; 84 std::function<socket_t*(void)> body{[this](void) { return return_value; }}; operatorsocket_new85 socket_t* operator()(void) { return body(); } 86 }; 87 extern struct socket_new socket_new; 88 89 // Name: socket_new_from_fd 90 // Params: int fd 91 // Return: socket_t* 92 struct socket_new_from_fd { 93 socket_t* return_value{0}; 94 std::function<socket_t*(int fd)> body{[this](int /* fd */) { return return_value; }}; operatorsocket_new_from_fd95 socket_t* operator()(int fd) { return body(fd); } 96 }; 97 extern struct socket_new_from_fd socket_new_from_fd; 98 99 // Name: socket_read 100 // Params: const socket_t* socket, void* buf, size_t count 101 // Return: ssize_t 102 struct socket_read { 103 ssize_t return_value{0}; 104 std::function<ssize_t(const socket_t* socket, void* buf, size_t count)> body{ 105 [this](const socket_t* /* socket */, void* /* buf */, size_t /* count */) { 106 return return_value; 107 }}; operatorsocket_read108 ssize_t operator()(const socket_t* socket, void* buf, size_t count) { 109 return body(socket, buf, count); 110 } 111 }; 112 extern struct socket_read socket_read; 113 114 // Name: socket_register 115 // Params: socket_t* socket, reactor_t* reactor, void* context, socket_cb 116 // read_cb, socket_cb write_cb Return: void 117 struct socket_register { 118 std::function<void(socket_t* socket, reactor_t* reactor, void* context, socket_cb read_cb, 119 socket_cb write_cb)> 120 body{[](socket_t* /* socket */, reactor_t* /* reactor */, void* /* context */, 121 socket_cb /* read_cb */, socket_cb /* write_cb */) {}}; operatorsocket_register122 void operator()(socket_t* socket, reactor_t* reactor, void* context, socket_cb read_cb, 123 socket_cb write_cb) { 124 body(socket, reactor, context, read_cb, write_cb); 125 } 126 }; 127 extern struct socket_register socket_register; 128 129 // Name: socket_unregister 130 // Params: socket_t* socket 131 // Return: void 132 struct socket_unregister { 133 std::function<void(socket_t* socket)> body{[](socket_t* /* socket */) {}}; operatorsocket_unregister134 void operator()(socket_t* socket) { body(socket); } 135 }; 136 extern struct socket_unregister socket_unregister; 137 138 // Name: socket_write 139 // Params: const socket_t* socket, const void* buf, size_t count 140 // Return: ssize_t 141 struct socket_write { 142 ssize_t return_value{0}; 143 std::function<ssize_t(const socket_t* socket, const void* buf, size_t count)> body{ 144 [this](const socket_t* /* socket */, const void* /* buf */, size_t /* count */) { 145 return return_value; 146 }}; operatorsocket_write147 ssize_t operator()(const socket_t* socket, const void* buf, size_t count) { 148 return body(socket, buf, count); 149 } 150 }; 151 extern struct socket_write socket_write; 152 153 // Name: socket_write_and_transfer_fd 154 // Params: const socket_t* socket, const void* buf, size_t count, int fd 155 // Return: ssize_t 156 struct socket_write_and_transfer_fd { 157 ssize_t return_value{0}; 158 std::function<ssize_t(const socket_t* socket, const void* buf, size_t count, int fd)> body{ 159 [this](const socket_t* /* socket */, const void* /* buf */, size_t /* count */, 160 int /* fd */) { return return_value; }}; operatorsocket_write_and_transfer_fd161 ssize_t operator()(const socket_t* socket, const void* buf, size_t count, int fd) { 162 return body(socket, buf, count, fd); 163 } 164 }; 165 extern struct socket_write_and_transfer_fd socket_write_and_transfer_fd; 166 167 } // namespace osi_socket 168 } // namespace mock 169 } // namespace test 170 171 // END mockcify generation 172