Fix pthread_test to work with gtest 1.7.0.
Now we're building it correctly configured, gtest takes a couple of TLS slots for itself. Change-Id: I1c2c4e9e5f9c6e2e2e6ecd1214cfc16a5af5afed
This commit is contained in:
parent
c75e7726ea
commit
718a5b5495
@ -35,15 +35,19 @@ TEST(pthread, pthread_key_create) {
|
||||
TEST(pthread, pthread_key_create_lots) {
|
||||
// POSIX says PTHREAD_KEYS_MAX should be at least 128.
|
||||
ASSERT_GE(PTHREAD_KEYS_MAX, 128);
|
||||
|
||||
int sysconf_max = sysconf(_SC_THREAD_KEYS_MAX);
|
||||
|
||||
// sysconf shouldn't return a smaller value.
|
||||
ASSERT_GE(sysconf(_SC_THREAD_KEYS_MAX), PTHREAD_KEYS_MAX);
|
||||
ASSERT_GE(sysconf_max, PTHREAD_KEYS_MAX);
|
||||
|
||||
// We can allocate _SC_THREAD_KEYS_MAX keys.
|
||||
sysconf_max -= 2; // (Except that gtest takes two for itself.)
|
||||
std::vector<pthread_key_t> keys;
|
||||
for (int i = 0; i < sysconf(_SC_THREAD_KEYS_MAX); ++i) {
|
||||
for (int i = 0; i < sysconf_max; ++i) {
|
||||
pthread_key_t key;
|
||||
// If this fails, it's likely that GLOBAL_INIT_THREAD_LOCAL_BUFFER_COUNT is wrong.
|
||||
ASSERT_EQ(0, pthread_key_create(&key, NULL)) << i << " of " << sysconf(_SC_THREAD_KEYS_MAX);
|
||||
ASSERT_EQ(0, pthread_key_create(&key, NULL)) << i << " of " << sysconf_max;
|
||||
keys.push_back(key);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user