summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 12:59:37 +0200
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-09-15 12:59:37 +0200
commit802e46f8ea36c344f112d7e1dd8d64d17a4cc939 (patch)
treecabf480269113686430053d66df3dadcd4d137a7 /plugins/tests
parenta3cf9041af810770daf5d9b83f1906fa9bb0dd11 (diff)
downloadmonitoring-plugins-802e46f8ea36c344f112d7e1dd8d64d17a4cc939.tar.gz
Run clang-format again
Diffstat (limited to 'plugins/tests')
-rw-r--r--plugins/tests/test_check_disk.c48
-rw-r--r--plugins/tests/test_check_swap.c4
2 files changed, 33 insertions, 19 deletions
diff --git a/plugins/tests/test_check_disk.c b/plugins/tests/test_check_disk.c
index 35c57bce..32b46c2d 100644
--- a/plugins/tests/test_check_disk.c
+++ b/plugins/tests/test_check_disk.c
@@ -21,7 +21,8 @@
21#include "../../tap/tap.h" 21#include "../../tap/tap.h"
22#include "regex.h" 22#include "regex.h"
23 23
24void np_test_mount_entry_regex(struct mount_entry *dummy_mount_list, char *regstr, int cflags, int expect, char *desc); 24void np_test_mount_entry_regex(struct mount_entry *dummy_mount_list, char *regstr, int cflags,
25 int expect, char *desc);
25 26
26int main(int argc, char **argv) { 27int main(int argc, char **argv) {
27 plan_tests(35); 28 plan_tests(35);
@@ -70,16 +71,26 @@ int main(int argc, char **argv) {
70 71
71 int cflags = REG_NOSUB | REG_EXTENDED; 72 int cflags = REG_NOSUB | REG_EXTENDED;
72 np_test_mount_entry_regex(dummy_mount_list, strdup("/"), cflags, 3, strdup("a")); 73 np_test_mount_entry_regex(dummy_mount_list, strdup("/"), cflags, 3, strdup("a"));
73 np_test_mount_entry_regex(dummy_mount_list, strdup("/dev"), cflags, 3, strdup("regex on dev names:")); 74 np_test_mount_entry_regex(dummy_mount_list, strdup("/dev"), cflags, 3,
74 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"), cflags, 0, strdup("regex on non existent dev/path:")); 75 strdup("regex on dev names:"));
75 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"), cflags | REG_ICASE, 0, strdup("regi on non existent dev/path:")); 76 np_test_mount_entry_regex(dummy_mount_list, strdup("/foo"), cflags, 0,
76 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"), cflags, 3, strdup("partial devname regex match:")); 77 strdup("regex on non existent dev/path:"));
77 np_test_mount_entry_regex(dummy_mount_list, strdup("c0t0"), cflags, 1, strdup("partial devname regex match:")); 78 np_test_mount_entry_regex(dummy_mount_list, strdup("/Foo"), cflags | REG_ICASE, 0,
78 np_test_mount_entry_regex(dummy_mount_list, strdup("C0t0"), cflags | REG_ICASE, 1, strdup("partial devname regi match:")); 79 strdup("regi on non existent dev/path:"));
79 np_test_mount_entry_regex(dummy_mount_list, strdup("home"), cflags, 1, strdup("partial pathname regex match:")); 80 np_test_mount_entry_regex(dummy_mount_list, strdup("/c.t0"), cflags, 3,
80 np_test_mount_entry_regex(dummy_mount_list, strdup("hOme"), cflags | REG_ICASE, 1, strdup("partial pathname regi match:")); 81 strdup("partial devname regex match:"));
81 np_test_mount_entry_regex(dummy_mount_list, strdup("(/home)|(/var)"), cflags, 2, strdup("grouped regex pathname match:")); 82 np_test_mount_entry_regex(dummy_mount_list, strdup("c0t0"), cflags, 1,
82 np_test_mount_entry_regex(dummy_mount_list, strdup("(/homE)|(/Var)"), cflags | REG_ICASE, 2, strdup("grouped regi pathname match:")); 83 strdup("partial devname regex match:"));
84 np_test_mount_entry_regex(dummy_mount_list, strdup("C0t0"), cflags | REG_ICASE, 1,
85 strdup("partial devname regi match:"));
86 np_test_mount_entry_regex(dummy_mount_list, strdup("home"), cflags, 1,
87 strdup("partial pathname regex match:"));
88 np_test_mount_entry_regex(dummy_mount_list, strdup("hOme"), cflags | REG_ICASE, 1,
89 strdup("partial pathname regi match:"));
90 np_test_mount_entry_regex(dummy_mount_list, strdup("(/home)|(/var)"), cflags, 2,
91 strdup("grouped regex pathname match:"));
92 np_test_mount_entry_regex(dummy_mount_list, strdup("(/homE)|(/Var)"), cflags | REG_ICASE, 2,
93 strdup("grouped regi pathname match:"));
83 94
84 filesystem_list test_paths = filesystem_list_init(); 95 filesystem_list test_paths = filesystem_list_init();
85 mp_int_fs_list_append(&test_paths, "/home/groups"); 96 mp_int_fs_list_append(&test_paths, "/home/groups");
@@ -94,15 +105,18 @@ int main(int argc, char **argv) {
94 struct mount_entry *temp_me; 105 struct mount_entry *temp_me;
95 temp_me = p->best_match; 106 temp_me = p->best_match;
96 if (!strcmp(p->name, "/home/groups")) { 107 if (!strcmp(p->name, "/home/groups")) {
97 ok(temp_me && !strcmp(temp_me->me_mountdir, "/home"), "/home/groups got right best match: /home"); 108 ok(temp_me && !strcmp(temp_me->me_mountdir, "/home"),
109 "/home/groups got right best match: /home");
98 } else if (!strcmp(p->name, "/var")) { 110 } else if (!strcmp(p->name, "/var")) {
99 ok(temp_me && !strcmp(temp_me->me_mountdir, "/var"), "/var got right best match: /var"); 111 ok(temp_me && !strcmp(temp_me->me_mountdir, "/var"), "/var got right best match: /var");
100 } else if (!strcmp(p->name, "/tmp")) { 112 } else if (!strcmp(p->name, "/tmp")) {
101 ok(temp_me && !strcmp(temp_me->me_mountdir, "/"), "/tmp got right best match: /"); 113 ok(temp_me && !strcmp(temp_me->me_mountdir, "/"), "/tmp got right best match: /");
102 } else if (!strcmp(p->name, "/home/tonvoon")) { 114 } else if (!strcmp(p->name, "/home/tonvoon")) {
103 ok(temp_me && !strcmp(temp_me->me_mountdir, "/home"), "/home/tonvoon got right best match: /home"); 115 ok(temp_me && !strcmp(temp_me->me_mountdir, "/home"),
116 "/home/tonvoon got right best match: /home");
104 } else if (!strcmp(p->name, "/dev/c2t0d0s0")) { 117 } else if (!strcmp(p->name, "/dev/c2t0d0s0")) {
105 ok(temp_me && !strcmp(temp_me->me_devname, "/dev/c2t0d0s0"), "/dev/c2t0d0s0 got right best match: /dev/c2t0d0s0"); 118 ok(temp_me && !strcmp(temp_me->me_devname, "/dev/c2t0d0s0"),
119 "/dev/c2t0d0s0 got right best match: /dev/c2t0d0s0");
106 } 120 }
107 } 121 }
108 122
@@ -180,7 +194,8 @@ int main(int argc, char **argv) {
180 return exit_status(); 194 return exit_status();
181} 195}
182 196
183void np_test_mount_entry_regex(struct mount_entry *dummy_mount_list, char *regstr, int cflags, int expect, char *desc) { 197void np_test_mount_entry_regex(struct mount_entry *dummy_mount_list, char *regstr, int cflags,
198 int expect, char *desc) {
184 regex_t regex; 199 regex_t regex;
185 if (regcomp(&regex, regstr, cflags) == 0) { 200 if (regcomp(&regex, regstr, cflags) == 0) {
186 int matches = 0; 201 int matches = 0;
@@ -189,7 +204,8 @@ void np_test_mount_entry_regex(struct mount_entry *dummy_mount_list, char *regst
189 matches++; 204 matches++;
190 } 205 }
191 } 206 }
192 ok(matches == expect, "%s '%s' matched %i/3 entries. ok: %i/3", desc, regstr, expect, matches); 207 ok(matches == expect, "%s '%s' matched %i/3 entries. ok: %i/3", desc, regstr, expect,
208 matches);
193 209
194 } else { 210 } else {
195 ok(false, "regex '%s' not compilable", regstr); 211 ok(false, "regex '%s' not compilable", regstr);
diff --git a/plugins/tests/test_check_swap.c b/plugins/tests/test_check_swap.c
index b85fb4ad..94d56ce7 100644
--- a/plugins/tests/test_check_swap.c
+++ b/plugins/tests/test_check_swap.c
@@ -5,9 +5,7 @@
5int verbose = 0; 5int verbose = 0;
6 6
7void print_usage(void) {} 7void print_usage(void) {}
8void print_help(swap_config config) { 8void print_help(swap_config config) { (void)config; }
9 (void) config;
10}
11 9
12const char *progname = "test_check_swap"; 10const char *progname = "test_check_swap";
13 11