未验证 提交 27ecc5d5 编写于 作者: O openharmony_ci 提交者: Gitee

!9083 修复 acts 仓安全告警问题

Merge pull request !9083 from scholar-lc/master
...@@ -34,6 +34,11 @@ sptr<INnrtDevice> INnrtDevice::Get(const std::string &serviceName, bool isStub) ...@@ -34,6 +34,11 @@ sptr<INnrtDevice> INnrtDevice::Get(const std::string &serviceName, bool isStub)
return mockIDevice; return mockIDevice;
} }
MockIDevice::MockIDevice()
{
m_bufferFd = 0;
}
MockIDevice::~MockIDevice() MockIDevice::~MockIDevice()
{ {
for (auto ash : m_ashmems) { for (auto ash : m_ashmems) {
......
...@@ -89,7 +89,7 @@ public: ...@@ -89,7 +89,7 @@ public:
static MockIDevice *GetInstance(); static MockIDevice *GetInstance();
MockIDevice() = default; MockIDevice();
virtual ~MockIDevice(); virtual ~MockIDevice();
private: private:
......
...@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, ...@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret); LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret);
return ret; return ret;
} }
memcpy_s(inputMemory->data, operandTem.length, (void *) operandTem.data, operandTem.length); memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length);
OHNNMemory[inputIndex] = inputMemory; OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1; inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......
...@@ -67,7 +67,7 @@ struct OHNNCompileParam { ...@@ -67,7 +67,7 @@ struct OHNNCompileParam {
bool enableFp16 = false; bool enableFp16 = false;
}; };
int BuildSingleOpGraph(OH_NNModel *modelptr, const OHNNGraphArgs &args); int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs);
int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[], int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[],
float* expect); float* expect);
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
} }
protected: protected:
OHNNCompileParam compileParam; OHNNCompileParam m_compileParam;
AddModel addModel; AddModel addModel;
OHNNGraphArgs graphArgs = addModel.graphArgs; OHNNGraphArgs graphArgs = addModel.graphArgs;
}; };
...@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function | ...@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function |
OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2); OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2);
ASSERT_NE(nullptr, compilation2); ASSERT_NE(nullptr, compilation2);
std::thread th1(CompileModel, compilation1, compileParam); std::thread th1(CompileModel, compilation1, m_compileParam);
std::thread th2(CompileModel, compilation2, compileParam); std::thread th2(CompileModel, compilation2, m_compileParam);
th1.join(); th1.join();
th2.join(); th2.join();
Free(model1, compilation1); Free(model1, compilation1);
......
...@@ -1135,7 +1135,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function | ...@@ -1135,7 +1135,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
OHNNMemory[inputIndex] = inputMemory; OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1; inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
...@@ -1205,7 +1205,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function | ...@@ -1205,7 +1205,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor));
// check result // check result
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)),
(float*) addModel.expectValue)); static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory); OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory);
ASSERT_EQ(outputMemory, nullptr); ASSERT_EQ(outputMemory, nullptr);
......
...@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function | ...@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function |
ASSERT_NE(nullptr, inputMemory); ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
graphArgs.outputIndices.end()) { graphArgs.outputIndices.end()) {
...@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function | ...@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function |
OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length); OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length);
ASSERT_NE(nullptr, inputMemory); ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} }
} }
ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor)); ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor));
...@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function | ...@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function |
auto outputIndex = graphArgs.inputIndices.size() + j; auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output // check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) addModel.expectValue)); static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]); OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr); ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
} }
...@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function | ...@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function |
auto outputIndex = graphArgs.inputIndices.size() + j; auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output // check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) avgModel.expectValue)); static_cast<float*>(avgModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]); OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr); ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
} }
......
...@@ -42,6 +42,11 @@ MockIDevice::~MockIDevice() ...@@ -42,6 +42,11 @@ MockIDevice::~MockIDevice()
} }
} }
MockIDevice::MockIDevice()
{
m_bufferFd = 0;
}
MockIPreparedModel::~MockIPreparedModel() MockIPreparedModel::~MockIPreparedModel()
{ {
for (auto ash : m_ashmems) { for (auto ash : m_ashmems) {
......
...@@ -92,7 +92,7 @@ public: ...@@ -92,7 +92,7 @@ public:
static MockIDevice *GetInstance(); static MockIDevice *GetInstance();
MockIDevice() = default; MockIDevice();
virtual ~MockIDevice(); virtual ~MockIDevice();
private: private:
......
...@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, ...@@ -278,7 +278,7 @@ int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs,
LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret); LOGE("[NNRtTest] OH_NNExecutor_SetInputWithMemory failed! ret=%d\n", ret);
return ret; return ret;
} }
memcpy_s(inputMemory->data, operandTem.length, (void *) operandTem.data, operandTem.length); memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length);
OHNNMemory[inputIndex] = inputMemory; OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1; inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
......
...@@ -67,7 +67,7 @@ struct OHNNCompileParam { ...@@ -67,7 +67,7 @@ struct OHNNCompileParam {
bool enableFp16 = false; bool enableFp16 = false;
}; };
int BuildSingleOpGraph(OH_NNModel *modelptr, const OHNNGraphArgs &args); int BuildSingleOpGraph(OH_NNModel *model, const OHNNGraphArgs &graphArgs);
int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[], int ExecutorWithMemory(OH_NNExecutor *executor, const OHNNGraphArgs &graphArgs, OH_NN_Memory *OHNNMemory[],
float* expect); float* expect);
......
...@@ -68,7 +68,7 @@ public: ...@@ -68,7 +68,7 @@ public:
} }
protected: protected:
OHNNCompileParam compileParam; OHNNCompileParam m_compileParam;
AddModel addModel; AddModel addModel;
OHNNGraphArgs graphArgs = addModel.graphArgs; OHNNGraphArgs graphArgs = addModel.graphArgs;
}; };
...@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function | ...@@ -835,8 +835,8 @@ HWTEST_F(CompileTest, SUB_AI_NNR_Func_North_Compilation_Combine_0100, Function |
OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2); OH_NNCompilation *compilation2 = OH_NNCompilation_Construct(model2);
ASSERT_NE(nullptr, compilation2); ASSERT_NE(nullptr, compilation2);
std::thread th1(CompileModel, compilation1, compileParam); std::thread th1(CompileModel, compilation1, m_compileParam);
std::thread th2(CompileModel, compilation2, compileParam); std::thread th2(CompileModel, compilation2, m_compileParam);
th1.join(); th1.join();
th2.join(); th2.join();
Free(model1, compilation1); Free(model1, compilation1);
......
...@@ -1240,7 +1240,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function | ...@@ -1240,7 +1240,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0400, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
OHNNMemory[inputIndex] = inputMemory; OHNNMemory[inputIndex] = inputMemory;
inputIndex += 1; inputIndex += 1;
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
...@@ -1310,7 +1310,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function | ...@@ -1310,7 +1310,7 @@ HWTEST_F(ExecutorTest, SUB_AI_NNRt_Func_North_Executor_Combine_0500, Function |
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_Run(executor));
// check result // check result
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(outputMemory->data)),
(float*) addModel.expectValue)); static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory); OH_NNExecutor_DestroyOutputMemory(executor, 0, &outputMemory);
ASSERT_EQ(outputMemory, nullptr); ASSERT_EQ(outputMemory, nullptr);
......
...@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function | ...@@ -776,7 +776,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0100, Function |
ASSERT_NE(nullptr, inputMemory); ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) != } else if (std::find(graphArgs.outputIndices.begin(), graphArgs.outputIndices.end(), i) !=
graphArgs.outputIndices.end()) { graphArgs.outputIndices.end()) {
...@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function | ...@@ -815,7 +815,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0200, Function |
OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length); OH_NN_Memory *inputMemory = OH_NNExecutor_AllocateInputMemory(executor, inputIndex, operandTem.length);
ASSERT_NE(nullptr, inputMemory); ASSERT_NE(nullptr, inputMemory);
ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory)); ASSERT_EQ(OH_NN_SUCCESS, OH_NNExecutor_SetInputWithMemory(executor, inputIndex, &operand, inputMemory));
ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, (void *)operandTem.data, operandTem.length)); ASSERT_EQ(EOK, memcpy_s(inputMemory->data, operandTem.length, static_cast<void*>(operandTem.data), operandTem.length));
} }
} }
ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor)); ASSERT_EQ(OH_NN_INVALID_PARAMETER, OH_NNExecutor_Run(executor));
...@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function | ...@@ -847,7 +847,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0300, Function |
auto outputIndex = graphArgs.inputIndices.size() + j; auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output // check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) addModel.expectValue)); static_cast<float*>(addModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]); OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr); ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
} }
...@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function | ...@@ -891,7 +891,7 @@ HWTEST_F(MemoryTest, SUB_AI_NNRt_Func_North_Executor_Memory_Run_0400, Function |
auto outputIndex = graphArgs.inputIndices.size() + j; auto outputIndex = graphArgs.inputIndices.size() + j;
// check memory output // check memory output
EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)), EXPECT_TRUE(CheckOutput(static_cast<float*>(const_cast<void*>(OHNNMemory[outputIndex]->data)),
(float*) avgModel.expectValue)); static_cast<float*>(avgModel.expectValue)));
OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]); OH_NNExecutor_DestroyOutputMemory(executor, j, &OHNNMemory[outputIndex]);
ASSERT_EQ(OHNNMemory[outputIndex], nullptr); ASSERT_EQ(OHNNMemory[outputIndex], nullptr);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册