blob: b37bec45a2408e9ceaf62c875d00a2f5e99996d5 [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
Stephan Pleinesad3085f2024-05-30 10:50:50 -07003#include <memory>
Brian Silverman459d37a2015-03-29 18:00:30 -04004#include <thread>
5
Austin Schuh60e77942022-05-16 17:48:24 -07006#include "gtest/gtest.h"
Brian Silverman459d37a2015-03-29 18:00:30 -04007
Philipp Schrader790cb542023-07-05 21:06:52 -07008#include "aos/logging/logging.h"
9
Stephan Pleinesf63bde82024-01-13 15:59:33 -080010namespace aos::testing {
Brian Silverman459d37a2015-03-29 18:00:30 -040011
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
Stephan Pleinesf63bde82024-01-13 15:59:33 -080028} // namespace aos::testing