mirror of
https://github.com/openharmony/distributedschedule_dms_fwk_lite.git
synced 2026-07-01 06:41:51 -04:00
update openharmony 1.0.1
This commit is contained in:
@@ -1,13 +0,0 @@
|
||||
### 该问题是怎么引起的?
|
||||
|
||||
|
||||
|
||||
### 重现步骤
|
||||
|
||||
|
||||
|
||||
### 报错信息
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
### 相关的Issue
|
||||
|
||||
|
||||
### 原因(目的、解决的问题等)
|
||||
|
||||
|
||||
### 描述(做了什么,变更了什么)
|
||||
|
||||
|
||||
### 测试用例(新增、改动、可能影响的功能)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
moduletest
|
||||
@@ -14,70 +14,67 @@
|
||||
import("//build/lite/config/component/lite_component.gni")
|
||||
|
||||
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
|
||||
lite_library("dmslite") {
|
||||
target_type = "shared_library"
|
||||
lite_library("dmslite") {
|
||||
target_type = "shared_library"
|
||||
|
||||
cflags = ["-Wall"]
|
||||
cflags_cc = cflags
|
||||
cflags = [ "-Wall" ]
|
||||
cflags_cc = cflags
|
||||
|
||||
defines = [
|
||||
"_GNU_SOURCE",
|
||||
"OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
|
||||
]
|
||||
defines = [
|
||||
"_GNU_SOURCE",
|
||||
"OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
|
||||
]
|
||||
|
||||
sources = [
|
||||
"source/distributed_schedule_service.c",
|
||||
"source/dmslite.c",
|
||||
"source/dmslite_famgr.c",
|
||||
"source/dmslite_msg_parser.c",
|
||||
"source/dmslite_tlv_common.c",
|
||||
"source/dmslite_session.c",
|
||||
"source/dmslite_check_remote_permission.c"
|
||||
]
|
||||
sources = [
|
||||
"source/distributed_schedule_service.c",
|
||||
"source/dmslite.c",
|
||||
"source/dmslite_check_remote_permission.c",
|
||||
"source/dmslite_famgr.c",
|
||||
"source/dmslite_msg_parser.c",
|
||||
"source/dmslite_session.c",
|
||||
"source/dmslite_tlv_common.c",
|
||||
]
|
||||
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//foundation/distributedschedule/interfaces/innerkits/samgr_lite",
|
||||
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
|
||||
"//foundation/aafwk/interfaces/innerkits/abilitymgr_lite",
|
||||
"//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
|
||||
"//foundation/communication/interfaces/kits/softbus_lite/transport",
|
||||
"//foundation/communication/interfaces/kits/softbus_lite/discovery",
|
||||
"//foundation/aafwk/interfaces/kits/ability_lite",
|
||||
"//foundation/aafwk/interfaces/kits/want_lite",
|
||||
"//foundation/appexecfwk/interfaces/kits/bundle_lite",
|
||||
"//foundation/appexecfwk/interfaces/innerkits/bundlemgr_lite",
|
||||
"//kernel/liteos_a/kernel/include",
|
||||
"//kernel/liteos_a/kernel/common",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//third_party/cJSON",
|
||||
"//utils/native/lite/include",
|
||||
]
|
||||
include_dirs = [
|
||||
"include",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/innerkits",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/samgr",
|
||||
"${aafwk_lite_path}/interfaces/innerkits/abilitymgr_lite",
|
||||
"//foundation/distributedschedule/samgr_lite/interfaces/kits/registry",
|
||||
"//foundation/communication/softbus_lite/interfaces/kits/transport",
|
||||
"//foundation/communication/softbus_lite/interfaces/kits/discovery",
|
||||
"${aafwk_lite_path}/interfaces/kits/ability_lite",
|
||||
"${aafwk_lite_path}/interfaces/kits/want_lite",
|
||||
"${appexecfwk_lite_path}/interfaces/kits/bundle_lite",
|
||||
"${appexecfwk_lite_path}/interfaces/innerkits/bundlemgr_lite",
|
||||
"//kernel/liteos_a/kernel/include",
|
||||
"//kernel/liteos_a/kernel/common",
|
||||
"//third_party/bounds_checking_function/include",
|
||||
"//third_party/cJSON",
|
||||
"//utils/native/lite/include",
|
||||
]
|
||||
|
||||
deps = [
|
||||
]
|
||||
deps = []
|
||||
|
||||
public_deps = [
|
||||
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
|
||||
"//base/security/frameworks/huks_lite/source:huks",
|
||||
"//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
|
||||
"//foundation/communication/services/softbus_lite:softbus_lite",
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
"//foundation/aafwk/frameworks/abilitymgr_lite:aafwk_abilityManager_lite",
|
||||
]
|
||||
}
|
||||
public_deps = [
|
||||
"${aafwk_lite_path}/frameworks/abilitymgr_lite:aafwk_abilityManager_lite",
|
||||
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
|
||||
"//base/security/huks/frameworks/huks_lite/source:huks",
|
||||
"//foundation/communication/softbus_lite:softbus",
|
||||
"//foundation/distributedschedule/samgr_lite/samgr:samgr",
|
||||
"//third_party/bounds_checking_function:libsec_shared",
|
||||
]
|
||||
}
|
||||
|
||||
lite_component("dtbschedmgr") {
|
||||
features = [
|
||||
":dmslite",
|
||||
]
|
||||
}
|
||||
lite_component("dtbschedmgr") {
|
||||
features = [ ":dmslite" ]
|
||||
}
|
||||
|
||||
generate_notice_file("dtbschedmgr_notice_file") {
|
||||
module_name = "dtbschedmgr"
|
||||
module_source_dir_list = [
|
||||
"//third_party/bounds_checking_function",
|
||||
"//third_party/cJSON",
|
||||
]
|
||||
}
|
||||
generate_notice_file("dtbschedmgr_notice_file") {
|
||||
module_name = "dtbschedmgr"
|
||||
module_source_dir_list = [
|
||||
"//third_party/bounds_checking_function",
|
||||
"//third_party/cJSON",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,128 @@
|
||||
# dms\_fwk\_lite<a name="EN-US_TOPIC_0000001128264105"></a>
|
||||
|
||||
- [Introduction](#section11660541593)
|
||||
- [Directory Structure](#section1464106163817)
|
||||
- [Constraints](#section1718733212019)
|
||||
- [Usage](#section10729231131110)
|
||||
- [Repositories Involved](#section176111311166)
|
||||
|
||||
## Introduction<a name="section11660541593"></a>
|
||||
|
||||
The Distributed Scheduler is used for cross-device component management. It allows the local device to access or control remote components, and enables application collaboration in distributed scenarios. The following figure shows the modules in the Distributed Scheduler.
|
||||
|
||||

|
||||
|
||||
## Directory Structure<a name="section1464106163817"></a>
|
||||
|
||||
The following table describes the directory structure of the Distributed Scheduler.
|
||||
|
||||
**Table 1** Directory structure of the major source code
|
||||
|
||||
<a name="table43531856201716"></a>
|
||||
<table><thead align="left"><tr id="row20416556201718"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="p10416456121716"><a name="p10416456121716"></a><a name="p10416456121716"></a>Directory</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.2"><p id="p1841645631717"><a name="p1841645631717"></a><a name="p1841645631717"></a>Description</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row64161056151718"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="p4160914132218"><a name="p4160914132218"></a><a name="p4160914132218"></a>dmsfwk_lite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p541645611177"><a name="p541645611177"></a><a name="p541645611177"></a>Implementation of the Distributed Scheduler</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row104169564177"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="p17416125614179"><a name="p17416125614179"></a><a name="p17416125614179"></a>safwk_lite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p04163569170"><a name="p04163569170"></a><a name="p04163569170"></a>Implementation of the foundation process</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
The source code directory structure of the Distributed Scheduler is as follows:
|
||||
|
||||
```
|
||||
├── BUILD.gn
|
||||
├── include
|
||||
│ ├── distributed_schedule_service.h # Header file for the open APIs provided by the Distributed Scheduler
|
||||
│ ├── dmslite_check_remote_permission.h # Header file for the permission management module of the Distributed Scheduler
|
||||
│ ├── dmslite_famgr.h # Header file for the FA management module of the Distributed Scheduler
|
||||
│ ├── dmslite_inner_common.h # Internal common file for the Distributed Scheduler
|
||||
│ ├── dmslite.h # Header file for the implementation of the Distributed Scheduler Service (also called the Distributed Manager Service)
|
||||
│ ├── dmslite_log.h # Header file for the log module
|
||||
│ ├── dmslite_msg_parser.h # Header file for the distributed message parsing module
|
||||
│ ├── dmslite_tlv_common.h # Header file for the TLV data parsing module
|
||||
│ └── dmslite_session.h # Header file for the inter-device communication module
|
||||
├── readme.md
|
||||
├── LICENSE
|
||||
├── source
|
||||
├── distributed_schedule_service.c
|
||||
├── dmslite.c
|
||||
├── dmslite_check_remote_permission.c
|
||||
├── dmslite_famgr.c
|
||||
├── dmslite_msg_parser.c
|
||||
├── dmslite_tlv_common.c
|
||||
└── dmslite_session.c
|
||||
```
|
||||
|
||||
## Constraints<a name="section1718733212019"></a>
|
||||
|
||||
**Programming language**: C/C++
|
||||
|
||||
**Networking environment**: The primary and secondary devices must be on the same LAN and can ping each other.
|
||||
|
||||
**Operating system**: OpenHarmony
|
||||
|
||||
**Limitations and constraints on remote startup**:
|
||||
|
||||
- Only Feature Abilities \(FAs\) can be started remotely. Remote startup is unavailable to abilities using the Service template.
|
||||
- Before the remote startup, ensure that the distributed networking between the primary and secondary devices is successful. Otherwise, the remote startup fails.
|
||||
|
||||
## Usage<a name="section10729231131110"></a>
|
||||
|
||||
- **Compiling and Building the Distributed Scheduler**
|
||||
|
||||
The code of the Distributed Scheduler is stored in the following directory:
|
||||
|
||||
```
|
||||
foundation/distributedschedule/dmsfwk_lite
|
||||
```
|
||||
|
||||
When compiling and building the code for a specific platform, you need to specify the target platform.
|
||||
|
||||
```
|
||||
hb build
|
||||
```
|
||||
|
||||
- **Primary device development** \(taking FA startup as an example\)
|
||||
|
||||
Create a **Want** instance to set the remote device ID, bundle name, and ability class name of the target FA and set the **Want.FLAG\_ABILITYSLICE\_MULTI\_DEVICE** flag to enable distributed startup.
|
||||
|
||||
```
|
||||
import ohos.aafwk.ability.Ability;
|
||||
import ohos.aafwk.content.Want;
|
||||
import ohos.bundle.ElementName;
|
||||
|
||||
// Create a Want instance that will be passed to the startAbility method.
|
||||
Want want = new Want();
|
||||
ElementName name = new ElementName(remote_device_id, "com.huawei.remote_bundle_name", "remote_ability_name");
|
||||
want.setElement(name); // Add information about the target FA for startup to the Want instance.
|
||||
want.setFlags(Want.FLAG_ABILITYSLICE_MULTI_DEVICE); // Set the multi-device startup flag. If this flag is not set, remote FA startup will be unavailable.
|
||||
|
||||
// Start the remote FA on the secondary device.
|
||||
startAbility(want); // Start the specified FA based on the want parameter. If the name and type of the want parameter are different from those used in the IDE, use the parameter name and type in the IDE.
|
||||
```
|
||||
|
||||
- **Prerequisites**
|
||||
|
||||
The target FA with the specified bundle name must have been installed on the secondary device.
|
||||
|
||||
- **Execution** \(taking FA startup as an example\)
|
||||
|
||||
Call the **startAbility** method on the primary device to start the target FA on the secondary device.
|
||||
|
||||
## Repositories Involved<a name="section176111311166"></a>
|
||||
|
||||
[Distributed Scheduler subsystem](en-us_topic_0000001115719369.md)
|
||||
|
||||
**[dms\_fwk\_lite](https://gitee.com/openharmony/distributedschedule_services_dtbschedmgr_lite)**
|
||||
|
||||
Executable
+128
@@ -0,0 +1,128 @@
|
||||
# 介绍<a name="ZH-CN_TOPIC_0000001128264105"></a>
|
||||
|
||||
- [简介](#section11660541593)
|
||||
- [目录](#section1464106163817)
|
||||
- [约束](#section1718733212019)
|
||||
- [使用](#section10729231131110)
|
||||
- [涉及仓](#section176111311166)
|
||||
|
||||
## 简介<a name="section11660541593"></a>
|
||||
|
||||
分布式任务调度模块负责跨设备组件管理,提供访问和控制远程组件的能力,支持分布式场景下的应用协同。分布式调度模块组成如下图所示:
|
||||
|
||||

|
||||
|
||||
## 目录<a name="section1464106163817"></a>
|
||||
|
||||
分布式任务调度源代码目录结构如下表所示:
|
||||
|
||||
**表1 **主要源代码目录结构
|
||||
|
||||
<a name="table43531856201716"></a>
|
||||
<table><thead align="left"><tr id="row20416556201718"><th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.1"><p id="p10416456121716"><a name="p10416456121716"></a><a name="p10416456121716"></a>名称</p>
|
||||
</th>
|
||||
<th class="cellrowborder" valign="top" width="50%" id="mcps1.1.3.1.2"><p id="p1841645631717"><a name="p1841645631717"></a><a name="p1841645631717"></a>描述</p>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr id="row64161056151718"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="p4160914132218"><a name="p4160914132218"></a><a name="p4160914132218"></a>dmsfwk_lite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p541645611177"><a name="p541645611177"></a><a name="p541645611177"></a>分布式任务调度实现</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr id="row104169564177"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.1 "><p id="p17416125614179"><a name="p17416125614179"></a><a name="p17416125614179"></a>safwk_lite</p>
|
||||
</td>
|
||||
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.1.3.1.2 "><p id="p04163569170"><a name="p04163569170"></a><a name="p04163569170"></a>foundation进程实现</p>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
其中轻量级分布式任务调度的源代码目录结构如下:
|
||||
|
||||
```
|
||||
├── BUILD.gn
|
||||
├── include
|
||||
│ ├── distributed_schedule_service.h # 分布式调度对外接口
|
||||
│ ├── dmslite_check_remote_permission.h # 分布式调度权限管理模块
|
||||
│ ├── dmslite_famgr.h # 分布式调度FA管理模块
|
||||
│ ├── dmslite_inner_common.h # 分布式调度内部通用文件
|
||||
│ ├── dmslite.h # 分布式调度服务实现
|
||||
│ ├── dmslite_log.h # 日志模块
|
||||
│ ├── dmslite_msg_parser.h # 分布式消息解析模块
|
||||
│ ├── dmslite_tlv_common.h # TLV格式数据解析模块
|
||||
│ └── dmslite_session.h # 跨设备通信收发模块
|
||||
├── readme.md
|
||||
├── LICENSE
|
||||
├── source
|
||||
├── distributed_schedule_service.c
|
||||
├── dmslite.c
|
||||
├── dmslite_check_remote_permission.c
|
||||
├── dmslite_famgr.c
|
||||
├── dmslite_msg_parser.c
|
||||
├── dmslite_tlv_common.c
|
||||
└── dmslite_session.c
|
||||
```
|
||||
|
||||
## 约束<a name="section1718733212019"></a>
|
||||
|
||||
**语言限制**:C/C++语言
|
||||
|
||||
**组网环境**:必须确保设备在同一个局域网中,主从设备能互相ping通
|
||||
|
||||
**操作系统限制**:OpenHarmony操作系统
|
||||
|
||||
**远程启动的约束与限制:**
|
||||
|
||||
- 支持远程启动FA,不支持远程启动SA
|
||||
- 远程启动前必须确保主设备与从设备间分布式组网成功,否则无法远程启动
|
||||
|
||||
## 使用<a name="section10729231131110"></a>
|
||||
|
||||
- **分布式任务调度模块编译**
|
||||
|
||||
分布式任务调度模块,其代码所在目录如下:
|
||||
|
||||
```
|
||||
foundation/distributedschedule/dmsfwk_lite
|
||||
```
|
||||
|
||||
在针对不同平台进行编译时,需要提前指定目标平台:
|
||||
|
||||
```
|
||||
hb build
|
||||
```
|
||||
|
||||
- **主设备程序开发**(以拉起FA为例)
|
||||
|
||||
构造意图参数want,设置需要启动的远端设备ID,包名,元能力类名信息,以及分布式标志位Want.FLAG\_ABILITYSLICE\_MULTI\_DEVICE以使能分布式启动
|
||||
|
||||
```
|
||||
import ohos.aafwk.ability.Ability;
|
||||
import ohos.aafwk.content.Want;
|
||||
import ohos.bundle.ElementName;
|
||||
|
||||
// 构造want参数
|
||||
Want want = new Want();
|
||||
ElementName name = new ElementName(remote_device_id, "com.huawei.remote_bundle_name", "remote_ability_name");
|
||||
want.setElement(name); // 将待启动的FA信息添加到Want中
|
||||
want.setFlags(Want.FLAG_ABILITYSLICE_MULTI_DEVICE); // 设置分布式标记,若不设置将无法使用分布式能力
|
||||
|
||||
// 启动远程设备FA
|
||||
startAbility(want); // 按照Want启动指定FA,want参数命名以实际开发平台API为准
|
||||
```
|
||||
|
||||
- **预置条件**
|
||||
|
||||
从设备侧需安装对应包名的FA
|
||||
|
||||
- **运行**(以拉起FA为例)
|
||||
|
||||
执行主设备侧的startAbility即可拉起从设备FA
|
||||
|
||||
## 涉及仓<a name="section176111311166"></a>
|
||||
|
||||
**[分布式任务调度子系统](zh-cn_topic_0000001115719369.md)**
|
||||
|
||||
[dms\_fwk\_lite](https://gitee.com/openharmony/distributedschedule_services_dtbschedmgr_lite)
|
||||
|
||||
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 118 KiB |
Executable
BIN
Binary file not shown.
|
After Width: | Height: | Size: 65 KiB |
Executable → Regular
Executable → Regular
Executable → Regular
Executable → Regular
@@ -26,7 +26,11 @@ extern "C" {
|
||||
|
||||
enum DmsAllowedUids {
|
||||
FOUNDATION_UID = 7,
|
||||
#ifdef __LINUX__
|
||||
SHELL_UID = 0,
|
||||
#else
|
||||
SHELL_UID = 2,
|
||||
#endif
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Executable → Regular
Executable → Regular
Executable → Regular
@@ -0,0 +1,33 @@
|
||||
# Copyright (c) 2020 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/test.gni")
|
||||
|
||||
if (ohos_kernel_type == "liteos_a" || ohos_kernel_type == "linux") {
|
||||
# feature: distributed_schedule_test_dms
|
||||
unittest("distributed_schedule_test_dms") {
|
||||
output_extension = "bin"
|
||||
sources = [ "source/tlv_parse_test.cpp" ]
|
||||
|
||||
include_dirs = [ "//foundation/distributedschedule/dmsfwk_lite/include" ]
|
||||
|
||||
deps = [
|
||||
"//base/hiviewdfx/hilog_lite/frameworks/featured:hilog_shared",
|
||||
"//foundation/distributedschedule/dmsfwk_lite:dtbschedmgr",
|
||||
]
|
||||
output_dir = "$root_out_dir/test/unittest/distributedschedule"
|
||||
}
|
||||
group("unittest") {
|
||||
deps = [ ":distributed_schedule_test_dms" ]
|
||||
}
|
||||
}
|
||||
Executable
+177
@@ -0,0 +1,177 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1,429 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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 "dmslite_msg_parser.h"
|
||||
#include "dmslite_tlv_common.h"
|
||||
|
||||
using namespace testing::ext;
|
||||
|
||||
namespace OHOS {
|
||||
namespace DistributedSchedule {
|
||||
class TlvParseTest : public testing::Test {
|
||||
protected:
|
||||
static void SetUpTestCase() { }
|
||||
static void TearDownTestCase() { }
|
||||
virtual void SetUp() { }
|
||||
virtual void TearDown() { }
|
||||
|
||||
static void RunTest(const uint8_t *buffer, uint16_t bufferLen,
|
||||
const TlvParseCallback onTlvParseDone, const StartAbilityCallback onStartAbilityDone)
|
||||
{
|
||||
IDmsFeatureCallback dmsFeatureCallback = {
|
||||
.onTlvParseDone = onTlvParseDone,
|
||||
.onStartAbilityDone = onStartAbilityDone
|
||||
};
|
||||
|
||||
CommuInterInfo interInfo;
|
||||
interInfo.payloadLength = bufferLen;
|
||||
interInfo.payload = buffer;
|
||||
|
||||
DmsLiteProcessCommuMsg(&interInfo, &dmsFeatureCallback);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @tc.name: NormalPackage_001
|
||||
* @tc.desc: normal package with small bundle name and ability name
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000ELTHO
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, NormalPackage_001, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0c, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79, 0x00, 0x04,
|
||||
0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65, 0x79,
|
||||
0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
const TlvDmsMsgInfo *msg = reinterpret_cast<const TlvDmsMsgInfo *>(dmsMsg);
|
||||
EXPECT_EQ(errCode, DMS_TLV_SUCCESS);
|
||||
EXPECT_EQ(msg->commandId, 0);
|
||||
EXPECT_EQ(string(msg->calleeBundleName), "com.huawei.launcher");
|
||||
EXPECT_EQ(string(msg->calleeAbilityName), "MainAbility");
|
||||
EXPECT_EQ(string(msg->callerSignature), "publickey");
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: NormalPackageWithLongBundleName
|
||||
* @tc.desc: normal package with 255 bytes long(upper boundary) bundle name
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000ENCTK
|
||||
*/
|
||||
|
||||
HWTEST_F(TlvParseTest, NormalPackage_002, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x82, 0x00, 0x63, 0x6f, 0x6d, 0x2e, 0x61,
|
||||
0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c,
|
||||
0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77,
|
||||
0x78, 0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
|
||||
0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53,
|
||||
0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64,
|
||||
0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f,
|
||||
0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
|
||||
0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
|
||||
0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56,
|
||||
0x57, 0x58, 0x59, 0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67,
|
||||
0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72,
|
||||
0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x41, 0x42, 0x43,
|
||||
0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e,
|
||||
0x4f, 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59,
|
||||
0x5a, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a,
|
||||
0x6b, 0x6c, 0x6d, 0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75,
|
||||
0x76, 0x77, 0x78, 0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46,
|
||||
0x47, 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50, 0x51,
|
||||
0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x61, 0x62,
|
||||
0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d,
|
||||
0x6e, 0x6f, 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78,
|
||||
0x79, 0x7a, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49,
|
||||
0x4a, 0x2e, 0x68, 0x75, 0x61, 0x77, 0x65, 0x69, 0x00, 0x03, 0x0c,
|
||||
0x4d, 0x61, 0x69, 0x6e, 0x41, 0x62, 0x69, 0x6c, 0x69, 0x74, 0x79,
|
||||
0x00, 0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
const TlvDmsMsgInfo *msg = reinterpret_cast<const TlvDmsMsgInfo *>(dmsMsg);
|
||||
EXPECT_EQ(errCode, DMS_TLV_SUCCESS);
|
||||
std::stringstream ss;
|
||||
ss << "com.";
|
||||
for (int8_t i = 0; i < 4; i++) {
|
||||
ss << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
}
|
||||
ss << "abcdefghijklmnopqrstuvwxyzABCDEFGHIJ";
|
||||
ss << ".huawei";
|
||||
EXPECT_EQ(msg->commandId, 0);
|
||||
EXPECT_EQ(string(msg->calleeBundleName), ss.str());
|
||||
EXPECT_EQ(string(msg->calleeAbilityName), "MainAbility");
|
||||
EXPECT_EQ(string(msg->callerSignature), "publickey");
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageOutOfOrder_001
|
||||
* @tc.desc: abnormal package with node type sequence in disorder
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000ELTIG
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageOutOfOrder_001, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68, 0x75, 0x61, 0x77,
|
||||
0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e, 0x63, 0x68, 0x65,
|
||||
0x72, 0x01, 0x01, 0x00, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageOutOfOrder_002
|
||||
* @tc.desc: abnormal package with node type sequence in non-continuous order
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000DRR3L
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageOutOfOrder_002, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x04, 0x00, 0x04, 0x6d, 0x80, 0xff,
|
||||
0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_OUT_OF_ORDER);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadNodeNum_001
|
||||
* @tc.desc: abnormal package without node
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DGE
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadNodeNum_001, TestSize.Level0) {
|
||||
uint8_t buffer[] = { };
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadNodeNum_002
|
||||
* @tc.desc: abnormal package with only one mandatory node
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE5
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadNodeNum_002, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00,
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadNodeNum_003
|
||||
* @tc.desc: abnormal package with only two mandatory nodes
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadNodeNum_003, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadNodeNum_004
|
||||
* @tc.desc: abnormal package with only three mandatory nodes
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000DSCRF
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadNodeNum_004, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadNodeNum_005
|
||||
* @tc.desc: abnormal package with an additional node
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000DSCRB
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadNodeNum_005, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00, 0x05, 0x01, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_NODE_NUM);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_001
|
||||
* @tc.desc: abnormal package tlv node without value
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: SR000E0DR9
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_001, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_002
|
||||
* @tc.desc: abnormal package tlv node with zero-size length
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0ECR
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_002, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_003
|
||||
* @tc.desc: abnormal package with mismatched buffer size
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_003, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer) + 1, onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_004
|
||||
* @tc.desc: abnormal package with mismatched buffer size
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_004, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer) - 1, onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_005
|
||||
* @tc.desc: abnormal package with mismatched buffer size
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_005, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
bool condition = (errCode == DMS_TLV_ERR_LEN
|
||||
|| errCode == DMS_TLV_ERR_BAD_NODE_NUM);
|
||||
EXPECT_EQ(true, condition);
|
||||
};
|
||||
|
||||
RunTest(buffer, MAX_DMS_MSG_LENGTH, onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadLength_006
|
||||
* @tc.desc: abnormal package with mismatched buffer size
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadLength_006, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0x00, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0x00,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0x00
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_LEN);
|
||||
};
|
||||
|
||||
RunTest(buffer, 0, onTlvParseDone, nullptr);
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: AbnormalPackageBadSource_001
|
||||
* @tc.desc: abnormal package string field with no '\0' in the ending
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: AR000E0DE0
|
||||
*/
|
||||
HWTEST_F(TlvParseTest, AbnormalPackageBadSource_001, TestSize.Level0) {
|
||||
uint8_t buffer[] = {
|
||||
0x01, 0x01, 0x00, 0x02, 0x14, 0x63, 0x6f, 0x6d, 0x2e, 0x68,
|
||||
0x75, 0x61, 0x77, 0x65, 0x69, 0x2e, 0x6c, 0x61, 0x75, 0x6e,
|
||||
0x63, 0x68, 0x65, 0x72, 0xff, 0x03, 0x0d, 0x4d, 0x61, 0x69,
|
||||
0x6e, 0x41, 0x63, 0x74, 0x69, 0x76, 0x69, 0x74, 0x79, 0xff,
|
||||
0x04, 0x0a, 0x70, 0x75, 0x62, 0x6C, 0x69, 0x63, 0x6B, 0x65,
|
||||
0x79, 0xff
|
||||
};
|
||||
|
||||
auto onTlvParseDone = [] (int8_t errCode, const void *dmsMsg) {
|
||||
EXPECT_EQ(errCode, DMS_TLV_ERR_BAD_SOURCE);
|
||||
};
|
||||
|
||||
RunTest(buffer, sizeof(buffer), onTlvParseDone, nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
详见:https://gitee.com/openharmony/docs/blob/master/readme/分布式任务调度子系统README.md
|
||||
|
||||
see: https://gitee.com/openharmony/docs/blob/master/docs-en/readme/distributed-scheduler.md
|
||||
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "distributed_schedule_service.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "distributed_service_interface.h"
|
||||
#include "dmslite_log.h"
|
||||
|
||||
@@ -54,7 +52,6 @@ static BOOL Initialize(Service *service, Identity identity)
|
||||
}
|
||||
|
||||
((DistributedService*) service)->identity = identity;
|
||||
(void) pthread_setname_np(pthread_self(), DISTRIBUTED_SCHEDULE_SERVICE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -82,7 +79,7 @@ static TaskConfig GetTaskConfig(Service *service)
|
||||
|
||||
static void Init()
|
||||
{
|
||||
SAMGR_GetInstance()->RegisterService((Service *)&g_distributedService);
|
||||
HILOGD("[dms service start success]");
|
||||
BOOL result = SAMGR_GetInstance()->RegisterService((Service *)&g_distributedService);
|
||||
HILOGI("[dms service start %s]", result ? "success" : "failed");
|
||||
}
|
||||
SYS_SERVICE_INIT(Init);
|
||||
|
||||
+10
-4
@@ -15,8 +15,6 @@
|
||||
|
||||
#include "dmslite.h"
|
||||
|
||||
#include <pthread.h>
|
||||
|
||||
#include "dmslite_log.h"
|
||||
#include "dmslite_msg_parser.h"
|
||||
#include "dmslite_session.h"
|
||||
@@ -122,7 +120,15 @@ static void OnPublishFail(int32_t publishId, PublishFailReason reason)
|
||||
|
||||
static void Init()
|
||||
{
|
||||
SAMGR_GetInstance()->RegisterFeature(DISTRIBUTED_SCHEDULE_SERVICE, (Feature*) &g_dmslite);
|
||||
SAMGR_GetInstance()->RegisterFeatureApi(DISTRIBUTED_SCHEDULE_SERVICE, DMSLITE_FEATURE, GET_IUNKNOWN(g_dmslite));
|
||||
BOOL result = SAMGR_GetInstance()->RegisterFeature(DISTRIBUTED_SCHEDULE_SERVICE, (Feature*) &g_dmslite);
|
||||
if (!result) {
|
||||
HILOGE("[dms register feature failed]");
|
||||
}
|
||||
|
||||
result = SAMGR_GetInstance()->RegisterFeatureApi(DISTRIBUTED_SCHEDULE_SERVICE,
|
||||
DMSLITE_FEATURE, GET_IUNKNOWN(g_dmslite));
|
||||
if (!result) {
|
||||
HILOGE("[dms register feature api failed]");
|
||||
}
|
||||
}
|
||||
SYS_FEATURE_INIT(Init);
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
#include "ohos_errno.h"
|
||||
#include "session.h"
|
||||
|
||||
#define DMS_SESSION_NAME "dms"
|
||||
#define DMS_SESSION_NAME "com.huawei.harmonyos.foundation.dms"
|
||||
#define DMS_MODULE_NAME "dms"
|
||||
#define ACCEPT_SESSION_OPEN 0
|
||||
|
||||
|
||||
Executable → Regular
Reference in New Issue
Block a user