summaryrefslogtreecommitdiffstats
path: root/collectors/cgroups.plugin/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-21 17:19:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-03-21 17:19:04 +0000
commit310edf444908b09ea6d00c03baceb7925f3bb7a2 (patch)
tree7064577c7fa7a851e2e930beb606ea8237b0bbd2 /collectors/cgroups.plugin/tests
parentReleasing debian version 1.44.3-2. (diff)
downloadnetdata-310edf444908b09ea6d00c03baceb7925f3bb7a2.tar.xz
netdata-310edf444908b09ea6d00c03baceb7925f3bb7a2.zip
Merging upstream version 1.45.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collectors/cgroups.plugin/tests')
-rw-r--r--collectors/cgroups.plugin/tests/test_cgroups_plugin.c130
-rw-r--r--collectors/cgroups.plugin/tests/test_cgroups_plugin.h16
-rw-r--r--collectors/cgroups.plugin/tests/test_doubles.c157
3 files changed, 0 insertions, 303 deletions
diff --git a/collectors/cgroups.plugin/tests/test_cgroups_plugin.c b/collectors/cgroups.plugin/tests/test_cgroups_plugin.c
deleted file mode 100644
index bb1fb3988..000000000
--- a/collectors/cgroups.plugin/tests/test_cgroups_plugin.c
+++ /dev/null
@@ -1,130 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "test_cgroups_plugin.h"
-#include "libnetdata/required_dummies.h"
-
-RRDHOST *localhost;
-int netdata_zero_metrics_enabled = 1;
-struct config netdata_config;
-char *netdata_configured_primary_plugins_dir = NULL;
-
-struct k8s_test_data {
- char *data;
- char *name;
- char *key[3];
- char *value[3];
-
- const char *result_key[3];
- const char *result_value[3];
- int result_ls[3];
- int i;
-};
-
-static int read_label_callback(const char *name, const char *value, void *data)
-{
- struct k8s_test_data *test_data = (struct k8s_test_data *)data;
-
- test_data->result_key[test_data->i] = name;
- test_data->result_value[test_data->i] = value;
-
- test_data->i++;
-
- return 1;
-}
-
-static void test_cgroup_parse_resolved_name(void **state)
-{
- UNUSED(state);
-
- RRDLABELS *labels = rrdlabels_create();
-
- struct k8s_test_data test_data[] = {
- // One label
- { .data = "name label1=\"value1\"",
- .name = "name",
- .key[0] = "label1", .value[0] = "value1" },
-
- // Three labels
- { .data = "name label1=\"value1\",label2=\"value2\",label3=\"value3\"",
- .name = "name",
- .key[0] = "label1", .value[0] = "value1",
- .key[1] = "label2", .value[1] = "value2",
- .key[2] = "label3", .value[2] = "value3" },
-
- // Comma at the end of the data string
- { .data = "name label1=\"value1\",",
- .name = "name",
- .key[0] = "label1", .value[0] = "value1" },
-
- // Equals sign in the value
- // { .data = "name label1=\"value=1\"",
- // .name = "name",
- // .key[0] = "label1", .value[0] = "value=1" },
-
- // Double quotation mark in the value
- // { .data = "name label1=\"value\"1\"",
- // .name = "name",
- // .key[0] = "label1", .value[0] = "value" },
-
- // Escaped double quotation mark in the value
- // { .data = "name label1=\"value\\\"1\"",
- // .name = "name",
- // .key[0] = "label1", .value[0] = "value\\\"1" },
-
- // Equals sign in the key
- // { .data = "name label=1=\"value1\"",
- // .name = "name",
- // .key[0] = "label", .value[0] = "1=\"value1\"" },
-
- // Skipped value
- // { .data = "name label1=,label2=\"value2\"",
- // .name = "name",
- // .key[0] = "label2", .value[0] = "value2" },
-
- // A pair of equals signs
- { .data = "name= =",
- .name = "name=" },
-
- // A pair of commas
- { .data = "name, ,",
- .name = "name," },
-
- { .data = NULL }
- };
-
- for (int i = 0; test_data[i].data != NULL; i++) {
- char *data = strdup(test_data[i].data);
-
- char *name = cgroup_parse_resolved_name_and_labels(labels, data);
-
- assert_string_equal(name, test_data[i].name);
-
- rrdlabels_walkthrough_read(labels, read_label_callback, &test_data[i]);
-
- for (int l = 0; l < 3 && test_data[i].key[l] != NULL; l++) {
- char *key = test_data[i].key[l];
- char *value = test_data[i].value[l];
-
- const char *result_key = test_data[i].result_key[l];
- const char *result_value = test_data[i].result_value[l];
- int ls = test_data[i].result_ls[l];
-
- assert_string_equal(key, result_key);
- assert_string_equal(value, result_value);
- assert_int_equal(RRDLABEL_SRC_AUTO | RRDLABEL_SRC_K8S, ls);
- }
-
- free(data);
- }
-}
-
-int main(void)
-{
- const struct CMUnitTest tests[] = {
- cmocka_unit_test(test_cgroup_parse_resolved_name),
- };
-
- int test_res = cmocka_run_group_tests_name("test_cgroup_parse_resolved_name", tests, NULL, NULL);
-
- return test_res;
-}
diff --git a/collectors/cgroups.plugin/tests/test_cgroups_plugin.h b/collectors/cgroups.plugin/tests/test_cgroups_plugin.h
deleted file mode 100644
index 3d68e9230..000000000
--- a/collectors/cgroups.plugin/tests/test_cgroups_plugin.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#ifndef TEST_CGROUPS_PLUGIN_H
-#define TEST_CGROUPS_PLUGIN_H 1
-
-#include "libnetdata/libnetdata.h"
-
-#include "../sys_fs_cgroup.h"
-
-#include <stdarg.h>
-#include <stddef.h>
-#include <setjmp.h>
-#include <stdint.h>
-#include <cmocka.h>
-
-#endif /* TEST_CGROUPS_PLUGIN_H */
diff --git a/collectors/cgroups.plugin/tests/test_doubles.c b/collectors/cgroups.plugin/tests/test_doubles.c
deleted file mode 100644
index b13d4b19c..000000000
--- a/collectors/cgroups.plugin/tests/test_doubles.c
+++ /dev/null
@@ -1,157 +0,0 @@
-// SPDX-License-Identifier: GPL-3.0-or-later
-
-#include "test_cgroups_plugin.h"
-
-void rrdset_is_obsolete___safe_from_collector_thread(RRDSET *st)
-{
- UNUSED(st);
-}
-
-void rrdset_isnot_obsolete___safe_from_collector_thread(RRDSET *st)
-{
- UNUSED(st);
-}
-
-struct mountinfo *mountinfo_read(int do_statvfs)
-{
- UNUSED(do_statvfs);
-
- return NULL;
-}
-
-struct mountinfo *
-mountinfo_find_by_filesystem_mount_source(struct mountinfo *root, const char *filesystem, const char *mount_source)
-{
- UNUSED(root);
- UNUSED(filesystem);
- UNUSED(mount_source);
-
- return NULL;
-}
-
-struct mountinfo *
-mountinfo_find_by_filesystem_super_option(struct mountinfo *root, const char *filesystem, const char *super_options)
-{
- UNUSED(root);
- UNUSED(filesystem);
- UNUSED(super_options);
-
- return NULL;
-}
-
-void mountinfo_free_all(struct mountinfo *mi)
-{
- UNUSED(mi);
-}
-
-RRDSET *rrdset_create_custom(
- RRDHOST *host, const char *type, const char *id, const char *name, const char *family, const char *context,
- const char *title, const char *units, const char *plugin, const char *module, long priority, int update_every,
- RRDSET_TYPE chart_type, RRD_MEMORY_MODE memory_mode, long history_entries)
-{
- UNUSED(host);
- UNUSED(type);
- UNUSED(id);
- UNUSED(name);
- UNUSED(family);
- UNUSED(context);
- UNUSED(title);
- UNUSED(units);
- UNUSED(plugin);
- UNUSED(module);
- UNUSED(priority);
- UNUSED(update_every);
- UNUSED(chart_type);
- UNUSED(memory_mode);
- UNUSED(history_entries);
-
- return NULL;
-}
-
-RRDDIM *rrddim_add_custom(
- RRDSET *st, const char *id, const char *name, collected_number multiplier, collected_number divisor,
- RRD_ALGORITHM algorithm, RRD_MEMORY_MODE memory_mode)
-{
- UNUSED(st);
- UNUSED(id);
- UNUSED(name);
- UNUSED(multiplier);
- UNUSED(divisor);
- UNUSED(algorithm);
- UNUSED(memory_mode);
-
- return NULL;
-}
-
-collected_number rrddim_set(RRDSET *st, const char *id, collected_number value)
-{
- UNUSED(st);
- UNUSED(id);
- UNUSED(value);
-
- return 0;
-}
-
-collected_number rrddim_set_by_pointer(RRDSET *st, RRDDIM *rd, collected_number value)
-{
- UNUSED(st);
- UNUSED(rd);
- UNUSED(value);
-
- return 0;
-}
-
-const RRDSETVAR_ACQUIRED *rrdsetvar_custom_chart_variable_add_and_acquire(RRDSET *st, const char *name)
-{
- UNUSED(st);
- UNUSED(name);
-
- return NULL;
-}
-
-void rrdsetvar_custom_chart_variable_set(RRDSET *st, const RRDSETVAR_ACQUIRED *rsa, NETDATA_DOUBLE value)
-{
- UNUSED(st);
- UNUSED(rsa);
- UNUSED(value);
-}
-
-void rrdset_next_usec(RRDSET *st, usec_t microseconds)
-{
- UNUSED(st);
- UNUSED(microseconds);
-}
-
-void rrdset_done(RRDSET *st)
-{
- UNUSED(st);
-}
-
-void update_pressure_charts(struct pressure_charts *charts)
-{
- UNUSED(charts);
-}
-
-void netdev_rename_device_add(
- const char *host_device, const char *container_device, const char *container_name, DICTIONARY *labels, const char *ctx_prefix)
-{
- UNUSED(host_device);
- UNUSED(container_device);
- UNUSED(container_name);
- UNUSED(labels);
- UNUSED(ctx_prefix);
-}
-
-void netdev_rename_device_del(const char *host_device)
-{
- UNUSED(host_device);
-}
-
-void rrdcalc_update_rrdlabels(RRDSET *st) {
- (void)st;
-}
-
-void db_execute(const char *cmd)
-{
- UNUSED(cmd);
-}