blob: f39c6cf8ee31d435d59fc6abb0785440a54ee043 [file] [log] [blame]
Brian Silvermanf5f8d8e2015-12-06 18:39:12 -05001#include "aos/testing/test_logging.h"
Brian Silverman459d37a2015-03-29 18:00:30 -04002
3#include <thread>
4
5#include "gtest/gtest.h"
6
John Park33858a32018-09-28 23:05:48 -07007#include "aos/logging/logging.h"
Brian Silverman459d37a2015-03-29 18:00:30 -04008
9namespace aos {
Brian Silverman459d37a2015-03-29 18:00:30 -040010namespace testing {
11
12// Tests logging from multiple threads.
13// tsan used to complain about this.
14TEST(QueueTestutilsTest, MultithreadedLog) {
15 EnableTestLogging();
16
17 ::std::thread thread([]() {
18 for (int i = 0; i < 1000; ++i) {
Austin Schuhf257f3c2019-10-27 21:00:43 -070019 AOS_LOG(INFO, "test from thread\n");
Brian Silverman459d37a2015-03-29 18:00:30 -040020 }
21 });
22 for (int i = 0; i < 1000; ++i) {
Austin Schuhf257f3c2019-10-27 21:00:43 -070023 AOS_LOG(INFO, "not from thread\n");
Brian Silverman459d37a2015-03-29 18:00:30 -040024 }
25 thread.join();
26}
27
28} // namespace testing
Brian Silverman459d37a2015-03-29 18:00:30 -040029} // namespace aos