From: Florian Forster Date: Thu, 25 Jan 2024 14:15:57 +0000 (+0100) Subject: libplugin_mock: Link with the "real" cache. X-Git-Tag: collectd-6.0.0.rc2~13^2~13 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b570c9a7ff8b4db37f4f6e0becd3f52e4ea686c3;p=thirdparty%2Fcollectd.git libplugin_mock: Link with the "real" cache. --- diff --git a/Makefile.am b/Makefile.am index eb4b60318..7086ecb24 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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 \ diff --git a/src/daemon/plugin_mock.c b/src/daemon/plugin_mock.c index 4fe205cc2..9cb8ab3b3 100644 --- a/src/daemon/plugin_mock.c +++ b/src/daemon/plugin_mock.c @@ -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 index a88dfeee2..000000000 --- a/src/daemon/utils_cache_mock.c +++ /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 - */ - -#include "utils_cache.h" -#include - -#include - -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; -} diff --git a/src/mdevents_test.c b/src/mdevents_test.c index 5f2cf66e7..c183efbee 100644 --- a/src/mdevents_test.c +++ b/src/mdevents_test.c @@ -108,6 +108,8 @@ DEF_TEST(dispatch_notification) { int ret; char buf[130]; + hostname_set("example.com"); + memset(buf, 'a', 129); buf[129] = '\0'; diff --git a/src/pcie_errors_test.c b/src/pcie_errors_test.c index 5cb95fa48..7145cb96f 100644 --- a/src/pcie_errors_test.c +++ b/src/pcie_errors_test.c @@ -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();