• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cstdint>
25 #include <functional>
26 #include <map>
27 #include <string>
28 
29 extern std::map<std::string, int> mock_function_count_map;
30 
31 // Original included files, if any
32 // NOTE: Since this is a mock file with mock definitions some number of
33 //       include files may not be required.  The include-what-you-use
34 //       still applies, but crafting proper inclusion is out of scope
35 //       for this effort.  This compilation unit may compile as-is, or
36 //       may need attention to prune from (or add to ) the inclusion set.
37 #include <asm/ioctls.h>
38 #include <base/logging.h>
39 #include <errno.h>
40 #include <netinet/in.h>
41 #include <string.h>
42 #include <sys/ioctl.h>
43 #include <sys/socket.h>
44 #include <unistd.h>
45 
46 #include "check.h"
47 #include "osi/include/allocator.h"
48 #include "osi/include/log.h"
49 #include "osi/include/osi.h"
50 #include "osi/include/reactor.h"
51 #include "osi/include/socket.h"
52 
53 // Mocked compile conditionals, if any
54 
55 namespace test {
56 namespace mock {
57 namespace osi_socket {
58 
59 // Shared state between mocked functions and tests
60 // Name: socket_accept
61 // Params: const socket_t* socket
62 // Return: socket_t*
63 struct socket_accept {
64   socket_t* return_value{0};
65   std::function<socket_t*(const socket_t* socket)> body{
66       [this](const socket_t* socket) { return return_value; }};
operatorsocket_accept67   socket_t* operator()(const socket_t* socket) { return body(socket); };
68 };
69 extern struct socket_accept socket_accept;
70 
71 // Name: socket_bytes_available
72 // Params: const socket_t* socket
73 // Return: ssize_t
74 struct socket_bytes_available {
75   ssize_t return_value{0};
76   std::function<ssize_t(const socket_t* socket)> body{
77       [this](const socket_t* socket) { return return_value; }};
operatorsocket_bytes_available78   ssize_t operator()(const socket_t* socket) { return body(socket); };
79 };
80 extern struct socket_bytes_available socket_bytes_available;
81 
82 // Name: socket_free
83 // Params: socket_t* socket
84 // Return: void
85 struct socket_free {
86   std::function<void(socket_t* socket)> body{[](socket_t* socket) {}};
operatorsocket_free87   void operator()(socket_t* socket) { body(socket); };
88 };
89 extern struct socket_free socket_free;
90 
91 // Name: socket_listen
92 // Params: const socket_t* socket, port_t port
93 // Return: bool
94 struct socket_listen {
95   bool return_value{false};
96   std::function<bool(const socket_t* socket, port_t port)> body{
97       [this](const socket_t* socket, port_t port) { return return_value; }};
operatorsocket_listen98   bool operator()(const socket_t* socket, port_t port) {
99     return body(socket, port);
100   };
101 };
102 extern struct socket_listen socket_listen;
103 
104 // Name: socket_new
105 // Params: void
106 // Return: socket_t*
107 struct socket_new {
108   socket_t* return_value{0};
109   std::function<socket_t*(void)> body{[this](void) { return return_value; }};
operatorsocket_new110   socket_t* operator()(void) { return body(); };
111 };
112 extern struct socket_new socket_new;
113 
114 // Name: socket_new_from_fd
115 // Params: int fd
116 // Return: socket_t*
117 struct socket_new_from_fd {
118   socket_t* return_value{0};
119   std::function<socket_t*(int fd)> body{
120       [this](int fd) { return return_value; }};
operatorsocket_new_from_fd121   socket_t* operator()(int fd) { return body(fd); };
122 };
123 extern struct socket_new_from_fd socket_new_from_fd;
124 
125 // Name: socket_read
126 // Params: const socket_t* socket, void* buf, size_t count
127 // Return: ssize_t
128 struct socket_read {
129   ssize_t return_value{0};
130   std::function<ssize_t(const socket_t* socket, void* buf, size_t count)> body{
131       [this](const socket_t* socket, void* buf, size_t count) {
132         return return_value;
133       }};
operatorsocket_read134   ssize_t operator()(const socket_t* socket, void* buf, size_t count) {
135     return body(socket, buf, count);
136   };
137 };
138 extern struct socket_read socket_read;
139 
140 // Name: socket_register
141 // Params: socket_t* socket, reactor_t* reactor, void* context, socket_cb
142 // read_cb, socket_cb write_cb Return: void
143 struct socket_register {
144   std::function<void(socket_t* socket, reactor_t* reactor, void* context,
145                      socket_cb read_cb, socket_cb write_cb)>
146       body{[](socket_t* socket, reactor_t* reactor, void* context,
147               socket_cb read_cb, socket_cb write_cb) {}};
operatorsocket_register148   void operator()(socket_t* socket, reactor_t* reactor, void* context,
149                   socket_cb read_cb, socket_cb write_cb) {
150     body(socket, reactor, context, read_cb, write_cb);
151   };
152 };
153 extern struct socket_register socket_register;
154 
155 // Name: socket_unregister
156 // Params: socket_t* socket
157 // Return: void
158 struct socket_unregister {
159   std::function<void(socket_t* socket)> body{[](socket_t* socket) {}};
operatorsocket_unregister160   void operator()(socket_t* socket) { body(socket); };
161 };
162 extern struct socket_unregister socket_unregister;
163 
164 // Name: socket_write
165 // Params: const socket_t* socket, const void* buf, size_t count
166 // Return: ssize_t
167 struct socket_write {
168   ssize_t return_value{0};
169   std::function<ssize_t(const socket_t* socket, const void* buf, size_t count)>
170       body{[this](const socket_t* socket, const void* buf, size_t count) {
171         return return_value;
172       }};
operatorsocket_write173   ssize_t operator()(const socket_t* socket, const void* buf, size_t count) {
174     return body(socket, buf, count);
175   };
176 };
177 extern struct socket_write socket_write;
178 
179 // Name: socket_write_and_transfer_fd
180 // Params: const socket_t* socket, const void* buf, size_t count, int fd
181 // Return: ssize_t
182 struct socket_write_and_transfer_fd {
183   ssize_t return_value{0};
184   std::function<ssize_t(const socket_t* socket, const void* buf, size_t count,
185                         int fd)>
186       body{[this](const socket_t* socket, const void* buf, size_t count,
187                   int fd) { return return_value; }};
operatorsocket_write_and_transfer_fd188   ssize_t operator()(const socket_t* socket, const void* buf, size_t count,
189                      int fd) {
190     return body(socket, buf, count, fd);
191   };
192 };
193 extern struct socket_write_and_transfer_fd socket_write_and_transfer_fd;
194 
195 }  // namespace osi_socket
196 }  // namespace mock
197 }  // namespace test
198 
199 // END mockcify generation