netdata_doubles.c 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. // SPDX-License-Identifier: GPL-3.0-or-later
  2. #include "test_exporting_engine.h"
  3. // Use memory allocation functions guarded by CMocka in strdupz
  4. const char *__wrap_strdupz(const char *s)
  5. {
  6. char *duplicate = malloc(sizeof(char) * (strlen(s) + 1));
  7. strcpy(duplicate, s);
  8. return duplicate;
  9. }
  10. time_t __wrap_now_realtime_sec(void)
  11. {
  12. function_called();
  13. return mock_type(time_t);
  14. }
  15. void __wrap_uv_thread_set_name_np(uv_thread_t ut, const char* name)
  16. {
  17. (void)ut;
  18. (void)name;
  19. function_called();
  20. }
  21. void __wrap_info_int(const char *file, const char *function, const unsigned long line, const char *fmt, ...)
  22. {
  23. (void)file;
  24. (void)function;
  25. (void)line;
  26. function_called();
  27. va_list args;
  28. va_start(args, fmt);
  29. vsnprintf(log_line, MAX_LOG_LINE, fmt, args);
  30. va_end(args);
  31. }
  32. int __wrap_connect_to_one_of(
  33. const char *destination,
  34. int default_port,
  35. struct timeval *timeout,
  36. size_t *reconnects_counter,
  37. char *connected_to,
  38. size_t connected_to_size)
  39. {
  40. (void)timeout;
  41. function_called();
  42. check_expected(destination);
  43. check_expected_ptr(default_port);
  44. // TODO: check_expected_ptr(timeout);
  45. check_expected(reconnects_counter);
  46. check_expected(connected_to);
  47. check_expected(connected_to_size);
  48. return mock_type(int);
  49. }
  50. void __rrdhost_check_rdlock(RRDHOST *host, const char *file, const char *function, const unsigned long line)
  51. {
  52. (void)host;
  53. (void)file;
  54. (void)function;
  55. (void)line;
  56. }
  57. void __rrdset_check_rdlock(RRDSET *st, const char *file, const char *function, const unsigned long line)
  58. {
  59. (void)st;
  60. (void)file;
  61. (void)function;
  62. (void)line;
  63. }
  64. void __rrd_check_rdlock(const char *file, const char *function, const unsigned long line)
  65. {
  66. (void)file;
  67. (void)function;
  68. (void)line;
  69. }
  70. RRDSET *rrdset_create_custom(
  71. RRDHOST *host,
  72. const char *type,
  73. const char *id,
  74. const char *name,
  75. const char *family,
  76. const char *context,
  77. const char *title,
  78. const char *units,
  79. const char *plugin,
  80. const char *module,
  81. long priority,
  82. int update_every,
  83. RRDSET_TYPE chart_type,
  84. RRD_MEMORY_MODE memory_mode,
  85. long history_entries)
  86. {
  87. check_expected_ptr(host);
  88. check_expected_ptr(type);
  89. check_expected_ptr(id);
  90. check_expected_ptr(name);
  91. check_expected_ptr(family);
  92. check_expected_ptr(context);
  93. UNUSED(title);
  94. check_expected_ptr(units);
  95. check_expected_ptr(plugin);
  96. check_expected_ptr(module);
  97. check_expected(priority);
  98. check_expected(update_every);
  99. check_expected(chart_type);
  100. UNUSED(memory_mode);
  101. UNUSED(history_entries);
  102. function_called();
  103. return mock_ptr_type(RRDSET *);
  104. }
  105. void rrdset_next_usec(RRDSET *st, usec_t microseconds)
  106. {
  107. check_expected_ptr(st);
  108. UNUSED(microseconds);
  109. function_called();
  110. }
  111. void rrdset_done(RRDSET *st)
  112. {
  113. check_expected_ptr(st);
  114. function_called();
  115. }
  116. RRDDIM *rrddim_add_custom(
  117. RRDSET *st,
  118. const char *id,
  119. const char *name,
  120. collected_number multiplier,
  121. collected_number divisor,
  122. RRD_ALGORITHM algorithm,
  123. RRD_MEMORY_MODE memory_mode)
  124. {
  125. check_expected_ptr(st);
  126. UNUSED(id);
  127. check_expected_ptr(name);
  128. check_expected(multiplier);
  129. check_expected(divisor);
  130. check_expected(algorithm);
  131. UNUSED(memory_mode);
  132. function_called();
  133. return NULL;
  134. }
  135. collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value)
  136. {
  137. check_expected_ptr(st);
  138. UNUSED(rd);
  139. UNUSED(value);
  140. function_called();
  141. return 0;
  142. }
  143. const char *rrd_memory_mode_name(RRD_MEMORY_MODE id)
  144. {
  145. (void)id;
  146. return RRD_MEMORY_MODE_NONE_NAME;
  147. }
  148. calculated_number rrdvar2number(RRDVAR *rv)
  149. {
  150. (void)rv;
  151. return 0;
  152. }
  153. int foreach_host_variable_callback(RRDHOST *host, int (*callback)(RRDVAR *rv, void *data), void *data)
  154. {
  155. (void)host;
  156. (void)callback;
  157. (void)data;
  158. return 0;
  159. }
  160. void rrdset_update_heterogeneous_flag(RRDSET *st)
  161. {
  162. (void)st;
  163. }
  164. time_t __mock_rrddim_query_oldest_time(RRDDIM *rd)
  165. {
  166. (void)rd;
  167. function_called();
  168. return mock_type(time_t);
  169. }
  170. time_t __mock_rrddim_query_latest_time(RRDDIM *rd)
  171. {
  172. (void)rd;
  173. function_called();
  174. return mock_type(time_t);
  175. }
  176. void __mock_rrddim_query_init(RRDDIM *rd, struct rrddim_query_handle *handle, time_t start_time, time_t end_time)
  177. {
  178. (void)rd;
  179. (void)handle;
  180. function_called();
  181. check_expected(start_time);
  182. check_expected(end_time);
  183. }
  184. int __mock_rrddim_query_is_finished(struct rrddim_query_handle *handle)
  185. {
  186. (void)handle;
  187. function_called();
  188. return mock_type(int);
  189. }
  190. storage_number __mock_rrddim_query_next_metric(struct rrddim_query_handle *handle, time_t *current_time)
  191. {
  192. (void)handle;
  193. (void)current_time;
  194. function_called();
  195. return mock_type(storage_number);
  196. }
  197. void __mock_rrddim_query_finalize(struct rrddim_query_handle *handle)
  198. {
  199. (void)handle;
  200. function_called();
  201. }