make queue_testutils logging thread-safe and test it
Change-Id: I0d1ed4831cb3cfde4a172839bcc1f2b02756f5f3
diff --git a/aos/common/queue_testutils_test.cc b/aos/common/queue_testutils_test.cc
new file mode 100644
index 0000000..2defe74
--- /dev/null
+++ b/aos/common/queue_testutils_test.cc
@@ -0,0 +1,31 @@
+#include "aos/common/queue_testutils.h"
+
+#include <thread>
+
+#include "gtest/gtest.h"
+
+#include "aos/common/logging/logging.h"
+
+namespace aos {
+namespace common {
+namespace testing {
+
+// Tests logging from multiple threads.
+// tsan used to complain about this.
+TEST(QueueTestutilsTest, MultithreadedLog) {
+ EnableTestLogging();
+
+ ::std::thread thread([]() {
+ for (int i = 0; i < 1000; ++i) {
+ LOG(INFO, "test from thread\n");
+ }
+ });
+ for (int i = 0; i < 1000; ++i) {
+ LOG(INFO, "not from thread\n");
+ }
+ thread.join();
+}
+
+} // namespace testing
+} // namespace common
+} // namespace aos