summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2014-06-25 13:46:46 -0700
committerElliott Hughes <enh@google.com>2014-06-25 13:46:46 -0700
commitebb770f90d9a8d7f75a9d8b0e6a96ded96c617af (patch)
tree6b70574665d414ccc2b3d90921bdc7a196e4a415 /tests
parentba4ebf78ad29ab2ee57c05807140bdf751f59cc6 (diff)
downloadbionic-ebb770f90d9a8d7f75a9d8b0e6a96ded96c617af.zip
bionic-ebb770f90d9a8d7f75a9d8b0e6a96ded96c617af.tar.gz
bionic-ebb770f90d9a8d7f75a9d8b0e6a96ded96c617af.tar.bz2
Add a new pthread_key_delete test.
Bug: https://code.google.com/p/android/issues/detail?id=66813 Change-Id: Ida87bc1fb15a73a08c223a7099456d9f049cd3c5
Diffstat (limited to 'tests')
-rw-r--r--tests/pthread_test.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp
index 0f42d43..36da481 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -69,6 +69,19 @@ TEST(pthread, pthread_key_create_lots) {
#endif // __BIONIC__
}
+TEST(pthread, pthread_key_delete) {
+ void* expected = reinterpret_cast<void*>(1234);
+ pthread_key_t key;
+ ASSERT_EQ(0, pthread_key_create(&key, NULL));
+ ASSERT_EQ(0, pthread_setspecific(key, expected));
+ ASSERT_EQ(expected, pthread_getspecific(key));
+ ASSERT_EQ(0, pthread_key_delete(key));
+ // After deletion, pthread_getspecific returns NULL.
+ ASSERT_EQ(NULL, pthread_getspecific(key));
+ // And you can't use pthread_setspecific with the deleted key.
+ ASSERT_EQ(EINVAL, pthread_setspecific(key, expected));
+}
+
static void* IdFn(void* arg) {
return arg;
}