add ares_gethostbyname testcase

This commit is contained in:
Shuhei Tanuma 2012-06-30 12:35:01 +09:00
parent 3abb548c43
commit 4d90f621f8
2 changed files with 39 additions and 0 deletions

View File

@ -3095,6 +3095,10 @@ PHP_FUNCTION(ares_gethostbyname)
}
ZEND_FETCH_RESOURCE(uv, php_uv_ares_t *, &handle, -1, PHP_UV_ARES_RESOURCE_NAME, uv_ares_handle);
if (uv->gethostbyname_cb != NULL) {
zval_ptr_dtor(&uv->gethostbyname_cb);
uv->gethostbyname_cb = NULL;
}
Z_ADDREF_P(byname_cb);
uv->gethostbyname_cb = byname_cb;

View File

@ -0,0 +1,35 @@
--TEST--
Check for ares_gethostbyname
--FILE--
<?php
$uv = uv_ares_init_options(uv_default_loop(), array(
"servers" => array(
"8.8.8.8"
),
"port"=>53
),null);
ares_gethostbyname($uv,"php.net",AF_INET, function($name, $addr){
echo $name . PHP_EOL;
if (is_array($addr)) {
echo "OK";
} else {
echo "FAILED";
}
});
ares_gethostbyname($uv,"php.net",AF_INET, function($name, $addr){
echo $name . PHP_EOL;
if (is_array($addr)) {
echo "OK" . PHP_EOL;
} else {
echo "FAILED: 2nd parameter does not array" . PHP_EOL;
}
});
uv_run();
--EXPECT--
php.net
OK
php.net
OK