mirror of
https://github.com/monitoring-plugins/monitoring-plugins.git
synced 2026-04-15 22:00:06 -04:00
Implement first unit test for check_swap
This commit is contained in:
parent
2dec5182c5
commit
6fcbbaafc4
5 changed files with 48 additions and 3 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -221,7 +221,9 @@ NP-VERSION-FILE
|
|||
/plugins/tests/Makefile.in
|
||||
/plugins/tests/test_utils
|
||||
/plugins/tests/test_disk
|
||||
/plugins/tests/test_check_swap
|
||||
/plugins/tests/.deps
|
||||
/plugins/tests/.dirstamp
|
||||
|
||||
# /plugins/check_swap.d
|
||||
/plugins/check_swap.d/.deps
|
||||
|
|
|
|||
|
|
@ -185,6 +185,9 @@ fi
|
|||
if test "$enable_libtap" = "yes" ; then
|
||||
EXTRA_TEST="test_utils test_disk test_tcp test_cmd test_base64"
|
||||
AC_SUBST(EXTRA_TEST)
|
||||
|
||||
EXTRA_PLUGIN_TESTS="tests/test_check_swap"
|
||||
AC_SUBST(EXTRA_PLUGIN_TESTS)
|
||||
fi
|
||||
|
||||
dnl INI Parsing
|
||||
|
|
|
|||
|
|
@ -38,19 +38,27 @@ check_tcp_programs = check_ftp check_imap check_nntp check_pop \
|
|||
EXTRA_PROGRAMS = check_mysql check_radius check_pgsql check_snmp check_hpjd \
|
||||
check_swap check_fping check_ldap check_game check_dig \
|
||||
check_nagios check_by_ssh check_dns check_nt check_ide_smart \
|
||||
check_procs check_mysql_query check_apt check_dbi check_curl
|
||||
check_procs check_mysql_query check_apt check_dbi check_curl \
|
||||
\
|
||||
tests/test_check_swap
|
||||
|
||||
SUBDIRS = picohttpparser
|
||||
|
||||
EXTRA_DIST = t tests
|
||||
np_test_scripts = tests/test_check_swap.t
|
||||
|
||||
EXTRA_DIST = t tests $(np_test_scripts)
|
||||
|
||||
PLUGINHDRS = common.h
|
||||
|
||||
noinst_LIBRARIES = libnpcommon.a
|
||||
noinst_PROGRAMS = @EXTRA_PLUGIN_TESTS@
|
||||
# These two lines support "make check", but we use "make test"
|
||||
check_PROGRAMS = @EXTRA_PLUGIN_TESTS@
|
||||
|
||||
libnpcommon_a_SOURCES = utils.c netutils.c sslutils.c runcmd.c \
|
||||
popen.c utils.h netutils.h popen.h common.h runcmd.c runcmd.h
|
||||
|
||||
|
||||
BASEOBJS = libnpcommon.a ../lib/libmonitoringplug.a ../gl/libgnu.a $(LIB_CRYPTO)
|
||||
NETOBJS = $(BASEOBJS) $(EXTRA_NETOBLS)
|
||||
NETLIBS = $(NETOBJS) $(SOCKETLIBS)
|
||||
|
|
@ -58,7 +66,10 @@ SSLOBJS = $(BASEOBJS) $(NETLIBS) $(SSLLIBS) $(LIB_CRYPTO)
|
|||
|
||||
TESTS_ENVIRONMENT = perl -I $(top_builddir) -I $(top_srcdir)
|
||||
|
||||
TESTS = @PLUGIN_TEST@
|
||||
tap_ldflags = -L$(top_srcdir)/tap
|
||||
|
||||
TESTS = @PLUGIN_TEST@ @EXTRA_PLUGIN_TESTS@
|
||||
|
||||
|
||||
test:
|
||||
perl -I $(top_builddir) -I $(top_srcdir) ../test.pl
|
||||
|
|
@ -122,6 +133,8 @@ if !HAVE_UTMPX
|
|||
check_users_LDADD += popen.o
|
||||
endif
|
||||
|
||||
tests_test_check_swap_LDADD = $(BASEOBJS) check_swap.d/swap.o $(tap_ldflags) -ltap
|
||||
|
||||
##############################################################################
|
||||
# secondary dependencies
|
||||
|
||||
|
|
|
|||
21
plugins/tests/test_check_swap.c
Normal file
21
plugins/tests/test_check_swap.c
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
|
||||
#include "../check_swap.d/check_swap.h"
|
||||
#include "../../tap/tap.h"
|
||||
|
||||
void print_usage() {};
|
||||
void print_help(swap_config config) {
|
||||
(void) config;
|
||||
};
|
||||
|
||||
const char *progname = "test_check_swap";
|
||||
|
||||
int main() {
|
||||
|
||||
swap_config config = swap_config_init();
|
||||
|
||||
swap_result test_data = get_swap_data(config);
|
||||
|
||||
plan_tests(1);
|
||||
|
||||
ok(test_data.errorcode == 0, "Test whether we manage to retrieve swap data");
|
||||
}
|
||||
6
plugins/tests/test_check_swap.t
Normal file
6
plugins/tests/test_check_swap.t
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#!/usr/bin/perl
|
||||
use Test::More;
|
||||
if (! -e "./test_check_swap") {
|
||||
plan skip_all => "./test_swap not compiled - please enable libtap library to test";
|
||||
}
|
||||
exec "./test_check_swap";
|
||||
Loading…
Reference in a new issue