summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d059eeb)
raw | patch | inline | side by side (parent: d059eeb)
author | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Sun, 3 Jun 2007 15:00:34 +0000 (15:00 +0000) | ||
committer | Matthias Eble <psychotrahe@users.sourceforge.net> | |
Sun, 3 Jun 2007 15:00:34 +0000 (15:00 +0000) |
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@1730 f882894a-f735-0410-b71e-b25c423dba1c
configure.in | patch | blob | history | |
lib/tests/.cvsignore | patch | blob | history | |
lib/tests/test_tcp.c | [new file with mode: 0644] | patch | blob |
lib/tests/test_tcp.t | [new file with mode: 0755] | patch | blob |
diff --git a/configure.in b/configure.in
index 264a0676aad430c6db37dd670f904fa086ccceae..26b0d2461d4005e15ebd5631df7f9fc5d0ab8247 100644 (file)
--- a/configure.in
+++ b/configure.in
dnl Check for libtap, to run perl-like tests
AC_CHECK_LIB(tap, plan_tests,
- EXTRA_TEST="test_utils test_disk"
+ EXTRA_TEST="test_utils test_disk test_tcp"
AC_SUBST(EXTRA_TEST)
)
diff --git a/lib/tests/.cvsignore b/lib/tests/.cvsignore
index 6dc692f54a5ca6787cdb2f5eb4614ca75950c3f0..8e1d1afce01580c739c040a2800fd17ec2734873 100644 (file)
--- a/lib/tests/.cvsignore
+++ b/lib/tests/.cvsignore
Makefile.in
test_utils
test_disk
+test_tcp
.deps
diff --git a/lib/tests/test_tcp.c b/lib/tests/test_tcp.c
--- /dev/null
+++ b/lib/tests/test_tcp.c
@@ -0,0 +1,62 @@
+/******************************************************************************
+
+ 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$
+
+******************************************************************************/
+
+#include "common.h"
+#include "utils_tcp.h"
+#include "tap.h"
+
+int
+main (int argc, char **argv)
+{
+ int i;
+ char** server_expect;
+ char* status;
+ bool verbose;
+ bool exact_match;
+ int server_expect_count = 3;
+ plan_tests(8);
+
+ server_expect = malloc(sizeof(char*) * server_expect_count);
+
+ server_expect[0] = strdup("AA");
+ server_expect[1] = strdup("bb");
+ server_expect[2] = strdup("CC");
+
+ ok(np_expect_match("AA bb CC XX", server_expect, server_expect_count, false, true, false) == true,
+ "Test matching any string at the beginning (first expect string)");
+ ok(np_expect_match("bb AA CC XX", server_expect, server_expect_count, false, true, false) == true,
+ "Test matching any string at the beginning (second expect string)");
+ ok(np_expect_match("XX bb AA CC XX", server_expect, server_expect_count, false, true, false) == false,
+ "Test with strings not matching at the beginning");
+ ok(np_expect_match("XX CC XX", server_expect, server_expect_count, false, true, false) == false,
+ "Test matching any string");
+ ok(np_expect_match("XX", server_expect, server_expect_count, false, false, false) == false,
+ "Test not matching any string");
+ ok(np_expect_match("XX AA bb CC XX", server_expect, server_expect_count, true, false, false) == true,
+ "Test matching all strings");
+ ok(np_expect_match("XX bb CC XX", server_expect, server_expect_count, true, false, false) == false,
+ "Test not matching all strings");
+ ok(np_expect_match("XX XX", server_expect, server_expect_count, true, false, false) == false,
+ "Test not matching any string (testing all)");
+
+
+ return exit_status();
+}
+
diff --git a/lib/tests/test_tcp.t b/lib/tests/test_tcp.t
--- /dev/null
+++ b/lib/tests/test_tcp.t
@@ -0,0 +1,6 @@
+#!/usr/bin/perl
+use Test::More;
+if (! -e "./test_tcp") {
+ plan skip_all => "./test_tcp not compiled - please install tap library to test";
+}
+exec "./test_tcp";