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

Side by Side Diff: sandbox/linux/services/thread_helpers_unittests.cc

Issue 188193002: Linux sandbox: add basic Yama support (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments. Add testing. Created 6 years, 9 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 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 "sandbox/linux/services/thread_helpers.h" 5 #include "sandbox/linux/services/thread_helpers.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <fcntl.h> 8 #include <fcntl.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/types.h> 10 #include <sys/types.h>
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 #define MAYBE_IsSingleThreadedStartAndStop DISABLED_IsSingleThreadedStartAndStop 57 #define MAYBE_IsSingleThreadedStartAndStop DISABLED_IsSingleThreadedStartAndStop
58 #else 58 #else
59 #define MAYBE_IsSingleThreadedBasic IsSingleThreadedBasic 59 #define MAYBE_IsSingleThreadedBasic IsSingleThreadedBasic
60 #define MAYBE_IsSingleThreadedIterated IsSingleThreadedIterated 60 #define MAYBE_IsSingleThreadedIterated IsSingleThreadedIterated
61 #define MAYBE_IsSingleThreadedStartAndStop IsSingleThreadedStartAndStop 61 #define MAYBE_IsSingleThreadedStartAndStop IsSingleThreadedStartAndStop
62 #endif 62 #endif
63 63
64 TEST(ThreadHelpers, MAYBE_IsSingleThreadedBasic) { 64 TEST(ThreadHelpers, MAYBE_IsSingleThreadedBasic) {
65 ScopedProcSelfTask task; 65 ScopedProcSelfTask task;
66 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd())); 66 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd()));
67 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(-1));
67 68
68 base::Thread thread("sandbox_tests"); 69 base::Thread thread("sandbox_tests");
69 ASSERT_TRUE(thread.Start()); 70 ASSERT_TRUE(thread.Start());
70 ASSERT_FALSE(ThreadHelpers::IsSingleThreaded(task.fd())); 71 ASSERT_FALSE(ThreadHelpers::IsSingleThreaded(task.fd()));
72 ASSERT_FALSE(ThreadHelpers::IsSingleThreaded(-1));
71 // Explicitly stop the thread here to not pollute the next test. 73 // Explicitly stop the thread here to not pollute the next test.
72 ASSERT_TRUE(ThreadHelpers::StopThreadAndWatchProcFS(task.fd(), &thread)); 74 ASSERT_TRUE(ThreadHelpers::StopThreadAndWatchProcFS(task.fd(), &thread));
73 } 75 }
74 76
75 TEST(ThreadHelpers, MAYBE_IsSingleThreadedIterated) { 77 TEST(ThreadHelpers, MAYBE_IsSingleThreadedIterated) {
76 ScopedProcSelfTask task; 78 ScopedProcSelfTask task;
77 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd())); 79 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd()));
78 80
79 // Iterate to check for race conditions. 81 // Iterate to check for race conditions.
80 for (int i = 0; i < GetRaceTestIterations(); ++i) { 82 for (int i = 0; i < GetRaceTestIterations(); ++i) {
(...skipping 18 matching lines...) Expand all
99 101
100 ASSERT_TRUE(ThreadHelpers::StopThreadAndWatchProcFS(task.fd(), &thread)); 102 ASSERT_TRUE(ThreadHelpers::StopThreadAndWatchProcFS(task.fd(), &thread));
101 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd())); 103 ASSERT_TRUE(ThreadHelpers::IsSingleThreaded(task.fd()));
102 ASSERT_EQ(1, base::GetNumberOfThreads(base::GetCurrentProcessHandle())); 104 ASSERT_EQ(1, base::GetNumberOfThreads(base::GetCurrentProcessHandle()));
103 } 105 }
104 } 106 }
105 107
106 } // namespace 108 } // namespace
107 109
108 } // namespace sandbox 110 } // namespace sandbox
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698