[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pecl-cvs
Subject:    [PECL-CVS] com =?UTF-8?Q?pecl/database/mysql=5Fxdevapi=3A=20WL=23=31=32=31=38=39=20?= =?UTF-8?Q?=3A=
From:       hery ramilison <mysqlre () php ! net>
Date:       2018-07-19 11:20:43
Message-ID: php-mail-33d9a46620d7ac69156f53bb8549c0b7429192914 () git ! php ! net
[Download RAW message or body]

Commit:    cbf58b8dcc163124a2ac602a914f4b6e4b8a39bd
Author:    Darek Slusarczyk <dariusz.slusarczyk@oracle.com>         Thu, 19 Jul 2018 \
                13:20:43 +0200
Parents:   e729a864d72712a8efe31d2c5b4208525e8ff26d
Branches:  release/8.0.13

Link:       http://git.php.net/?p=pecl/database/mysql_xdevapi.git;a=commitdiff;h=cbf58b8dcc163124a2ac602a914f4b6e4b8a39bd


Log:
WL#12189 : Implement connect timeout
- fix connecting time vs timeout verification

Bugs:
https://bugs.php.net/12189

Changed paths:
  M  tests/auth/timeout/timeout_utils.inc
  M  tests/connect.inc


Diff:
diff --git a/tests/auth/timeout/timeout_utils.inc \
b/tests/auth/timeout/timeout_utils.inc index f7444eb..a32ea73 100644
--- a/tests/auth/timeout/timeout_utils.inc
+++ b/tests/auth/timeout/timeout_utils.inc
@@ -27,11 +27,16 @@ function test_incorrect_timeout($host, $port, $timeout) {
 }
 
 function verify_connecting_time($connecting_time, $timeout) {
-	if (!$timeout) return true;
-
-	if ($timeout == 0) $timeout = $Default_connection_time_out;
-
-	expect_true(($timeout - 1.0 < $connecting_time) && ($connecting_time < $timeout + \
1.0)); +	global $Default_connection_time_out;
+	if ($timeout === null) {
+		$timeout = $Default_connection_time_out;
+	} else if ($timeout === 0) {
+		$timeout = intval(ini_get('default_socket_timeout'));
+	}
+
+	expect_true(
+		is_in_range($connecting_time, $timeout - 1.0, $timeout + 1.0),
+		"expected: $timeout, actual: $connecting_time");
 }
 
 function test_elapsed_timeout($host, $port, $timeout) {
diff --git a/tests/connect.inc b/tests/connect.inc
index b26eb53..bcb155c 100644
--- a/tests/connect.inc
+++ b/tests/connect.inc
@@ -37,6 +37,14 @@
 
 	// ----------------------------------------------------------------------
 
+	if (!function_exists('is_in_range')) {
+		function is_in_range($value, $min, $max) {
+			return ($min <= $value) && ($value <= $max);
+		}
+	}
+
+	// ----------------------------------------------------------------------
+
 	if (!function_exists('verify_os')) {
 		function verify_os($os_mask) {
 			return strtoupper(substr(PHP_OS, 0, 3)) === $os_mask;


--
PECL CVS Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic