summaryrefslogtreecommitdiffstats
path: root/tests/pthread_test.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/pthread_test.cpp')
-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 f96ccf9..6dbd964 100644
--- a/tests/pthread_test.cpp
+++ b/tests/pthread_test.cpp
@@ -181,6 +181,19 @@ TEST(pthread, pthread_key_dirty) {
ASSERT_EQ(0, pthread_key_delete(key));
}
+TEST(pthread, static_pthread_key_used_before_creation) {
+#if defined(__BIONIC__)
+ // See http://b/19625804. The bug is about a static/global pthread key being used before creation.
+ // So here tests if the static/global default value 0 can be detected as invalid key.
+ static pthread_key_t key;
+ ASSERT_EQ(nullptr, pthread_getspecific(key));
+ ASSERT_EQ(EINVAL, pthread_setspecific(key, nullptr));
+ ASSERT_EQ(EINVAL, pthread_key_delete(key));
+#else
+ GTEST_LOG_(INFO) << "This test tests bionic pthread key implementation detail.\n";
+#endif
+}
+
static void* IdFn(void* arg) {
return arg;
}