summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-18 15:57:44 +0100
committerLorenz Kästle <12514511+RincewindsHat@users.noreply.github.com>2025-03-18 15:57:44 +0100
commit59e0a258f9c0f393bf29cced1f35743f74e7b10c (patch)
treeb58756ef9284f4a02546fcc098f036a677e4481f
parent7994b478187d38c04dd2d7d9241d237875589738 (diff)
downloadmonitoring-plugins-59e0a258f9c0f393bf29cced1f35743f74e7b10c.tar.gz
Migrate disk tests from lib, tool
-rw-r--r--.gitignore3
-rw-r--r--configure.ac4
-rw-r--r--lib/tests/Makefile.am6
-rwxr-xr-xlib/tests/test_disk.t6
-rw-r--r--plugins/Makefile.am8
-rw-r--r--plugins/check_disk.d/utils_disk.c4
-rw-r--r--plugins/check_disk.d/utils_disk.h2
-rw-r--r--plugins/common.h6
-rw-r--r--plugins/tests/test_check_disk.c (renamed from lib/tests/test_disk.c)4
-rwxr-xr-xplugins/tests/test_check_disk.t6
10 files changed, 26 insertions, 23 deletions
diff --git a/.gitignore b/.gitignore
index 5245495e..8b14f429 100644
--- a/.gitignore
+++ b/.gitignore
@@ -114,7 +114,6 @@ NP-VERSION-FILE
114/lib/tests/Makefile.in 114/lib/tests/Makefile.in
115/lib/tests/test_base64 115/lib/tests/test_base64
116/lib/tests/test_cmd 116/lib/tests/test_cmd
117/lib/tests/test_disk
118/lib/tests/test_tcp 117/lib/tests/test_tcp
119/lib/tests/test_utils 118/lib/tests/test_utils
120/lib/tests/utils_base.Po 119/lib/tests/utils_base.Po
@@ -223,7 +222,7 @@ plugins/check_disk.d/.dirstamp
223/plugins/tests/Makefile 222/plugins/tests/Makefile
224/plugins/tests/Makefile.in 223/plugins/tests/Makefile.in
225/plugins/tests/test_utils 224/plugins/tests/test_utils
226/plugins/tests/test_disk 225/plugins/tests/test_check_disk
227/plugins/tests/test_check_swap 226/plugins/tests/test_check_swap
228/plugins/tests/.deps 227/plugins/tests/.deps
229/plugins/tests/.dirstamp 228/plugins/tests/.dirstamp
diff --git a/configure.ac b/configure.ac
index 204fc6e3..fdc9b699 100644
--- a/configure.ac
+++ b/configure.ac
@@ -181,10 +181,10 @@ fi
181 181
182# Finally, define tests if we use libtap 182# Finally, define tests if we use libtap
183if test "$enable_libtap" = "yes" ; then 183if test "$enable_libtap" = "yes" ; then
184 EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64" 184 EXTRA_TEST="test_utils test_tcp test_cmd test_base64"
185 AC_SUBST(EXTRA_TEST) 185 AC_SUBST(EXTRA_TEST)
186 186
187 EXTRA_PLUGIN_TESTS="tests/test_check_swap" 187 EXTRA_PLUGIN_TESTS="tests/test_check_swap tests/test_check_disk"
188 AC_SUBST(EXTRA_PLUGIN_TESTS) 188 AC_SUBST(EXTRA_PLUGIN_TESTS)
189fi 189fi
190 190
diff --git a/lib/tests/Makefile.am b/lib/tests/Makefile.am
index 9be94f6d..7798a72e 100644
--- a/lib/tests/Makefile.am
+++ b/lib/tests/Makefile.am
@@ -8,9 +8,9 @@ check_PROGRAMS = @EXTRA_TEST@
8AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \ 8AM_CPPFLAGS = -DNP_STATE_DIR_PREFIX=\"$(localstatedir)\" \
9 -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins 9 -I$(top_srcdir)/lib -I$(top_srcdir)/gl -I$(top_srcdir)/intl -I$(top_srcdir)/plugins
10 10
11EXTRA_PROGRAMS = test_utils test_disk test_tcp test_cmd test_base64 test_ini1 test_ini3 test_opts1 test_opts2 test_opts3 test_generic_output 11EXTRA_PROGRAMS = test_utils test_tcp test_cmd test_base64 test_ini1 test_ini3 test_opts1 test_opts2 test_opts3 test_generic_output
12 12
13np_test_scripts = test_base64.t test_cmd.t test_disk.t test_ini1.t test_ini3.t test_opts1.t test_opts2.t test_opts3.t test_tcp.t test_utils.t test_generic_output.t 13np_test_scripts = test_base64.t test_cmd.t test_ini1.t test_ini3.t test_opts1.t test_opts2.t test_opts3.t test_tcp.t test_utils.t test_generic_output.t
14np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini 14np_test_files = config-dos.ini config-opts.ini config-tiny.ini plugin.ini plugins.ini
15EXTRA_DIST = $(np_test_scripts) $(np_test_files) var 15EXTRA_DIST = $(np_test_scripts) $(np_test_files) var
16 16
@@ -29,7 +29,7 @@ AM_CFLAGS = -g -I$(top_srcdir)/lib -I$(top_srcdir)/gl $(tap_cflags)
29AM_LDFLAGS = $(tap_ldflags) -ltap 29AM_LDFLAGS = $(tap_ldflags) -ltap
30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a $(LIB_CRYPTO) 30LDADD = $(top_srcdir)/lib/libmonitoringplug.a $(top_srcdir)/gl/libgnu.a $(LIB_CRYPTO)
31 31
32SOURCES = test_utils.c test_disk.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c test_generic_output.c 32SOURCES = test_utils.c test_tcp.c test_cmd.c test_base64.c test_ini1.c test_ini3.c test_opts1.c test_opts2.c test_opts3.c test_generic_output.c
33 33
34test: ${noinst_PROGRAMS} 34test: ${noinst_PROGRAMS}
35 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) 35 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
diff --git a/lib/tests/test_disk.t b/lib/tests/test_disk.t
deleted file mode 100755
index da84dfdf..00000000
--- a/lib/tests/test_disk.t
+++ /dev/null
@@ -1,6 +0,0 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_disk") {
4 plan skip_all => "./test_disk not compiled - please enable libtap library to test";
5}
6exec "./test_disk";
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 30283cb4..04fb7ed2 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -40,11 +40,13 @@ EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
40 check_nagios check_by_ssh check_dns check_nt check_ide_smart \ 40 check_nagios check_by_ssh check_dns check_nt check_ide_smart \
41 check_procs check_mysql_query check_apt check_dbi check_curl \ 41 check_procs check_mysql_query check_apt check_dbi check_curl \
42 \ 42 \
43 tests/test_check_swap 43 tests/test_check_swap \
44 tests/test_check_disk
44 45
45SUBDIRS = picohttpparser 46SUBDIRS = picohttpparser
46 47
47np_test_scripts = tests/test_check_swap.t 48np_test_scripts = tests/test_check_swap.t \
49 tests/test_check_disk.t
48 50
49EXTRA_DIST = t \ 51EXTRA_DIST = t \
50 tests \ 52 tests \
@@ -167,6 +169,8 @@ endif
167 169
168tests_test_check_swap_LDADD = $(BASEOBJS) $(tap_ldflags) -ltap 170tests_test_check_swap_LDADD = $(BASEOBJS) $(tap_ldflags) -ltap
169tests_test_check_swap_SOURCES = tests/test_check_swap.c check_swap.d/swap.c 171tests_test_check_swap_SOURCES = tests/test_check_swap.c check_swap.d/swap.c
172tests_test_check_disk_LDADD = $(BASEOBJS) $(tap_ldflags) check_disk.d/utils_disk.c -ltap
173tests_test_check_disk_SOURCES = tests/test_check_disk.c
170 174
171############################################################################## 175##############################################################################
172# secondary dependencies 176# secondary dependencies
diff --git a/plugins/check_disk.d/utils_disk.c b/plugins/check_disk.d/utils_disk.c
index 1d806715..369c85d5 100644
--- a/plugins/check_disk.d/utils_disk.c
+++ b/plugins/check_disk.d/utils_disk.c
@@ -26,9 +26,9 @@
26 * 26 *
27 *****************************************************************************/ 27 *****************************************************************************/
28 28
29#include "common.h" 29#include "../common.h"
30#include "utils_disk.h" 30#include "utils_disk.h"
31#include "gl/fsusage.h" 31#include "../../gl/fsusage.h"
32#include <string.h> 32#include <string.h>
33 33
34void np_add_name(struct name_list **list, const char *name) { 34void np_add_name(struct name_list **list, const char *name) {
diff --git a/plugins/check_disk.d/utils_disk.h b/plugins/check_disk.d/utils_disk.h
index 1c68fed9..0c69f987 100644
--- a/plugins/check_disk.d/utils_disk.h
+++ b/plugins/check_disk.d/utils_disk.h
@@ -2,7 +2,7 @@
2 2
3#include "../../config.h" 3#include "../../config.h"
4#include "../../gl/mountlist.h" 4#include "../../gl/mountlist.h"
5#include "utils_base.h" 5#include "../../lib/utils_base.h"
6#include "regex.h" 6#include "regex.h"
7#include <stdint.h> 7#include <stdint.h>
8 8
diff --git a/plugins/common.h b/plugins/common.h
index 603bae55..35d1e549 100644
--- a/plugins/common.h
+++ b/plugins/common.h
@@ -31,7 +31,7 @@
31#ifndef _COMMON_H_ 31#ifndef _COMMON_H_
32#define _COMMON_H_ 32#define _COMMON_H_
33 33
34#include "config.h" 34#include "../config.h"
35#include "../lib/monitoringplug.h" 35#include "../lib/monitoringplug.h"
36 36
37#ifdef HAVE_FEATURES_H 37#ifdef HAVE_FEATURES_H
@@ -110,7 +110,7 @@
110 110
111/* GNU Libraries */ 111/* GNU Libraries */
112#include <getopt.h> 112#include <getopt.h>
113#include "dirname.h" 113#include "../gl/dirname.h"
114 114
115#include <locale.h> 115#include <locale.h>
116 116
@@ -190,7 +190,7 @@ enum {
190 * Internationalization 190 * Internationalization
191 * 191 *
192 */ 192 */
193#include "gettext.h" 193#include "../gl/gettext.h"
194#define _(String) gettext (String) 194#define _(String) gettext (String)
195#if ! ENABLE_NLS 195#if ! ENABLE_NLS
196# undef textdomain 196# undef textdomain
diff --git a/lib/tests/test_disk.c b/plugins/tests/test_check_disk.c
index c18db7a4..92d0d270 100644
--- a/lib/tests/test_disk.c
+++ b/plugins/tests/test_check_disk.c
@@ -17,8 +17,8 @@
17 *****************************************************************************/ 17 *****************************************************************************/
18 18
19#include "common.h" 19#include "common.h"
20#include "utils_disk.h" 20#include "../check_disk.d/utils_disk.h"
21#include "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, int expect, char *desc);
diff --git a/plugins/tests/test_check_disk.t b/plugins/tests/test_check_disk.t
new file mode 100755
index 00000000..56354650
--- /dev/null
+++ b/plugins/tests/test_check_disk.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_check_disk") {
4 plan skip_all => "./test_check_disk not compiled - please enable libtap library to test";
5}
6exec "./test_check_disk";