Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: native_client_sdk/src/libraries/gtest_ppapi/gtest_runner.cc

Issue 10854137: [NaCl SDK] gtest_ppapi library. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove hacks Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "c_salt/test/gtest_runner.h" 4 #include "gtest_ppapi/gtest_runner.h"
5 5
6 #include <cassert> 6 #include <cassert>
7 7
8 #include "c_salt/test/gtest_event_listener.h"
9 #include "c_salt/test/gtest_nacl_environment.h"
10 #include "gtest/gtest.h" 8 #include "gtest/gtest.h"
11 9 #include "gtest_ppapi/gtest_event_listener.h"
12 namespace c_salt { 10 #include "gtest_ppapi/gtest_nacl_environment.h"
13 11
14 pthread_t GTestRunner::g_test_runner_thread_ = NACL_PTHREAD_ILLEGAL_THREAD_ID; 12 pthread_t GTestRunner::g_test_runner_thread_ = NACL_PTHREAD_ILLEGAL_THREAD_ID;
15 GTestRunner* GTestRunner::gtest_runner_ = NULL; 13 GTestRunner* GTestRunner::gtest_runner_ = NULL;
16 14
17 void GTestRunner::CreateGTestRunnerThread(pp::Instance* instance, 15 void GTestRunner::CreateGTestRunnerThread(pp::Instance* instance,
18 int argc, char** argv) { 16 int argc, char** argv) {
19 assert(g_test_runner_thread_ == NACL_PTHREAD_ILLEGAL_THREAD_ID); 17 assert(g_test_runner_thread_ == NACL_PTHREAD_ILLEGAL_THREAD_ID);
20 if (g_test_runner_thread_ == NACL_PTHREAD_ILLEGAL_THREAD_ID) { 18 if (g_test_runner_thread_ == NACL_PTHREAD_ILLEGAL_THREAD_ID) {
21 gtest_runner_ = new GTestRunner(); 19 gtest_runner_ = new GTestRunner();
22 gtest_runner_->Init(instance, argc, argv); 20 gtest_runner_->Init(instance, argc, argv);
(...skipping 21 matching lines...) Expand all
44 42
45 void GTestRunner::Init(pp::Instance* instance, int argc, char** argv) { 43 void GTestRunner::Init(pp::Instance* instance, int argc, char** argv) {
46 // Init gtest. 44 // Init gtest.
47 testing::InitGoogleTest(&argc, argv); 45 testing::InitGoogleTest(&argc, argv);
48 46
49 // Add GTestEventListener to the list of listeners. That will cause the 47 // Add GTestEventListener to the list of listeners. That will cause the
50 // test output to go to nacltest.js through PostMessage. 48 // test output to go to nacltest.js through PostMessage.
51 ::testing::TestEventListeners& listeners = 49 ::testing::TestEventListeners& listeners =
52 ::testing::UnitTest::GetInstance()->listeners(); 50 ::testing::UnitTest::GetInstance()->listeners();
53 delete listeners.Release(listeners.default_result_printer()); 51 delete listeners.Release(listeners.default_result_printer());
54 listeners.Append(new c_salt::GTestEventListener(instance)); 52 listeners.Append(new GTestEventListener(instance));
55 53
56 // We use our own gtest environment, mainly to make the nacl instance 54 // We use our own gtest environment, mainly to make the nacl instance
57 // available to the individual unit tests. 55 // available to the individual unit tests.
58 c_salt::GTestNaclEnvironment* test_env = new c_salt::GTestNaclEnvironment(); 56 GTestNaclEnvironment* test_env = new GTestNaclEnvironment();
59 test_env->set_global_instance(instance); 57 test_env->set_global_instance(instance);
60 ::testing::AddGlobalTestEnvironment(test_env); 58 ::testing::AddGlobalTestEnvironment(test_env);
61 } 59 }
62 60
63 void GTestRunner::RunLoop() { 61 void GTestRunner::RunLoop() {
64 // Stay idle until RunAlltests is called. 62 // Stay idle until RunAlltests is called.
65 status_signal_.Lock(); 63 status_signal_.Lock();
66 while (status_ == kIdle) { 64 while (status_ == kIdle) {
67 status_signal_.Wait(); 65 status_signal_.Wait();
68 } 66 }
69 67
70 assert(status_ == kRunTests); 68 assert(status_ == kRunTests);
71 status_signal_.Unlock(); 69 status_signal_.Unlock();
72 RUN_ALL_TESTS(); 70 int result = RUN_ALL_TESTS();
71 (void)result;
73 } 72 }
74
75 } // namespace c_salt
76
OLDNEW
« no previous file with comments | « native_client_sdk/src/libraries/gtest_ppapi/gtest_runner.h ('k') | native_client_sdk/src/libraries/gtest_ppapi/library.dsc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698