]> git.ipfire.org Git - collecty.git/commitdiff
sources: Add a test that stalls the event loop
authorMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Oct 2025 16:02:09 +0000 (16:02 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sat, 4 Oct 2025 16:02:09 +0000 (16:02 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
Makefile.am
src/daemon/sources.c
src/daemon/sources/test-stall.c [new file with mode: 0644]
src/daemon/sources/test-stall.h [new file with mode: 0644]

index 56204ac76294e76a76ab7d3e3a9b885430af8a37..9a63a104ea4beaab726160a6770cd8c4e14f5e38 100644 (file)
@@ -146,6 +146,8 @@ dist_collectyd_SOURCES = \
        src/daemon/sources/test-error.h \
        src/daemon/sources/test-flapping.c \
        src/daemon/sources/test-flapping.h \
+       src/daemon/sources/test-stall.c \
+       src/daemon/sources/test-stall.h \
        src/daemon/util.c \
        src/daemon/util.h
 
index 25d91db51f85cc4ba01f2b6ddb364172014ba0ed..309bc687b3c57a8ba8c8cca768e3fc065105e988 100644 (file)
@@ -38,6 +38,7 @@
 #include "sources/processor.h"
 #include "sources/test-error.h"
 #include "sources/test-flapping.h"
+#include "sources/test-stall.h"
 
 // Register all sources
 static const collecty_source_impl* source_impls[] = {
@@ -53,6 +54,7 @@ static const collecty_source_impl* source_impls[] = {
        // Tests
        &test_error_source,
        &test_flapping_source,
+       &test_stall_source,
 
        NULL,
 };
diff --git a/src/daemon/sources/test-stall.c b/src/daemon/sources/test-stall.c
new file mode 100644 (file)
index 0000000..8c5c9bb
--- /dev/null
@@ -0,0 +1,39 @@
+/*#############################################################################
+#                                                                             #
+# collecty - A system statistics collection daemon for IPFire                 #
+# Copyright (C) 2025 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#include "../ctx.h"
+#include "../source.h"
+#include "test-stall.h"
+
+/*
+       This is a test stalls the event loop.
+*/
+
+static int test_stall_collect(collecty_ctx* ctx, collecty_source* source) {
+       // Sleep for 500ms
+       return usleep(500000);
+}
+
+const collecty_source_impl test_stall_source = {
+       .name    = "test-stall",
+
+       // Methods
+       .collect = test_stall_collect,
+};
diff --git a/src/daemon/sources/test-stall.h b/src/daemon/sources/test-stall.h
new file mode 100644 (file)
index 0000000..6f3f314
--- /dev/null
@@ -0,0 +1,28 @@
+/*#############################################################################
+#                                                                             #
+# collecty - A system statistics collection daemon for IPFire                 #
+# Copyright (C) 2025 IPFire Development Team                                  #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+#############################################################################*/
+
+#ifndef COLLECTY_SOURCE_TEST_STALL_H
+#define COLLECTY_SOURCE_TEST_STALL_H
+
+#include "../source.h"
+
+extern const collecty_source_impl test_stall_source;
+
+#endif /* COLLECTY_SOURCE_TEST_STALL_H */