#include "base/allocator/dispatcher/tls.h"
#include <string_view>
#if USE_LOCAL_TLS_EMULATION()
#include <algorithm>
#include <array>
#include <cstddef>
#include <functional>
#include <list>
#include <mutex>
#include <thread>
#include <unordered_set>
#include <utility>
#include <vector>
#include "base/debug/crash_logging.h"
#include "base/strings/stringprintf.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
_;
InSequence;
NiceMock;
NotNull;
Return;
ReturnNull;
namespace base::allocator::dispatcher {
namespace {
struct DataToStore { … };
struct AllocatorMockBase { … };
struct TLSSystemMockBase { … };
struct CrashKeyImplementationMockBase
: public base::debug::CrashKeyImplementation { … };
AllocatorMock;
TLSSystemMock;
CrashKeyImplementationMock;
template <typename T, typename Allocator, typename TLSSystem>
auto CreateThreadLocalStorage(Allocator& allocator, TLSSystem& tlsSystem) { … }
template <typename T>
auto CreateThreadLocalStorage() { … }
}
struct BaseThreadLocalStorageTest : public ::testing::Test { … };
TEST_F(BaseThreadLocalStorageTest,
VerifyDataIsIndependentBetweenDifferentSUTs) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyDistinctEntriesForEachThread) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyEntriesAreReusedForNewThreads) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyDataIsSameWithinEachThread) { … }
TEST_F(BaseThreadLocalStorageTest, VerifySetupTeardownSequence) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyAllocatorIsUsed) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyAllocatorIsUsedForMultipleChunks) { … }
TEST_F(BaseThreadLocalStorageTest, VerifyTLSSystemIsUsed) { … }
#if defined(GTEST_HAS_DEATH_TEST)
struct BaseThreadLocalStorageDeathTest : public ::testing::Test { … };
TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfAllocationFails) { … }
TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfFreeFails) { … }
TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfTLSSetupFails) { … }
TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfStoringTLSDataFails) { … }
TEST_F(BaseThreadLocalStorageDeathTest, VerifyDeathIfTLSTeardownFails) { … }
#endif
struct BasePThreadTLSSystemTest : public ::testing::Test { … };
std::atomic<size_t> BasePThreadTLSSystemTest::thread_termination_counter{ … };
TEST_F(BasePThreadTLSSystemTest, VerifySetupNTeardownSequence) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyThreadTerminationFunctionIsCalled) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyGetWithoutSetReturnsNull) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyGetAfterTeardownReturnsNull) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyGetAfterTeardownReturnsNullThreaded) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyGetSetSequence) { … }
#if DCHECK_IS_ON()
TEST_F(BasePThreadTLSSystemTest, VerifyGetWithoutSetupReturnsNull) { … }
TEST_F(BasePThreadTLSSystemTest, VerifyStoreWithoutSetupFails) { … }
#endif
#if defined(GTEST_HAS_DEATH_TEST) && DCHECK_IS_ON()
struct BasePThreadTLSSystemDeathTest : public ::testing::Test { … };
TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfSetupTwice) { … }
TEST_F(BasePThreadTLSSystemDeathTest, VerifyDeathIfTearDownWithoutSetup) { … }
#endif
}
#endif