summaryrefslogtreecommitdiffstats
path: root/plugins/tests
diff options
context:
space:
mode:
authorTon Voon <tonvoon@users.sourceforge.net>2006-07-12 12:15:42 (GMT)
committerTon Voon <tonvoon@users.sourceforge.net>2006-07-12 12:15:42 (GMT)
commitee03f1415acc9f4f8901593d9045244fbb3bbbb0 (patch)
tree32faccd0a0ac25373fec4823499969e62c2541ae /plugins/tests
parentdf23fd75267c830f85a74cfde3020981c37e82a5 (diff)
downloadmonitoring-plugins-ee03f1415acc9f4f8901593d9045244fbb3bbbb0.tar.gz
Moving check_disk functions into utils_disk.c and testing them
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1447 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/tests')
-rw-r--r--plugins/tests/Makefile.am9
-rw-r--r--plugins/tests/test_disk.c85
-rwxr-xr-xplugins/tests/test_disk.t6
3 files changed, 98 insertions, 2 deletions
diff --git a/plugins/tests/Makefile.am b/plugins/tests/Makefile.am
index 8ed3fc1..741499d 100644
--- a/plugins/tests/Makefile.am
+++ b/plugins/tests/Makefile.am
@@ -7,9 +7,9 @@ check_PROGRAMS = @EXTRA_TEST@
7 7
8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl 8INCLUDES = -I$(top_srcdir)/lib -I$(top_srcdir)/intl
9 9
10EXTRA_PROGRAMS = test_utils 10EXTRA_PROGRAMS = test_utils test_disk
11 11
12EXTRA_DIST = test_utils.t 12EXTRA_DIST = test_utils.t test_disk.t
13 13
14LIBS = @LIBINTL@ 14LIBS = @LIBINTL@
15 15
@@ -18,6 +18,11 @@ test_utils_CFLAGS = -g -I..
18test_utils_LDFLAGS = -L/usr/local/lib -ltap 18test_utils_LDFLAGS = -L/usr/local/lib -ltap
19test_utils_LDADD = ../utils.o 19test_utils_LDADD = ../utils.o
20 20
21test_disk_SOURCES = test_disk.c
22test_disk_CFLAGS = -g -I..
23test_disk_LDFLAGS = -L/usr/local/lib -ltap
24test_disk_LDADD = ../utils_disk.o
25
21test: ${noinst_PROGRAMS} 26test: ${noinst_PROGRAMS}
22 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS) 27 perl -MTest::Harness -e '$$Test::Harness::switches=""; runtests(map {$$_ .= ".t"} @ARGV)' $(EXTRA_PROGRAMS)
23 28
diff --git a/plugins/tests/test_disk.c b/plugins/tests/test_disk.c
new file mode 100644
index 0000000..19cc3ac
--- /dev/null
+++ b/plugins/tests/test_disk.c
@@ -0,0 +1,85 @@
1/******************************************************************************
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2 of the License, or
6 (at your option) any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16
17 $Id$
18
19******************************************************************************/
20
21#include "common.h"
22#include "utils_disk.h"
23#include "tap.h"
24
25int
26main (int argc, char **argv)
27{
28 struct name_list *exclude_filesystem=NULL;
29 struct name_list *exclude_fstype=NULL;
30
31 plan_tests(8);
32
33 ok( np_find_name(exclude_filesystem, "/var") == FALSE, "/var not in list");
34 np_add_name(&exclude_filesystem, "/var");
35 ok( np_find_name(exclude_filesystem, "/var") == TRUE, "is in list now");
36 ok( np_find_name(exclude_filesystem, "/home") == FALSE, "/home not in list");
37 np_add_name(&exclude_filesystem, "/home");
38 ok( np_find_name(exclude_filesystem, "/home") == TRUE, "is in list now");
39 ok( np_find_name(exclude_filesystem, "/var") == TRUE, "/var still in list");
40
41 ok( np_find_name(exclude_fstype, "iso9660") == FALSE, "iso9660 not in list");
42 np_add_name(&exclude_fstype, "iso9660");
43 ok( np_find_name(exclude_fstype, "iso9660") == TRUE, "is in list now");
44
45 ok( np_find_name(exclude_filesystem, "iso9660") == FALSE, "Make sure no clashing in variables");
46
47
48
49
50 /*
51 range = parse_range_string("6");
52 ok( range != NULL, "'6' is valid range");
53 ok( range->start == 0, "Start correct");
54 ok( range->start_infinity == FALSE, "Not using negative infinity");
55 ok( range->end == 6, "End correct");
56 ok( range->end_infinity == FALSE, "Not using infinity");
57 free(range);
58
59 range = parse_range_string("-7:23");
60 ok( range != NULL, "'-7:23' is valid range");
61 ok( range->start == -7, "Start correct");
62 ok( range->start_infinity == FALSE, "Not using negative infinity");
63 ok( range->end == 23, "End correct");
64 ok( range->end_infinity == FALSE, "Not using infinity");
65 free(range);
66
67 range = parse_range_string(":5.75");
68 ok( range != NULL, "':5.75' is valid range");
69 ok( range->start == 0, "Start correct");
70 ok( range->start_infinity == FALSE, "Not using negative infinity");
71 ok( range->end == 5.75, "End correct");
72 ok( range->end_infinity == FALSE, "Not using infinity");
73 free(range);
74
75 range = parse_range_string("~:-95.99");
76 ok( range != NULL, "~:-95.99' is valid range");
77 ok( range->start_infinity == TRUE, "Using negative infinity");
78 ok( range->end == -95.99, "End correct (with rounding errors)");
79 ok( range->end_infinity == FALSE, "Not using infinity");
80 free(range);
81 */
82
83 return exit_status();
84}
85
diff --git a/plugins/tests/test_disk.t b/plugins/tests/test_disk.t
new file mode 100755
index 0000000..d32567a
--- /dev/null
+++ b/plugins/tests/test_disk.t
@@ -0,0 +1,6 @@
1#!/usr/bin/perl
2use Test::More;
3if (! -e "./test_disk") {
4 plan skip_all => "./test_disk not compiled - please install tap library to test";
5}
6exec "./test_disk";