Merge "Remove pthread_detach_no_leak test."
This commit is contained in:
		@@ -458,42 +458,6 @@ TEST(pthread, pthread_detach__no_such_thread) {
 | 
				
			|||||||
  ASSERT_EQ(ESRCH, pthread_detach(dead_thread));
 | 
					  ASSERT_EQ(ESRCH, pthread_detach(dead_thread));
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TEST(pthread, pthread_detach_no_leak) {
 | 
					 | 
				
			||||||
  size_t initial_bytes = 0;
 | 
					 | 
				
			||||||
  // Run this loop more than once since the first loop causes some memory
 | 
					 | 
				
			||||||
  // to be allocated permenantly. Run an extra loop to help catch any subtle
 | 
					 | 
				
			||||||
  // memory leaks.
 | 
					 | 
				
			||||||
  for (size_t loop = 0; loop < 3; loop++) {
 | 
					 | 
				
			||||||
    // Set the initial bytes on the second loop since the memory in use
 | 
					 | 
				
			||||||
    // should have stabilized.
 | 
					 | 
				
			||||||
    if (loop == 1) {
 | 
					 | 
				
			||||||
      initial_bytes = mallinfo().uordblks;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    pthread_attr_t attr;
 | 
					 | 
				
			||||||
    ASSERT_EQ(0, pthread_attr_init(&attr));
 | 
					 | 
				
			||||||
    ASSERT_EQ(0, pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    std::vector<pthread_t> threads;
 | 
					 | 
				
			||||||
    for (size_t i = 0; i < 32; ++i) {
 | 
					 | 
				
			||||||
      pthread_t t;
 | 
					 | 
				
			||||||
      ASSERT_EQ(0, pthread_create(&t, &attr, IdFn, NULL));
 | 
					 | 
				
			||||||
      threads.push_back(t);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    sleep(1);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    for (size_t i = 0; i < 32; ++i) {
 | 
					 | 
				
			||||||
      ASSERT_EQ(0, pthread_detach(threads[i])) << i;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  size_t final_bytes = mallinfo().uordblks;
 | 
					 | 
				
			||||||
  int leaked_bytes = (final_bytes - initial_bytes);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  ASSERT_EQ(0, leaked_bytes);
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
TEST(pthread, pthread_getcpuclockid__clock_gettime) {
 | 
					TEST(pthread, pthread_getcpuclockid__clock_gettime) {
 | 
				
			||||||
  SpinFunctionHelper spinhelper;
 | 
					  SpinFunctionHelper spinhelper;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user