mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-04 15:53:45 +08:00
Print_formatter refactor
Change-Id: Icb03697281b009c853d91a63d5d21ffcde545a8f Signed-off-by: Maciej Plewka <maciej.plewka@intel.com>
This commit is contained in:
committed by
sys_ocldev
parent
7392856a8c
commit
f2a8fc7ea9
@@ -610,14 +610,9 @@ HWTEST_P(EnqueueKernelPrintfTest, GivenKernelWithPrintfBlockedByEventWhenEventUn
|
||||
|
||||
auto crossThreadData = reinterpret_cast<uint64_t *>(mockKernel.mockKernel->getCrossThreadData());
|
||||
|
||||
char *testString = new char[sizeof("test")];
|
||||
strcpy_s(testString, sizeof("test"), "test");
|
||||
std::string testString = "test";
|
||||
|
||||
PrintfStringInfo printfStringInfo;
|
||||
printfStringInfo.SizeInBytes = sizeof("test");
|
||||
printfStringInfo.pStringData = testString;
|
||||
|
||||
mockKernel.kernelInfo.patchInfo.stringDataMap.insert(std::make_pair(0, printfStringInfo));
|
||||
mockKernel.kernelInfo.patchInfo.stringDataMap.insert(std::make_pair(0, testString));
|
||||
|
||||
cl_uint workDim = 1;
|
||||
size_t globalWorkOffset[3] = {0, 0, 0};
|
||||
|
||||
@@ -548,19 +548,13 @@ TEST_F(InternalsEventTest, givenBlockedKernelWithPrintfWhenSubmittedThenPrintOut
|
||||
pPrintfSurface->DataParamOffset = 0;
|
||||
pPrintfSurface->DataParamSize = 8;
|
||||
|
||||
char *testString = new char[sizeof("test")];
|
||||
|
||||
strcpy_s(testString, sizeof("test"), "test");
|
||||
|
||||
PrintfStringInfo printfStringInfo;
|
||||
printfStringInfo.SizeInBytes = sizeof("test");
|
||||
printfStringInfo.pStringData = testString;
|
||||
std::string testString = "test";
|
||||
|
||||
MockKernelWithInternals mockKernelWithInternals(*pDevice);
|
||||
auto pKernel = mockKernelWithInternals.mockKernel;
|
||||
KernelInfo *kernelInfo = const_cast<KernelInfo *>(&pKernel->getKernelInfo());
|
||||
kernelInfo->patchInfo.pAllocateStatelessPrintfSurface = pPrintfSurface;
|
||||
kernelInfo->patchInfo.stringDataMap.insert(std::make_pair(0, printfStringInfo));
|
||||
kernelInfo->patchInfo.stringDataMap.insert(std::make_pair(0, testString));
|
||||
uint64_t crossThread[10];
|
||||
pKernel->setCrossThreadData(&crossThread, sizeof(uint64_t) * 8);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2017-2018 Intel Corporation
|
||||
* Copyright (C) 2017-2019 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -123,7 +123,7 @@ TEST_F(KernelDataTest, PrintfString) {
|
||||
|
||||
buildAndDecode();
|
||||
|
||||
EXPECT_EQ_VAL(0, strcmp(stringValue, pKernelInfo->queryPrintfString(0)));
|
||||
EXPECT_EQ_VAL(0, strcmp(stringValue, pKernelInfo->patchInfo.stringDataMap.find(0)->second.c_str()));
|
||||
delete[] pPrintfString;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace iOpenCL;
|
||||
// -------------------- Base Fixture ------------------------
|
||||
class PrintFormatterTest : public testing::Test {
|
||||
public:
|
||||
PrintFormatter *printFormatter;
|
||||
std::unique_ptr<PrintFormatter> printFormatter;
|
||||
|
||||
std::string format;
|
||||
uint8_t buffer;
|
||||
@@ -50,7 +50,7 @@ class PrintFormatterTest : public testing::Test {
|
||||
program = std::make_unique<MockProgram>(*device->getExecutionEnvironment());
|
||||
kernel = new MockKernel(program.get(), *kernelInfo, *device);
|
||||
|
||||
printFormatter = new PrintFormatter(*kernel, *data);
|
||||
printFormatter = std::unique_ptr<PrintFormatter>(new PrintFormatter(static_cast<uint8_t *>(data->getUnderlyingBuffer()), PrintFormatter::maxPrintfOutputLength, is32bit, kernelInfo->patchInfo.stringDataMap));
|
||||
|
||||
underlyingBuffer[0] = 0;
|
||||
underlyingBuffer[1] = 0;
|
||||
@@ -59,7 +59,6 @@ class PrintFormatterTest : public testing::Test {
|
||||
}
|
||||
|
||||
void TearDown() override {
|
||||
delete printFormatter;
|
||||
delete data;
|
||||
delete kernel;
|
||||
delete device;
|
||||
@@ -751,6 +750,7 @@ TEST_F(PrintFormatterTest, GivenPrintfFormatWhenPointerThenInsertAddress) {
|
||||
}
|
||||
|
||||
TEST_F(PrintFormatterTest, GivenPrintfFormatWhenPointerWith32BitKernelThenPrint32BitPointer) {
|
||||
printFormatter.reset(new PrintFormatter(static_cast<uint8_t *>(data->getUnderlyingBuffer()), PrintFormatter::maxPrintfOutputLength, true, kernelInfo->patchInfo.stringDataMap));
|
||||
auto stringIndex = injectFormatString("%p");
|
||||
storeData(stringIndex);
|
||||
kernelInfo->gpuPointerSize = 4;
|
||||
|
||||
Reference in New Issue
Block a user