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

Side by Side Diff: mojo/public/cpp/utility/tests/thread_unittest.cc

Issue 360563004: Enable Mojo on iOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Reduce diff in mojo_public.gypi Created 6 years, 5 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
« no previous file with comments | « mojo/public/cpp/utility/tests/mutex_unittest.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 4
5 #include "mojo/public/cpp/utility/thread.h" 5 #include "mojo/public/cpp/utility/thread.h"
6 6
7 #include "mojo/public/cpp/system/macros.h" 7 #include "mojo/public/cpp/system/macros.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace mojo { 10 namespace mojo {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 EXPECT_EQ(12345678, value); 63 EXPECT_EQ(12345678, value);
64 } 64 }
65 } 65 }
66 66
67 // Tests of assertions for Debug builds. 67 // Tests of assertions for Debug builds.
68 // Note: It's okay to create threads, despite gtest having to fork. (The threads 68 // Note: It's okay to create threads, despite gtest having to fork. (The threads
69 // are in the child process.) 69 // are in the child process.)
70 #if !defined(NDEBUG) 70 #if !defined(NDEBUG)
71 TEST(ThreadTest, DebugAssertionFailures) { 71 TEST(ThreadTest, DebugAssertionFailures) {
72 // Can only start once. 72 // Can only start once.
73 EXPECT_DEATH({ 73 EXPECT_DEATH_IF_SUPPORTED({
74 int value = 0; 74 int value = 0;
75 SetIntThread thread(&value, 1); 75 SetIntThread thread(&value, 1);
76 thread.Start(); 76 thread.Start();
77 thread.Start(); 77 thread.Start();
78 }, ""); 78 }, "");
79 79
80 // Must join (if you start). 80 // Must join (if you start).
81 EXPECT_DEATH({ 81 EXPECT_DEATH_IF_SUPPORTED({
82 int value = 0; 82 int value = 0;
83 SetIntThread thread(&value, 2); 83 SetIntThread thread(&value, 2);
84 thread.Start(); 84 thread.Start();
85 }, ""); 85 }, "");
86 86
87 // Can only join once. 87 // Can only join once.
88 EXPECT_DEATH({ 88 EXPECT_DEATH_IF_SUPPORTED({
89 int value = 0; 89 int value = 0;
90 SetIntThread thread(&value, 3); 90 SetIntThread thread(&value, 3);
91 thread.Start(); 91 thread.Start();
92 thread.Join(); 92 thread.Join();
93 thread.Join(); 93 thread.Join();
94 }, ""); 94 }, "");
95 95
96 // Stack too big (we're making certain assumptions here). 96 // Stack too big (we're making certain assumptions here).
97 EXPECT_DEATH({ 97 EXPECT_DEATH_IF_SUPPORTED({
98 int value = 0; 98 int value = 0;
99 Thread::Options options; 99 Thread::Options options;
100 options.set_stack_size(static_cast<size_t>(-1)); 100 options.set_stack_size(static_cast<size_t>(-1));
101 SetIntThread thread(options, &value, 4); 101 SetIntThread thread(options, &value, 4);
102 thread.Start(); 102 thread.Start();
103 thread.Join(); 103 thread.Join();
104 }, ""); 104 }, "");
105 } 105 }
106 #endif // !defined(NDEBUG) 106 #endif // !defined(NDEBUG)
107 107
108 } // namespace 108 } // namespace
109 } // namespace mojo 109 } // namespace mojo
OLDNEW
« no previous file with comments | « mojo/public/cpp/utility/tests/mutex_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698