提交 c1a64e5b 编写于 作者: O openharmony_ci 提交者: Gitee

!160 AI子系统修改依赖的测试demo的位置,修改公共build.gn中AI的编译用例路径

Merge pull request !160 from Gloria Yin/yinge20210423
...@@ -57,9 +57,9 @@ hcpptest_suite("ActsAiEngineTest") { ...@@ -57,9 +57,9 @@ hcpptest_suite("ActsAiEngineTest") {
"//foundation/ai/engine/services/client:client", "//foundation/ai/engine/services/client:client",
"//foundation/ai/engine/services/common/platform/dl_operation:dlOperation", "//foundation/ai/engine/services/common/platform/dl_operation:dlOperation",
"//foundation/ai/engine/services/server/plugin_manager:plugin_manager", "//foundation/ai/engine/services/server/plugin_manager:plugin_manager",
"//foundation/ai/engine/test/sample:sample_plugin_1",
"//foundation/ai/engine/test/sample:sample_plugin_2",
"//foundation/distributedschedule/samgr_lite/samgr:samgr", "//foundation/distributedschedule/samgr_lite/samgr:samgr",
"//test/xts/acts/ai_lite/ai_engine_posix/base/src/sample:sample_plugin_1_sync",
"//test/xts/acts/ai_lite/ai_engine_posix/base/src/sample:sample_plugin_2_async",
] ]
cflags = [ "-Wno-error" ] cflags = [ "-Wno-error" ]
ldflags = [ "-lstdc++" ] ldflags = [ "-lstdc++" ]
......
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import("//build/lite/config/component/lite_component.gni")
source_set("syncDemoPluginCode") {
sources = [ "source/sample_plugin_1.cpp" ]
cflags = [ "-fPIC" ]
cflags_cc = cflags
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
"//foundation/ai/engine/services/common",
"//foundation/ai/engine/services/server",
"//foundation/ai/engine/test",
"//third_party/bounds_checking_function/include",
]
}
lite_component("sample_plugin_1_sync") {
target_type = "shared_library"
cflags = [ "-fPIC" ]
cflags_cc = cflags
features = [ ":syncDemoPluginCode" ]
deps = [
"//foundation/ai/engine/services/common/protocol/data_channel:data_channel",
]
}
source_set("asyncDemoPluginCode") {
sources = [ "source/sample_plugin_2.cpp" ]
cflags = [ "-fPIC" ]
cflags_cc = cflags
include_dirs = [
"//base/hiviewdfx/hilog_lite/interfaces/native/kits/hilog",
"//foundation/ai/engine/services/common",
"//foundation/ai/engine/services/server",
"//foundation/ai/engine/test",
"//third_party/bounds_checking_function/include",
]
}
lite_component("sample_plugin_2_async") {
target_type = "shared_library"
cflags = [ "-fPIC" ]
cflags_cc = cflags
features = [ ":asyncDemoPluginCode" ]
deps = [
"//foundation/ai/engine/services/common/protocol/data_channel:data_channel",
]
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SAMPLE_PLUGIN_1_H
#define SAMPLE_PLUGIN_1_H
#include <cstring>
#include "plugin/i_plugin.h"
namespace OHOS {
namespace AI {
class SamplePlugin1 : public IPlugin {
const long long ALG_VERSION = 1;
const char *ALG_NAME = "SAMPLE_PLUGIN_1";
const char * const PLUGIN_INFER_MODEL = "SYNC";
const char *DEFAULT_OPTION_DATA = "default option data";
unsigned char *optionData = nullptr;
int optionLength = 0;
public:
SamplePlugin1();
~SamplePlugin1();
const long long GetVersion() const override;
const char *GetName() const override;
const char *GetInferMode() const override;
int SyncProcess(IRequest *request, IResponse *&response) override;
int AsyncProcess(IRequest *request, IPluginCallback *callback) override;
int Prepare(long long transactionId, const DataInfo &inputInfo, DataInfo &outputInfo) override;
int Release(bool isFullUnload, long long transactionId, const DataInfo &inputInfo) override;
int SetOption(int optionType, const DataInfo &inputInfo) override;
int GetOption(int optionType, const DataInfo &inputInfo, DataInfo &outputInfo) override;
};
}
}
#endif // SAMPLE_PLUGIN_1_H
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef SAMPLE_PLUGIN_2_H
#define SAMPLE_PLUGIN_2_H
#include <cstring>
#include "plugin/i_plugin.h"
namespace OHOS {
namespace AI {
class SamplePlugin2 : public IPlugin {
const long long ALG_VERSION = 1;
const char *ALG_NAME = "SAMPLE_PLUGIN_2";
const char * const PLUGIN_INFER_MODEL = "ASYNC";
const char *DEFAULT_OPTION_DATA = "default option data";
unsigned char *optionData = nullptr;
int optionLength = 0;
public:
SamplePlugin2();
~SamplePlugin2();
const long long GetVersion() const override;
const char *GetName() const override;
const char *GetInferMode() const override;
int SyncProcess(IRequest *request, IResponse *&response) override;
int AsyncProcess(IRequest *request, IPluginCallback *callback) override;
int Prepare(long long transactionId, const DataInfo &inputInfo, DataInfo &outputInfo) override;
int Release(bool isFullUnload, long long transactionId, const DataInfo &inputInfo) override;
int SetOption(int optionType, const DataInfo &inputInfo) override;
int GetOption(int optionType, const DataInfo &inputInfo, DataInfo &outputInfo) override;
};
}
}
#endif // SAMPLE_PLUGIN_2_H
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "sample/include/sample_plugin_1.h"
#include <cstring>
#include "securec.h"
#include "protocol/retcode_inner/aie_retcode_inner.h"
#include "utils/log/aie_log.h"
namespace OHOS {
namespace AI {
SamplePlugin1::SamplePlugin1() = default;
SamplePlugin1::~SamplePlugin1()
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
}
const long long SamplePlugin1::GetVersion() const
{
return ALG_VERSION;
}
const char *SamplePlugin1::GetName() const
{
return ALG_NAME;
}
const char *SamplePlugin1::GetInferMode() const
{
return PLUGIN_INFER_MODEL;
}
int SamplePlugin1::SyncProcess(IRequest *request, IResponse *&response)
{
DataInfo inputInfo = request->GetMsg();
if (inputInfo.data != nullptr) {
HILOGE("[SamplePlugin2]inputInfo data is %p.", inputInfo.data);
}
response = IResponse::Create(request);
CHK_RET(response == nullptr, RETCODE_FAILURE);
const char *str = "sample_plugin_1 SyncProcess outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
DataInfo outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
response->SetResult(outputInfo);
response->SetRetCode(RETCODE_SUCCESS);
return RETCODE_SUCCESS;
}
int SamplePlugin1::AsyncProcess(IRequest *request, IPluginCallback *callback)
{
DataInfo inputInfo = request->GetMsg();
if (inputInfo.data != nullptr) {
HILOGE("[SamplePlugin2]inputInfo data is %p.", inputInfo.data);
}
IResponse *response = IResponse::Create(request);
CHK_RET(response == nullptr, RETCODE_FAILURE);
const char *str = "sample_plugin_1 AsyncProcess outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
DataInfo outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
response->SetResult(outputInfo);
response->SetRetCode(RETCODE_SUCCESS);
int retCode = callback->OnEvent(ON_PLUGIN_SUCCEED, response);
return retCode;
}
int SamplePlugin1::Prepare(long long transactionId, const DataInfo &inputInfo, DataInfo &outputInfo)
{
const char *str = "sample_plugin_1 Prepare outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
return RETCODE_SUCCESS;
}
int SamplePlugin1::Release(bool isFullUnload, long long transactionId, const DataInfo &inputInfo)
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
return RETCODE_SUCCESS;
}
int SamplePlugin1::SetOption(int optionType, const DataInfo &inputInfo)
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
if (inputInfo.data == nullptr) {
return RETCODE_SUCCESS;
}
optionLength = inputInfo.length;
optionData = (unsigned char *)malloc(sizeof(unsigned char) * optionLength);
if (optionData == nullptr) {
HILOGE("[SamplePlugin1]Failed to request memory.");
return RETCODE_OUT_OF_MEMORY;
}
errno_t retCode = memcpy_s(optionData, optionLength, inputInfo.data, optionLength);
if (retCode != EOK) {
HILOGE("[SamplePlugin1]Failed to memory copy, retCode[%d].", retCode);
free(optionData);
optionData = nullptr;
return RETCODE_MEMORY_COPY_FAILURE;
}
return RETCODE_SUCCESS;
}
int SamplePlugin1::GetOption(int optionType, const DataInfo &inputInfo, DataInfo &outputInfo)
{
if (optionData == nullptr) {
optionLength = strlen(DEFAULT_OPTION_DATA) + 1;
optionData = (unsigned char *)malloc(sizeof(unsigned char) * optionLength);
if (optionData == nullptr) {
HILOGE("[SamplePlugin1]Failed to request memory.");
return RETCODE_OUT_OF_MEMORY;
}
errno_t retCode = memcpy_s(optionData, optionLength, DEFAULT_OPTION_DATA, optionLength);
if (retCode != EOK) {
HILOGE("[SamplePlugin1]Failed to memory copy, retCode[%d].", retCode);
free(optionData);
optionData = nullptr;
return RETCODE_MEMORY_COPY_FAILURE;
}
}
outputInfo = {
.data = optionData,
.length = optionLength
};
return RETCODE_SUCCESS;
}
PLUGIN_INTERFACE_IMPL(SamplePlugin1);
}
}
/*
* Copyright (C) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "sample/include/sample_plugin_2.h"
#include <cstring>
#include "securec.h"
#include "protocol/retcode_inner/aie_retcode_inner.h"
#include "utils/log/aie_log.h"
namespace OHOS {
namespace AI {
SamplePlugin2::SamplePlugin2() = default;
SamplePlugin2::~SamplePlugin2()
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
}
const long long SamplePlugin2::GetVersion() const
{
return ALG_VERSION;
}
const char *SamplePlugin2::GetName() const
{
return ALG_NAME;
}
const char *SamplePlugin2::GetInferMode() const
{
return PLUGIN_INFER_MODEL;
}
int SamplePlugin2::SyncProcess(IRequest *request, IResponse *&response)
{
DataInfo inputInfo = request->GetMsg();
if (inputInfo.data != nullptr) {
HILOGE("[SamplePlugin2]inputInfo data is %p.", inputInfo.data);
}
response = IResponse::Create(request);
CHK_RET(response == nullptr, RETCODE_FAILURE);
const char *str = "sample_plugin_2 Process outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
DataInfo outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
response->SetResult(outputInfo);
response->SetRetCode(RETCODE_SUCCESS);
return RETCODE_SUCCESS;
}
int SamplePlugin2::AsyncProcess(IRequest *request, IPluginCallback *callback)
{
DataInfo inputInfo = request->GetMsg();
if (inputInfo.data != nullptr) {
HILOGE("[SamplePlugin2]inputInfo data is %p.", inputInfo.data);
}
IResponse *response = IResponse::Create(request);
CHK_RET(response == nullptr, RETCODE_FAILURE);
const char *str = "sample_plugin_2 AsyncProcess outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
DataInfo outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
response->SetResult(outputInfo);
response->SetRetCode(RETCODE_SUCCESS);
int retCode = callback->OnEvent(ON_PLUGIN_SUCCEED, response);
return retCode;
}
int SamplePlugin2::Prepare(long long transactionId, const DataInfo &inputInfo, DataInfo &outputInfo)
{
const char *str = "sample_plugin_2 Prepare outputInfo";
char *outputData = const_cast<char*>(str);
int len = strlen(str) + 1;
outputInfo = {
.data = (unsigned char*)outputData,
.length = len,
};
return RETCODE_SUCCESS;
}
int SamplePlugin2::Release(bool isFullUnload, long long transactionId, const DataInfo &inputInfo)
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
return RETCODE_SUCCESS;
}
int SamplePlugin2::SetOption(int optionType, const DataInfo &inputInfo)
{
if (optionData != nullptr) {
free(optionData);
optionData = nullptr;
optionLength = 0;
}
if (inputInfo.data == nullptr) {
return RETCODE_SUCCESS;
}
optionLength = inputInfo.length;
optionData = (unsigned char *)malloc(sizeof(unsigned char) * optionLength);
if (optionData == nullptr) {
HILOGE("[SamplePlugin2]Failed to request memory.");
return RETCODE_OUT_OF_MEMORY;
}
errno_t retCode = memcpy_s(optionData, optionLength, inputInfo.data, optionLength);
if (retCode != EOK) {
HILOGE("[SamplePlugin2]Failed to memory copy, retCode[%d].", retCode);
free(optionData);
optionData = nullptr;
return RETCODE_MEMORY_COPY_FAILURE;
}
return RETCODE_SUCCESS;
}
int SamplePlugin2::GetOption(int optionType, const DataInfo &inputInfo, DataInfo &outputInfo)
{
if (optionData == nullptr) {
optionLength = strlen(DEFAULT_OPTION_DATA) + 1;
optionData = (unsigned char *)malloc(sizeof(unsigned char) * optionLength);
if (optionData == nullptr) {
HILOGE("[SamplePlugin1]Failed to request memory.");
return RETCODE_OUT_OF_MEMORY;
}
errno_t retCode = memcpy_s(optionData, optionLength, DEFAULT_OPTION_DATA, optionLength);
if (retCode != EOK) {
HILOGE("[SamplePlugin1]Failed to memory copy, retCode[%d].", retCode);
free(optionData);
optionData = nullptr;
return RETCODE_MEMORY_COPY_FAILURE;
}
}
outputInfo = {
.data = optionData,
.length = optionLength
};
return RETCODE_SUCCESS;
}
PLUGIN_INTERFACE_IMPL(SamplePlugin2);
}
}
...@@ -71,7 +71,7 @@ lite_component("acts_component") { ...@@ -71,7 +71,7 @@ lite_component("acts_component") {
"//test/xts/acts/communication_lite/softbus_posix:ActsSoftBusTest", "//test/xts/acts/communication_lite/softbus_posix:ActsSoftBusTest",
"//test/xts/acts/communication_lite/lwip_posix:ActsLwipTest", "//test/xts/acts/communication_lite/lwip_posix:ActsLwipTest",
"//test/xts/acts/ai_lite:ActsAiTest", "//test/xts/acts/ai_lite/ai_engine_posix/base:ActsAiEngineTest",
"//test/xts/acts/global_lite:ActsGlobalTest", "//test/xts/acts/global_lite:ActsGlobalTest",
"//test/xts/acts/sensors_lite:sensorstest", "//test/xts/acts/sensors_lite:sensorstest",
] ]
...@@ -86,7 +86,7 @@ lite_component("acts_component") { ...@@ -86,7 +86,7 @@ lite_component("acts_component") {
"//test/xts/acts/distributed_schedule_lite/system_ability_manager_posix:ActsSamgrTest", "//test/xts/acts/distributed_schedule_lite/system_ability_manager_posix:ActsSamgrTest",
"//test/xts/acts/appexecfwk_lite/bundle_mgr_posix:ActsBundleMgrTest", "//test/xts/acts/appexecfwk_lite/bundle_mgr_posix:ActsBundleMgrTest",
"//test/xts/acts/aafwk_lite/ability_posix:ActsAbilityMgrTest", "//test/xts/acts/aafwk_lite/ability_posix:ActsAbilityMgrTest",
"//test/xts/acts/ai_lite:ActsAiTest", "//test/xts/acts/ai_lite/ai_engine_posix/base:ActsAiEngineTest",
] ]
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册