From 14fadf61b05c6f5684a667eb07ce9b3e2cf6708c Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 8 Jun 2010 15:13:46 +0100 Subject: [PATCH] Recognise TIMEOUT errors as well as CONNECT errors in the attempt to connect to no.such.host -- fixes Red hat problem with test suite --- t/1-Net-Z3950-ZOOM.t | 6 ++++-- t/2-ZOOM.t | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/t/1-Net-Z3950-ZOOM.t b/t/1-Net-Z3950-ZOOM.t index 74e3990..27c479e 100644 --- a/t/1-Net-Z3950-ZOOM.t +++ b/t/1-Net-Z3950-ZOOM.t @@ -19,8 +19,10 @@ my($errcode, $errmsg, $addinfo) = (undef, "dummy", "dummy"); my $host = "no.such.host"; my $conn = Net::Z3950::ZOOM::connection_new($host, 0); $errcode = Net::Z3950::ZOOM::connection_error($conn, $errmsg, $addinfo); -ok($errcode == Net::Z3950::ZOOM::ERROR_CONNECT && $addinfo eq $host, - "connection to non-existent host '$host' fails: \$conn=$conn, errcode=$errcode, addinfo=$addinfo"); +# For some reason, Red Hat signals this as a TIMEOUT rather than a CONNECT +ok(($errcode == Net::Z3950::ZOOM::ERROR_CONNECT || + $errcode == Net::Z3950::ZOOM::ERROR_TIMEOUT) && $addinfo eq $host, + "connection to non-existent host '$host' fails: errcode=$errcode, addinfo=$addinfo"); $host = "z3950.indexdata.com/gils"; $conn = Net::Z3950::ZOOM::connection_new($host, 0); diff --git a/t/2-ZOOM.t b/t/2-ZOOM.t index e369e39..aaf867d 100644 --- a/t/2-ZOOM.t +++ b/t/2-ZOOM.t @@ -17,9 +17,11 @@ ok($msg eq "Empty term unsupported", "SRW diagnostic string lookup works"); my $host = "no.such.host"; my $conn; eval { $conn = new ZOOM::Connection($host, 0) }; +# For some reason, Red Hat signals this as a TIMEOUT rather than a CONNECT ok($@ && $@->isa("ZOOM::Exception") && - $@->code() == ZOOM::Error::CONNECT && $@->addinfo() eq $host, - "connection to non-existent host '$host' fails: \$conn=$conn, \$\@=$@"); + ($@->code() == ZOOM::Error::CONNECT || + $@->code() == ZOOM::Error::TIMEOUT) && $@->addinfo() eq $host, + "connection to non-existent host '$host' fails: \$\@=$@"); $host = "z3950.indexdata.com/gils"; eval { $conn = new ZOOM::Connection($host, 0) }; -- 1.7.10.4