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:8 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 <stdlib.h> 37 #include <string.h> 38 39 #include <mutex> 40 #include <unordered_map> 41 42 #include "check.h" 43 #include "osi/include/allocation_tracker.h" 44 #include "osi/include/allocator.h" 45 #include "osi/include/log.h" 46 #include "osi/include/osi.h" 47 #include "test/common/mock_functions.h" 48 49 // Mocked compile conditionals, if any 50 51 namespace test { 52 namespace mock { 53 namespace osi_allocation_tracker { 54 55 // Shared state between mocked functions and tests 56 // Name: allocation_tracker_expect_no_allocations 57 // Params: void 58 // Return: size_t 59 struct allocation_tracker_expect_no_allocations { 60 size_t return_value{0}; 61 std::function<size_t(void)> body{[this](void) { return return_value; }}; operatorallocation_tracker_expect_no_allocations62 size_t operator()(void) { return body(); }; 63 }; 64 extern struct allocation_tracker_expect_no_allocations 65 allocation_tracker_expect_no_allocations; 66 67 // Name: allocation_tracker_init 68 // Params: void 69 // Return: void 70 struct allocation_tracker_init { 71 std::function<void(void)> body{[](void) {}}; operatorallocation_tracker_init72 void operator()(void) { body(); }; 73 }; 74 extern struct allocation_tracker_init allocation_tracker_init; 75 76 // Name: allocation_tracker_notify_alloc 77 // Params: uint8_t allocator_id, void* ptr, size_t requested_size 78 // Return: void* 79 struct allocation_tracker_notify_alloc { 80 void* return_value{}; 81 std::function<void*(uint8_t allocator_id, void* ptr, size_t requested_size)> 82 body{[this](uint8_t allocator_id, void* ptr, size_t requested_size) { 83 return return_value; 84 }}; operatorallocation_tracker_notify_alloc85 void* operator()(uint8_t allocator_id, void* ptr, size_t requested_size) { 86 return body(allocator_id, ptr, requested_size); 87 }; 88 }; 89 extern struct allocation_tracker_notify_alloc allocation_tracker_notify_alloc; 90 91 // Name: allocation_tracker_notify_free 92 // Params: uint8_t allocator_id, void* ptr 93 // Return: void* 94 struct allocation_tracker_notify_free { 95 void* return_value{}; 96 std::function<void*(uint8_t allocator_id, void* ptr)> body{ 97 [this](uint8_t allocator_id, void* ptr) { return return_value; }}; operatorallocation_tracker_notify_free98 void* operator()(uint8_t allocator_id, void* ptr) { 99 return body(allocator_id, ptr); 100 }; 101 }; 102 extern struct allocation_tracker_notify_free allocation_tracker_notify_free; 103 104 // Name: allocation_tracker_reset 105 // Params: void 106 // Return: void 107 struct allocation_tracker_reset { 108 std::function<void(void)> body{[](void) {}}; operatorallocation_tracker_reset109 void operator()(void) { body(); }; 110 }; 111 extern struct allocation_tracker_reset allocation_tracker_reset; 112 113 // Name: allocation_tracker_resize_for_canary 114 // Params: size_t size 115 // Return: size_t 116 struct allocation_tracker_resize_for_canary { 117 size_t return_value{0}; 118 std::function<size_t(size_t size)> body{ 119 [this](size_t size) { return return_value; }}; operatorallocation_tracker_resize_for_canary120 size_t operator()(size_t size) { return body(size); }; 121 }; 122 extern struct allocation_tracker_resize_for_canary 123 allocation_tracker_resize_for_canary; 124 125 // Name: allocation_tracker_uninit 126 // Params: void 127 // Return: void 128 struct allocation_tracker_uninit { 129 std::function<void(void)> body{[](void) {}}; operatorallocation_tracker_uninit130 void operator()(void) { body(); }; 131 }; 132 extern struct allocation_tracker_uninit allocation_tracker_uninit; 133 134 // Name: osi_allocator_debug_dump 135 // Params: int fd 136 // Return: void 137 struct osi_allocator_debug_dump { 138 std::function<void(int fd)> body{[](int fd) {}}; operatorosi_allocator_debug_dump139 void operator()(int fd) { body(fd); }; 140 }; 141 extern struct osi_allocator_debug_dump osi_allocator_debug_dump; 142 143 } // namespace osi_allocation_tracker 144 } // namespace mock 145 } // namespace test 146 147 // END mockcify generation