]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
libplugin_mock: Link with the "real" cache.
authorFlorian Forster <octo@collectd.org>
Thu, 25 Jan 2024 14:15:57 +0000 (15:15 +0100)
committerFlorian Forster <octo@collectd.org>
Thu, 25 Jan 2024 19:53:29 +0000 (20:53 +0100)
Makefile.am
src/daemon/plugin_mock.c
src/daemon/utils_cache_mock.c [deleted file]
src/mdevents_test.c
src/pcie_errors_test.c

index eb4b60318abec548b494a067c81bad9749101a89..7086ecb24df6761cf9e1373841858e3f51eacb59 100644 (file)
@@ -445,11 +445,14 @@ libplugin_mock_la_SOURCES = \
        src/daemon/plugin_mock.c \
        src/daemon/configfile.c \
        src/daemon/configfile.h \
+       src/daemon/globals.c \
+       src/daemon/globals.h \
        src/daemon/resource.c \
        src/daemon/resource.h \
        src/daemon/types_list.c \
        src/daemon/types_list.h \
-       src/daemon/utils_cache_mock.c \
+       src/daemon/utils_cache.c \
+       src/daemon/utils_cache.h \
        src/daemon/utils_complain.c \
        src/daemon/utils_complain.h \
        src/daemon/utils_time.c \
@@ -457,7 +460,7 @@ libplugin_mock_la_SOURCES = \
        src/utils/value_list/value_list.c \
        src/utils/value_list/value_list.h
 libplugin_mock_la_CPPFLAGS = $(AM_CPPFLAGS) -DMOCK_TIME
-libplugin_mock_la_LIBADD = libmetric.la liboconfig.la libcommon.la libignorelist.la $(COMMON_LIBS)
+libplugin_mock_la_LIBADD = libavltree.la libmetric.la liboconfig.la libcommon.la libignorelist.la $(COMMON_LIBS)
 
 libformat_graphite_la_SOURCES = \
        src/utils/format_graphite/format_graphite.c \
index 4fe205cc23e41e32eab1e271b33fe60586315aae..9cb8ab3b3c17dd4ff91f293fe470aa6549f50623 100644 (file)
@@ -34,8 +34,6 @@
 kstat_ctl_t *kc = NULL;
 #endif /* HAVE_LIBKSTAT */
 
-char *hostname_g = "example.com";
-
 void plugin_set_dir(const char *dir) { /* nop */
 }
 
@@ -123,6 +121,19 @@ int plugin_dispatch_metric_family(metric_family_t const *fam) {
   return ENOTSUP;
 }
 
+int plugin_dispatch_missing(__attribute__((unused))
+                            metric_family_t const *fam) {
+  return ENOTSUP;
+}
+
+void plugin_dispatch_cache_event(
+    __attribute__((unused)) enum cache_event_type_e event_type,
+    __attribute__((unused)) unsigned long callbacks_mask,
+    __attribute__((unused)) const char *name,
+    __attribute__((unused)) metric_t const *m) {
+  // no-op
+}
+
 int plugin_dispatch_notification(__attribute__((unused))
                                  const notification_t *notif) {
   return ENOTSUP;
diff --git a/src/daemon/utils_cache_mock.c b/src/daemon/utils_cache_mock.c
deleted file mode 100644 (file)
index a88dfee..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-/**
- * collectd - src/tests/mock/utils_cache.c
- * Copyright (C) 2013       Florian octo Forster
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
- * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- *
- * Authors:
- *   Florian octo Forster <octo at collectd.org>
- */
-
-#include "utils_cache.h"
-#include <errno.h>
-
-#include <errno.h>
-
-gauge_t *uc_get_rate_vl(__attribute__((unused)) data_set_t const *ds,
-                        __attribute__((unused)) value_list_t const *vl) {
-  errno = ENOTSUP;
-  return NULL;
-}
-
-int uc_get_rate(__attribute__((unused)) metric_t const *m,
-                __attribute__((unused)) gauge_t *ret_value) {
-  return ENOTSUP;
-}
-
-int uc_get_rate_by_name(const char *name, gauge_t *ret_value) {
-  return ENOTSUP;
-}
-
-int uc_get_names(char ***ret_names, cdtime_t **ret_times, size_t *ret_number) {
-  return ENOTSUP;
-}
-
-int uc_get_value_by_name_vl(const char *name, value_t **ret_values,
-                            size_t *ret_values_num) {
-  return ENOTSUP;
-}
-
-int uc_meta_data_get_signed_int(metric_t const *m, const char *key,
-                                int64_t *value) {
-  return -ENOENT;
-}
-
-int uc_meta_data_get_unsigned_int(metric_t const *m, const char *key,
-                                  uint64_t *value) {
-  return -ENOENT;
-}
-
-int uc_meta_data_add_signed_int(metric_t const *m, const char *key,
-                                int64_t value) {
-  return 0;
-}
-
-int uc_meta_data_add_unsigned_int(metric_t const *m, const char *key,
-                                  uint64_t value) {
-  return 0;
-}
index 5f2cf66e7587e0b087a4d41c65c1af729fbda1bb..c183efbee7191199f83b40b2876e89dce72ed4c9 100644 (file)
@@ -108,6 +108,8 @@ DEF_TEST(dispatch_notification) {
   int ret;
   char buf[130];
 
+  hostname_set("example.com");
+
   memset(buf, 'a', 129);
   buf[129] = '\0';
 
index 5cb95fa48dd645a81bc8398aafc14fcf06a8b517..7145cb96faae31741462bb5a3e8eee1de53ade63 100644 (file)
@@ -149,6 +149,8 @@ DEF_TEST(pcie_read) {
 }
 
 DEF_TEST(dispatch_notification) {
+  hostname_set("example.com");
+
   pcie_device_t dev = {0, TEST_DOMAIN, TEST_BUS, TEST_DEVICE, TEST_FUNCTION,
                        0, 0,           0,        0,           0};
   cdtime_t t = cdtime();