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 <base/logging.h> 38 #include <errno.h> 39 #include <malloc.h> 40 #include <pthread.h> 41 #include <string.h> 42 #include <sys/prctl.h> 43 #include <sys/resource.h> 44 #include <sys/types.h> 45 #include <unistd.h> 46 47 #include <atomic> 48 49 #include "check.h" 50 #include "osi/include/allocator.h" 51 #include "osi/include/compat.h" 52 #include "osi/include/fixed_queue.h" 53 #include "osi/include/log.h" 54 #include "osi/include/reactor.h" 55 #include "osi/include/semaphore.h" 56 #include "osi/include/thread.h" 57 58 // Mocked compile conditionals, if any 59 60 namespace test { 61 namespace mock { 62 namespace osi_thread { 63 64 // Shared state between mocked functions and tests 65 // Name: thread_free 66 // Params: thread_t* thread 67 // Return: void 68 struct thread_free { 69 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_free70 void operator()(thread_t* thread) { body(thread); }; 71 }; 72 extern struct thread_free thread_free; 73 74 // Name: thread_get_reactor 75 // Params: const thread_t* thread 76 // Return: reactor_t* 77 struct thread_get_reactor { 78 reactor_t* return_value{0}; 79 std::function<reactor_t*(const thread_t* thread)> body{ 80 [this](const thread_t* thread) { return return_value; }}; operatorthread_get_reactor81 reactor_t* operator()(const thread_t* thread) { return body(thread); }; 82 }; 83 extern struct thread_get_reactor thread_get_reactor; 84 85 // Name: thread_is_self 86 // Params: const thread_t* thread 87 // Return: bool 88 struct thread_is_self { 89 bool return_value{false}; 90 std::function<bool(const thread_t* thread)> body{ 91 [this](const thread_t* thread) { return return_value; }}; operatorthread_is_self92 bool operator()(const thread_t* thread) { return body(thread); }; 93 }; 94 extern struct thread_is_self thread_is_self; 95 96 // Name: thread_join 97 // Params: thread_t* thread 98 // Return: void 99 struct thread_join { 100 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_join101 void operator()(thread_t* thread) { body(thread); }; 102 }; 103 extern struct thread_join thread_join; 104 105 // Name: thread_name 106 // Params: const thread_t* thread 107 // Return: const char* 108 struct thread_name { 109 const char* return_value{0}; 110 std::function<const char*(const thread_t* thread)> body{ 111 [this](const thread_t* thread) { return return_value; }}; operatorthread_name112 const char* operator()(const thread_t* thread) { return body(thread); }; 113 }; 114 extern struct thread_name thread_name; 115 116 // Name: thread_new 117 // Params: const char* name 118 // Return: thread_t* 119 struct thread_new { 120 thread_t* return_value{0}; 121 std::function<thread_t*(const char* name)> body{ 122 [this](const char* name) { return return_value; }}; operatorthread_new123 thread_t* operator()(const char* name) { return body(name); }; 124 }; 125 extern struct thread_new thread_new; 126 127 // Name: thread_new_sized 128 // Params: const char* name, size_t work_queue_capacity 129 // Return: thread_t* 130 struct thread_new_sized { 131 thread_t* return_value{0}; 132 std::function<thread_t*(const char* name, size_t work_queue_capacity)> body{ 133 [this](const char* name, size_t work_queue_capacity) { 134 return return_value; 135 }}; operatorthread_new_sized136 thread_t* operator()(const char* name, size_t work_queue_capacity) { 137 return body(name, work_queue_capacity); 138 }; 139 }; 140 extern struct thread_new_sized thread_new_sized; 141 142 // Name: thread_post 143 // Params: thread_t* thread, thread_fn func, void* context 144 // Return: bool 145 struct thread_post { 146 bool return_value{false}; 147 std::function<bool(thread_t* thread, thread_fn func, void* context)> body{ 148 [this](thread_t* thread, thread_fn func, void* context) { 149 return return_value; 150 }}; operatorthread_post151 bool operator()(thread_t* thread, thread_fn func, void* context) { 152 return body(thread, func, context); 153 }; 154 }; 155 extern struct thread_post thread_post; 156 157 // Name: thread_set_priority 158 // Params: thread_t* thread, int priority 159 // Return: bool 160 struct thread_set_priority { 161 bool return_value{false}; 162 std::function<bool(thread_t* thread, int priority)> body{ 163 [this](thread_t* thread, int priority) { return return_value; }}; operatorthread_set_priority164 bool operator()(thread_t* thread, int priority) { 165 return body(thread, priority); 166 }; 167 }; 168 extern struct thread_set_priority thread_set_priority; 169 170 // Name: thread_set_rt_priority 171 // Params: thread_t* thread, int priority 172 // Return: bool 173 struct thread_set_rt_priority { 174 bool return_value{false}; 175 std::function<bool(thread_t* thread, int priority)> body{ 176 [this](thread_t* thread, int priority) { return return_value; }}; operatorthread_set_rt_priority177 bool operator()(thread_t* thread, int priority) { 178 return body(thread, priority); 179 }; 180 }; 181 extern struct thread_set_rt_priority thread_set_rt_priority; 182 183 // Name: thread_stop 184 // Params: thread_t* thread 185 // Return: void 186 struct thread_stop { 187 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_stop188 void operator()(thread_t* thread) { body(thread); }; 189 }; 190 extern struct thread_stop thread_stop; 191 192 } // namespace osi_thread 193 } // namespace mock 194 } // namespace test 195 196 // END mockcify generation