From 7532f6665e035d377bef618412e691fe9b3332e4 Mon Sep 17 00:00:00 2001 From: Le Hoang Quyen Date: Fri, 14 Apr 2023 22:38:28 +0000 Subject: [PATCH] Disable OOM tests when TSAN is enabled. Bug: dawn:1725 Change-Id: I83ddaaf0d98d2831f95abbfbf5adfad268ebdba5 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/127380 Kokoro: Kokoro Reviewed-by: Austin Eng Commit-Queue: Quyen Le --- src/dawn/tests/DawnTest.cpp | 31 +++++++++++++++++--------- src/dawn/tests/DawnTest.h | 1 + src/dawn/tests/end2end/BufferTests.cpp | 3 +++ 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/dawn/tests/DawnTest.cpp b/src/dawn/tests/DawnTest.cpp index c5aefc24ed..97f930130b 100644 --- a/src/dawn/tests/DawnTest.cpp +++ b/src/dawn/tests/DawnTest.cpp @@ -887,6 +887,14 @@ bool DawnTestBase::IsAsan() const { #endif } +bool DawnTestBase::IsTsan() const { +#if defined(THREAD_SANITIZER) + return true; +#else + return false; +#endif +} + bool DawnTestBase::HasToggleEnabled(const char* toggle) const { auto toggles = dawn::native::GetTogglesUsed(backendDevice); return std::find_if(toggles.begin(), toggles.end(), [toggle](const char* name) { @@ -999,8 +1007,8 @@ wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) { // to CreateDeviceImpl. mNextIsolationKeyQueue.push(std::move(isolationKey)); - // RequestDevice is overriden by CreateDeviceImpl and device descriptor is ignored by it. Give - // an empty descriptor. + // RequestDevice is overriden by CreateDeviceImpl and device descriptor is ignored by it. + // Give an empty descriptor. // TODO(dawn:1684): Replace empty DeviceDescriptor with nullptr after Dawn wire support it. wgpu::DeviceDescriptor deviceDesc = {}; mAdapter.RequestDevice( @@ -1012,8 +1020,8 @@ wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) { FlushWire(); ASSERT(apiDevice); - // Set up the mocks for uncaptured errors and device loss. The loss of the device is expected - // to happen at the end of the test so at it directly. + // Set up the mocks for uncaptured errors and device loss. The loss of the device is + // expected to happen at the end of the test so at it directly. apiDevice.SetUncapturedErrorCallback(mDeviceErrorCallback.Callback(), mDeviceErrorCallback.MakeUserdata(apiDevice.Get())); apiDevice.SetDeviceLostCallback(mDeviceLostCallback.Callback(), @@ -1045,8 +1053,8 @@ wgpu::Device DawnTestBase::CreateDevice(std::string isolationKey) { } void DawnTestBase::SetUp() { - // Setup the per-test platform. Tests can provide one by overloading CreateTestPlatform. This is - // NOT a thread-safe operation and is allowed here for testing only. + // Setup the per-test platform. Tests can provide one by overloading CreateTestPlatform. + // This is NOT a thread-safe operation and is allowed here for testing only. mTestPlatform = CreateTestPlatform(); dawn::native::FromAPI(gTestEnv->GetInstance()->Get()) ->SetPlatformForTesting(mTestPlatform.get()); @@ -1058,9 +1066,10 @@ void DawnTestBase::SetUp() { "_" + ::testing::UnitTest::GetInstance()->current_test_info()->name(); mWireHelper->BeginWireTrace(traceName.c_str()); - // RequestAdapter is overriden to ignore RequestAdapterOptions, but dawn_wire requires a valid - // pointer, so give a empty option. - // TODO(dawn:1684): Replace empty RequestAdapterOptions with nullptr after Dawn wire support it. + // RequestAdapter is overriden to ignore RequestAdapterOptions, but dawn_wire requires a + // valid pointer, so give a empty option. + // TODO(dawn:1684): Replace empty RequestAdapterOptions with nullptr after Dawn wire support + // it. wgpu::RequestAdapterOptions options = {}; mInstance.RequestAdapter( &options, @@ -1094,8 +1103,8 @@ void DawnTestBase::DestroyDevice(wgpu::Device device) { resolvedDevice = this->device; } - // No expectation is added because the expectations for this kind of destruction is set up as - // soon as the device is created. + // No expectation is added because the expectations for this kind of destruction is set up + // as soon as the device is created. resolvedDevice.Destroy(); } diff --git a/src/dawn/tests/DawnTest.h b/src/dawn/tests/DawnTest.h index 259995e7ad..8482c7c9ae 100644 --- a/src/dawn/tests/DawnTest.h +++ b/src/dawn/tests/DawnTest.h @@ -260,6 +260,7 @@ class DawnTestBase { bool IsDXC() const; bool IsAsan() const; + bool IsTsan() const; bool HasToggleEnabled(const char* workaround) const; diff --git a/src/dawn/tests/end2end/BufferTests.cpp b/src/dawn/tests/end2end/BufferTests.cpp index 98a96a73b5..a9b33d7ee4 100644 --- a/src/dawn/tests/end2end/BufferTests.cpp +++ b/src/dawn/tests/end2end/BufferTests.cpp @@ -984,6 +984,7 @@ TEST_P(BufferTests, CreateBufferOOM) { DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); DAWN_TEST_UNSUPPORTED_IF(IsAsan()); + DAWN_TEST_UNSUPPORTED_IF(IsTsan()); wgpu::BufferDescriptor descriptor; descriptor.usage = wgpu::BufferUsage::CopyDst; @@ -1010,6 +1011,7 @@ TEST_P(BufferTests, BufferMappedAtCreationOOM) { DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); DAWN_TEST_UNSUPPORTED_IF(IsAsan()); + DAWN_TEST_UNSUPPORTED_IF(IsTsan()); // Test non-mappable buffer { @@ -1076,6 +1078,7 @@ TEST_P(BufferTests, CreateBufferOOMMapAsync) { DAWN_TEST_UNSUPPORTED_IF(IsOpenGL()); DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES()); DAWN_TEST_UNSUPPORTED_IF(IsAsan()); + DAWN_TEST_UNSUPPORTED_IF(IsTsan()); auto RunTest = [this](const wgpu::BufferDescriptor& descriptor) { wgpu::Buffer buffer;