• 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:6
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 "check.h"
40 #include "osi/include/allocation_tracker.h"
41 #include "osi/include/allocator.h"
42 #include "test/common/mock_functions.h"
43 
44 // Mocked compile conditionals, if any
45 
46 namespace test {
47 namespace mock {
48 namespace osi_allocator {
49 
50 // Shared state between mocked functions and tests
51 // Name: osi_calloc
52 // Params: size_t size
53 // Return: void*
54 struct osi_calloc {
55   void* return_value{};
56   std::function<void*(size_t size)> body{
57       [this](size_t size) { return return_value; }};
operatorosi_calloc58   void* operator()(size_t size) { return body(size); };
59 };
60 extern struct osi_calloc osi_calloc;
61 
62 // Name: osi_free
63 // Params: void* ptr
64 // Return: void
65 struct osi_free {
66   std::function<void(void* ptr)> body{[](void* ptr) {}};
operatorosi_free67   void operator()(void* ptr) { body(ptr); };
68 };
69 extern struct osi_free osi_free;
70 
71 // Name: osi_free_and_reset
72 // Params: void** p_ptr
73 // Return: void
74 struct osi_free_and_reset {
75   std::function<void(void** p_ptr)> body{[](void** p_ptr) {}};
operatorosi_free_and_reset76   void operator()(void** p_ptr) { body(p_ptr); };
77 };
78 extern struct osi_free_and_reset osi_free_and_reset;
79 
80 // Name: osi_malloc
81 // Params: size_t size
82 // Return: void*
83 struct osi_malloc {
84   void* return_value{};
85   std::function<void*(size_t size)> body{
86       [this](size_t size) { return return_value; }};
operatorosi_malloc87   void* operator()(size_t size) { return body(size); };
88 };
89 extern struct osi_malloc osi_malloc;
90 
91 // Name: osi_strdup
92 // Params: const char* str
93 // Return: char*
94 struct osi_strdup {
95   char* return_value{0};
96   std::function<char*(const char* str)> body{
97       [this](const char* str) { return return_value; }};
operatorosi_strdup98   char* operator()(const char* str) { return body(str); };
99 };
100 extern struct osi_strdup osi_strdup;
101 
102 // Name: osi_strndup
103 // Params: const char* str, size_t len
104 // Return: char*
105 struct osi_strndup {
106   char* return_value{0};
107   std::function<char*(const char* str, size_t len)> body{
108       [this](const char* str, size_t len) { return return_value; }};
operatorosi_strndup109   char* operator()(const char* str, size_t len) { return body(str, len); };
110 };
111 extern struct osi_strndup osi_strndup;
112 
113 }  // namespace osi_allocator
114 }  // namespace mock
115 }  // namespace test
116 
117 // END mockcify generation