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 */) {
75         return return_value;
76       }};
operatorsocket_listen77   bool operator()(const socket_t* socket, port_t port) {
78     return body(socket, port);
79   };
80 };
81 extern struct socket_listen socket_listen;
82 
83 // Name: socket_new
84 // Params: void
85 // Return: socket_t*
86 struct socket_new {
87   socket_t* return_value{0};
88   std::function<socket_t*(void)> body{[this](void) { return return_value; }};
operatorsocket_new89   socket_t* operator()(void) { return body(); };
90 };
91 extern struct socket_new socket_new;
92 
93 // Name: socket_new_from_fd
94 // Params: int fd
95 // Return: socket_t*
96 struct socket_new_from_fd {
97   socket_t* return_value{0};
98   std::function<socket_t*(int fd)> body{
99       [this](int /* fd */) { return return_value; }};
operatorsocket_new_from_fd100   socket_t* operator()(int fd) { return body(fd); };
101 };
102 extern struct socket_new_from_fd socket_new_from_fd;
103 
104 // Name: socket_read
105 // Params: const socket_t* socket, void* buf, size_t count
106 // Return: ssize_t
107 struct socket_read {
108   ssize_t return_value{0};
109   std::function<ssize_t(const socket_t* socket, void* buf, size_t count)> body{
110       [this](const socket_t* /* socket */, void* /* buf */,
111              size_t /* count */) { return return_value; }};
operatorsocket_read112   ssize_t operator()(const socket_t* socket, void* buf, size_t count) {
113     return body(socket, buf, count);
114   };
115 };
116 extern struct socket_read socket_read;
117 
118 // Name: socket_register
119 // Params: socket_t* socket, reactor_t* reactor, void* context, socket_cb
120 // read_cb, socket_cb write_cb Return: void
121 struct socket_register {
122   std::function<void(socket_t* socket, reactor_t* reactor, void* context,
123                      socket_cb read_cb, socket_cb write_cb)>
124       body{[](socket_t* /* socket */, reactor_t* /* reactor */,
125               void* /* context */, socket_cb /* read_cb */,
126               socket_cb /* write_cb */) {}};
operatorsocket_register127   void operator()(socket_t* socket, reactor_t* reactor, void* context,
128                   socket_cb read_cb, socket_cb write_cb) {
129     body(socket, reactor, context, read_cb, write_cb);
130   };
131 };
132 extern struct socket_register socket_register;
133 
134 // Name: socket_unregister
135 // Params: socket_t* socket
136 // Return: void
137 struct socket_unregister {
138   std::function<void(socket_t* socket)> body{[](socket_t* /* socket */) {}};
operatorsocket_unregister139   void operator()(socket_t* socket) { body(socket); };
140 };
141 extern struct socket_unregister socket_unregister;
142 
143 // Name: socket_write
144 // Params: const socket_t* socket, const void* buf, size_t count
145 // Return: ssize_t
146 struct socket_write {
147   ssize_t return_value{0};
148   std::function<ssize_t(const socket_t* socket, const void* buf, size_t count)>
149       body{[this](const socket_t* /* socket */, const void* /* buf */,
150                   size_t /* count */) { return return_value; }};
operatorsocket_write151   ssize_t operator()(const socket_t* socket, const void* buf, size_t count) {
152     return body(socket, buf, count);
153   };
154 };
155 extern struct socket_write socket_write;
156 
157 // Name: socket_write_and_transfer_fd
158 // Params: const socket_t* socket, const void* buf, size_t count, int fd
159 // Return: ssize_t
160 struct socket_write_and_transfer_fd {
161   ssize_t return_value{0};
162   std::function<ssize_t(const socket_t* socket, const void* buf, size_t count,
163                         int fd)>
164       body{[this](const socket_t* /* socket */, const void* /* buf */,
165                   size_t /* count */, int /* fd */) { return return_value; }};
operatorsocket_write_and_transfer_fd166   ssize_t operator()(const socket_t* socket, const void* buf, size_t count,
167                      int fd) {
168     return body(socket, buf, count, fd);
169   };
170 };
171 extern struct socket_write_and_transfer_fd socket_write_and_transfer_fd;
172 
173 }  // namespace osi_socket
174 }  // namespace mock
175 }  // namespace test
176 
177 // END mockcify generation
178