mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-25 05:24:02 +08:00
test: use stringstream instead of sprintf in tests
Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
a8e8044e00
commit
9a5be1bb58
@@ -2095,24 +2095,18 @@ TEST_F(DrmMemoryManagerTestPrelim,
|
||||
EXPECT_EQ(1u, bo->getRefCount());
|
||||
EXPECT_EQ(size, bo->peekSize());
|
||||
|
||||
char addressBufferString[17];
|
||||
sprintf(addressBufferString, "%lx",
|
||||
graphicsAllocation->getGpuAddress());
|
||||
|
||||
char addressBufferOffsetString[17];
|
||||
sprintf(addressBufferOffsetString, "%lx",
|
||||
ptrOffset(graphicsAllocation->getGpuAddress(), MemoryConstants::pageSize));
|
||||
std::stringstream expectedOutput;
|
||||
expectedOutput << "Created BO-0 range: ";
|
||||
expectedOutput << std::hex << graphicsAllocation->getGpuAddress();
|
||||
expectedOutput << " - ";
|
||||
expectedOutput << std::hex << ptrOffset(graphicsAllocation->getGpuAddress(), MemoryConstants::pageSize);
|
||||
expectedOutput << ", size: 4096 from PRIME_FD_TO_HANDLE\nCalling gem close on handle: BO-0\n";
|
||||
|
||||
memoryManager->freeGraphicsMemory(graphicsAllocation);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
std::string expectedOutput("Created BO-0 range: ");
|
||||
expectedOutput += addressBufferString;
|
||||
expectedOutput += " - ";
|
||||
expectedOutput += addressBufferOffsetString;
|
||||
expectedOutput += ", size: 4096 from PRIME_FD_TO_HANDLE\nCalling gem close on handle: BO-0\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
EXPECT_EQ(expectedOutput.str(), output);
|
||||
}
|
||||
|
||||
TEST_F(DrmMemoryManagerTestPrelim, givenDrmMemoryManagerAndOsHandleWhenCreateIsCalledWithBufferHostMemoryAllocationTypeThenGraphicsAllocationIsReturned) {
|
||||
|
||||
@@ -3445,24 +3445,18 @@ TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
auto allocation = memoryManger.createGraphicsAllocationFromSharedHandle(handle, properties, false, false, false);
|
||||
ASSERT_NE(nullptr, allocation);
|
||||
|
||||
char addressBufferString[17];
|
||||
sprintf(addressBufferString, "%lx",
|
||||
allocation->getGpuAddress());
|
||||
|
||||
char addressBufferOffsetString[17];
|
||||
sprintf(addressBufferOffsetString, "%lx",
|
||||
ptrOffset(allocation->getGpuAddress(), MemoryConstants::pageSize));
|
||||
std::stringstream expectedOutput;
|
||||
expectedOutput << "Created BO-0 range: ";
|
||||
expectedOutput << std::hex << allocation->getGpuAddress();
|
||||
expectedOutput << " - ";
|
||||
expectedOutput << std::hex << ptrOffset(allocation->getGpuAddress(), MemoryConstants::pageSize);
|
||||
expectedOutput << ", size: 4096 from PRIME_FD_TO_HANDLE\nCalling gem close on handle: BO-0\n";
|
||||
|
||||
memoryManger.freeGraphicsMemory(allocation);
|
||||
|
||||
std::string output = testing::internal::GetCapturedStdout();
|
||||
|
||||
std::string expectedOutput("Created BO-0 range: ");
|
||||
expectedOutput += addressBufferString;
|
||||
expectedOutput += " - ";
|
||||
expectedOutput += addressBufferOffsetString;
|
||||
expectedOutput += ", size: 4096 from PRIME_FD_TO_HANDLE\nCalling gem close on handle: BO-0\n";
|
||||
EXPECT_EQ(expectedOutput, output);
|
||||
EXPECT_EQ(expectedOutput.str(), output);
|
||||
}
|
||||
|
||||
TEST(DrmMemoryManagerFreeGraphicsMemoryUnreferenceTest,
|
||||
|
||||
Reference in New Issue
Block a user