uw Mon, 20 Sep 2010 19:01:13 +0000 Revision: http://svn.php.net/viewvc?view=revision&revision=303630
Log: Trying to pimp gcov.php.net code coverage tests.. trying to cover mysqlnd compress code with a standard test run Changed paths: U php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_fetch_array_large.phpt U php/php-src/trunk/ext/mysqli/tests/mysqli_fetch_array_large.phpt Modified: php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_fetch_array_large.phpt =================================================================== --- php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_fetch_array_large.phpt 2010-09-20 18:26:11 UTC (rev 303629) +++ php/php-src/branches/PHP_5_3/ext/mysqli/tests/mysqli_fetch_array_large.phpt 2010-09-20 19:01:13 UTC (rev 303630) @@ -100,49 +100,61 @@ } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } + function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) { - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) - printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $link = mysqli_init(); + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + return false; + } - $package_size = 524288; - $offset = 3; - $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) { + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + return false; + } - /* try to respect php.ini but make run time a soft limit */ - $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; - set_time_limit(0); + $package_size = 524288; + $offset = 3; + $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); - do { - if ($package_size > $limit) { - printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); - break; - } + /* try to respect php.ini but make run time a soft limit */ + $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; + set_time_limit(0); - $start = microtime(true); - if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { - printf("stop: packet size - %d\n", $package_size); - break; - } + do { + if ($package_size > $limit) { + printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); + break; + } - $duration = microtime(true) - $start; - $max_runtime -= $duration; - if ($max_runtime < ($duration * 3)) { - /* likely the next iteration will not be within max_execution_time */ - printf("stop: time limit - %2.2fs\n", $max_runtime); - break; - } + $start = microtime(true); + if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { + printf("stop: packet size - %d\n", $package_size); + break; + } - $package_size += $package_size; + $duration = microtime(true) - $start; + $max_runtime -= $duration; + if ($max_runtime < ($duration * 3)) { + /* likely the next iteration will not be within max_execution_time */ + printf("stop: time limit - %2.2fs\n", $max_runtime); + break; + } - } while (true); + $package_size += $package_size; + } while (true); - mysqli_close($link); + + mysqli_close($link); + return true; + } + + + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null); + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS); print "done!"; ?> --CLEAN-- @@ -151,4 +163,5 @@ ?> --EXPECTF-- stop: %s +stop: %s done! \ No newline at end of file Modified: php/php-src/trunk/ext/mysqli/tests/mysqli_fetch_array_large.phpt =================================================================== --- php/php-src/trunk/ext/mysqli/tests/mysqli_fetch_array_large.phpt 2010-09-20 18:26:11 UTC (rev 303629) +++ php/php-src/trunk/ext/mysqli/tests/mysqli_fetch_array_large.phpt 2010-09-20 19:01:13 UTC (rev 303630) @@ -100,49 +100,61 @@ } - if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) { - printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", - $host, $user, $db, $port, $socket); - } + function test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, $flags = null) { - if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || - !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) - printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + $link = mysqli_init(); + if (!my_mysqli_real_connect($link, $host, $user, $passwd, $db, $port, $socket, $flags)) { + printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", + $host, $user, $db, $port, $socket); + return false; + } - $package_size = 524288; - $offset = 3; - $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); + if (!mysqli_query($link, "DROP TABLE IF EXISTS test") || + !mysqli_query($link, sprintf("CREATE TABLE test(id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, label VARCHAR(255)) ENGINE = %s", $engine))) { + printf("[002] [%d] %s\n", mysqli_errno($link), mysqli_error($link)); + return false; + } - /* try to respect php.ini but make run time a soft limit */ - $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; - set_time_limit(0); + $package_size = 524288; + $offset = 3; + $limit = (ini_get('memory_limit') > 0) ? parse_memory_limit(ini_get('memory_limit')) : pow(2, 32); - do { - if ($package_size > $limit) { - printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); - break; - } + /* try to respect php.ini but make run time a soft limit */ + $max_runtime = (ini_get('max_execution_time') > 0) ? ini_get('max_execution_time') : 30; + set_time_limit(0); - $start = microtime(true); - if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { - printf("stop: packet size - %d\n", $package_size); - break; - } + do { + if ($package_size > $limit) { + printf("stop: memory limit - %s vs. %s\n", $package_size, $limit); + break; + } - $duration = microtime(true) - $start; - $max_runtime -= $duration; - if ($max_runtime < ($duration * 3)) { - /* likely the next iteration will not be within max_execution_time */ - printf("stop: time limit - %2.2fs\n", $max_runtime); - break; - } + $start = microtime(true); + if (!mysqli_fetch_array_large($offset++, $link, $package_size)) { + printf("stop: packet size - %d\n", $package_size); + break; + } - $package_size += $package_size; + $duration = microtime(true) - $start; + $max_runtime -= $duration; + if ($max_runtime < ($duration * 3)) { + /* likely the next iteration will not be within max_execution_time */ + printf("stop: time limit - %2.2fs\n", $max_runtime); + break; + } - } while (true); + $package_size += $package_size; + } while (true); - mysqli_close($link); + + mysqli_close($link); + return true; + } + + + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, null); + test_fetch($host, $user, $passwd, $db, $port, $socket, $engine, MYSQLI_CLIENT_COMPRESS); print "done!"; ?> --CLEAN-- @@ -151,4 +163,5 @@ ?> --EXPECTF-- stop: %s +stop: %s done! \ No newline at end of file
-- PHP CVS Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php