Renames ThreadStartSempahore to Notificaton (by Vlad Losev); adds threading tests for SCOPED_TRACE() (by Vlad Losev); replaces native pthread calls with gtest's threading constructs (by Vlad Losev); fixes flakiness in CountedDestructor (by Vlad Losev); minor MSVC 7.1 clean-up (by Zhanyong Wan).

This commit is contained in:
zhanyong.wan
2010-03-04 22:15:53 +00:00
parent 0928f00c6b
commit 12a92c26fc
12 changed files with 359 additions and 179 deletions

View File

@@ -49,16 +49,15 @@
namespace testing {
namespace {
using internal::scoped_ptr;
using internal::Notification;
using internal::String;
using internal::TestPropertyKeyIs;
using internal::ThreadStartSemaphore;
using internal::ThreadWithParam;
using internal::scoped_ptr;
// In order to run tests in this file, for platforms where Google Test is
// thread safe, implement ThreadWithParam and ThreadStartSemaphore. See the
// description of their API in gtest-port.h, where they are defined for
// already supported platforms.
// thread safe, implement ThreadWithParam. See the description of its API
// in gtest-port.h, where it is defined for already supported platforms.
// How many threads to create?
const int kThreadCount = 50;
@@ -129,11 +128,13 @@ void CheckTestFailureCount(int expected_failures) {
TEST(StressTest, CanUseScopedTraceAndAssertionsInManyThreads) {
{
scoped_ptr<ThreadWithParam<int> > threads[kThreadCount];
ThreadStartSemaphore semaphore;
Notification threads_can_start;
for (int i = 0; i != kThreadCount; i++)
threads[i].reset(new ThreadWithParam<int>(&ManyAsserts, i, &semaphore));
threads[i].reset(new ThreadWithParam<int>(&ManyAsserts,
i,
&threads_can_start));
semaphore.Signal(); // Starts all the threads.
threads_can_start.Notify();
// Blocks until all the threads are done.
for (int i = 0; i != kThreadCount; i++)