Brian Silverman | f5f8d8e | 2015-12-06 18:39:12 -0500 | [diff] [blame] | 1 | #include "aos/testing/test_logging.h" |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 2 | |
| 3 | #include <thread> |
| 4 | |
| 5 | #include "gtest/gtest.h" |
| 6 | |
John Park | 33858a3 | 2018-09-28 23:05:48 -0700 | [diff] [blame] | 7 | #include "aos/logging/logging.h" |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 8 | |
| 9 | namespace aos { |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 10 | namespace testing { |
| 11 | |
| 12 | // Tests logging from multiple threads. |
| 13 | // tsan used to complain about this. |
| 14 | TEST(QueueTestutilsTest, MultithreadedLog) { |
| 15 | EnableTestLogging(); |
| 16 | |
| 17 | ::std::thread thread([]() { |
| 18 | for (int i = 0; i < 1000; ++i) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame^] | 19 | AOS_LOG(INFO, "test from thread\n"); |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 20 | } |
| 21 | }); |
| 22 | for (int i = 0; i < 1000; ++i) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame^] | 23 | AOS_LOG(INFO, "not from thread\n"); |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 24 | } |
| 25 | thread.join(); |
| 26 | } |
| 27 | |
| 28 | } // namespace testing |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 29 | } // namespace aos |