blob: 5731545d05f16a8c42d2285dd6f238e25d228253 [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
Austin Schuh60e77942022-05-16 17:48:24 -07005#include "gtest/gtest.h"
Brian Silverman459d37a2015-03-29 18:00:30 -04006
Philipp Schrader790cb542023-07-05 21:06:52 -07007#include "aos/logging/logging.h"
8
Stephan Pleinesf63bde82024-01-13 15:59:33 -08009namespace aos::testing {
Brian Silverman459d37a2015-03-29 18:00:30 -040010
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
Stephan Pleinesf63bde82024-01-13 15:59:33 -080027} // namespace aos::testing