summaryrefslogtreecommitdiffstats
path: root/plugins/t/check_tcp.t
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/t/check_tcp.t')
-rw-r--r--plugins/t/check_tcp.t21
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/t/check_tcp.t b/plugins/t/check_tcp.t
index c100cad..0e6a964 100644
--- a/plugins/t/check_tcp.t
+++ b/plugins/t/check_tcp.t
@@ -9,7 +9,18 @@ use Test;
9use NPTest; 9use NPTest;
10 10
11use vars qw($tests); 11use vars qw($tests);
12BEGIN {$tests = 14; plan tests => $tests} 12my $has_ipv6;
13BEGIN {
14 $tests = 11;
15 # do we have ipv6
16 `ping6 -c 1 2a02:2e0:3fe:100::7 2>&1`;
17 if($? == 0) {
18 $has_ipv6 = 1;
19 $tests += 3;
20 }
21 plan tests => $tests;
22}
23
13 24
14my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost", 25my $host_tcp_http = getTestParameter( "host_tcp_http", "NP_HOST_TCP_HTTP", "localhost",
15 "A host providing the HTTP Service (a web server)" ); 26 "A host providing the HTTP Service (a web server)" );
@@ -27,7 +38,6 @@ my $failedExpect = '/^TCP WARNING\s-\sUnexpected response from host/socket on po
27my $t; 38my $t;
28 39
29$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput ); 40$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600", 0, $successOutput );
30$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600 -6 ", 0, $successOutput );
31$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test 41$t += checkCmd( "./check_tcp $host_tcp_http -p 81 -wt 0 -ct 0 -to 1", 2 ); # use invalid port for this test
32$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 ); 42$t += checkCmd( "./check_tcp $host_nonresponsive -p 80 -wt 0 -ct 0 -to 1", 2 );
33$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 ); 43$t += checkCmd( "./check_tcp $hostname_invalid -p 80 -wt 0 -ct 0 -to 1", 2 );
@@ -35,11 +45,16 @@ $t += checkCmd( "./check_tcp -S -D 1 -H www.verisign.com -p 443", 0
35$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 ); 45$t += checkCmd( "./check_tcp -S -D 9000,1 -H www.verisign.com -p 443", 1 );
36$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 ); 46$t += checkCmd( "./check_tcp -S -D 9000 -H www.verisign.com -p 443", 1 );
37$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 ); 47$t += checkCmd( "./check_tcp -S -D 9000,8999 -H www.verisign.com -p 443", 2 );
38$t += checkCmd( "./check_tcp -6 -p 80 www.heise.de", 0 );
39 48
40# Need the \r\n to make it more standards compliant with web servers. Need the various quotes 49# Need the \r\n to make it more standards compliant with web servers. Need the various quotes
41# so that perl doesn't interpret the \r\n and is passed onto command line correctly 50# so that perl doesn't interpret the \r\n and is passed onto command line correctly
42$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -E -s ".'"GET / HTTP/1.1\r\n\r\n"'." -e 'ThisShouldntMatch' -j", 1, $failedExpect ); 51$t += checkCmd( "./check_tcp $host_tcp_http -p 80 -E -s ".'"GET / HTTP/1.1\r\n\r\n"'." -e 'ThisShouldntMatch' -j", 1, $failedExpect );
43 52
53# IPv6 checks
54if($has_ipv6) {
55 $t += checkCmd( "./check_tcp $host_tcp_http -p 80 -wt 300 -ct 600 -6 ", 0, $successOutput );
56 $t += checkCmd( "./check_tcp -6 -p 80 www.heise.de", 0 );
57}
58
44exit(0) if defined($Test::Harness::VERSION); 59exit(0) if defined($Test::Harness::VERSION);
45exit($tests - $t); 60exit($tests - $t);