diff options
author | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-06-03 15:00:34 +0000 |
---|---|---|
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | 2007-06-03 15:00:34 +0000 |
commit | 0ad5dc61893b282ca3ea31c43bf0e372eb4de4cb (patch) | |
tree | b4a8accd76e2b6d331baae48bbcd6054d6e90638 /lib | |
parent | d059eeb2948f9d24d801f930e99e81fdf96d5c37 (diff) | |
download | monitoring-plugins-0ad5dc61893b282ca3ea31c43bf0e372eb4de4cb.tar.gz |
Added test cases for utils_tcp
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1730 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tests/.cvsignore | 1 | ||||
-rw-r--r-- | lib/tests/test_tcp.c | 62 | ||||
-rwxr-xr-x | lib/tests/test_tcp.t | 6 |
3 files changed, 69 insertions, 0 deletions
diff --git a/lib/tests/.cvsignore b/lib/tests/.cvsignore index 6dc692f5..8e1d1afc 100644 --- a/lib/tests/.cvsignore +++ b/lib/tests/.cvsignore | |||
@@ -2,4 +2,5 @@ Makefile | |||
2 | Makefile.in | 2 | Makefile.in |
3 | test_utils | 3 | test_utils |
4 | test_disk | 4 | test_disk |
5 | test_tcp | ||
5 | .deps | 6 | .deps |
diff --git a/lib/tests/test_tcp.c b/lib/tests/test_tcp.c new file mode 100644 index 00000000..68aa9dc5 --- /dev/null +++ b/lib/tests/test_tcp.c | |||
@@ -0,0 +1,62 @@ | |||
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_tcp.h" | ||
23 | #include "tap.h" | ||
24 | |||
25 | int | ||
26 | main (int argc, char **argv) | ||
27 | { | ||
28 | int i; | ||
29 | char** server_expect; | ||
30 | char* status; | ||
31 | bool verbose; | ||
32 | bool exact_match; | ||
33 | int server_expect_count = 3; | ||
34 | plan_tests(8); | ||
35 | |||
36 | server_expect = malloc(sizeof(char*) * server_expect_count); | ||
37 | |||
38 | server_expect[0] = strdup("AA"); | ||
39 | server_expect[1] = strdup("bb"); | ||
40 | server_expect[2] = strdup("CC"); | ||
41 | |||
42 | ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, false, true, false) == true, | ||
43 | "Test matching any string at the beginning (first expect string)"); | ||
44 | ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, false, true, false) == true, | ||
45 | "Test matching any string at the beginning (second expect string)"); | ||
46 | ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, false, true, false) == false, | ||
47 | "Test with strings not matching at the beginning"); | ||
48 | ok(np_expect_match("XX CC XX", server_expect, server_expect_count, false, true, false) == false, | ||
49 | "Test matching any string"); | ||
50 | ok(np_expect_match("XX", server_expect, server_expect_count, false, false, false) == false, | ||
51 | "Test not matching any string"); | ||
52 | ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, true, false, false) == true, | ||
53 | "Test matching all strings"); | ||
54 | ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, true, false, false) == false, | ||
55 | "Test not matching all strings"); | ||
56 | ok(np_expect_match("XX XX", server_expect, server_expect_count, true, false, false) == false, | ||
57 | "Test not matching any string (testing all)"); | ||
58 | |||
59 | |||
60 | return exit_status(); | ||
61 | } | ||
62 | |||
diff --git a/lib/tests/test_tcp.t b/lib/tests/test_tcp.t new file mode 100755 index 00000000..8f34b67b --- /dev/null +++ b/lib/tests/test_tcp.t | |||
@@ -0,0 +1,6 @@ | |||
1 | #!/usr/bin/perl | ||
2 | use Test::More; | ||
3 | if (! -e "./test_tcp") { | ||
4 | plan skip_all => "./test_tcp not compiled - please install tap library to test"; | ||
5 | } | ||
6 | exec "./test_tcp"; | ||