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 // Original included files, if any 30 // NOTE: Since this is a mock file with mock definitions some number of 31 // include files may not be required. The include-what-you-use 32 // still applies, but crafting proper inclusion is out of scope 33 // for this effort. This compilation unit may compile as-is, or 34 // may need attention to prune from (or add to ) the inclusion set. 35 #include <base/logging.h> 36 #include <errno.h> 37 #include <malloc.h> 38 #include <pthread.h> 39 #include <string.h> 40 #include <sys/prctl.h> 41 #include <sys/resource.h> 42 #include <sys/types.h> 43 #include <unistd.h> 44 45 #include <atomic> 46 47 #include "check.h" 48 #include "osi/include/allocator.h" 49 #include "osi/include/compat.h" 50 #include "osi/include/fixed_queue.h" 51 #include "osi/include/log.h" 52 #include "osi/include/reactor.h" 53 #include "osi/include/thread.h" 54 #include "test/common/mock_functions.h" 55 56 // Mocked compile conditionals, if any 57 58 namespace test { 59 namespace mock { 60 namespace osi_thread { 61 62 // Shared state between mocked functions and tests 63 // Name: thread_free 64 // Params: thread_t* thread 65 // Return: void 66 struct thread_free { 67 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_free68 void operator()(thread_t* thread) { body(thread); }; 69 }; 70 extern struct thread_free thread_free; 71 72 // Name: thread_get_reactor 73 // Params: const thread_t* thread 74 // Return: reactor_t* 75 struct thread_get_reactor { 76 reactor_t* return_value{0}; 77 std::function<reactor_t*(const thread_t* thread)> body{ 78 [this](const thread_t* thread) { return return_value; }}; operatorthread_get_reactor79 reactor_t* operator()(const thread_t* thread) { return body(thread); }; 80 }; 81 extern struct thread_get_reactor thread_get_reactor; 82 83 // Name: thread_is_self 84 // Params: const thread_t* thread 85 // Return: bool 86 struct thread_is_self { 87 bool return_value{false}; 88 std::function<bool(const thread_t* thread)> body{ 89 [this](const thread_t* thread) { return return_value; }}; operatorthread_is_self90 bool operator()(const thread_t* thread) { return body(thread); }; 91 }; 92 extern struct thread_is_self thread_is_self; 93 94 // Name: thread_join 95 // Params: thread_t* thread 96 // Return: void 97 struct thread_join { 98 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_join99 void operator()(thread_t* thread) { body(thread); }; 100 }; 101 extern struct thread_join thread_join; 102 103 // Name: thread_name 104 // Params: const thread_t* thread 105 // Return: const char* 106 struct thread_name { 107 const char* return_value{0}; 108 std::function<const char*(const thread_t* thread)> body{ 109 [this](const thread_t* thread) { return return_value; }}; operatorthread_name110 const char* operator()(const thread_t* thread) { return body(thread); }; 111 }; 112 extern struct thread_name thread_name; 113 114 // Name: thread_new 115 // Params: const char* name 116 // Return: thread_t* 117 struct thread_new { 118 thread_t* return_value{0}; 119 std::function<thread_t*(const char* name)> body{ 120 [this](const char* name) { return return_value; }}; operatorthread_new121 thread_t* operator()(const char* name) { return body(name); }; 122 }; 123 extern struct thread_new thread_new; 124 125 // Name: thread_new_sized 126 // Params: const char* name, size_t work_queue_capacity 127 // Return: thread_t* 128 struct thread_new_sized { 129 thread_t* return_value{0}; 130 std::function<thread_t*(const char* name, size_t work_queue_capacity)> body{ 131 [this](const char* name, size_t work_queue_capacity) { 132 return return_value; 133 }}; operatorthread_new_sized134 thread_t* operator()(const char* name, size_t work_queue_capacity) { 135 return body(name, work_queue_capacity); 136 }; 137 }; 138 extern struct thread_new_sized thread_new_sized; 139 140 // Name: thread_post 141 // Params: thread_t* thread, thread_fn func, void* context 142 // Return: bool 143 struct thread_post { 144 bool return_value{false}; 145 std::function<bool(thread_t* thread, thread_fn func, void* context)> body{ 146 [this](thread_t* thread, thread_fn func, void* context) { 147 return return_value; 148 }}; operatorthread_post149 bool operator()(thread_t* thread, thread_fn func, void* context) { 150 return body(thread, func, context); 151 }; 152 }; 153 extern struct thread_post thread_post; 154 155 // Name: thread_set_priority 156 // Params: thread_t* thread, int priority 157 // Return: bool 158 struct thread_set_priority { 159 bool return_value{false}; 160 std::function<bool(thread_t* thread, int priority)> body{ 161 [this](thread_t* thread, int priority) { return return_value; }}; operatorthread_set_priority162 bool operator()(thread_t* thread, int priority) { 163 return body(thread, priority); 164 }; 165 }; 166 extern struct thread_set_priority thread_set_priority; 167 168 // Name: thread_set_rt_priority 169 // Params: thread_t* thread, int priority 170 // Return: bool 171 struct thread_set_rt_priority { 172 bool return_value{false}; 173 std::function<bool(thread_t* thread, int priority)> body{ 174 [this](thread_t* thread, int priority) { return return_value; }}; operatorthread_set_rt_priority175 bool operator()(thread_t* thread, int priority) { 176 return body(thread, priority); 177 }; 178 }; 179 extern struct thread_set_rt_priority thread_set_rt_priority; 180 181 // Name: thread_stop 182 // Params: thread_t* thread 183 // Return: void 184 struct thread_stop { 185 std::function<void(thread_t* thread)> body{[](thread_t* thread) {}}; operatorthread_stop186 void operator()(thread_t* thread) { body(thread); }; 187 }; 188 extern struct thread_stop thread_stop; 189 190 } // namespace osi_thread 191 } // namespace mock 192 } // namespace test 193 194 // END mockcify generation