Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Startup Init Lite
提交
33075c51
S
Startup Init Lite
项目概览
OpenHarmony
/
Startup Init Lite
1 年多 前同步成功
通知
3
Star
37
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Startup Init Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
33075c51
编写于
6月 21, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 21, 2022
浏览文件
操作
浏览文件
下载
差异文件
!816 【OpenHarmony开源贡献者计划2022】去掉一部分文件中存在的windows换行符^M
Merge pull request !816 from linuxKernel/master
上级
b8112696
df26e0e2
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
2734 addition
and
2734 deletion
+2734
-2734
device_info/device_info.cpp
device_info/device_info.cpp
+72
-72
device_info/device_info_kits.cpp
device_info/device_info_kits.cpp
+92
-92
device_info/device_info_proxy.cpp
device_info/device_info_proxy.cpp
+49
-49
device_info/device_info_stub.cpp
device_info/device_info_stub.cpp
+113
-113
interfaces/innerkits/syspara/param_wrapper.cpp
interfaces/innerkits/syspara/param_wrapper.cpp
+176
-176
test/unittest/begetctl/begetctl_unittest.cpp
test/unittest/begetctl/begetctl_unittest.cpp
+140
-140
test/unittest/init/group_unittest.cpp
test/unittest/init/group_unittest.cpp
+364
-364
test/unittest/init/init_reboot_unittest.cpp
test/unittest/init/init_reboot_unittest.cpp
+58
-58
test/unittest/init/loopevent_unittest.cpp
test/unittest/init/loopevent_unittest.cpp
+327
-327
test/unittest/init/sandbox_unittest.cpp
test/unittest/init/sandbox_unittest.cpp
+277
-277
test/unittest/innerkits/modulemgr_unittest.cpp
test/unittest/innerkits/modulemgr_unittest.cpp
+137
-137
test/unittest/param/param_shell_unittest.cpp
test/unittest/param/param_shell_unittest.cpp
+218
-218
test/unittest/param/param_stub.cpp
test/unittest/param/param_stub.cpp
+418
-418
test/unittest/syspara/syspara_unittest.cpp
test/unittest/syspara/syspara_unittest.cpp
+293
-293
未找到文件。
device_info/device_info.cpp
浏览文件 @
33075c51
/*
* 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 "beget_ext.h"
#ifdef PARAM_FEATURE_DEVICEINFO
#include "device_info_kits.h"
#endif
#include "param_comm.h"
#include "securec.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
/* __cplusplus */
int
AclGetDevUdid
(
char
*
udid
,
int
size
)
{
if
(
udid
==
nullptr
||
size
<
UDID_LEN
)
{
return
-
1
;
}
#ifdef PARAM_FEATURE_DEVICEINFO
std
::
string
result
=
{};
OHOS
::
device_info
::
DeviceInfoKits
&
instance
=
OHOS
::
device_info
::
DeviceInfoKits
::
GetInstance
();
int
ret
=
instance
.
GetUdid
(
result
);
if
(
ret
==
0
)
{
ret
=
strcpy_s
(
udid
,
size
,
result
.
c_str
());
}
#else
int
ret
=
GetDevUdid_
(
udid
,
size
);
#endif
BEGET_LOGI
(
"AclGetDevUdid %s"
,
udid
);
return
ret
;
}
const
char
*
AclGetSerial
(
void
)
{
static
char
serialNumber
[
MAX_SERIAL_LEN
]
=
{
"1234567890"
};
#ifdef PARAM_FEATURE_DEVICEINFO
std
::
string
result
=
{};
OHOS
::
device_info
::
DeviceInfoKits
&
instance
=
OHOS
::
device_info
::
DeviceInfoKits
::
GetInstance
();
int
ret
=
instance
.
GetSerialID
(
result
);
if
(
ret
==
0
)
{
ret
=
strcpy_s
(
serialNumber
,
sizeof
(
serialNumber
),
result
.
c_str
());
BEGET_ERROR_CHECK
(
ret
==
0
,
return
nullptr
,
"Failed to copy"
);
}
#else
const
char
*
tmpSerial
=
GetSerial_
();
if
(
tmpSerial
!=
nullptr
)
{
int
ret
=
strcpy_s
(
serialNumber
,
sizeof
(
serialNumber
),
tmpSerial
);
BEGET_ERROR_CHECK
(
ret
==
0
,
return
nullptr
,
"Failed to copy"
);
}
#endif
BEGET_LOGI
(
"AclGetSerial %s"
,
serialNumber
);
return
serialNumber
;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
/*
* 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 "beget_ext.h"
#ifdef PARAM_FEATURE_DEVICEINFO
#include "device_info_kits.h"
#endif
#include "param_comm.h"
#include "securec.h"
#ifdef __cplusplus
#if __cplusplus
extern
"C"
{
#endif
#endif
/* __cplusplus */
int
AclGetDevUdid
(
char
*
udid
,
int
size
)
{
if
(
udid
==
nullptr
||
size
<
UDID_LEN
)
{
return
-
1
;
}
#ifdef PARAM_FEATURE_DEVICEINFO
std
::
string
result
=
{};
OHOS
::
device_info
::
DeviceInfoKits
&
instance
=
OHOS
::
device_info
::
DeviceInfoKits
::
GetInstance
();
int
ret
=
instance
.
GetUdid
(
result
);
if
(
ret
==
0
)
{
ret
=
strcpy_s
(
udid
,
size
,
result
.
c_str
());
}
#else
int
ret
=
GetDevUdid_
(
udid
,
size
);
#endif
BEGET_LOGI
(
"AclGetDevUdid %s"
,
udid
);
return
ret
;
}
const
char
*
AclGetSerial
(
void
)
{
static
char
serialNumber
[
MAX_SERIAL_LEN
]
=
{
"1234567890"
};
#ifdef PARAM_FEATURE_DEVICEINFO
std
::
string
result
=
{};
OHOS
::
device_info
::
DeviceInfoKits
&
instance
=
OHOS
::
device_info
::
DeviceInfoKits
::
GetInstance
();
int
ret
=
instance
.
GetSerialID
(
result
);
if
(
ret
==
0
)
{
ret
=
strcpy_s
(
serialNumber
,
sizeof
(
serialNumber
),
result
.
c_str
());
BEGET_ERROR_CHECK
(
ret
==
0
,
return
nullptr
,
"Failed to copy"
);
}
#else
const
char
*
tmpSerial
=
GetSerial_
();
if
(
tmpSerial
!=
nullptr
)
{
int
ret
=
strcpy_s
(
serialNumber
,
sizeof
(
serialNumber
),
tmpSerial
);
BEGET_ERROR_CHECK
(
ret
==
0
,
return
nullptr
,
"Failed to copy"
);
}
#endif
BEGET_LOGI
(
"AclGetSerial %s"
,
serialNumber
);
return
serialNumber
;
}
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
/* __cplusplus */
\ No newline at end of file
device_info/device_info_kits.cpp
浏览文件 @
33075c51
/*
* 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 "device_info_kits.h"
#include "beget_ext.h"
#include "device_info_proxy.h"
#include "idevice_info.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "securec.h"
namespace
OHOS
{
namespace
device_info
{
DeviceInfoKits
::
DeviceInfoKits
()
{}
DeviceInfoKits
::~
DeviceInfoKits
()
{}
DeviceInfoKits
&
DeviceInfoKits
::
GetInstance
()
{
return
DelayedRefSingleton
<
DeviceInfoKits
>::
GetInstance
();
}
void
DeviceInfoKits
::
ResetService
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lock_
);
if
(
deviceInfoService_
!=
nullptr
)
{
sptr
<
IRemoteObject
>
object
=
deviceInfoService_
->
AsObject
();
if
((
object
!=
nullptr
)
&&
(
remote
==
object
))
{
object
->
RemoveDeathRecipient
(
deathRecipient_
);
deviceInfoService_
=
nullptr
;
}
}
}
sptr
<
IDeviceInfo
>
DeviceInfoKits
::
GetService
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lock_
);
if
(
deviceInfoService_
!=
nullptr
)
{
return
deviceInfoService_
;
}
sptr
<
ISystemAbilityManager
>
samgr
=
SystemAbilityManagerClient
::
GetInstance
().
GetSystemAbilityManager
();
DINFO_CHECK
(
samgr
!=
nullptr
,
return
nullptr
,
"Get samgr failed"
);
sptr
<
IRemoteObject
>
object
=
samgr
->
GetSystemAbility
(
SYSPARAM_DEVICE_SERVICE_ID
);
DINFO_CHECK
(
object
!=
nullptr
,
return
nullptr
,
"Get device service object from samgr failed"
);
if
(
deathRecipient_
==
nullptr
)
{
deathRecipient_
=
new
DeathRecipient
();
}
if
((
object
->
IsProxyObject
())
&&
(
!
object
->
AddDeathRecipient
(
deathRecipient_
)))
{
DINFO_LOGE
(
"Failed to add death recipient"
);
}
deviceInfoService_
=
iface_cast
<
IDeviceInfo
>
(
object
);
if
(
deviceInfoService_
==
nullptr
)
{
DINFO_LOGE
(
"device service iface_cast failed"
);
}
return
deviceInfoService_
;
}
void
DeviceInfoKits
::
DeathRecipient
::
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
DelayedRefSingleton
<
DeviceInfoKits
>::
GetInstance
().
ResetService
(
remote
);
}
int32_t
DeviceInfoKits
::
GetUdid
(
std
::
string
&
result
)
{
auto
deviceService
=
GetService
();
DINFO_CHECK
(
deviceService
!=
nullptr
,
return
-
1
,
"Failed to get watcher manager"
);
return
deviceService
->
GetUdid
(
result
);
}
int32_t
DeviceInfoKits
::
GetSerialID
(
std
::
string
&
result
)
{
auto
deviceService
=
GetService
();
DINFO_CHECK
(
deviceService
!=
nullptr
,
return
-
1
,
"Failed to get watcher manager"
);
return
deviceService
->
GetSerialID
(
result
);
}
}
// namespace device_info
}
// namespace OHOS
/*
* 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 "device_info_kits.h"
#include "beget_ext.h"
#include "device_info_proxy.h"
#include "idevice_info.h"
#include "if_system_ability_manager.h"
#include "iservice_registry.h"
#include "system_ability_definition.h"
#include "securec.h"
namespace
OHOS
{
namespace
device_info
{
DeviceInfoKits
::
DeviceInfoKits
()
{}
DeviceInfoKits
::~
DeviceInfoKits
()
{}
DeviceInfoKits
&
DeviceInfoKits
::
GetInstance
()
{
return
DelayedRefSingleton
<
DeviceInfoKits
>::
GetInstance
();
}
void
DeviceInfoKits
::
ResetService
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lock_
);
if
(
deviceInfoService_
!=
nullptr
)
{
sptr
<
IRemoteObject
>
object
=
deviceInfoService_
->
AsObject
();
if
((
object
!=
nullptr
)
&&
(
remote
==
object
))
{
object
->
RemoveDeathRecipient
(
deathRecipient_
);
deviceInfoService_
=
nullptr
;
}
}
}
sptr
<
IDeviceInfo
>
DeviceInfoKits
::
GetService
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lock_
);
if
(
deviceInfoService_
!=
nullptr
)
{
return
deviceInfoService_
;
}
sptr
<
ISystemAbilityManager
>
samgr
=
SystemAbilityManagerClient
::
GetInstance
().
GetSystemAbilityManager
();
DINFO_CHECK
(
samgr
!=
nullptr
,
return
nullptr
,
"Get samgr failed"
);
sptr
<
IRemoteObject
>
object
=
samgr
->
GetSystemAbility
(
SYSPARAM_DEVICE_SERVICE_ID
);
DINFO_CHECK
(
object
!=
nullptr
,
return
nullptr
,
"Get device service object from samgr failed"
);
if
(
deathRecipient_
==
nullptr
)
{
deathRecipient_
=
new
DeathRecipient
();
}
if
((
object
->
IsProxyObject
())
&&
(
!
object
->
AddDeathRecipient
(
deathRecipient_
)))
{
DINFO_LOGE
(
"Failed to add death recipient"
);
}
deviceInfoService_
=
iface_cast
<
IDeviceInfo
>
(
object
);
if
(
deviceInfoService_
==
nullptr
)
{
DINFO_LOGE
(
"device service iface_cast failed"
);
}
return
deviceInfoService_
;
}
void
DeviceInfoKits
::
DeathRecipient
::
OnRemoteDied
(
const
wptr
<
IRemoteObject
>
&
remote
)
{
DelayedRefSingleton
<
DeviceInfoKits
>::
GetInstance
().
ResetService
(
remote
);
}
int32_t
DeviceInfoKits
::
GetUdid
(
std
::
string
&
result
)
{
auto
deviceService
=
GetService
();
DINFO_CHECK
(
deviceService
!=
nullptr
,
return
-
1
,
"Failed to get watcher manager"
);
return
deviceService
->
GetUdid
(
result
);
}
int32_t
DeviceInfoKits
::
GetSerialID
(
std
::
string
&
result
)
{
auto
deviceService
=
GetService
();
DINFO_CHECK
(
deviceService
!=
nullptr
,
return
-
1
,
"Failed to get watcher manager"
);
return
deviceService
->
GetSerialID
(
result
);
}
}
// namespace device_info
}
// namespace OHOS
device_info/device_info_proxy.cpp
浏览文件 @
33075c51
/*
* 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 "device_info_proxy.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "parcel.h"
#include "string_ex.h"
namespace
OHOS
{
namespace
device_info
{
int32_t
DeviceInfoProxy
::
GetUdid
(
std
::
string
&
result
)
{
MessageParcel
data
;
MessageParcel
reply
;
MessageOption
option
{
MessageOption
::
TF_SYNC
};
data
.
WriteInterfaceToken
(
DeviceInfoProxy
::
GetDescriptor
());
int32_t
ret
=
Remote
()
->
SendRequest
(
COMMAND_GET_UDID
,
data
,
reply
,
option
);
DINFO_CHECK
(
ret
==
ERR_NONE
,
return
ret
,
"getUdid failed, error code is %d"
,
ret
);
result
=
Str16ToStr8
(
reply
.
ReadString16
());
return
ERR_OK
;
}
int32_t
DeviceInfoProxy
::
GetSerialID
(
std
::
string
&
result
)
{
MessageParcel
data
;
MessageParcel
reply
;
MessageOption
option
{
MessageOption
::
TF_SYNC
};
data
.
WriteInterfaceToken
(
DeviceInfoProxy
::
GetDescriptor
());
int32_t
ret
=
Remote
()
->
SendRequest
(
COMMAND_GET_SERIAL_ID
,
data
,
reply
,
option
);
DINFO_CHECK
(
ret
==
ERR_NONE
,
return
ret
,
"GetSerial failed, error code is %d"
,
ret
);
result
=
Str16ToStr8
(
reply
.
ReadString16
());
return
ERR_OK
;
}
}
// namespace device_info
}
// namespace OHOS
/*
* 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 "device_info_proxy.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "parcel.h"
#include "string_ex.h"
namespace
OHOS
{
namespace
device_info
{
int32_t
DeviceInfoProxy
::
GetUdid
(
std
::
string
&
result
)
{
MessageParcel
data
;
MessageParcel
reply
;
MessageOption
option
{
MessageOption
::
TF_SYNC
};
data
.
WriteInterfaceToken
(
DeviceInfoProxy
::
GetDescriptor
());
int32_t
ret
=
Remote
()
->
SendRequest
(
COMMAND_GET_UDID
,
data
,
reply
,
option
);
DINFO_CHECK
(
ret
==
ERR_NONE
,
return
ret
,
"getUdid failed, error code is %d"
,
ret
);
result
=
Str16ToStr8
(
reply
.
ReadString16
());
return
ERR_OK
;
}
int32_t
DeviceInfoProxy
::
GetSerialID
(
std
::
string
&
result
)
{
MessageParcel
data
;
MessageParcel
reply
;
MessageOption
option
{
MessageOption
::
TF_SYNC
};
data
.
WriteInterfaceToken
(
DeviceInfoProxy
::
GetDescriptor
());
int32_t
ret
=
Remote
()
->
SendRequest
(
COMMAND_GET_SERIAL_ID
,
data
,
reply
,
option
);
DINFO_CHECK
(
ret
==
ERR_NONE
,
return
ret
,
"GetSerial failed, error code is %d"
,
ret
);
result
=
Str16ToStr8
(
reply
.
ReadString16
());
return
ERR_OK
;
}
}
// namespace device_info
}
// namespace OHOS
device_info/device_info_stub.cpp
浏览文件 @
33075c51
/*
* 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 "device_info_stub.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "ipc_skeleton.h"
#include "accesstoken_kit.h"
#include "parcel.h"
#include "string_ex.h"
#include "system_ability_definition.h"
#include "param_comm.h"
using
std
::
u16string
;
namespace
OHOS
{
using
namespace
Security
;
using
namespace
Security
::
AccessToken
;
namespace
device_info
{
REGISTER_SYSTEM_ABILITY_BY_ID
(
DeviceInfoService
,
SYSPARAM_DEVICE_SERVICE_ID
,
true
)
int32_t
DeviceInfoStub
::
OnRemoteRequest
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
)
{
std
::
u16string
myDescripter
=
IDeviceInfo
::
GetDescriptor
();
std
::
u16string
remoteDescripter
=
data
.
ReadInterfaceToken
();
DINFO_CHECK
(
myDescripter
==
remoteDescripter
,
return
ERR_INVALD_DESC
,
"Invalid remoteDescripter"
);
int
ret
=
ERR_FAIL
;
switch
(
code
)
{
case
COMMAND_GET_UDID
:
{
if
(
!
CheckPermission
(
data
,
PERMISSION_UDID
))
{
return
ERR_FAIL
;
}
char
localDeviceInfo
[
UDID_LEN
]
=
{
0
};
ret
=
GetDevUdid_
(
localDeviceInfo
,
UDID_LEN
);
DINFO_CHECK
(
ret
==
0
,
break
,
"Failed to get dev udid"
);
reply
.
WriteString16
(
Str8ToStr16
(
localDeviceInfo
));
break
;
}
case
COMMAND_GET_SERIAL_ID
:
{
if
(
!
CheckPermission
(
data
,
PERMISSION_UDID
))
{
return
ERR_FAIL
;
}
const
char
*
serialNumber
=
GetSerial_
();
DINFO_CHECK
(
serialNumber
!=
nullptr
,
break
,
"Failed to get serialNumber"
);
reply
.
WriteString16
(
Str8ToStr16
(
serialNumber
));
break
;
}
default:
{
return
IPCObjectStub
::
OnRemoteRequest
(
code
,
data
,
reply
,
option
);
}
}
return
ret
;
}
bool
DeviceInfoStub
::
CheckPermission
(
MessageParcel
&
data
,
const
std
::
string
&
permission
)
{
AccessTokenID
callerToken
=
IPCSkeleton
::
GetCallingTokenID
();
int32_t
result
=
TypePermissionState
::
PERMISSION_GRANTED
;
int32_t
tokenType
=
AccessTokenKit
::
GetTokenTypeFlag
(
callerToken
);
if
(
tokenType
==
TOKEN_NATIVE
)
{
result
=
AccessTokenKit
::
VerifyNativeToken
(
callerToken
,
permission
);
}
else
if
(
tokenType
==
TOKEN_HAP
)
{
result
=
AccessTokenKit
::
VerifyAccessToken
(
callerToken
,
permission
);
}
else
{
DINFO_LOGE
(
"AccessToken type:%d, permission:%d denied!"
,
tokenType
,
callerToken
);
return
false
;
}
if
(
result
==
TypePermissionState
::
PERMISSION_DENIED
)
{
DINFO_LOGE
(
"AccessTokenID:%d, permission:%s denied!"
,
callerToken
,
permission
.
c_str
());
return
false
;
}
DINFO_LOGI
(
"tokenType %d dAccessTokenID:%d, permission:%s matched!"
,
tokenType
,
callerToken
,
permission
.
c_str
());
return
true
;
}
int32_t
DeviceInfoService
::
GetUdid
(
std
::
string
&
result
)
{
return
0
;
}
int32_t
DeviceInfoService
::
GetSerialID
(
std
::
string
&
result
)
{
return
0
;
}
void
DeviceInfoService
::
OnStart
(
void
)
{
DINFO_LOGI
(
"WatcherManager OnStart"
);
bool
res
=
Publish
(
this
);
if
(
!
res
)
{
DINFO_LOGE
(
"WatcherManager Publish failed"
);
}
return
;
}
void
DeviceInfoService
::
OnStop
()
{
}
}
// namespace device_info
}
// namespace OHOS
/*
* 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 "device_info_stub.h"
#include "beget_ext.h"
#include "idevice_info.h"
#include "ipc_skeleton.h"
#include "accesstoken_kit.h"
#include "parcel.h"
#include "string_ex.h"
#include "system_ability_definition.h"
#include "param_comm.h"
using
std
::
u16string
;
namespace
OHOS
{
using
namespace
Security
;
using
namespace
Security
::
AccessToken
;
namespace
device_info
{
REGISTER_SYSTEM_ABILITY_BY_ID
(
DeviceInfoService
,
SYSPARAM_DEVICE_SERVICE_ID
,
true
)
int32_t
DeviceInfoStub
::
OnRemoteRequest
(
uint32_t
code
,
MessageParcel
&
data
,
MessageParcel
&
reply
,
MessageOption
&
option
)
{
std
::
u16string
myDescripter
=
IDeviceInfo
::
GetDescriptor
();
std
::
u16string
remoteDescripter
=
data
.
ReadInterfaceToken
();
DINFO_CHECK
(
myDescripter
==
remoteDescripter
,
return
ERR_INVALD_DESC
,
"Invalid remoteDescripter"
);
int
ret
=
ERR_FAIL
;
switch
(
code
)
{
case
COMMAND_GET_UDID
:
{
if
(
!
CheckPermission
(
data
,
PERMISSION_UDID
))
{
return
ERR_FAIL
;
}
char
localDeviceInfo
[
UDID_LEN
]
=
{
0
};
ret
=
GetDevUdid_
(
localDeviceInfo
,
UDID_LEN
);
DINFO_CHECK
(
ret
==
0
,
break
,
"Failed to get dev udid"
);
reply
.
WriteString16
(
Str8ToStr16
(
localDeviceInfo
));
break
;
}
case
COMMAND_GET_SERIAL_ID
:
{
if
(
!
CheckPermission
(
data
,
PERMISSION_UDID
))
{
return
ERR_FAIL
;
}
const
char
*
serialNumber
=
GetSerial_
();
DINFO_CHECK
(
serialNumber
!=
nullptr
,
break
,
"Failed to get serialNumber"
);
reply
.
WriteString16
(
Str8ToStr16
(
serialNumber
));
break
;
}
default:
{
return
IPCObjectStub
::
OnRemoteRequest
(
code
,
data
,
reply
,
option
);
}
}
return
ret
;
}
bool
DeviceInfoStub
::
CheckPermission
(
MessageParcel
&
data
,
const
std
::
string
&
permission
)
{
AccessTokenID
callerToken
=
IPCSkeleton
::
GetCallingTokenID
();
int32_t
result
=
TypePermissionState
::
PERMISSION_GRANTED
;
int32_t
tokenType
=
AccessTokenKit
::
GetTokenTypeFlag
(
callerToken
);
if
(
tokenType
==
TOKEN_NATIVE
)
{
result
=
AccessTokenKit
::
VerifyNativeToken
(
callerToken
,
permission
);
}
else
if
(
tokenType
==
TOKEN_HAP
)
{
result
=
AccessTokenKit
::
VerifyAccessToken
(
callerToken
,
permission
);
}
else
{
DINFO_LOGE
(
"AccessToken type:%d, permission:%d denied!"
,
tokenType
,
callerToken
);
return
false
;
}
if
(
result
==
TypePermissionState
::
PERMISSION_DENIED
)
{
DINFO_LOGE
(
"AccessTokenID:%d, permission:%s denied!"
,
callerToken
,
permission
.
c_str
());
return
false
;
}
DINFO_LOGI
(
"tokenType %d dAccessTokenID:%d, permission:%s matched!"
,
tokenType
,
callerToken
,
permission
.
c_str
());
return
true
;
}
int32_t
DeviceInfoService
::
GetUdid
(
std
::
string
&
result
)
{
return
0
;
}
int32_t
DeviceInfoService
::
GetSerialID
(
std
::
string
&
result
)
{
return
0
;
}
void
DeviceInfoService
::
OnStart
(
void
)
{
DINFO_LOGI
(
"WatcherManager OnStart"
);
bool
res
=
Publish
(
this
);
if
(
!
res
)
{
DINFO_LOGE
(
"WatcherManager Publish failed"
);
}
return
;
}
void
DeviceInfoService
::
OnStop
()
{
}
}
// namespace device_info
}
// namespace OHOS
interfaces/innerkits/syspara/param_wrapper.cpp
浏览文件 @
33075c51
/*
* Copyright (c) 2021-2022 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 "param_wrapper.h"
#include <unordered_map>
#include <vector>
#include <climits>
#include "beget_ext.h"
#include "param_comm.h"
#include "init_param.h"
#include "sysparam_errno.h"
#include "securec.h"
#include "parameter.h"
#include "parameters.h"
namespace
OHOS
{
namespace
system
{
bool
SetParameter
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
{
int
ret
=
SystemSetParameter
(
key
.
c_str
(),
value
.
c_str
());
return
(
ret
==
0
)
?
true
:
false
;
}
template
<
typename
T
>
bool
StringToInt
(
const
std
::
string
&
str
,
T
min
,
T
max
,
T
&
out
)
{
long
long
int
result
=
0
;
if
(
StringToLL
(
str
.
c_str
(),
&
result
)
!=
0
)
{
return
false
;
}
if
(
result
<
min
||
max
<
result
)
{
return
false
;
}
out
=
static_cast
<
T
>
(
result
);
return
true
;
}
template
<
typename
T
>
bool
StringToUint
(
const
std
::
string
&
str
,
T
max
,
T
&
out
)
{
unsigned
long
long
int
result
=
0
;
if
(
StringToULL
(
str
.
c_str
(),
&
result
)
!=
0
)
{
return
false
;
}
if
(
max
<
result
)
{
return
false
;
}
out
=
static_cast
<
T
>
(
result
);
return
true
;
}
std
::
string
GetParameter
(
const
std
::
string
&
key
,
const
std
::
string
&
def
)
{
uint32_t
size
=
0
;
int
ret
=
SystemReadParam
(
key
.
c_str
(),
NULL
,
&
size
);
if
(
ret
==
0
)
{
std
::
vector
<
char
>
value
(
size
+
1
);
ret
=
SystemReadParam
(
key
.
c_str
(),
value
.
data
(),
&
size
);
if
(
ret
==
0
)
{
return
std
::
string
(
value
.
data
());
}
}
if
(
IsValidParamValue
(
def
.
c_str
(),
MAX_VALUE_LEN
)
==
1
)
{
return
std
::
string
(
def
);
}
return
""
;
}
bool
GetBoolParameter
(
const
std
::
string
&
key
,
bool
def
)
{
static
const
std
::
string
trueMap
[]
=
{
"1"
,
"y"
,
"yes"
,
"on"
,
"true"
};
static
const
std
::
string
falseMap
[]
=
{
"0"
,
"off"
,
"n"
,
"no"
,
"false"
};
std
::
string
value
=
GetParameter
(
key
,
""
);
for
(
size_t
i
=
0
;
i
<
sizeof
(
trueMap
)
/
sizeof
(
trueMap
[
0
]);
i
++
)
{
if
(
trueMap
[
i
]
==
value
)
{
return
true
;
}
}
for
(
size_t
i
=
0
;
i
<
sizeof
(
falseMap
)
/
sizeof
(
falseMap
[
0
]);
i
++
)
{
if
(
falseMap
[
i
]
==
value
)
{
return
false
;
}
}
return
def
;
}
int
GetStringParameter
(
const
std
::
string
key
,
std
::
string
&
value
,
const
std
::
string
def
)
{
uint32_t
size
=
0
;
int
ret
=
SystemReadParam
(
key
.
c_str
(),
NULL
,
&
size
);
if
(
ret
==
0
)
{
std
::
vector
<
char
>
data
(
size
+
1
);
ret
=
SystemReadParam
(
key
.
c_str
(),
data
.
data
(),
&
size
);
if
(
ret
==
0
)
{
value
=
std
::
string
(
data
.
data
());
return
EC_SUCCESS
;
}
}
if
(
IsValidParamValue
(
def
.
c_str
(),
MAX_VALUE_LEN
)
==
1
)
{
value
=
std
::
string
(
def
);
return
EC_SUCCESS
;
}
return
EC_FAILURE
;
}
template
<
typename
T
>
T
GetIntParameter
(
const
std
::
string
&
key
,
T
def
,
T
min
,
T
max
)
{
if
(
!
std
::
is_signed
<
T
>::
value
)
{
return
def
;
}
T
result
;
std
::
string
value
=
GetParameter
(
key
,
""
);
if
(
!
value
.
empty
()
&&
StringToInt
(
value
,
min
,
max
,
result
))
{
return
result
;
}
return
def
;
}
template
int8_t
GetIntParameter
(
const
std
::
string
&
,
int8_t
,
int8_t
,
int8_t
);
template
int16_t
GetIntParameter
(
const
std
::
string
&
,
int16_t
,
int16_t
,
int16_t
);
template
int32_t
GetIntParameter
(
const
std
::
string
&
,
int32_t
,
int32_t
,
int32_t
);
template
int64_t
GetIntParameter
(
const
std
::
string
&
,
int64_t
,
int64_t
,
int64_t
);
template
<
typename
T
>
T
GetUintParameter
(
const
std
::
string
&
key
,
T
def
,
T
max
)
{
if
(
!
std
::
is_unsigned
<
T
>::
value
)
{
return
def
;
}
T
result
;
std
::
string
value
=
GetParameter
(
key
,
""
);
if
(
!
value
.
empty
()
&&
StringToUint
(
value
,
max
,
result
))
{
return
result
;
}
return
def
;
}
template
uint8_t
GetUintParameter
(
const
std
::
string
&
,
uint8_t
,
uint8_t
);
template
uint16_t
GetUintParameter
(
const
std
::
string
&
,
uint16_t
,
uint16_t
);
template
uint32_t
GetUintParameter
(
const
std
::
string
&
,
uint32_t
,
uint32_t
);
template
uint64_t
GetUintParameter
(
const
std
::
string
&
,
uint64_t
,
uint64_t
);
std
::
string
GetDeviceType
(
void
)
{
std
::
unordered_map
<
std
::
string
,
std
::
string
>
deviceTypeMap
=
{
{
"watch"
,
"wearable"
},
{
"fitnessWatch"
,
"liteWearable"
},
};
static
const
char
*
productType
=
nullptr
;
const
char
*
type
=
GetProperty
(
"const.build.characteristics"
,
&
productType
);
if
(
deviceTypeMap
.
count
(
type
)
!=
0
)
{
return
deviceTypeMap
[
type
];
}
return
std
::
string
(
type
);
}
int
GetIntParameter
(
const
std
::
string
key
,
int
def
)
{
return
GetIntParameter
(
key
,
def
,
INT_MIN
,
INT_MAX
);
}
}
// namespace system
/*
* Copyright (c) 2021-2022 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 "param_wrapper.h"
#include <unordered_map>
#include <vector>
#include <climits>
#include "beget_ext.h"
#include "param_comm.h"
#include "init_param.h"
#include "sysparam_errno.h"
#include "securec.h"
#include "parameter.h"
#include "parameters.h"
namespace
OHOS
{
namespace
system
{
bool
SetParameter
(
const
std
::
string
&
key
,
const
std
::
string
&
value
)
{
int
ret
=
SystemSetParameter
(
key
.
c_str
(),
value
.
c_str
());
return
(
ret
==
0
)
?
true
:
false
;
}
template
<
typename
T
>
bool
StringToInt
(
const
std
::
string
&
str
,
T
min
,
T
max
,
T
&
out
)
{
long
long
int
result
=
0
;
if
(
StringToLL
(
str
.
c_str
(),
&
result
)
!=
0
)
{
return
false
;
}
if
(
result
<
min
||
max
<
result
)
{
return
false
;
}
out
=
static_cast
<
T
>
(
result
);
return
true
;
}
template
<
typename
T
>
bool
StringToUint
(
const
std
::
string
&
str
,
T
max
,
T
&
out
)
{
unsigned
long
long
int
result
=
0
;
if
(
StringToULL
(
str
.
c_str
(),
&
result
)
!=
0
)
{
return
false
;
}
if
(
max
<
result
)
{
return
false
;
}
out
=
static_cast
<
T
>
(
result
);
return
true
;
}
std
::
string
GetParameter
(
const
std
::
string
&
key
,
const
std
::
string
&
def
)
{
uint32_t
size
=
0
;
int
ret
=
SystemReadParam
(
key
.
c_str
(),
NULL
,
&
size
);
if
(
ret
==
0
)
{
std
::
vector
<
char
>
value
(
size
+
1
);
ret
=
SystemReadParam
(
key
.
c_str
(),
value
.
data
(),
&
size
);
if
(
ret
==
0
)
{
return
std
::
string
(
value
.
data
());
}
}
if
(
IsValidParamValue
(
def
.
c_str
(),
MAX_VALUE_LEN
)
==
1
)
{
return
std
::
string
(
def
);
}
return
""
;
}
bool
GetBoolParameter
(
const
std
::
string
&
key
,
bool
def
)
{
static
const
std
::
string
trueMap
[]
=
{
"1"
,
"y"
,
"yes"
,
"on"
,
"true"
};
static
const
std
::
string
falseMap
[]
=
{
"0"
,
"off"
,
"n"
,
"no"
,
"false"
};
std
::
string
value
=
GetParameter
(
key
,
""
);
for
(
size_t
i
=
0
;
i
<
sizeof
(
trueMap
)
/
sizeof
(
trueMap
[
0
]);
i
++
)
{
if
(
trueMap
[
i
]
==
value
)
{
return
true
;
}
}
for
(
size_t
i
=
0
;
i
<
sizeof
(
falseMap
)
/
sizeof
(
falseMap
[
0
]);
i
++
)
{
if
(
falseMap
[
i
]
==
value
)
{
return
false
;
}
}
return
def
;
}
int
GetStringParameter
(
const
std
::
string
key
,
std
::
string
&
value
,
const
std
::
string
def
)
{
uint32_t
size
=
0
;
int
ret
=
SystemReadParam
(
key
.
c_str
(),
NULL
,
&
size
);
if
(
ret
==
0
)
{
std
::
vector
<
char
>
data
(
size
+
1
);
ret
=
SystemReadParam
(
key
.
c_str
(),
data
.
data
(),
&
size
);
if
(
ret
==
0
)
{
value
=
std
::
string
(
data
.
data
());
return
EC_SUCCESS
;
}
}
if
(
IsValidParamValue
(
def
.
c_str
(),
MAX_VALUE_LEN
)
==
1
)
{
value
=
std
::
string
(
def
);
return
EC_SUCCESS
;
}
return
EC_FAILURE
;
}
template
<
typename
T
>
T
GetIntParameter
(
const
std
::
string
&
key
,
T
def
,
T
min
,
T
max
)
{
if
(
!
std
::
is_signed
<
T
>::
value
)
{
return
def
;
}
T
result
;
std
::
string
value
=
GetParameter
(
key
,
""
);
if
(
!
value
.
empty
()
&&
StringToInt
(
value
,
min
,
max
,
result
))
{
return
result
;
}
return
def
;
}
template
int8_t
GetIntParameter
(
const
std
::
string
&
,
int8_t
,
int8_t
,
int8_t
);
template
int16_t
GetIntParameter
(
const
std
::
string
&
,
int16_t
,
int16_t
,
int16_t
);
template
int32_t
GetIntParameter
(
const
std
::
string
&
,
int32_t
,
int32_t
,
int32_t
);
template
int64_t
GetIntParameter
(
const
std
::
string
&
,
int64_t
,
int64_t
,
int64_t
);
template
<
typename
T
>
T
GetUintParameter
(
const
std
::
string
&
key
,
T
def
,
T
max
)
{
if
(
!
std
::
is_unsigned
<
T
>::
value
)
{
return
def
;
}
T
result
;
std
::
string
value
=
GetParameter
(
key
,
""
);
if
(
!
value
.
empty
()
&&
StringToUint
(
value
,
max
,
result
))
{
return
result
;
}
return
def
;
}
template
uint8_t
GetUintParameter
(
const
std
::
string
&
,
uint8_t
,
uint8_t
);
template
uint16_t
GetUintParameter
(
const
std
::
string
&
,
uint16_t
,
uint16_t
);
template
uint32_t
GetUintParameter
(
const
std
::
string
&
,
uint32_t
,
uint32_t
);
template
uint64_t
GetUintParameter
(
const
std
::
string
&
,
uint64_t
,
uint64_t
);
std
::
string
GetDeviceType
(
void
)
{
std
::
unordered_map
<
std
::
string
,
std
::
string
>
deviceTypeMap
=
{
{
"watch"
,
"wearable"
},
{
"fitnessWatch"
,
"liteWearable"
},
};
static
const
char
*
productType
=
nullptr
;
const
char
*
type
=
GetProperty
(
"const.build.characteristics"
,
&
productType
);
if
(
deviceTypeMap
.
count
(
type
)
!=
0
)
{
return
deviceTypeMap
[
type
];
}
return
std
::
string
(
type
);
}
int
GetIntParameter
(
const
std
::
string
key
,
int
def
)
{
return
GetIntParameter
(
key
,
def
,
INT_MIN
,
INT_MAX
);
}
}
// namespace system
}
// namespace OHOS
\ No newline at end of file
test/unittest/begetctl/begetctl_unittest.cpp
浏览文件 @
33075c51
/*
* 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 "begetctl.h"
#include "param_stub.h"
#include "securec.h"
#include "shell.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
class
BegetctlUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{
PrepareInitUnitTestEnv
();
};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
};
HWTEST_F
(
BegetctlUnitTest
,
TestShellInit
,
TestSize
.
Level0
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
1
,
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLs
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"ls"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithR
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsGet
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"get"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellSet
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"set"
,
"aaaaa"
,
"1234567"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellGetWithKey
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"get"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWait
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitFalse
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitWithKey
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
,
"12*"
,
"30"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellParamShell
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"shell"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalue
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
BShellEnvSetParam
(
GetShellHandle
(),
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"..a"
,
PARAM_STRING
,
(
void
*
)
"..a"
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalueExist
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
BShellEnvSetParam
(
GetShellHandle
(),
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"#"
,
PARAM_STRING
,
(
void
*
)
"#"
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
}
// namespace init_ut
/*
* 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 "begetctl.h"
#include "param_stub.h"
#include "securec.h"
#include "shell.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
class
BegetctlUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{
PrepareInitUnitTestEnv
();
};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
};
HWTEST_F
(
BegetctlUnitTest
,
TestShellInit
,
TestSize
.
Level0
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
1
,
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLs
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"ls"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithR
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsGet
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"get"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellSet
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"set"
,
"aaaaa"
,
"1234567"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellGetWithKey
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"get"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWait
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitFalse
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellWaitWithKey
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"wait"
,
"aaaaa"
,
"12*"
,
"30"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellParamShell
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
const
char
*
args
[]
=
{
"param"
,
"shell"
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalue
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
BShellEnvSetParam
(
GetShellHandle
(),
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"..a"
,
PARAM_STRING
,
(
void
*
)
"..a"
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
HWTEST_F
(
BegetctlUnitTest
,
TestShellLsWithvalueExist
,
TestSize
.
Level1
)
{
BShellParamCmdRegister
(
GetShellHandle
(),
0
);
BShellEnvSetParam
(
GetShellHandle
(),
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"#"
,
PARAM_STRING
,
(
void
*
)
"#"
);
const
char
*
args
[]
=
{
"param"
,
"ls"
,
"-r"
,
PARAM_REVERESD_NAME_CURR_PARAMETER
};
BShellEnvDirectExecute
(
GetShellHandle
(),
sizeof
(
args
)
/
sizeof
(
args
[
0
]),
(
char
**
)
args
);
}
}
// namespace init_ut
test/unittest/init/group_unittest.cpp
浏览文件 @
33075c51
此差异已折叠。
点击以展开。
test/unittest/init/init_reboot_unittest.cpp
浏览文件 @
33075c51
/*
* 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 <sys/statvfs.h>
#include "init_cmds.h"
#include "init_reboot.h"
#include "init_param.h"
#include "param_stub.h"
#include "init_utils.h"
#include "trigger_manager.h"
#include "init_group_manager.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
namespace
init_ut
{
class
InitRebootUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
()
{};
void
TearDown
()
{};
};
HWTEST_F
(
InitRebootUnitTest
,
TestInitReboot
,
TestSize
.
Level1
)
{
ExecReboot
(
"reboot"
);
ExecReboot
(
"reboot,shutdown"
);
ExecReboot
(
"reboot,bootloader"
);
ExecReboot
(
"reboot,updater:123"
);
ExecReboot
(
"reboot,flash:123"
);
ExecReboot
(
"reboot,flashd:123"
);
ExecReboot
(
"reboot,suspend:123"
);
const
char
*
option
=
nullptr
;
int
ret
=
DoReboot
(
option
);
EXPECT_EQ
(
ret
,
0
);
option
=
"updater"
;
ret
=
DoReboot
(
option
);
EXPECT_EQ
(
ret
,
0
);
ret
=
DoReboot
(
DEVICE_CMD_SUSPEND
);
EXPECT_EQ
(
ret
,
0
);
ret
=
DoReboot
(
DEVICE_CMD_FREEZE
);
EXPECT_EQ
(
ret
,
0
);
clearMisc
();
}
}
// namespace init_ut
/*
* 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 <sys/statvfs.h>
#include "init_cmds.h"
#include "init_reboot.h"
#include "init_param.h"
#include "param_stub.h"
#include "init_utils.h"
#include "trigger_manager.h"
#include "init_group_manager.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
namespace
init_ut
{
class
InitRebootUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
()
{};
void
TearDown
()
{};
};
HWTEST_F
(
InitRebootUnitTest
,
TestInitReboot
,
TestSize
.
Level1
)
{
ExecReboot
(
"reboot"
);
ExecReboot
(
"reboot,shutdown"
);
ExecReboot
(
"reboot,bootloader"
);
ExecReboot
(
"reboot,updater:123"
);
ExecReboot
(
"reboot,flash:123"
);
ExecReboot
(
"reboot,flashd:123"
);
ExecReboot
(
"reboot,suspend:123"
);
const
char
*
option
=
nullptr
;
int
ret
=
DoReboot
(
option
);
EXPECT_EQ
(
ret
,
0
);
option
=
"updater"
;
ret
=
DoReboot
(
option
);
EXPECT_EQ
(
ret
,
0
);
ret
=
DoReboot
(
DEVICE_CMD_SUSPEND
);
EXPECT_EQ
(
ret
,
0
);
ret
=
DoReboot
(
DEVICE_CMD_FREEZE
);
EXPECT_EQ
(
ret
,
0
);
clearMisc
();
}
}
// namespace init_ut
test/unittest/init/loopevent_unittest.cpp
浏览文件 @
33075c51
此差异已折叠。
点击以展开。
test/unittest/init/sandbox_unittest.cpp
浏览文件 @
33075c51
此差异已折叠。
点击以展开。
test/unittest/innerkits/modulemgr_unittest.cpp
浏览文件 @
33075c51
/*
* 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 "init_cmds.h"
#include "init_group_manager.h"
#include "init_hashmap.h"
#include "init_param.h"
#include "init_module_engine.h"
#include "init_cmdexecutor.h"
#include "param_stub.h"
#include "init_utils.h"
#include "securec.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
namespace
init_ut
{
class
ModuleMgrUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
};
int
g_cmdExecId
=
0
;
int
TestCmdExecutor
(
int
id
,
const
char
*
name
,
int
argc
,
const
char
**
argv
)
{
printf
(
"TestCmdExecutor id %d, name %s
\n
"
,
id
,
name
);
g_cmdExecId
=
id
;
return
0
;
}
HWTEST_F
(
ModuleMgrUnitTest
,
PluginAddCmd
,
TestSize
.
Level1
)
{
InitServiceSpace
();
const
char
*
testName
=
"testCmd1"
;
const
char
*
cmdContent
=
"testCmd1 test1 test2 test3"
;
const
char
*
cmdContentNotValid
=
"testCmd1 t e s t 1 t e s t 2 t"
;
int
cmdExecId1
=
AddCmdExecutor
(
testName
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId1
>
0
,
0
);
int
cmdExecId2
=
AddCmdExecutor
(
"testCmd2"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId2
>
0
,
0
);
cmdExecId2
=
AddCmdExecutor
(
"testCmd3"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId2
>
0
,
0
);
int
cmdExecId4
=
AddCmdExecutor
(
"testCmd4"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId4
>
0
,
0
);
PluginExecCmd
(
"testCmd4"
,
0
,
nullptr
);
int
cmdIndex
=
0
;
const
char
*
cmdName
=
PluginGetCmdIndex
(
cmdContent
,
&
cmdIndex
);
ASSERT_EQ
(
strcmp
(
cmdName
,
testName
),
0
);
printf
(
"TestCmdExecutor cmdIndex 0x%04x, name %s
\n
"
,
cmdIndex
,
cmdName
);
// exec
g_cmdExecId
=
-
1
;
PluginExecCmdByName
(
cmdName
,
cmdContent
);
ASSERT_EQ
(
cmdExecId1
,
g_cmdExecId
);
PluginExecCmdByName
(
cmdName
,
nullptr
);
PluginExecCmdByName
(
cmdName
,
cmdContentNotValid
);
g_cmdExecId
=
-
1
;
PluginExecCmdByCmdIndex
(
cmdIndex
,
cmdContent
);
ASSERT_EQ
(
cmdExecId1
,
g_cmdExecId
);
const
char
*
argv
[]
=
{
"test"
};
PluginExecCmd
(
"install"
,
1
,
argv
);
PluginExecCmd
(
"uninstall"
,
1
,
argv
);
// del
RemoveCmdExecutor
(
"testCmd4"
,
cmdExecId4
);
}
HWTEST_F
(
ModuleMgrUnitTest
,
ModuleInstallTest
,
TestSize
.
Level1
)
{
int
ret
;
int
cnt
;
// Create module manager
MODULE_MGR
*
moduleMgr
=
ModuleMgrCreate
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install one module
ret
=
ModuleMgrInstall
(
moduleMgr
,
"libbootchart"
,
0
,
NULL
);
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"libbootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install two module
ret
=
ModuleMgrInstall
(
moduleMgr
,
"libbootchart"
,
0
,
NULL
);
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
ret
=
ModuleMgrInstall
(
moduleMgr
,
"notexist"
,
0
,
NULL
);
ASSERT_NE
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"libbootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrUninstall
(
moduleMgr
,
"notexist"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrDestroy
(
moduleMgr
);
// Scan all modules
moduleMgr
=
ModuleMgrScan
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_NE
(
cnt
,
0
);
ModuleMgrUninstall
(
moduleMgr
,
NULL
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrGetArgs
();
ModuleMgrDestroy
(
moduleMgr
);
}
}
// namespace init_ut
/*
* 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 "init_cmds.h"
#include "init_group_manager.h"
#include "init_hashmap.h"
#include "init_param.h"
#include "init_module_engine.h"
#include "init_cmdexecutor.h"
#include "param_stub.h"
#include "init_utils.h"
#include "securec.h"
using
namespace
testing
::
ext
;
using
namespace
std
;
namespace
init_ut
{
class
ModuleMgrUnitTest
:
public
testing
::
Test
{
public:
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
};
int
g_cmdExecId
=
0
;
int
TestCmdExecutor
(
int
id
,
const
char
*
name
,
int
argc
,
const
char
**
argv
)
{
printf
(
"TestCmdExecutor id %d, name %s
\n
"
,
id
,
name
);
g_cmdExecId
=
id
;
return
0
;
}
HWTEST_F
(
ModuleMgrUnitTest
,
PluginAddCmd
,
TestSize
.
Level1
)
{
InitServiceSpace
();
const
char
*
testName
=
"testCmd1"
;
const
char
*
cmdContent
=
"testCmd1 test1 test2 test3"
;
const
char
*
cmdContentNotValid
=
"testCmd1 t e s t 1 t e s t 2 t"
;
int
cmdExecId1
=
AddCmdExecutor
(
testName
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId1
>
0
,
0
);
int
cmdExecId2
=
AddCmdExecutor
(
"testCmd2"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId2
>
0
,
0
);
cmdExecId2
=
AddCmdExecutor
(
"testCmd3"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId2
>
0
,
0
);
int
cmdExecId4
=
AddCmdExecutor
(
"testCmd4"
,
TestCmdExecutor
);
ASSERT_NE
(
cmdExecId4
>
0
,
0
);
PluginExecCmd
(
"testCmd4"
,
0
,
nullptr
);
int
cmdIndex
=
0
;
const
char
*
cmdName
=
PluginGetCmdIndex
(
cmdContent
,
&
cmdIndex
);
ASSERT_EQ
(
strcmp
(
cmdName
,
testName
),
0
);
printf
(
"TestCmdExecutor cmdIndex 0x%04x, name %s
\n
"
,
cmdIndex
,
cmdName
);
// exec
g_cmdExecId
=
-
1
;
PluginExecCmdByName
(
cmdName
,
cmdContent
);
ASSERT_EQ
(
cmdExecId1
,
g_cmdExecId
);
PluginExecCmdByName
(
cmdName
,
nullptr
);
PluginExecCmdByName
(
cmdName
,
cmdContentNotValid
);
g_cmdExecId
=
-
1
;
PluginExecCmdByCmdIndex
(
cmdIndex
,
cmdContent
);
ASSERT_EQ
(
cmdExecId1
,
g_cmdExecId
);
const
char
*
argv
[]
=
{
"test"
};
PluginExecCmd
(
"install"
,
1
,
argv
);
PluginExecCmd
(
"uninstall"
,
1
,
argv
);
// del
RemoveCmdExecutor
(
"testCmd4"
,
cmdExecId4
);
}
HWTEST_F
(
ModuleMgrUnitTest
,
ModuleInstallTest
,
TestSize
.
Level1
)
{
int
ret
;
int
cnt
;
// Create module manager
MODULE_MGR
*
moduleMgr
=
ModuleMgrCreate
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install one module
ret
=
ModuleMgrInstall
(
moduleMgr
,
"libbootchart"
,
0
,
NULL
);
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"libbootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
// Install two module
ret
=
ModuleMgrInstall
(
moduleMgr
,
"libbootchart"
,
0
,
NULL
);
ASSERT_EQ
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
ret
=
ModuleMgrInstall
(
moduleMgr
,
"notexist"
,
0
,
NULL
);
ASSERT_NE
(
ret
,
0
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
1
);
// Uninstall the module
ModuleMgrUninstall
(
moduleMgr
,
"libbootchart"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrUninstall
(
moduleMgr
,
"notexist"
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrDestroy
(
moduleMgr
);
// Scan all modules
moduleMgr
=
ModuleMgrScan
(
"init"
);
ASSERT_NE
(
moduleMgr
,
nullptr
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_NE
(
cnt
,
0
);
ModuleMgrUninstall
(
moduleMgr
,
NULL
);
cnt
=
ModuleMgrGetCnt
(
moduleMgr
);
ASSERT_EQ
(
cnt
,
0
);
ModuleMgrGetArgs
();
ModuleMgrDestroy
(
moduleMgr
);
}
}
// namespace init_ut
test/unittest/param/param_shell_unittest.cpp
浏览文件 @
33075c51
/*
* 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 "begetctl.h"
#include "securec.h"
#include "shell.h"
#include "shell_utils.h"
#include "shell_bas.h"
#include "init_param.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
class
ParamShellUnitTest
:
public
testing
::
Test
{
public:
ParamShellUnitTest
()
{};
virtual
~
ParamShellUnitTest
()
{};
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
void
TestBody
(
void
)
{};
void
TestInitParamShell
()
{
SystemSetParameter
(
"aaa"
,
"aaa"
);
BShellHandle
bshd
=
GetShellHandle
();
if
(
bshd
==
nullptr
)
{
return
;
}
const
char
*
args
[]
=
{
"paramshell"
,
"
\n
"
};
const
ParamInfo
*
param
=
BShellEnvGetReservedParam
(
bshd
,
PARAM_REVERESD_NAME_CURR_PARAMETER
);
int
ret
=
BShellEnvSetParam
(
bshd
,
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"..a"
,
PARAM_STRING
,
(
void
*
)
"..a"
);
EXPECT_EQ
(
ret
,
0
);
SetParamShellPrompt
(
bshd
,
args
[
1
]);
SetParamShellPrompt
(
bshd
,
".."
);
ret
=
BShellEnvSetParam
(
bshd
,
param
->
name
,
param
->
desc
,
param
->
type
,
(
void
*
)
""
);
SetParamShellPrompt
(
bshd
,
".."
);
SetParamShellPrompt
(
bshd
,
".a"
);
SetParamShellPrompt
(
bshd
,
"."
);
SetParamShellPrompt
(
bshd
,
args
[
1
]);
BShellParamCmdRegister
(
bshd
,
1
);
BShellEnvStart
(
bshd
);
ret
=
BShellEnvOutputPrompt
(
bshd
,
"testprompt"
);
ret
=
BShellEnvOutputPrompt
(
bshd
,
"testprompt1111111111111111111111111111111111111111111111111111111111"
);
BShellEnvOutputByte
(
bshd
,
'o'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cd const"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cat aaa"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testnotcmd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test param start with "
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"
\"
ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test argc is 0
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
",ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"$test$"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"exit"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd1
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"pwd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"help"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump verbose"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellcmdEndkey
()
{
BShellHandle
bshd
=
GetShellHandle
();
bshd
->
input
(
nullptr
,
0
);
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\b'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
"testb"
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
key
=
BShellEnvGetDefaultKey
(
'\t'
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testtab"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\t'
);
EXPECT_NE
(
key
,
nullptr
);
BShellEnvProcessInput
(
bshd
,
(
char
)
3
);
// 3 is ctrl c
BShellEnvProcessInput
(
bshd
,
'\e'
);
BShellEnvProcessInput
(
bshd
,
'['
);
bshd
->
length
=
1
;
bshd
->
cursor
=
1
;
BShellEnvProcessInput
(
bshd
,
'C'
);
BShellEnvProcessInput
(
bshd
,
'D'
);
}
};
HWTEST_F
(
ParamShellUnitTest
,
TestInitParamShell
,
TestSize
.
Level1
)
{
ParamShellUnitTest
test
;
test
.
TestInitParamShell
();
test
.
TestParamShellCmd
();
test
.
TestParamShellCmd1
();
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellInput
,
TestSize
.
Level1
)
{
BShellHandle
bshd
=
GetShellHandle
();
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
BSH_COMMAND_MAX_LENGTH
;
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
sizeof
(
'l'
);
bshd
->
cursor
=
0
;
BShellEnvProcessInput
(
bshd
,
's'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
// test bshd buff length is 0
int
ret
=
BShellEnvRegisterKeyHandle
(
bshd
,
'z'
,
(
BShellkeyHandle
)(
void
*
)
0x409600
);
// 0x409600 construct address
EXPECT_EQ
(
ret
,
0
);
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellcmd2
,
TestSize
.
Level1
)
{
ParamShellUnitTest
test
;
test
.
TestParamShellcmdEndkey
();
GetSystemCommitId
();
BShellEnvLoop
(
nullptr
);
BShellEnvErrString
(
GetShellHandle
(),
1
);
BShellEnvOutputResult
(
GetShellHandle
(),
1
);
demoExit
();
}
}
// namespace init_ut
/*
* 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 "begetctl.h"
#include "securec.h"
#include "shell.h"
#include "shell_utils.h"
#include "shell_bas.h"
#include "init_param.h"
using
namespace
std
;
using
namespace
testing
::
ext
;
namespace
init_ut
{
class
ParamShellUnitTest
:
public
testing
::
Test
{
public:
ParamShellUnitTest
()
{};
virtual
~
ParamShellUnitTest
()
{};
static
void
SetUpTestCase
(
void
)
{};
static
void
TearDownTestCase
(
void
)
{};
void
SetUp
(
void
)
{};
void
TearDown
(
void
)
{};
void
TestBody
(
void
)
{};
void
TestInitParamShell
()
{
SystemSetParameter
(
"aaa"
,
"aaa"
);
BShellHandle
bshd
=
GetShellHandle
();
if
(
bshd
==
nullptr
)
{
return
;
}
const
char
*
args
[]
=
{
"paramshell"
,
"
\n
"
};
const
ParamInfo
*
param
=
BShellEnvGetReservedParam
(
bshd
,
PARAM_REVERESD_NAME_CURR_PARAMETER
);
int
ret
=
BShellEnvSetParam
(
bshd
,
PARAM_REVERESD_NAME_CURR_PARAMETER
,
"..a"
,
PARAM_STRING
,
(
void
*
)
"..a"
);
EXPECT_EQ
(
ret
,
0
);
SetParamShellPrompt
(
bshd
,
args
[
1
]);
SetParamShellPrompt
(
bshd
,
".."
);
ret
=
BShellEnvSetParam
(
bshd
,
param
->
name
,
param
->
desc
,
param
->
type
,
(
void
*
)
""
);
SetParamShellPrompt
(
bshd
,
".."
);
SetParamShellPrompt
(
bshd
,
".a"
);
SetParamShellPrompt
(
bshd
,
"."
);
SetParamShellPrompt
(
bshd
,
args
[
1
]);
BShellParamCmdRegister
(
bshd
,
1
);
BShellEnvStart
(
bshd
);
ret
=
BShellEnvOutputPrompt
(
bshd
,
"testprompt"
);
ret
=
BShellEnvOutputPrompt
(
bshd
,
"testprompt1111111111111111111111111111111111111111111111111111111111"
);
BShellEnvOutputByte
(
bshd
,
'o'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cd const"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"cat aaa"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testnotcmd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test param start with "
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"
\"
ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
// test argc is 0
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
",ls"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"$test$"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"exit"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellCmd1
()
{
BShellHandle
bshd
=
GetShellHandle
();
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\n'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"pwd"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"help"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"dump verbose"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\n'
);
EXPECT_EQ
(
ret
,
0
);
}
void
TestParamShellcmdEndkey
()
{
BShellHandle
bshd
=
GetShellHandle
();
bshd
->
input
(
nullptr
,
0
);
BShellKey
*
key
=
BShellEnvGetDefaultKey
(
'\b'
);
EXPECT_NE
(
key
,
nullptr
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
"testb"
);
int
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testbbackspace"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
bshd
->
cursor
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\b'
);
EXPECT_EQ
(
ret
,
0
);
key
=
BShellEnvGetDefaultKey
(
'\t'
);
if
(
strcpy_s
(
bshd
->
buffer
,
sizeof
(
bshd
->
buffer
),
"testtab"
)
!=
EOK
)
{
return
;
}
bshd
->
length
=
strlen
(
bshd
->
buffer
);
ret
=
key
->
keyHandle
(
bshd
,
'\t'
);
EXPECT_NE
(
key
,
nullptr
);
BShellEnvProcessInput
(
bshd
,
(
char
)
3
);
// 3 is ctrl c
BShellEnvProcessInput
(
bshd
,
'\e'
);
BShellEnvProcessInput
(
bshd
,
'['
);
bshd
->
length
=
1
;
bshd
->
cursor
=
1
;
BShellEnvProcessInput
(
bshd
,
'C'
);
BShellEnvProcessInput
(
bshd
,
'D'
);
}
};
HWTEST_F
(
ParamShellUnitTest
,
TestInitParamShell
,
TestSize
.
Level1
)
{
ParamShellUnitTest
test
;
test
.
TestInitParamShell
();
test
.
TestParamShellCmd
();
test
.
TestParamShellCmd1
();
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellInput
,
TestSize
.
Level1
)
{
BShellHandle
bshd
=
GetShellHandle
();
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
BSH_COMMAND_MAX_LENGTH
;
BShellEnvProcessInput
(
bshd
,
'l'
);
bshd
->
length
=
sizeof
(
'l'
);
bshd
->
cursor
=
0
;
BShellEnvProcessInput
(
bshd
,
's'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
BShellEnvProcessInput
(
bshd
,
'\n'
);
// test bshd buff length is 0
int
ret
=
BShellEnvRegisterKeyHandle
(
bshd
,
'z'
,
(
BShellkeyHandle
)(
void
*
)
0x409600
);
// 0x409600 construct address
EXPECT_EQ
(
ret
,
0
);
}
HWTEST_F
(
ParamShellUnitTest
,
TestParamShellcmd2
,
TestSize
.
Level1
)
{
ParamShellUnitTest
test
;
test
.
TestParamShellcmdEndkey
();
GetSystemCommitId
();
BShellEnvLoop
(
nullptr
);
BShellEnvErrString
(
GetShellHandle
(),
1
);
BShellEnvOutputResult
(
GetShellHandle
(),
1
);
demoExit
();
}
}
// namespace init_ut
test/unittest/param/param_stub.cpp
浏览文件 @
33075c51
此差异已折叠。
点击以展开。
test/unittest/syspara/syspara_unittest.cpp
浏览文件 @
33075c51
此差异已折叠。
点击以展开。
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录