From a6364da286954615d2ae9f20b4276564b9d4818c Mon Sep 17 00:00:00 2001 From: Bryan Bernhart Date: Thu, 22 Sep 2022 10:38:12 -0700 Subject: [PATCH] Use test name for trace file when using --dump. --- src/tests/D3D12Test.cpp | 11 ++++++++++- src/tests/GPGMMTest.cpp | 10 +++++----- src/tests/GPGMMTest.h | 6 +++--- src/tests/end2end/D3D12ResidencyManagerTests.cpp | 2 +- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/tests/D3D12Test.cpp b/src/tests/D3D12Test.cpp index f3b0ebe55..593a8297b 100644 --- a/src/tests/D3D12Test.cpp +++ b/src/tests/D3D12Test.cpp @@ -106,10 +106,19 @@ namespace gpgmm::d3d12 { desc.MinLogLevel = GetMessageSeverity(GetLogLevel()); - if (IsDumpAllEventsEnabled()) { + if (IsDumpEventsEnabled()) { desc.RecordOptions.Flags |= EVENT_RECORD_FLAG_ALL_EVENTS; desc.RecordOptions.MinMessageLevel = desc.MinLogLevel; desc.RecordOptions.UseDetailedTimingEvents = true; + + // Format the output trace file as .. + const testing::TestInfo* const testInfoPtr = + ::testing::UnitTest::GetInstance()->current_test_info(); + ASSERT(testInfoPtr != nullptr); + desc.RecordOptions.TraceFile = + std::string(std::string(testInfoPtr->test_suite_name()) + "_" + + std::string(testInfoPtr->name()) + ".json") + .c_str(); } return desc; diff --git a/src/tests/GPGMMTest.cpp b/src/tests/GPGMMTest.cpp index 356821c18..cfc1a3a29 100644 --- a/src/tests/GPGMMTest.cpp +++ b/src/tests/GPGMMTest.cpp @@ -38,8 +38,8 @@ gpgmm::DebugPlatform* GPGMMTestBase::GetDebugPlatform() { return mDebugPlatform.get(); } -bool GPGMMTestBase::IsDumpAllEventsEnabled() const { - return gTestEnv->IsDumpAllEventsEnabled(); +bool GPGMMTestBase::IsDumpEventsEnabled() const { + return gTestEnv->IsDumpEventsEnabled(); } gpgmm::LogSeverity GPGMMTestBase::GetLogLevel() const { @@ -103,7 +103,7 @@ void InitGPGMMEnd2EndTestEnvironment(int argc, char** argv) { GPGMMTestEnvironment::GPGMMTestEnvironment(int argc, char** argv) { for (int i = 1; i < argc; ++i) { if (strcmp("--dump", argv[i]) == 0) { - mIsDumpAllEventsEnabled = true; + mIsDumpEventsEnabled = true; continue; } @@ -156,8 +156,8 @@ void GPGMMTestEnvironment::SetEnvironment(GPGMMTestEnvironment* env) { void GPGMMTestEnvironment::SetUp() { } -bool GPGMMTestEnvironment::IsDumpAllEventsEnabled() const { - return mIsDumpAllEventsEnabled; +bool GPGMMTestEnvironment::IsDumpEventsEnabled() const { + return mIsDumpEventsEnabled; } gpgmm::LogSeverity GPGMMTestEnvironment::GetLogLevel() const { diff --git a/src/tests/GPGMMTest.h b/src/tests/GPGMMTest.h index a86c65f29..bfaa64ef2 100644 --- a/src/tests/GPGMMTest.h +++ b/src/tests/GPGMMTest.h @@ -61,7 +61,7 @@ class GPGMMTestBase { gpgmm::DebugPlatform* GetDebugPlatform(); - bool IsDumpAllEventsEnabled() const; + bool IsDumpEventsEnabled() const; gpgmm::LogSeverity GetLogLevel() const; static std::vector GenerateTestAllocations(uint64_t alignment); @@ -77,11 +77,11 @@ class GPGMMTestEnvironment : public testing::Environment { void SetUp() override; - bool IsDumpAllEventsEnabled() const; + bool IsDumpEventsEnabled() const; gpgmm::LogSeverity GetLogLevel() const; private: - bool mIsDumpAllEventsEnabled = false; + bool mIsDumpEventsEnabled = false; #if defined(NDEBUG) gpgmm::LogSeverity mLogLevel = gpgmm::LogSeverity::Warning; diff --git a/src/tests/end2end/D3D12ResidencyManagerTests.cpp b/src/tests/end2end/D3D12ResidencyManagerTests.cpp index eeaa05f46..1d3549eba 100644 --- a/src/tests/end2end/D3D12ResidencyManagerTests.cpp +++ b/src/tests/end2end/D3D12ResidencyManagerTests.cpp @@ -72,7 +72,7 @@ class D3D12ResidencyManagerTests : public D3D12TestBase, public ::testing::Test residencyDesc.MinLogLevel = GetMessageSeverity(GetLogLevel()); - if (IsDumpAllEventsEnabled()) { + if (IsDumpEventsEnabled()) { residencyDesc.RecordOptions.Flags |= EVENT_RECORD_FLAG_ALL_EVENTS; residencyDesc.RecordOptions.MinMessageLevel = residencyDesc.MinLogLevel; residencyDesc.RecordOptions.UseDetailedTimingEvents = true;