tsan: fix trace tests on darwin
authorDmitry Vyukov <dvyukov@google.com>
Mon, 27 Sep 2021 12:57:18 +0000 (14:57 +0200)
committerDmitry Vyukov <dvyukov@google.com>
Mon, 27 Sep 2021 14:40:57 +0000 (16:40 +0200)
commit94ea36649ecc854d290c6797e6adb91bdfac756d
treedd517b6e3654d89ed63e9180508d7882fef3085e
parentb72176b9bc06146d12e495167977effe050dc326
tsan: fix trace tests on darwin

The trace tests crashed on darwin because of some thread
initialization issues (thread initialization is somewhat
different on darwin).
Instead of starting real threads, create a new ThreadState
in the main thread. This makes the tests more unit-testy
and hopefully won't crash on darwin (there is almost no
platform-specific code involved now).
This will also help with future trace tests that will need
more than 1 thread. Creating more than 1 real thread and
dispatching test actions across multiple threads in the
required deterministic order is painful.

Depends on D110539.

Reviewed By: melver

Differential Revision: https://reviews.llvm.org/D110546
compiler-rt/lib/tsan/rtl/tsan_platform_linux.cpp
compiler-rt/lib/tsan/tests/unit/tsan_trace_test.cpp