| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // Tests of the static thread annotation macros. These fall into two categories, | 5 // Tests of the static thread annotation macros. These fall into two categories, |
| 6 // positive tests (testing that correct code compiles and works) and negative | 6 // positive tests (testing that correct code compiles and works) and negative |
| 7 // tests (testing that incorrect code does not compile). | 7 // tests (testing that incorrect code does not compile). |
| 8 // | 8 // |
| 9 // Unfortunately, we don't have systematic/automated negative compilation tests. | 9 // Unfortunately, we don't have systematic/automated negative compilation tests. |
| 10 // So instead we have some cheesy macros that you can define to enable | 10 // So instead we have some cheesy macros that you can define to enable |
| 11 // individual compilation failures. | 11 // individual compilation failures. |
| 12 | 12 |
| 13 #include "mojo/edk/system/thread_annotations.h" | 13 #include "mojo/edk/util/thread_annotations.h" |
| 14 | 14 |
| 15 #include "mojo/edk/system/mutex.h" | 15 #include "mojo/edk/util/mutex.h" |
| 16 #include "mojo/public/cpp/system/macros.h" | 16 #include "mojo/public/cpp/system/macros.h" |
| 17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
| 18 | 18 |
| 19 // Uncomment these to enable particular compilation failure tests. | 19 // Uncomment these to enable particular compilation failure tests. |
| 20 // #define NC_GUARDED_BY | 20 // #define NC_GUARDED_BY |
| 21 // TODO(vtl): |ACQUIRED_{BEFORE,AFTER}()| are currently unimplemented in clang | 21 // TODO(vtl): |ACQUIRED_{BEFORE,AFTER}()| are currently unimplemented in clang |
| 22 // as of 2015-07-06 ("To be fixed in a future update."). So this actually | 22 // as of 2015-07-06 ("To be fixed in a future update."). So this actually |
| 23 // compiles! | 23 // compiles! |
| 24 // #define NC_ACQUIRED_BEFORE | 24 // #define NC_ACQUIRED_BEFORE |
| 25 | 25 |
| 26 namespace mojo { | 26 namespace mojo { |
| 27 namespace system { | 27 namespace util { |
| 28 namespace { | 28 namespace { |
| 29 | 29 |
| 30 // Test MOJO_GUARDED_BY -------------------------------------------------------- | 30 // Test MOJO_GUARDED_BY -------------------------------------------------------- |
| 31 | 31 |
| 32 class GuardedByClass { | 32 class GuardedByClass { |
| 33 public: | 33 public: |
| 34 GuardedByClass() : x_() {} | 34 GuardedByClass() : x_() {} |
| 35 ~GuardedByClass() {} | 35 ~GuardedByClass() {} |
| 36 | 36 |
| 37 void GoodSet(int x) { | 37 void GoodSet(int x) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 AcquiredBeforeClass2 c2; | 113 AcquiredBeforeClass2 c2; |
| 114 c2.GoodMethod(&c1); | 114 c2.GoodMethod(&c1); |
| 115 #ifdef NC_ACQUIRED_BEFORE | 115 #ifdef NC_ACQUIRED_BEFORE |
| 116 c1.BadMethod(&c2); | 116 c1.BadMethod(&c2); |
| 117 #endif | 117 #endif |
| 118 } | 118 } |
| 119 | 119 |
| 120 // TODO(vtl): Test more things. | 120 // TODO(vtl): Test more things. |
| 121 | 121 |
| 122 } // namespace | 122 } // namespace |
| 123 } // namespace system | 123 } // namespace util |
| 124 } // namespace mojo | 124 } // namespace mojo |
| OLD | NEW |