From 54222bb4ae97160588b74685231fc7096eb82cc9 Mon Sep 17 00:00:00 2001 From: gobhardw Date: Tue, 30 May 2023 21:13:35 +0530 Subject: [PATCH] Fixing profiler API test Change-Id: Ie9b473f5e20b41a73c16d2d7218395fee116ad1d --- .../featuretests/profiler/profiler_gtest.cpp | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/tests/featuretests/profiler/profiler_gtest.cpp b/tests/featuretests/profiler/profiler_gtest.cpp index 2445b1d0cd..e2a89d3d06 100644 --- a/tests/featuretests/profiler/profiler_gtest.cpp +++ b/tests/featuretests/profiler/profiler_gtest.cpp @@ -27,6 +27,7 @@ THE SOFTWARE. #include #include "rocprofiler.h" #include +#include #include #include @@ -815,8 +816,23 @@ TEST_F(ATTCollection, WhenRunningATTItCollectsTraceData) { // empty kernel __global__ void kernel() {} +void __attribute__((constructor)) globalsetting() { + init_test_path(); + std::string app_path = GetRunningPath(running_path); + std::stringstream gfx_path; + gfx_path << app_path << metrics_path; + std::cout << gfx_path.str() << std::endl; + setenv("ROCPROFILER_METRICS_PATH", gfx_path.str().c_str(), true); +} + class ProfilerAPITest : public ::testing::Test { protected: + void SetUp() { + std::string app_path = GetRunningPath(running_path); + std::stringstream gfx_path; + gfx_path << app_path << metrics_path; + setenv("ROCPROFILER_METRICS_PATH", gfx_path.str().c_str(), true); + } // function to check profiler API status static void CheckApi(rocprofiler_status_t status) { ASSERT_EQ(status, ROCPROFILER_STATUS_SUCCESS); @@ -863,12 +879,6 @@ TEST_F(ProfilerAPITest, WhenRunningMultipleThreadsProfilerAPIsWorkFine) { // set global path init_test_path(); - std::string app_path = GetRunningPath(running_path); - std::stringstream gfx_path; - gfx_path << app_path << metrics_path; - - setenv("ROCPROFILER_METRICS_PATH", gfx_path.str().c_str(), true); - // Get the system cores int num_cpu_cores = GetNumberOfCores();