Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Xts Acts
提交
02c2d852
X
Xts Acts
项目概览
OpenHarmony
/
Xts Acts
大约 1 年 前同步成功
通知
9
Star
22
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
Xts Acts
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
02c2d852
编写于
4月 29, 2021
作者:
O
openharmony_ci
提交者:
Gitee
4月 29, 2021
浏览文件
操作
浏览文件
下载
差异文件
!173 适配AI子系统图新需求I3INEZ新增用例
Merge pull request !173 from Gloria Yin/yinge0429
上级
6d055a04
7ade23b8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
244 addition
and
0 deletion
+244
-0
ai_lite/ai_engine_posix/base/BUILD.gn
ai_lite/ai_engine_posix/base/BUILD.gn
+1
-0
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSyncProcessShareMemoryFunctionTest.cpp
...ie_client/AieClientSyncProcessShareMemoryFunctionTest.cpp
+243
-0
未找到文件。
ai_lite/ai_engine_posix/base/BUILD.gn
浏览文件 @
02c2d852
...
...
@@ -27,6 +27,7 @@ hcpptest_suite("ActsAiEngineTest") {
"src/aie_client/AieClientReleaseFunctionTest.cpp",
"src/aie_client/AieClientSetOptionFunctionTest.cpp",
"src/aie_client/AieClientSyncProcessFunctionTest.cpp",
"src/aie_client/AieClientSyncProcessShareMemoryFunctionTest.cpp",
# pluginManager Function Test Cases
"src/plugin_manager/PluginManagerFunctionTest.cpp",
...
...
ai_lite/ai_engine_posix/base/src/aie_client/AieClientSyncProcessShareMemoryFunctionTest.cpp
0 → 100644
浏览文件 @
02c2d852
/*
* 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 "gtest/gtest.h"
#include <cstring>
#include <unistd.h>
#include "client_executor/include/i_aie_client.inl"
#include "platform/time/include/time.h"
#include "utils/aie_client_callback.h"
#include "utils/aie_client_const.h"
#include "utils/log/aie_log.h"
#include "utils/service_dead_cb.h"
#include "utils/utils.h"
using
namespace
::
testing
;
using
namespace
testing
::
ext
;
using
namespace
OHOS
::
AI
;
namespace
{
const
int
WAIT_CALLBACK_TIME_MS
=
2000
;
}
class
AieClientSyncProcessShareMemoryFunctionTest
:
public
testing
::
Test
{};
/**
* Constructs ConfigInfo parameters.
*/
static
void
GetConfigInfo
(
ConfigInfo
&
configInfo
)
{
configInfo
=
{.
description
=
CONFIG_DESCRIPTION
};
}
/**
* Constructs ClientInfo parameters.
*/
static
void
GetClientInfo
(
ClientInfo
&
clientInfo
)
{
const
char
*
str
=
CLIENT_EXTEND_MSG
;
char
*
extendMsg
=
const_cast
<
char
*>
(
str
);
int
len
=
strlen
(
str
)
+
1
;
clientInfo
=
{
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
clientId
=
INVALID_CLIENT_ID
,
.
sessionId
=
INVALID_SESSION_ID
,
.
serverUid
=
INVALID_UID
,
.
clientUid
=
INVALID_UID
,
.
extendLen
=
len
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
}
/**
* Constructs AlgorithmInfo parameters.
*/
static
void
GetSyncAlgorithmInfo
(
AlgorithmInfo
&
algorithmInfo
,
bool
isAsync
,
int
algorithmType
)
{
const
char
*
str
=
ALGORITHM_EXTEND_MSG
;
char
*
extendMsg
=
const_cast
<
char
*>
(
str
);
int
extendLen
=
strlen
(
str
)
+
1
;
algorithmInfo
=
{
.
clientVersion
=
CLIENT_VERSION_VALID
,
.
isAsync
=
isAsync
,
.
algorithmType
=
algorithmType
,
.
algorithmVersion
=
ALGORITHM_VERSION_VALID
,
.
isCloud
=
GetRandomBool
(),
.
operateId
=
GetRandomInt
(
65535
),
.
requestId
=
GetRandomInt
(
65535
),
.
extendLen
=
extendLen
,
.
extendMsg
=
(
unsigned
char
*
)
extendMsg
,
};
}
/**
* Constructs DataInfo.
*/
static
DataInfo
GetDataInfo
(
bool
isDataInfoNull
=
true
,
const
char
*
dataString
=
DATA_INFO_DEFAULT
)
{
// Sets default dataInfo to null.
DataInfo
dataInfo
=
{
.
data
=
nullptr
,
.
length
=
0
,
};
// Sets dataInfo to specified value.
if
(
!
isDataInfoNull
)
{
const
char
*
str
=
dataString
;
char
*
data
=
const_cast
<
char
*>
(
str
);
int
length
=
strlen
(
str
)
+
1
;
dataInfo
=
{
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
data
),
.
length
=
length
,
};
}
return
dataInfo
;
}
/**
* Constructs DataInfo with a big length data.
*/
static
DataInfo
GetBigDataInfo
(
bool
isDataInfoNull
=
true
)
{
// Sets default dataInfo to null.
DataInfo
dataInfo
=
{
.
data
=
nullptr
,
.
length
=
0
,
};
// Sets dataInfo to specified value.
if
(
!
isDataInfoNull
)
{
#ifdef __LINUX__
int
length
=
2
*
1024
*
1024
;
// 2 MB long data, the unit is Byte here.
#else // liteos device has no enough remaining memory to contain 2MB long data.
int
length
=
1
*
1024
*
1024
;
// 1 MB long data, the unit is Byte here.
#endif
char
*
data
=
reinterpret_cast
<
char
*>
(
malloc
(
length
));
dataInfo
=
{
.
data
=
reinterpret_cast
<
unsigned
char
*>
(
data
),
.
length
=
length
,
};
}
return
dataInfo
;
}
/**
* Release DataInfo.
*/
static
void
FreeDataInfo
(
DataInfo
&
dataInfo
)
{
if
(
dataInfo
.
data
!=
nullptr
)
{
free
(
dataInfo
.
data
);
dataInfo
.
data
=
nullptr
;
dataInfo
.
length
=
0
;
}
}
/**
* Tests AieClientSyncProcess().
*
* isAsync The value of the input parameter AlgorithmInfo.isAsync of AieClientInit.
* isSyncProcessInputInfoNull Whether the input parameter InputInfo of AieClientSyncProcess is null or not.
* isSyncProcessSuccess Whether the expected result of AieClientSyncProcess is successful or not.
* isExpectedSyncProcessOutputInfoNotNull Whether the expected cb of AieClientSyncProcess is not null or not.
*/
static
void
TestAieClientSyncProcess
(
bool
isAsync
,
bool
isSyncProcessInputInfoNull
,
bool
isSyncProcessSuccess
,
bool
isExpectedSyncProcessOutputInfoNotNull
)
{
// Step 0: Defines variables.
ConfigInfo
configInfo
;
GetConfigInfo
(
configInfo
);
ClientInfo
clientInfo
;
GetClientInfo
(
clientInfo
);
AlgorithmInfo
algorithmInfo
;
int
algorithmType
=
isAsync
?
ALGORITHM_TYPE_ASYNC
:
ALGORITHM_TYPE_SYNC
;
GetSyncAlgorithmInfo
(
algorithmInfo
,
isAsync
,
algorithmType
);
ServiceDeadCb
*
cb
=
nullptr
;
AIE_NEW
(
cb
,
ServiceDeadCb
());
// Step 1: Invokes AieClientInit.
int
initReturnCode
=
AieClientInit
(
configInfo
,
clientInfo
,
algorithmInfo
,
cb
);
EXPECT_EQ
(
RETCODE_SUCCESS
,
initReturnCode
)
<<
"AieClientInit is failed!"
;
EXPECT_EQ
(
true
,
clientInfo
.
clientId
>
0
)
<<
"clientId("
<<
std
::
to_string
(
clientInfo
.
clientId
)
<<
") is incorrect!"
;
EXPECT_EQ
(
true
,
clientInfo
.
sessionId
>
0
)
<<
"sessionId("
<<
std
::
to_string
(
clientInfo
.
sessionId
)
<<
") is incorrect!"
;
// Step 2: Invokes AieClientPrepare.
bool
isPrepareInputInfoNull
=
GetRandomBool
();
DataInfo
prepareInputInfo
=
GetDataInfo
(
isPrepareInputInfoNull
,
INPUT_INFO_PREPARE
);
DataInfo
prepareOutputInfo
=
GetDataInfo
();
ClientCallback
*
callback
=
nullptr
;
if
(
isAsync
)
{
AIE_NEW
(
callback
,
ClientCallback
());
}
int
prepareReturnCode
=
AieClientPrepare
(
clientInfo
,
algorithmInfo
,
prepareInputInfo
,
prepareOutputInfo
,
callback
);
EXPECT_EQ
(
RETCODE_SUCCESS
,
prepareReturnCode
)
<<
"AieClientPrepare is failed!"
;
EXPECT_EQ
(
true
,
prepareOutputInfo
.
data
!=
nullptr
)
<<
"Prepare outputInfo is incorrect!"
;
// Step 3: Invokes AieClientSyncProcess.
DataInfo
syncProcessInputInfo
=
GetBigDataInfo
(
isSyncProcessInputInfoNull
);
DataInfo
syncProcessOutputInfo
=
GetDataInfo
();
int
syncProcessReturnCode
=
AieClientSyncProcess
(
clientInfo
,
algorithmInfo
,
syncProcessInputInfo
,
syncProcessOutputInfo
);
EXPECT_EQ
(
isSyncProcessSuccess
,
syncProcessReturnCode
==
RETCODE_SUCCESS
)
<<
"AieClientSyncProcess is failed!"
;
EXPECT_EQ
(
isExpectedSyncProcessOutputInfoNotNull
,
syncProcessOutputInfo
.
data
!=
nullptr
)
<<
"AieClientSyncProcess outputInfo is incorrect!"
;
// Step 4: Sleeps.
StepSleepMs
(
WAIT_CALLBACK_TIME_MS
);
// Step 5: Invokes AieClientRelease.
DataInfo
releaseInputInfo
=
GetDataInfo
(
false
,
INPUT_INFO_RELEASE
);
int
releaseReturnCode
=
AieClientRelease
(
clientInfo
,
algorithmInfo
,
releaseInputInfo
);
EXPECT_EQ
(
RETCODE_SUCCESS
,
releaseReturnCode
)
<<
"AieClientRelease is failed!"
;
// Step 6: Invokes AieClientDestroy.
int
destroyReturnCode
=
AieClientDestroy
(
clientInfo
);
EXPECT_EQ
(
RETCODE_SUCCESS
,
destroyReturnCode
)
<<
"AieClientDestroy is failed!"
;
// Step 7: Deletes callback.
AIE_DELETE
(
cb
);
AIE_DELETE
(
callback
);
// Step 8: Release data info.
FreeDataInfo
(
syncProcessInputInfo
);
FreeDataInfo
(
syncProcessOutputInfo
);
}
/**
* @tc.number : SUB_AI_AIDistributedAbility_HiAiEngine_Lite_Function_HiAiAPI_AIEClient_AieClientSyncProcessShareMemory_0100
* @tc.name : 01. algorithmInfo中isAsync=false,inputInfo不为空,调用AieClientSyncProcess返回成功_共享内存传大数据
* @tc.desc : [C- SOFTWARE -0200]
*/
HWTEST_F
(
AieClientSyncProcessShareMemoryFunctionTest
,
testAieClientSyncProcessShareMemoryFunction0101
,
Function
|
MediumTest
|
Level2
)
{
HILOGI
(
"[Test]testAieClientSyncProcessShareMemoryFunction0101."
);
TestAieClientSyncProcess
(
false
,
false
,
true
,
true
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录