summaryrefslogtreecommitdiff
path: root/deps/uv/test
diff options
context:
space:
mode:
authorBert Belder <bertbelder@gmail.com>2013-08-29 15:04:27 +0200
committerBert Belder <bertbelder@gmail.com>2013-08-29 15:38:32 +0200
commite83a0cd016ef03d3ec3b491325b347be886c1476 (patch)
treef9c61bd589f91c07f2dbaec25e09cc8f34d5745f /deps/uv/test
parenta9eb96d0201fa7d13c898a154e81fd9531358d2f (diff)
downloadnode-new-e83a0cd016ef03d3ec3b491325b347be886c1476.tar.gz
uv: upgrade to v0.11.11
Diffstat (limited to 'deps/uv/test')
-rw-r--r--deps/uv/test/test-list.h2
-rw-r--r--deps/uv/test/test-thread.c26
2 files changed, 28 insertions, 0 deletions
diff --git a/deps/uv/test/test-list.h b/deps/uv/test/test-list.h
index feca46700a..334b48322a 100644
--- a/deps/uv/test/test-list.h
+++ b/deps/uv/test/test-list.h
@@ -203,6 +203,7 @@ TEST_DECLARE (threadpool_cancel_getaddrinfo)
TEST_DECLARE (threadpool_cancel_work)
TEST_DECLARE (threadpool_cancel_fs)
TEST_DECLARE (threadpool_cancel_single)
+TEST_DECLARE (thread_local_storage)
TEST_DECLARE (thread_mutex)
TEST_DECLARE (thread_rwlock)
TEST_DECLARE (thread_create)
@@ -496,6 +497,7 @@ TASK_LIST_START
TEST_ENTRY (threadpool_cancel_work)
TEST_ENTRY (threadpool_cancel_fs)
TEST_ENTRY (threadpool_cancel_single)
+ TEST_ENTRY (thread_local_storage)
TEST_ENTRY (thread_mutex)
TEST_ENTRY (thread_rwlock)
TEST_ENTRY (thread_create)
diff --git a/deps/uv/test/test-thread.c b/deps/uv/test/test-thread.c
index 4bec8428f0..c396baa100 100644
--- a/deps/uv/test/test-thread.c
+++ b/deps/uv/test/test-thread.c
@@ -55,6 +55,7 @@ static void fs_do(struct fs_req* req);
static void fs_cb(uv_fs_t* handle);
static volatile int thread_called;
+static uv_key_t tls_key;
static void getaddrinfo_do(struct getaddrinfo_req* req) {
@@ -181,3 +182,28 @@ TEST_IMPL(threadpool_multiple_event_loops) {
return 0;
}
+
+
+static void tls_thread(void* arg) {
+ ASSERT(NULL == uv_key_get(&tls_key));
+ uv_key_set(&tls_key, arg);
+ ASSERT(arg == uv_key_get(&tls_key));
+ uv_key_set(&tls_key, NULL);
+ ASSERT(NULL == uv_key_get(&tls_key));
+}
+
+
+TEST_IMPL(thread_local_storage) {
+ char name[] = "main";
+ uv_thread_t threads[2];
+ ASSERT(0 == uv_key_create(&tls_key));
+ ASSERT(NULL == uv_key_get(&tls_key));
+ uv_key_set(&tls_key, name);
+ ASSERT(name == uv_key_get(&tls_key));
+ ASSERT(0 == uv_thread_create(threads + 0, tls_thread, threads + 0));
+ ASSERT(0 == uv_thread_create(threads + 1, tls_thread, threads + 1));
+ ASSERT(0 == uv_thread_join(threads + 0));
+ ASSERT(0 == uv_thread_join(threads + 1));
+ uv_key_delete(&tls_key);
+ return 0;
+}