umd/external/protobuf-2.6/gtest/fused-src/gtest/gtest-all.cc
int UnitTestImpl::RunAllTests() {
  // Makes sure InitGoogleTest() was called.
  if (!GTestIsInitialized()) {
    printf("%s",
           "\nThis test program did NOT call ::testing::InitGoogleTest "
           "before calling RUN_ALL_TESTS().  Please fix it.\n");
    return 1;
  }

  // Do not run any test if the --help flag was specified.
  if (g_help_flag)
    return 0;

  // Repeats the call to the post-flag parsing initialization in case the
  // user didn't call InitGoogleTest.
  PostFlagParsingInit();

  // Even if sharding is not on, test runners may want to use the
  // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding
  // protocol.
  internal::WriteToShardStatusFileIfNeeded();

  // True iff we are in a subprocess for running a thread-safe-style
  // death test.
  bool in_subprocess_for_death_test = false;

#if GTEST_HAS_DEATH_TEST
  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
#endif  // GTEST_HAS_DEATH_TEST

  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
                                        in_subprocess_for_death_test);

  // Compares the full test names with the filter to decide which
  // tests to run.
  const bool has_tests_to_run = FilterTests(should_shard
                                              ? HONOR_SHARDING_PROTOCOL
                                              : IGNORE_SHARDING_PROTOCOL) > 0;

  // Lists the tests and exits if the --gtest_list_tests flag was specified.
  if (GTEST_FLAG(list_tests)) {
    // This must be called *after* FilterTests() has been called.
    ListTestsMatchingFilter();
    return 0;
  }

  random_seed_ = GTEST_FLAG(shuffle) ?
      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;

  // True iff at least one test has failed.
  bool failed = false;

  TestEventListener* repeater = listeners()->repeater();

  repeater->OnTestProgramStart(*parent_);

  // How many times to repeat the tests?  We don't want to repeat them
  // when we are inside the subprocess of a death test.
  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
  // Repeats forever if the repeat count is negative.
  const bool forever = repeat < 0;
  for (int i = 0; forever || i != repeat; i++) {
    ClearResult();

    const TimeInMillis start = GetTimeInMillis();

    // Shuffles test cases and tests if requested.
    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
      random()->Reseed(random_seed_);
      // This should be done before calling OnTestIterationStart(),
      // such that a test event listener can see the actual test order
      // in the event.
      ShuffleTests();
    }

    // Tells the unit test event listeners that the tests are about to start.
    repeater->OnTestIterationStart(*parent_, i);

    // Runs each test case if there is at least one test to run.
    if (has_tests_to_run) {
      // Sets up all environments beforehand.
      repeater->OnEnvironmentsSetUpStart(*parent_);
      ForEach(environments_, SetUpEnvironment);
      repeater->OnEnvironmentsSetUpEnd(*parent_);

      // Runs the tests only if there was no fatal failure during global
      // set-up.
      if (!Test::HasFatalFailure()) {
        for (int test_index = 0; test_index < total_test_case_count();
             test_index++) {
          GetMutableTestCase(test_index)->Run();
        }
      }

      // Tears down all environments in reverse order afterwards.
      repeater->OnEnvironmentsTearDownStart(*parent_);
      std::for_each(environments_.rbegin(), environments_.rend(),
                    TearDownEnvironment);
      repeater->OnEnvironmentsTearDownEnd(*parent_);
    }

    elapsed_time_ = GetTimeInMillis() - start;

    // Tells the unit test event listener that the tests have just finished.
    repeater->OnTestIterationEnd(*parent_, i);

    // Gets the result and clears it.
    if (!Passed()) {
      failed = true;
    }

    // Restores the original test order after the iteration.  This
    // allows the user to quickly repro a failure that happens in the
    // N-th iteration without repeating the first (N - 1) iterations.
    // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in
    // case the user somehow changes the value of the flag somewhere
    // (it's always safe to unshuffle the tests).
    UnshuffleTests();

    if (GTEST_FLAG(shuffle)) {
      // Picks a new random seed for each iteration.
      random_seed_ = GetNextRandomSeed(random_seed_);
    }
  }

  repeater->OnTestProgramEnd(*parent_);

  // Returns 0 if all tests passed, or 1 other wise.
  return failed ? 1 : 0;
}
// Runs all tests in this UnitTest object, prints the result, and
// returns 0 if all tests are successful, or 1 otherwise.  If any
// exception is thrown during a test on Windows, this test is
// considered to be failed, but the rest of the tests will still be
// run.  (We disable exceptions on Linux and Mac OS X, so the issue
// doesn't apply there.)
// When parameterized tests are enabled, it expands and registers
// parameterized tests first in RegisterParameterizedTests().
// All other functions called from RunAllTests() may safely assume that
// parameterized tests are ready to be counted and run.
Runs all tests in this UnitTest object, prints the result, and
returns 0 if all tests are successful, or 1 otherwise.  If any
exception is thrown during a test on Windows, this test is
considered to be failed, but the rest of the tests will still be
run.  (We disable exceptions on Linux and Mac OS X, so the issue
doesn't apply there.)
When parameterized tests are enabled, it expands and registers
parameterized tests first in RegisterParameterizedTests().
All other functions called from RunAllTests() may safely assume that
parameterized tests are ready to be counted and run.
Runs all tests in this UnitTest object prints the result and returns 0 if all tests are successful or 1 otherwise . If any exception is thrown during a test on Windows this test is considered to be failed but the rest of the tests will still be run . ( We disable exceptions on Linux and Mac OS X so the issue doesn ' t apply there . ) When parameterized tests are enabled it expands and registers parameterized tests first in RegisterParameterizedTests () . All other functions called from RunAllTests () may safely assume that parameterized tests are ready to be counted and run .
int UnitTestImpl::RunAllTests() {
  if (!GTestIsInitialized()) {
    printf("%s",
           "\nThis test program did NOT call ::testing::InitGoogleTest "
           "before calling RUN_ALL_TESTS().  Please fix it.\n");
    return 1;
  }
  if (g_help_flag)
    return 0;
  PostFlagParsingInit();
  internal::WriteToShardStatusFileIfNeeded();
  bool in_subprocess_for_death_test = false;
#if GTEST_HAS_DEATH_TEST
  in_subprocess_for_death_test = (internal_run_death_test_flag_.get() != NULL);
#endif  
  const bool should_shard = ShouldShard(kTestTotalShards, kTestShardIndex,
                                        in_subprocess_for_death_test);
  const bool has_tests_to_run = FilterTests(should_shard
                                              ? HONOR_SHARDING_PROTOCOL
                                              : IGNORE_SHARDING_PROTOCOL) > 0;
  if (GTEST_FLAG(list_tests)) {
    ListTestsMatchingFilter();
    return 0;
  }
  random_seed_ = GTEST_FLAG(shuffle) ?
      GetRandomSeedFromFlag(GTEST_FLAG(random_seed)) : 0;
  bool failed = false;
  TestEventListener* repeater = listeners()->repeater();
  repeater->OnTestProgramStart(*parent_);
  const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG(repeat);
  const bool forever = repeat < 0;
  for (int i = 0; forever || i != repeat; i++) {
    ClearResult();
    const TimeInMillis start = GetTimeInMillis();
    if (has_tests_to_run && GTEST_FLAG(shuffle)) {
      random()->Reseed(random_seed_);
      ShuffleTests();
    }
    repeater->OnTestIterationStart(*parent_, i);
    if (has_tests_to_run) {
      repeater->OnEnvironmentsSetUpStart(*parent_);
      ForEach(environments_, SetUpEnvironment);
      repeater->OnEnvironmentsSetUpEnd(*parent_);
      if (!Test::HasFatalFailure()) {
        for (int test_index = 0; test_index < total_test_case_count();
             test_index++) {
          GetMutableTestCase(test_index)->Run();
        }
      }
      repeater->OnEnvironmentsTearDownStart(*parent_);
      std::for_each(environments_.rbegin(), environments_.rend(),
                    TearDownEnvironment);
      repeater->OnEnvironmentsTearDownEnd(*parent_);
    }
    elapsed_time_ = GetTimeInMillis() - start;
    repeater->OnTestIterationEnd(*parent_, i);
    if (!Passed()) {
      failed = true;
    }
    UnshuffleTests();
    if (GTEST_FLAG(shuffle)) {
      random_seed_ = GetNextRandomSeed(random_seed_);
    }
  }
  repeater->OnTestProgramEnd(*parent_);
  return failed ? 1 : 0;
}
int UnitTestImpl :: RunAllTests ( ) { if ( ! GTestIsInitialized ( ) ) { printf ( " " , " \n " " \n " ) ; return 1 ; } if ( g_help_flag ) return 0 ; PostFlagParsingInit ( ) ; internal :: WriteToShardStatusFileIfNeeded ( ) ; bool in_subprocess_for_death_test = false ; #if GTEST_HAS_DEATH_TEST in_subprocess_for_death_test = ( internal_run_death_test_flag_ . get ( ) != NULL ) ; #endif const bool should_shard = ShouldShard ( kTestTotalShards , kTestShardIndex , in_subprocess_for_death_test ) ; const bool has_tests_to_run = FilterTests ( should_shard ? HONOR_SHARDING_PROTOCOL : IGNORE_SHARDING_PROTOCOL ) > 0 ; if ( GTEST_FLAG ( list_tests ) ) { ListTestsMatchingFilter ( ) ; return 0 ; } random_seed_ = GTEST_FLAG ( shuffle ) ? GetRandomSeedFromFlag ( GTEST_FLAG ( random_seed ) ) : 0 ; bool failed = false ; TestEventListener * repeater = listeners ( ) -> repeater ( ) ; repeater -> OnTestProgramStart ( * parent_ ) ; const int repeat = in_subprocess_for_death_test ? 1 : GTEST_FLAG ( repeat ) ; const bool forever = repeat < 0 ; for ( int i = 0 ; forever || i != repeat ; i ++ ) { ClearResult ( ) ; const TimeInMillis start = GetTimeInMillis ( ) ; if ( has_tests_to_run && GTEST_FLAG ( shuffle ) ) { random ( ) -> Reseed ( random_seed_ ) ; ShuffleTests ( ) ; } repeater -> OnTestIterationStart ( * parent_ , i ) ; if ( has_tests_to_run ) { repeater -> OnEnvironmentsSetUpStart ( * parent_ ) ; ForEach ( environments_ , SetUpEnvironment ) ; repeater -> OnEnvironmentsSetUpEnd ( * parent_ ) ; if ( ! Test :: HasFatalFailure ( ) ) { for ( int test_index = 0 ; test_index < total_test_case_count ( ) ; test_index ++ ) { GetMutableTestCase ( test_index ) -> Run ( ) ; } } repeater -> OnEnvironmentsTearDownStart ( * parent_ ) ; std :: for_each ( environments_ . rbegin ( ) , environments_ . rend ( ) , TearDownEnvironment ) ; repeater -> OnEnvironmentsTearDownEnd ( * parent_ ) ; } elapsed_time_ = GetTimeInMillis ( ) - start ; repeater -> OnTestIterationEnd ( * parent_ , i ) ; if ( ! Passed ( ) ) { failed = true ; } UnshuffleTests ( ) ; if ( GTEST_FLAG ( shuffle ) ) { random_seed_ = GetNextRandomSeed ( random_seed_ ) ; } } repeater -> OnTestProgramEnd ( * parent_ ) ; return failed ? 1 : 0 ; }
Runs all tests in this UnitTest object, prints the result, and
returns 0 if all tests are successful, or 1 otherwise.
Runs all tests in this UnitTest object prints the result and returns 0 if all tests are successful or 1 otherwise .
// Makes sure InitGoogleTest() was called. // Do not run any test if the --help flag was specified. // Repeats the call to the post-flag parsing initialization in case the // user didn't call InitGoogleTest. // Even if sharding is not on, test runners may want to use the // GTEST_SHARD_STATUS_FILE to query whether the test supports the sharding // protocol. // True iff we are in a subprocess for running a thread-safe-style // death test. // GTEST_HAS_DEATH_TEST // Compares the full test names with the filter to decide which // tests to run. // Lists the tests and exits if the --gtest_list_tests flag was specified. // This must be called *after* FilterTests() has been called. // True iff at least one test has failed. // How many times to repeat the tests?  We don't want to repeat them // when we are inside the subprocess of a death test. // Repeats forever if the repeat count is negative. // Shuffles test cases and tests if requested. // This should be done before calling OnTestIterationStart(), // such that a test event listener can see the actual test order // in the event. // Tells the unit test event listeners that the tests are about to start. // Runs each test case if there is at least one test to run. // Sets up all environments beforehand. // Runs the tests only if there was no fatal failure during global // set-up. // Tears down all environments in reverse order afterwards. // Tells the unit test event listener that the tests have just finished. // Gets the result and clears it. // Restores the original test order after the iteration.  This // allows the user to quickly repro a failure that happens in the // N-th iteration without repeating the first (N - 1) iterations. // This is not enclosed in "if (GTEST_FLAG(shuffle)) { ... }", in // case the user somehow changes the value of the flag somewhere // (it's always safe to unshuffle the tests). // Picks a new random seed for each iteration. // Returns 0 if all tests passed, or 1 other wise.