blob: e7f98063eaa83f0de3a058b363deb4f80ff78971 [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
John Park33858a32018-09-28 23:05:48 -07005#include "aos/logging/logging.h"
Austin Schuh60e77942022-05-16 17:48:24 -07006#include "gtest/gtest.h"
Brian Silverman459d37a2015-03-29 18:00:30 -04007
8namespace aos {
Brian Silverman459d37a2015-03-29 18:00:30 -04009namespace testing {
10
11// Tests logging from multiple threads.
12// tsan used to complain about this.
13TEST(QueueTestutilsTest, MultithreadedLog) {
14 EnableTestLogging();
15
16 ::std::thread thread([]() {
17 for (int i = 0; i < 1000; ++i) {
Austin Schuhf257f3c2019-10-27 21:00:43 -070018 AOS_LOG(INFO, "test from thread\n");
Brian Silverman459d37a2015-03-29 18:00:30 -040019 }
20 });
21 for (int i = 0; i < 1000; ++i) {
Austin Schuhf257f3c2019-10-27 21:00:43 -070022 AOS_LOG(INFO, "not from thread\n");
Brian Silverman459d37a2015-03-29 18:00:30 -040023 }
24 thread.join();
25}
26
27} // namespace testing
Brian Silverman459d37a2015-03-29 18:00:30 -040028} // namespace aos