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 | |
Austin Schuh | 60e7794 | 2022-05-16 17:48:24 -0700 | [diff] [blame] | 5 | #include "gtest/gtest.h" |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 6 | |
Philipp Schrader | 790cb54 | 2023-07-05 21:06:52 -0700 | [diff] [blame] | 7 | #include "aos/logging/logging.h" |
| 8 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 9 | namespace aos::testing { |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 10 | |
| 11 | // Tests logging from multiple threads. |
| 12 | // tsan used to complain about this. |
| 13 | TEST(QueueTestutilsTest, MultithreadedLog) { |
| 14 | EnableTestLogging(); |
| 15 | |
| 16 | ::std::thread thread([]() { |
| 17 | for (int i = 0; i < 1000; ++i) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 18 | AOS_LOG(INFO, "test from thread\n"); |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 19 | } |
| 20 | }); |
| 21 | for (int i = 0; i < 1000; ++i) { |
Austin Schuh | f257f3c | 2019-10-27 21:00:43 -0700 | [diff] [blame] | 22 | AOS_LOG(INFO, "not from thread\n"); |
Brian Silverman | 459d37a | 2015-03-29 18:00:30 -0400 | [diff] [blame] | 23 | } |
| 24 | thread.join(); |
| 25 | } |
| 26 | |
Stephan Pleines | f63bde8 | 2024-01-13 15:59:33 -0800 | [diff] [blame] | 27 | } // namespace aos::testing |