diff options
author | Elliott Hughes <enh@google.com> | 2014-05-14 11:46:08 -0700 |
---|---|---|
committer | Elliott Hughes <enh@google.com> | 2014-05-14 11:46:08 -0700 |
commit | 3694ec6c4b644064f7e00b898cd11e138e4f6c09 (patch) | |
tree | 9eab4a160dacd3a71ac6d43db983ed4b965968b4 /tests/pthread_test.cpp | |
parent | e6c27a7af7a9b13e4e3d3ebd604d28effa9e9322 (diff) | |
download | android_bionic-3694ec6c4b644064f7e00b898cd11e138e4f6c09.tar.gz android_bionic-3694ec6c4b644064f7e00b898cd11e138e4f6c09.tar.bz2 android_bionic-3694ec6c4b644064f7e00b898cd11e138e4f6c09.zip |
Add a regression test for a long-fixed pthread_once bug.
Bug: 1934122
Change-Id: Iae09baedc2c6ed4036521e51718fe9d015bc56b9
Diffstat (limited to 'tests/pthread_test.cpp')
-rw-r--r-- | tests/pthread_test.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/pthread_test.cpp b/tests/pthread_test.cpp index b9a0c2c8a..fa66d21d9 100644 --- a/tests/pthread_test.cpp +++ b/tests/pthread_test.cpp @@ -572,6 +572,26 @@ TEST(pthread, pthread_once_smoke) { ASSERT_EQ(1, g_once_fn_call_count); } +static std::string pthread_once_1934122_result = ""; + +static void Routine2() { + pthread_once_1934122_result += "2"; +} + +static void Routine1() { + pthread_once_t once_control_2 = PTHREAD_ONCE_INIT; + pthread_once_1934122_result += "1"; + pthread_once(&once_control_2, &Routine2); +} + +TEST(pthread, pthread_once_1934122) { + // Very old versions of Android couldn't call pthread_once from a + // pthread_once init routine. http://b/1934122. + pthread_once_t once_control_1 = PTHREAD_ONCE_INIT; + ASSERT_EQ(0, pthread_once(&once_control_1, &Routine1)); + ASSERT_EQ("12", pthread_once_1934122_result); +} + static int g_atfork_prepare_calls = 0; static void AtForkPrepare1() { g_atfork_prepare_calls = (g_atfork_prepare_calls << 4) | 1; } static void AtForkPrepare2() { g_atfork_prepare_calls = (g_atfork_prepare_calls << 4) | 2; } |