diff options
author | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-08-21 11:15:21 -0700 |
---|---|---|
committer | Timothy J Fontaine <tjfontaine@gmail.com> | 2013-08-21 11:15:21 -0700 |
commit | a784abaff631449533d44846987c1537c080e03d (patch) | |
tree | 0982d9a92450edb9e46ba683d75eb7822ea004b3 /deps/uv/test | |
parent | 41f55dc59b423b8b76e6f7971fd8f3a326a6fbad (diff) | |
download | android-node-v8-a784abaff631449533d44846987c1537c080e03d.tar.gz android-node-v8-a784abaff631449533d44846987c1537c080e03d.tar.bz2 android-node-v8-a784abaff631449533d44846987c1537c080e03d.zip |
uv: Upgrade to v0.11.8
Diffstat (limited to 'deps/uv/test')
-rw-r--r-- | deps/uv/test/test-async-null-cb.c | 55 | ||||
-rw-r--r-- | deps/uv/test/test-ip6-addr.c | 90 | ||||
-rw-r--r-- | deps/uv/test/test-list.h | 2 |
3 files changed, 100 insertions, 47 deletions
diff --git a/deps/uv/test/test-async-null-cb.c b/deps/uv/test/test-async-null-cb.c new file mode 100644 index 0000000000..d654884268 --- /dev/null +++ b/deps/uv/test/test-async-null-cb.c @@ -0,0 +1,55 @@ +/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +#include "uv.h" +#include "task.h" + +static uv_async_t async_handle; +static uv_check_t check_handle; +static int check_cb_called; +static uv_thread_t thread; + + +static void thread_cb(void* dummy) { + (void) &dummy; + uv_async_send(&async_handle); +} + + +static void check_cb(uv_check_t* handle, int status) { + ASSERT(check_cb_called == 0); + uv_close((uv_handle_t*) &async_handle, NULL); + uv_close((uv_handle_t*) &check_handle, NULL); + check_cb_called++; +} + + +TEST_IMPL(async_null_cb) { + ASSERT(0 == uv_async_init(uv_default_loop(), &async_handle, NULL)); + ASSERT(0 == uv_check_init(uv_default_loop(), &check_handle)); + ASSERT(0 == uv_check_start(&check_handle, check_cb)); + ASSERT(0 == uv_thread_create(&thread, thread_cb, NULL)); + ASSERT(0 == uv_run(uv_default_loop(), UV_RUN_DEFAULT)); + ASSERT(0 == uv_thread_join(&thread)); + ASSERT(1 == check_cb_called); + MAKE_VALGRIND_HAPPY(); + return 0; +} diff --git a/deps/uv/test/test-ip6-addr.c b/deps/uv/test/test-ip6-addr.c index 9cd9b97cf1..91891bffb9 100644 --- a/deps/uv/test/test-ip6-addr.c +++ b/deps/uv/test/test-ip6-addr.c @@ -30,72 +30,68 @@ # include <net/if.h> #endif -typedef void (*iface_info_cb)(const char* ip6_addr, const char* device_name, - unsigned iface_index); -void call_iface_info_cb(iface_info_cb iface_cb, - char const* iface_name, - struct sockaddr_in6 const* address) { +TEST_IMPL(ip6_addr_link_local) { +#ifdef UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS char string_address[INET6_ADDRSTRLEN]; - - ASSERT(0 == uv_inet_ntop(AF_INET6, - &address->sin6_addr, - string_address, - INET6_ADDRSTRLEN)); - iface_cb(string_address, iface_name, address->sin6_scope_id); -} - - -void foreach_ip6_interface(iface_info_cb iface_cb) { - int count, ix; uv_interface_address_t* addresses; + uv_interface_address_t* address; + struct sockaddr_in6 addr; + unsigned int iface_index; + const char* device_name; + /* 40 bytes address, 16 bytes device name, plus reserve. */ + char scoped_addr[128]; + int count; + int ix; ASSERT(0 == uv_interface_addresses(&addresses, &count)); for (ix = 0; ix < count; ix++) { - if (addresses[ix].address.address4.sin_family != AF_INET6) - continue; + address = addresses + ix; - call_iface_info_cb(iface_cb, - addresses[ix].name, - &addresses[ix].address.address6); - } - - uv_free_interface_addresses(addresses, count); -} + if (address->address.address6.sin6_family != AF_INET6) + continue; + ASSERT(0 == uv_inet_ntop(AF_INET6, + &address->address.address6.sin6_addr, + string_address, + sizeof(string_address))); -void test_ip6_addr_scope(const char* ip6_addr, - const char* device_name, - unsigned iface_index) { - /* 40 bytes address, 16 bytes device name, plus reserve */ - char scoped_addr[128]; - struct sockaddr_in6 addr; + /* Skip addresses that are not link-local. */ + if (strncmp(string_address, "fe80::", 6) != 0) + continue; - /* skip addresses that are not link-local */ - if (strncmp(ip6_addr, "fe80::", 6) != 0) return; + iface_index = address->address.address6.sin6_scope_id; + device_name = address->name; #ifdef _WIN32 - snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%d", ip6_addr, iface_index); + snprintf(scoped_addr, + sizeof(scoped_addr), + "%s%%%d", + string_address, + iface_index); #else - snprintf(scoped_addr, sizeof(scoped_addr), "%s%%%s", ip6_addr, device_name); + snprintf(scoped_addr, + sizeof(scoped_addr), + "%s%%%s", + string_address, + device_name); #endif - LOGF("Testing link-local address %s (iface_index: 0x%02x, device_name: %s)\n", - scoped_addr, - iface_index, - device_name); - - addr = uv_ip6_addr(scoped_addr, TEST_PORT); + LOGF("Testing link-local address %s " + "(iface_index: 0x%02x, device_name: %s)\n", + scoped_addr, + iface_index, + device_name); - LOGF("Got scope_id 0x%02x\n", addr.sin6_scope_id); - ASSERT(iface_index == addr.sin6_scope_id); -} + addr = uv_ip6_addr(scoped_addr, TEST_PORT); + LOGF("Got scope_id 0x%02x\n", addr.sin6_scope_id); + ASSERT(iface_index == addr.sin6_scope_id); + } + uv_free_interface_addresses(addresses, count); -TEST_IMPL(ip6_addr_link_local) { -#ifdef UV_PLATFORM_HAS_IP6_LINK_LOCAL_ADDRESS - foreach_ip6_interface(&test_ip6_addr_scope); + MAKE_VALGRIND_HAPPY(); return 0; #else RETURN_SKIP("Qualified link-local addresses are not supported."); diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h index d3371a8093..feca46700a 100644 --- a/deps/uv/test/test-list.h +++ b/deps/uv/test/test-list.h @@ -134,6 +134,7 @@ TEST_DECLARE (has_ref) TEST_DECLARE (active) TEST_DECLARE (embed) TEST_DECLARE (async) +TEST_DECLARE (async_null_cb) TEST_DECLARE (get_currentexe) TEST_DECLARE (process_title) TEST_DECLARE (cwd_and_chdir) @@ -396,6 +397,7 @@ TASK_LIST_START TEST_ENTRY (embed) TEST_ENTRY (async) + TEST_ENTRY (async_null_cb) TEST_ENTRY (get_currentexe) |