mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-22 19:29:06 +08:00
Add option to log allocations to std out
Signed-off-by: Lukasz Jobczyk <lukasz.jobczyk@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
205e2e1957
commit
35f6cd00ee
@@ -63,6 +63,59 @@ TEST(FileLogger, GivenLogAllocationMemoryPoolFlagThenLogsCorrectInfo) {
|
||||
}
|
||||
}
|
||||
|
||||
TEST(FileLogger, givenLogAllocationStdoutWhenLogAllocationThenLogToStdoutInsteadOfFileAndDoNotCreateFile) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
flags.LogAllocationMemoryPool.set(true);
|
||||
flags.LogAllocationStdout.set(true);
|
||||
FullyEnabledFileLogger fileLogger(testFile, flags);
|
||||
|
||||
// Log file not created
|
||||
bool logFileCreated = fileExists(fileLogger.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
MockDrmAllocation allocation(GraphicsAllocation::AllocationType::BUFFER, MemoryPool::System64KBPages);
|
||||
|
||||
allocation.setCpuPtrAndGpuAddress(&allocation, 0x12345);
|
||||
|
||||
MockBufferObject bo(&drm);
|
||||
bo.handle = 4;
|
||||
|
||||
allocation.bufferObjects[0] = &bo;
|
||||
|
||||
testing::internal::CaptureStdout();
|
||||
fileLogger.logAllocation(&allocation);
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
std::thread::id thisThread = std::this_thread::get_id();
|
||||
|
||||
std::stringstream threadIDCheck;
|
||||
threadIDCheck << " ThreadID: " << thisThread;
|
||||
|
||||
std::stringstream memoryPoolCheck;
|
||||
memoryPoolCheck << " MemoryPool: " << allocation.getMemoryPool();
|
||||
|
||||
std::stringstream gpuAddressCheck;
|
||||
gpuAddressCheck << " GPU address: 0x" << std::hex << allocation.getGpuAddress();
|
||||
|
||||
std::stringstream rootDeviceIndexCheck;
|
||||
rootDeviceIndexCheck << " Root device index: " << allocation.getRootDeviceIndex();
|
||||
|
||||
EXPECT_TRUE(output.find(threadIDCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(output.find(memoryPoolCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(output.find(gpuAddressCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(output.find(rootDeviceIndexCheck.str()) != std::string::npos);
|
||||
EXPECT_TRUE(output.find("AllocationType: BUFFER") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("Handle: 4") != std::string::npos);
|
||||
EXPECT_TRUE(output.find("\n") != std::string::npos);
|
||||
|
||||
logFileCreated = fileExists(fileLogger.getLogFileName());
|
||||
EXPECT_FALSE(logFileCreated);
|
||||
}
|
||||
|
||||
TEST(FileLogger, GivenDrmAllocationWithoutBOThenNoHandleLogged) {
|
||||
std::string testFile = "testfile";
|
||||
DebugVariables flags;
|
||||
|
||||
@@ -329,6 +329,7 @@ AllowUnrestrictedSize = 0
|
||||
DoNotFreeResources = 0
|
||||
OverrideGmmResourceUsageField = -1
|
||||
LogAllocationType = 0
|
||||
LogAllocationStdout = 0
|
||||
ProgramPipeControlPriorToNonPipelinedStateCommand = -1
|
||||
ProgramWalkerPartitionSelfCleanup = -1
|
||||
WparidRegisterProgramming = -1
|
||||
|
||||
Reference in New Issue
Block a user