[Nagiosplug-checkins] nagiosplug/plugins/tests .cvsignore,NONE,1.1 Makefile.am,NONE,1.1 README,NONE,1.1 test_utils.c,NONE,1.1 test_utils.t,NONE,1.1 check_disk,1.1.1.1,NONE check_dns,1.1.1.1,NONE check_ftp,1.1.1.1,NONE check_hpjd,1.1.1.1,NONE check_http,1.1.1.1,NONE check_load,1.1.1.1,NONE check_ping,1.1.1.1,NONE check_procs,1.1.1.1,NONE check_swap,1.1.1.1,NONE check_users,1.1.1.1,NONE check_vsz,1.1.1.1,NONE
Ton Voon
tonvoon at users.sourceforge.net
Mon Jan 30 08:12:01 CET 2006
Update of /cvsroot/nagiosplug/nagiosplug/plugins/tests
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19248/plugins/tests
Added Files:
.cvsignore Makefile.am README test_utils.c test_utils.t
Removed Files:
check_disk check_dns check_ftp check_hpjd check_http
check_load check_ping check_procs check_swap check_users
check_vsz
Log Message:
Added libtap tests for utils.c library functions. Removed redundant
test files
--- check_swap DELETED ---
--- NEW FILE: .cvsignore ---
Makefile
Makefile.in
test_utils
--- NEW FILE: Makefile.am ---
noinst_PROGRAMS = @EXTRA_TEST@
# These two lines support "make check", but we use "make test"
TESTS = @EXTRA_TEST@
check_PROGRAMS = @EXTRA_TEST@
INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl
EXTRA_PROGRAMS = test_utils
LIBS = @LIBINTL@
test_utils_SOURCES = test_utils.c
test_utils_CFLAGS = -g -I..
test_utils_LDFLAGS = -L..
test_utils_LDADD = ../utils.o @EXTRA_TAPOBJ@
test: ${noinst_PROGRAMS}
perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
--- NEW FILE: test_utils.c ---
/******************************************************************************
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 2 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, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
$Id: test_utils.c,v 1.1 2006/01/30 16:10:50 tonvoon Exp $
******************************************************************************/
const char *progname = "utils";
#include "common.h"
#include "utils.h"
#include "popen.h"
#include "tap.h"
int
main (int argc, char **argv)
{
threshold *range;
double temp;
plan_tests(40);
range = parse_threshold("6");
ok( range != NULL, "'6' is valid threshold");
ok( range->start == 0, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end == 6, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
free(range);
range = parse_threshold("-7:23");
ok( range != NULL, "'-7:23' is valid threshold");
ok( range->start == -7, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end == 23, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
free(range);
range = parse_threshold(":5.75");
ok( range != NULL, "':5.75' is valid threshold");
ok( range->start == 0, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end == 5.75, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
free(range);
range = parse_threshold("~:-95.99");
ok( range != NULL, "~:-95.99' is valid threshold");
ok( range->start_infinity == TRUE, "Using negative infinity");
ok( range->end == -95.99, "End correct (with rounding errors)");
ok( range->end_infinity == FALSE, "Not using infinity");
free(range);
range = parse_threshold("12345678901234567890:");
temp = atof("12345678901234567890"); /* Can't just use this because number too large */
ok( range != NULL, "'12345678901234567890:' is valid threshold");
ok( range->start == temp, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end_infinity == TRUE, "Using infinity");
free(range);
range = parse_threshold("~:0");
ok( range != NULL, "'~:0' is valid threshold");
ok( range->start_infinity == TRUE, "Using negative infinity");
ok( range->end == 0, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
ok( range->alert_on == OUTSIDE, "Will alert on outside of this range");
free(range);
range = parse_threshold("@0:657.8210567");
ok( range != 0, "@0:657.8210567' is a valid threshold");
ok( range->start == 0, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end == 657.8210567, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
ok( range->alert_on == INSIDE, "Will alert on inside of this range" );
free(range);
range = parse_threshold("1:1");
ok( range != NULL, "'1:1' is a valid threshold");
ok( range->start == 1, "Start correct");
ok( range->start_infinity == FALSE, "Not using negative infinity");
ok( range->end == 1, "End correct");
ok( range->end_infinity == FALSE, "Not using infinity");
free(range);
range = parse_threshold("2:1");
ok( range == NULL, "''2:1' rejected");
return exit_status();
}
void print_usage() {
printf("Dummy");
}
--- check_disk DELETED ---
--- check_procs DELETED ---
--- check_vsz DELETED ---
--- check_ftp DELETED ---
--- check_dns DELETED ---
--- check_hpjd DELETED ---
--- NEW FILE: test_utils.t ---
#!/usr/bin/perl
use Test::More;
if (! -e "./test_utils") {
plan skip_all => "./test_utils not compiled - check ./configure --with-libtap-object is defined";
}
exec "./test_utils";
--- check_ping DELETED ---
--- NEW FILE: README ---
The tests in here use the libtap library functions
(http://jc.ngo.org.uk/trac-bin/trac.cgi/wiki/LibTap), so are
more for unit testing the utils.c library functions.
However, it probably should be merged into the plugins/t subdirectory.
--- check_load DELETED ---
--- check_users DELETED ---
--- check_http DELETED ---
More information about the Commits
mailing list