提交 77fcf328 编写于 作者: W wenjun

add OpenHarmony 1.0 baseline

上级 6725a1b2
### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
# 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("//test/xts/tools/build/suite_lite.gni")
import("//build/lite/config/subsystem/aafwk/config.gni")
lite_component("acts_compoment") {
all_features = []
features = []
if (ohos_xts_test_args != "") {
all_features += [ ohos_xts_test_args ]
} else {
if(ohos_kernel_type == "liteos_riscv") {
all_features += [
"//test/xts/acts/communication_lite/lwip_hal:ActsLwipTest",
"//test/xts/acts/communication_lite/softbus_hal:ActsSoftBusTest",
"//test/xts/acts/communication_lite/wifiservice_hal:ActsWifiServiceTest",
"//test/xts/acts/utils_lite/utilsfile_hal:ActsUtilsFileTest",
"//test/xts/acts/utils_lite/parameter_hal:ActsParameterTest",
"//test/xts/acts/iot_hardware_lite/wifiiot_hal:ActsWifiIotTest",
"//test/xts/acts/kernel_lite/kernelcmsis_hal:ActsCMSISTest",
"//test/xts/acts/kernel_lite/kernelkal_hal:ActsKalTest",
"//test/xts/acts/hiviewdfx_lite/dfx_hal:ActsDfxFuncTest",
"//test/xts/acts/utils_lite/kvstore_hal:ActsKvStoreTest",
"//test/xts/acts/security_lite/datahuks_hal:ActsSecurityDataTest",
"//test/xts/acts/distributedschedule_lite/samgr_hal:ActsSamgrTest",
]
} else if(ohos_kernel_type == "liteos_a") {
all_features += [
"//test/xts/acts/kernel_lite:ActsKernelTest",
"//test/xts/acts/security_lite:securitytest",
"//test/xts/acts/utils_lite/kvstore_posix:ActsKvStoreTest",
"//test/xts/acts/startup_lite/parameter_posix:ActsParameterTest",
"//test/xts/acts/startup_lite/bootstrap_posix:ActsBootstrapTest",
#"//test/xts/acts/multimedia_lite/multimedia_posix/camera:ActsMediaCameraTest",
"//test/xts/acts/open_posix_testsuite/conformance/interfaces:ActsOpenPosixTest",
"//test/xts/acts/distributedschedule_lite/samgr_posix:ActsSamgrTest",
#"//test/xts/acts/multimedia_lite/multimedia_posix/recorder:ActsMediaRecorderTest",
#"//test/xts/acts/uikit_lite:uikit_test",
"//test/xts/acts/appexecfwk_lite/bundlems_posix:ActsBundleMgrTest",
"//test/xts/acts/communication_lite/softbus_posix:ActsSoftBusTest",
"//test/xts/acts/communication_lite/lwip_posix:ActsLwipTest",
]
if (enable_ohos_appexecfwk_feature_ability == true) {
all_features += [
"//test/xts/acts/appexecfwk_lite/abilityms_posix:ActsAbilityMgrTest",
]
}
} else if(ohos_kernel_type == "linux") {
all_features += [
"//test/xts/acts/utils_lite/kvstore_posix:ActsKvStoreTest",
"//test/xts/acts/startup_lite/parameter_posix:ActsParameterTest"
]
}
}
if (ohos_build_type == "debug") {
_all_features = ""
_product_json = rebase_path("//build/lite/product/${product}.json")
foreach(one_feature, all_features) {
_all_features = _all_features + one_feature + ","
}
_args = [
"--method_name", "filter_by_subsystem",
"--arguments", "testsuites=${_all_features}#product_json=${_product_json}"
]
features += exec_script(rebase_path("//test/xts/tools/build/utils.py"), _args, "list lines")
}
}
test_suite("acts") {
deps = [ ":acts_compoment" ]
version = "OpenHarmony-ACTS-1.11.0"
if (ohos_kernel_type == "liteos_a") {
deps += [ "//test/xts/tools/others/query:query" ]
copy("query_copy") {
sources = ["$root_out_dir/bin/query.bin"]
outputs = ["$root_out_dir/suites/acts/resource/tools/query.bin"]
}
}
}
generate_notice_file("acts_notice_file") {
module_name = "acts"
module_source_dir_list = [
"//third_party/googletest",
"//third_party/unity",
"//third_party/bounds_checking_function",
"//third_party/iniparser"
]
}
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
\ No newline at end of file
# 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("//test/xts/tools/build/suite_lite.gni")
import("//build/lite/config/subsystem/aafwk/config.gni")
hcpptest_suite("ActsAbilityMgrTest") {
suite_name = "acts"
sources = [
"src/AbilityMgrTest.cpp"
]
ldflags = [
"-lstdc++",
]
deps = [
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
"//foundation/aafwk/frameworks/ability_lite:aafwk_abilitykit_lite",
"//foundation/appexecfwk/frameworks/bundle_lite:bundle",
"//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
"//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
"//utils/native/lite/kv_store:kv_store",
]
if (enable_ohos_appexecfwk_feature_ability == true) {
deps += [
"//foundation/graphic/lite/frameworks/ui:ui",
"//foundation/graphic/lite/utils:graphic_utils",
"//foundation/graphic/lite/frameworks/surface",
]
}
include_dirs = [
"src",
"//third_party/googletest/googletest/include",
"//foundation/aafwk/interfaces/innerkits/abilitymgr_lite",
"//foundation/aafwk/interfaces/kits/ability_lite",
"//foundation/aafwk/interfaces/kits/want_lite",
"//foundation/aafwk/services/abilitymgr_lite/include",
"//foundation/aafwk/frameworks/abilitymgr_lite/include",
"//foundation/appexecfwk/interfaces/kits/bundle_lite/",
"//foundation/appexecfwk/utils/bundle_lite",
"//foundation/appexecfwk/interfaces/innerkits/bundlemgr_lite/",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//kernel/liteos_a/kernel/include",
"//kernel/liteos_a/kernel/common",
"//third_party/bounds_checking_function/include",
"//third_party/cJSON",
"//utils/native/lite/include",
"//kernel/liteos_a/lib/libsec/include",
"//foundation/appexecfwk/interfaces/innerkits/bundlemgr_lite",
"//foundation/graphic/lite/interfaces/kits/ui",
"//foundation/graphic/lite/interfaces/kits/utils",
"//foundation/graphic/lite/interfaces/kits/config",
]
cflags = [ "-Wno-error" ]
defines = ["OHOS_APPEXECFWK_BMS_BUNDLEMANAGER",
"ABILITY_WINDOW_SUPPORT",
]
}
{
"description": "Config for abilityms test cases",
"environment": [
{
"type": "device",
"label": "ipcamera"
}
],
"kits": [
{
"type": "MountKit",
"server": "NfsServer",
"mount": [
{
"source": "testcases/appexecfwk",
"target": "/test_root/appexecfwk"
},{
"source": "resource/appexecfwk",
"target": "/test_root/appexecfwk"
}
]
}
],
"driver": {
"type": "CppTestLite",
"execute": "/test_root/appexecfwk/ActsAbilityMgrTest.bin"
}
}
\ No newline at end of file
此差异已折叠。
# 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("//test/xts/tools/build/suite_lite.gni")
hcpptest_suite("ActsBundleMgrTest") {
suite_name = "acts"
sources = [
"src/BundleMgrTest.cpp"
]
include_dirs = [
"src",
"//foundation/aafwk/interfaces/innerkits/abilitymgr_lite",
"//foundation/aafwk/interfaces/kits/ability_lite",
"//foundation/aafwk/interfaces/kits/want_lite",
"//foundation/aafwk/services/abilitymgr_lite/include",
"//foundation/appexecfwk/interfaces/kits/bundle_lite/",
"//foundation/appexecfwk/utils/bundle_lite",
"//foundation/appexecfwk/interfaces/innerkits/bundlemgr_lite/",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
"//third_party/googletest/googletest/include",
"//utils/native/lite/include",
"//foundation/aafwk/interfaces/innerkits/intent_lite",
"//kernel/liteos_a/kernel/include",
"//kernel/liteos_a/kernel/common",
"//third_party/cJSON",
]
ldflags = [
"-lstdc++",
]
deps = [
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
"//foundation/appexecfwk/frameworks/bundle_lite:bundle",
"//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
"//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
]
cflags = [ "-Wno-error" ]
defines = ["OHOS_APPEXECFWK_BMS_BUNDLEMANAGER"]
}
{
"description": "Config for bundlemgr test cases",
"environment": [
{
"type": "device",
"label": "ipcamera"
}
],
"kits": [
{
"type": "MountKit",
"server": "NfsServer",
"mount": [
{
"source": "testcases/appexecfwk",
"target": "/test_root/appexecfwk"
},{
"source": "resource/appexecfwk",
"target": "/test_root/appexecfwk"
}
]
}
],
"driver": {
"type": "CppTestLite",
"execute": "/test_root/appexecfwk/ActsBundleMgrTest.bin"
}
}
\ No newline at end of file
此差异已折叠。
# 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("//test/xts/tools/build/suite_lite.gni")
hctest_suite("ActsLwipTest") {
suite_name = "acts"
sources = [
"src/lwip_func_test.c",
]
include_dirs = [
"//vendor/hisi/hi3861/hi3861/third_party/lwip_sack/include",
"//kernel/liteos_m/components/cmsis",
"//kernel/liteos_m/components/cmsis/2.0",
]
cflags = ["-Wno-error"]
}
{
"description": "Config for $module test cases",
"environment": [
{
"type": "device",
"label": "wifiiot"
}
],
"kits": [
{
"type": "DeployKit",
"timeout": "20000",
"burn_file": "$subsystem/$module.bin"
}
],
"driver": {
"type": "CTestLite"
}
}
\ No newline at end of file
/*
* 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 "hctest.h"
#include "lwip/sockets.h"
#include "lwip/inet.h"
#include "lwip/tcp.h"
#include "securec.h"
#include "cmsis_os2.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <unistd.h>
#define LOCAL_HOST "127.0.0.1"
#define STACK_PORT 2277
#define STACK_IP LOCAL_HOST
#define PEER_PORT STACK_PORT
#define PEER_IP LOCAL_HOST
#define UDP_MSG "Hi, I am UDP"
#define SRV_MSG "Hi, I am TCP server"
#define CLI_MSG "Hi, I am TCP client"
#define BUF_SIZE (1024 * 8)
#define LWIP_TEST_SUCCESS 0
#define LWIP_TEST_FAIL (-1)
#define DEF_TASK_STACK 2000
#define DEF_TASK_PRIORITY 20
#define ONE_SECOND 1
#define TIMEOUT 4
static char g_buf[BUF_SIZE + 1] = {0};
static int g_clientWait = 0;
static int g_clientWaitOver = 0;
static int g_serverWait = 0;
static int g_serverWaitOver = 0;
static int g_clientResult = 0;
static int g_serverResult = 0;
static void waitClient(void)
{
while (1) {
sleep(ONE_SECOND);
if (g_clientWait) {
break;
}
}
g_clientWaitOver = 1;
g_clientWait = 0;
}
static void waitServer(void)
{
while (1) {
sleep(ONE_SECOND);
if (g_serverWait) {
break;
}
}
g_serverWaitOver = 1;
g_serverWait = 0;
}
static void SampleTcpServerTask(void)
{
int ret;
int sfd = -1;
int lsfd = -1;
struct msghdr msg = {0};
struct iovec iov[2] = {};
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
static char buf[BUF_SIZE + 1] = {0};
lsfd = socket(AF_INET, SOCK_STREAM, 0);
printf("[tcp server]create socket[server]\n");
TEST_ASSERT_NOT_EQUAL(lsfd, LWIP_TEST_FAIL);
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
srvAddr.sin_port = htons(STACK_PORT);
ret = bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
printf("[tcp server]bind %s:%d,ret=%d\n", inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = listen(lsfd, 0);
printf("[tcp server]listen,ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
waitServer();
sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
printf("[tcp server]accept <%s:%d>\n", inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
TEST_ASSERT_NOT_EQUAL(sfd, LWIP_TEST_FAIL);
int srvMsgLen = strlen(SRV_MSG);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, SRV_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = send(sfd, buf, srvMsgLen, 0);
printf("[tcp server]send, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, srvMsgLen);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp server]recv, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, strlen(CLI_MSG));
waitServer();
int len = 2;
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, SRV_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = srvMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = srvMsgLen;
ret = sendmsg(sfd, &msg, 0);
printf("[tcp server]sendmsg, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * srvMsgLen);
waitServer();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp server]recv, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * strlen(CLI_MSG));
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp server]shutdown, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
lwip_close(sfd);
lwip_close(lsfd);
g_serverResult = 1;
waitServer();
}
static void SampleTcpClientTask(void)
{
int ret;
int sfd = -1;
struct msghdr msg = {0};
struct iovec iov[2] = {};
struct sockaddr addr;
socklen_t addrLen = sizeof(addr);
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
static char buf[BUF_SIZE+1] = {0};
sfd = socket(AF_INET, SOCK_STREAM, 0);
printf("[tcp client]create socket[client]\n");
TEST_ASSERT_NOT_EQUAL(sfd, LWIP_TEST_FAIL);
waitClient();
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(PEER_IP);
srvAddr.sin_port = htons(PEER_PORT);
ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
printf("[tcp client]connect %s:%d, ret=%d\n", inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = getpeername(sfd, &addr, &addrLen);
printf("[tcp client]getpeername %s:%d, ret=%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
TEST_ASSERT_EQUAL_INT(addrLen, sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(((struct sockaddr_in*)&addr)->sin_addr.s_addr, inet_addr(PEER_IP));
ret = getsockname(sfd, &addr, &addrLen);
printf("[tcp client]getsockname %s:%d, ret=%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
TEST_ASSERT_EQUAL_INT(addrLen, sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(((struct sockaddr_in*)&addr)->sin_addr.s_addr, inet_addr(STACK_IP));
int cliMsgLen = strlen(CLI_MSG);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, CLI_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = send(sfd, buf, cliMsgLen, 0);
printf("[tcp client]send, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, cliMsgLen);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp client]recv,ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, strlen(SRV_MSG));
waitClient();
int len = 2;
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, CLI_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = cliMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = cliMsgLen;
ret = sendmsg(sfd, &msg, 0);
printf("[tcp client]sendmsg, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * cliMsgLen);
waitClient();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp client]recv, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, len * strlen(SRV_MSG));
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp client]shutdown, ret=%d\n", ret);
TEST_ASSERT_EQUAL_INT(ret, 0);
lwip_close(sfd);
g_clientResult = 1;
waitClient();
}
/**
* @tc.desc : register a test suite, this suite is used to test function
* @param : subsystem name is communication
* @param : module name is lwip
* @param : test suit name is LwipFuncTestSuite
*/
LITE_TEST_SUIT(communication, lwip, LwipFuncTestSuite);
/**
* @tc.setup : setup for every testcase
* @return : setup result, TRUE is success, FALSE is fail
*/
static BOOL LwipFuncTestSuiteSetUp(void)
{
return TRUE;
}
/**
* @tc.teardown : teardown for every testcase
* @return : teardown result, TRUE is success, FALSE is fail
*/
static BOOL LwipFuncTestSuiteTearDown(void)
{
printf("+----------------------------------------------------------+\n");
return TRUE;
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0100
* @tc.name : test upd
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE(LwipFuncTestSuite, testUdp, LEVEL2)
{
int sfd;
int ret;
int len = 2;
struct msghdr msg = {0};
struct iovec iov[2] = {0};
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
sfd = socket(AF_INET, SOCK_DGRAM, 0);
TEST_ASSERT_NOT_EQUAL(sfd, LWIP_TEST_FAIL);
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(STACK_IP);
srvAddr.sin_port = htons(STACK_PORT);
ret = bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(g_buf, BUF_SIZE, UDP_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = sendto(sfd, g_buf, strlen(UDP_MSG), 0, (struct sockaddr*)&clnAddr, (socklen_t)sizeof(clnAddr));
TEST_ASSERT_NOT_EQUAL(ret, LWIP_TEST_FAIL);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr, &clnAddrLen);
TEST_ASSERT_EQUAL_INT(ret, strlen(UDP_MSG));
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(PEER_IP);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(g_buf, BUF_SIZE, UDP_MSG);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = g_buf;
iov[0].iov_len = strlen(UDP_MSG);
iov[1].iov_base = g_buf;
iov[1].iov_len = strlen(UDP_MSG);
ret = sendmsg(sfd, &msg, 0);
TEST_ASSERT_EQUAL_INT(ret, len * strlen(UDP_MSG));
ret = lwip_close(sfd);
TEST_ASSERT_NOT_EQUAL(ret, LWIP_TEST_FAIL);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0200
* @tc.name : test socket operation
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE(LwipFuncTestSuite, testSocketOpt, LEVEL2)
{
int ret;
struct timeval timeout;
socklen_t len;
int fd;
fd = socket(AF_INET, SOCK_STREAM, 0);
TEST_ASSERT_NOT_EQUAL(fd, LWIP_TEST_FAIL);
int error = -1;
len = sizeof(error);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
TEST_ASSERT_EQUAL_INT(error, LWIP_TEST_SUCCESS);
len = sizeof(timeout);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
int sec = 1000;
timeout.tv_sec = sec;
len = sizeof(timeout);
ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
memset_s(&timeout, len, 0, len);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
error = -1;
len = sizeof(error);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
TEST_ASSERT_EQUAL_INT(error, LWIP_TEST_SUCCESS);
int flag = 1;
ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = lwip_close(fd);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0300
* @tc.name : test inet conversion
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE(LwipFuncTestSuite, testInetConv, LEVEL2)
{
int ret;
struct in_addr in;
ret = inet_pton(AF_INET, "300.10.10.10", &in);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_SUCCESS);
ret = inet_pton(AF_INET, "10.11.12.13", &in);
TEST_ASSERT_EQUAL_INT(ret, 1);
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
TEST_ASSERT_EQUAL_INT(in.s_addr, 0x0d0c0b0a);
#else
TEST_ASSERT_EQUAL_INT(in.s_addr, 0x0a0b0c0d);
#endif
const char *p = inet_ntoa(in);
TEST_ASSERT_NOT_NULL(p);
TEST_ASSERT_EQUAL_INT(strcmp(p, "10.11.12.13"), 0);
int bufLen = 32;
char buf[bufLen];
p = inet_ntop(AF_INET, &in, buf, sizeof(buf));
TEST_ASSERT_NOT_NULL(p);
TEST_ASSERT_EQUAL_INT(strcmp(p, "10.11.12.13"), 0);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0400
* @tc.name : test tcp
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE(LwipFuncTestSuite, testTcp, LEVEL2)
{
osThreadAttr_t attrServer;
attrServer.name = "SampleTcpServerTask";
attrServer.attr_bits = 0U;
attrServer.cb_mem = NULL;
attrServer.cb_size = 0U;
attrServer.stack_mem = NULL;
attrServer.stack_size = DEF_TASK_STACK;
attrServer.priority = DEF_TASK_PRIORITY;
osThreadAttr_t attrClient;
attrClient.name = "SampleTcpClientTask";
attrClient.attr_bits = 0U;
attrClient.cb_mem = NULL;
attrClient.cb_size = 0U;
attrClient.stack_mem = NULL;
attrClient.stack_size = DEF_TASK_STACK;
attrClient.priority = DEF_TASK_PRIORITY;
osThreadId_t serverTaskId = osThreadNew((osThreadFunc_t)SampleTcpServerTask, NULL, &attrServer);
TEST_ASSERT_NOT_NULL(serverTaskId);
if (serverTaskId == NULL) {
printf("[testTcp]create server task fail!\n");
}
osThreadId_t clientTaskId = osThreadNew((osThreadFunc_t)SampleTcpClientTask, NULL, &attrClient);
TEST_ASSERT_NOT_NULL(clientTaskId);
if (clientTaskId == NULL) {
printf("[testTcp]create client task fail!\n");
}
sleep(ONE_SECOND);
int timeout = TIMEOUT;
g_serverWait = 1;
g_clientWait = 1;
while (timeout > 0) {
if (g_serverWaitOver == 1 && g_clientWaitOver == 1) {
printf("[testTcp] wait success[1]!\n");
break;
}
timeout--;
sleep(ONE_SECOND);
printf("[testTcp] wait[1]...\n");
}
sleep(ONE_SECOND);
timeout = TIMEOUT;
g_serverWait = 1;
g_clientWait = 1;
while (timeout > 0) {
if (g_serverWaitOver == 1 && g_clientWaitOver == 1) {
printf("[testTcp] wait success[2]!\n");
break;
}
timeout--;
sleep(ONE_SECOND);
printf("[testTcp] wait[2]...\n");
}
sleep(ONE_SECOND);
timeout = TIMEOUT;
g_serverWait = 1;
g_clientWait = 1;
while (timeout > 0) {
if (g_serverWaitOver == 1 && g_clientWaitOver == 1) {
printf("[testTcp] wait success[3]!\n");
break;
}
timeout--;
sleep(ONE_SECOND);
printf("[testTcp] wait[3]...\n");
}
sleep(ONE_SECOND);
timeout = TIMEOUT;
g_serverWait = 1;
g_clientWait = 1;
while (timeout > 0) {
if (g_serverWaitOver == 1 && g_clientWaitOver == 1) {
printf("[testTcp] wait success[4]!\n");
break;
}
timeout--;
sleep(ONE_SECOND);
printf("[testTcp] wait[4]...\n");
}
TEST_ASSERT_EQUAL_INT(g_clientResult, 1);
TEST_ASSERT_EQUAL_INT(g_serverResult, 1);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0500
* @tc.name : test invalid parameter
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
LITE_TEST_CASE(LwipFuncTestSuite, testInvalidParameter, LEVEL2)
{
int ret;
int fdFail = -1;
int fdSuccess = -1;
fdFail = socket(0, 0, 0);
TEST_ASSERT_EQUAL_INT(fdFail, LWIP_TEST_FAIL);
fdSuccess = socket(AF_INET, SOCK_STREAM, 0);
TEST_ASSERT_NOT_EQUAL(fdSuccess, LWIP_TEST_FAIL);
ret = bind(fdFail, NULL, sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = bind(fdSuccess, NULL, sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = connect(fdFail, NULL, sizeof(struct sockaddr));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = connect(fdSuccess, NULL, sizeof(struct sockaddr));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = accept(fdFail, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = accept(fdSuccess, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getsockname(fdFail, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getsockname(fdSuccess, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getpeername(fdFail, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getpeername(fdSuccess, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = send(fdFail, NULL, strlen(SRV_MSG), 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = send(fdSuccess, NULL, strlen(SRV_MSG), 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = sendto(fdFail, NULL, strlen(SRV_MSG), 0, NULL, (socklen_t)sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = sendto(fdSuccess, NULL, strlen(SRV_MSG), 0, NULL, (socklen_t)sizeof(struct sockaddr_in));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = recv(fdFail, NULL, sizeof(SRV_MSG), 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = recv(fdSuccess, NULL, sizeof(SRV_MSG), 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = recvfrom(fdFail, NULL, sizeof(SRV_MSG), 0, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = recvfrom(fdSuccess, NULL, sizeof(SRV_MSG), 0, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = setsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, NULL, (socklen_t)sizeof(struct timeval));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = setsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, NULL, (socklen_t)sizeof(struct timeval));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, NULL, (socklen_t*)sizeof(struct timeval));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = getsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, NULL, (socklen_t*)sizeof(struct timeval));
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = sendmsg(fdFail, NULL, 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = sendmsg(fdSuccess, NULL, 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = listen(fdFail, 0);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = listen(fdSuccess, -1);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = select(fdFail, NULL, NULL, NULL, NULL);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = shutdown(fdFail, SHUT_RD);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = shutdown(fdSuccess, -1);
TEST_ASSERT_EQUAL_INT(ret, LWIP_TEST_FAIL);
ret = lwip_close(fdSuccess);
TEST_ASSERT_EQUAL_INT(ret, 0);
}
RUN_TEST_SUITE(LwipFuncTestSuite);
\ No newline at end of file
# 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("//test/xts/tools/build/suite_lite.gni")
hcpptest_suite("ActsLwipTest") {
suite_name = "acts"
sources = [
"src/ActsLwipTest.cpp",
]
defines = [
"_GNU_SOURCE",
"restrict=",
]
deps = [
"//test/xts/tools/hcpptest:hcpptest",
"//base/security/frameworks/huks_lite/source:huks",
]
cflags = ["-Wno-error"]
}
{
"description": "Config for hcpptest demo test cases",
"environment": [
{
"type": "device",
"label": "ipcamera"
}
],
"kits": [
{
"type": "MountKit",
"server": "NfsServer",
"mount": [
{
"source": "testcases/communication",
"target": "/test_root/communication"
}
]
}
],
"driver": {
"type": "CppTestLite",
"execute": "/test_root/communication/ActsLwipTest.bin"
}
}
\ No newline at end of file
/**
* 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 "sys/socket.h"
#include "arpa/inet.h"
#include "netinet/tcp.h"
#include "securec.h"
#include <string.h>
#include <errno.h>
#include <stdlib.h>
using namespace std;
using namespace testing::ext;
static const int STACK_PORT = 2277;
static const int PEER_PORT = 2277;
static const int BUF_SIZE = (1024 * 8);
static const int LWIP_TEST_SUCCESS = 0;
static const int LWIP_TEST_FAIL = -1;
static char g_buf[BUF_SIZE + 1] = {0};
static const char* g_udpMsg = "Hi, I am UDP";
static const char* g_srvMsg = "Hi, I am TCP server";
static const char* g_cliMsg = "Hi, I am TCP client";
static const char* g_localHost = "127.0.0.1";
static pthread_barrier_t g_barrier;
#define WAIT() pthread_barrier_wait(&g_barrier)
class ActsLwipTest : public testing::Test {
protected:
// SetUpTestCase: Testsuit setup, run before 1st testcase
static void SetUpTestCase(void) {}
// TearDownTestCase: Testsuit teardown, run after last testcase
static void TearDownTestCase(void) {}
// Testcase setup
virtual void SetUp() {}
// Testcase teardown
virtual void TearDown() {}
};
static void* SampleTcpServerTask(void *p)
{
int ret;
int sfd = -1;
int lsfd = -1;
static char buf[BUF_SIZE + 1] = {0};
struct msghdr msg = {0};
struct iovec iov[2] = {};
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
lsfd = socket(AF_INET, SOCK_STREAM, 0);
printf("[tcp server]create socket[server]\n");
EXPECT_NE(lsfd, LWIP_TEST_FAIL);
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(STACK_PORT);
ret = ::bind(lsfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
printf("[tcp server]bind %s:%d,ret=%d\n", inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = listen(lsfd, 0);
printf("[tcp server]listen,ret=%d\n", ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
WAIT();
sfd = accept(lsfd, (struct sockaddr*)&clnAddr, &clnAddrLen);
printf("[tcp server]accept <%s:%d>\n", inet_ntoa(clnAddr.sin_addr), ntohs(clnAddr.sin_port));
EXPECT_NE(sfd, LWIP_TEST_FAIL);
int srvMsgLen = strlen(g_srvMsg);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_srvMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = send(sfd, buf, srvMsgLen, 0);
printf("[tcp server]send, ret=%d\n", ret);
EXPECT_EQ(ret, srvMsgLen);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp server]recv, ret=%d\n", ret);
EXPECT_EQ(ret, strlen(g_cliMsg));
WAIT();
int len = 2;
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_srvMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = srvMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = srvMsgLen;
ret = sendmsg(sfd, &msg, 0);
printf("[tcp server]sendmsg, ret=%d\n", ret);
EXPECT_EQ(ret, len * srvMsgLen);
WAIT();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
memset_s(&msg, sizeof(msg), 0, sizeof(msg));
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
ret = recvmsg(sfd, &msg, 0);
printf("[tcp server]recvmsg on socket %d: %d\n", sfd, ret);
EXPECT_EQ(ret, len * strlen(g_cliMsg));
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp server]shutdown, ret=%d\n", ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = close(sfd);
EXPECT_NE(ret, LWIP_TEST_FAIL);
ret = close(lsfd);
EXPECT_NE(ret, LWIP_TEST_FAIL);
return nullptr;
}
static void* SampleTcpClientTask(void *p)
{
int ret;
int sfd = -1;
struct msghdr msg = {0};
struct iovec iov[2] = {};
struct sockaddr addr;
socklen_t addrLen = sizeof(addr);
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
static char buf[BUF_SIZE + 1] = {0};
sfd = socket(AF_INET, SOCK_STREAM, 0);
printf("[tcp client]create socket[client]\n");
EXPECT_NE(sfd, LWIP_TEST_FAIL);
WAIT();
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(PEER_PORT);
ret = connect(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
printf("[tcp client]connect %s:%d, ret=%d\n", inet_ntoa(srvAddr.sin_addr), ntohs(srvAddr.sin_port), ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = getpeername(sfd, &addr, &addrLen);
printf("[tcp client]getpeername %s:%d, ret=%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
EXPECT_EQ(addrLen, sizeof(struct sockaddr_in));
EXPECT_EQ(((struct sockaddr_in*)&addr)->sin_addr.s_addr, inet_addr(g_localHost));
ret = getsockname(sfd, &addr, &addrLen);
printf("[tcp client]getsockname %s:%d, ret=%d\n", inet_ntoa(((struct sockaddr_in*)&addr)->sin_addr),
ntohs(((struct sockaddr_in*)&addr)->sin_port), ret);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
EXPECT_EQ(addrLen, sizeof(struct sockaddr_in));
EXPECT_EQ(((struct sockaddr_in*)&addr)->sin_addr.s_addr, inet_addr(g_localHost));
int cliMsgLen = strlen(g_cliMsg);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_cliMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = send(sfd, buf, cliMsgLen, 0);
printf("[tcp client]send, ret=%d\n", ret);
EXPECT_EQ(ret, cliMsgLen);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = recv(sfd, buf, sizeof(buf), 0);
printf("[tcp client]recv,ret=%d\n", ret);
EXPECT_EQ(ret, strlen(g_srvMsg));
WAIT();
int len = 2;
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(buf, BUF_SIZE, g_cliMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = buf;
iov[0].iov_len = cliMsgLen;
iov[1].iov_base = buf;
iov[1].iov_len = cliMsgLen;
ret = sendmsg(sfd, &msg, 0);
printf("[tcp client]sendmsg, ret=%d\n", ret);
EXPECT_EQ(ret, len * cliMsgLen);
WAIT();
memset_s(buf, BUF_SIZE, 0, BUF_SIZE);
memset_s(&msg, sizeof(msg), 0, sizeof(msg));
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = 1;
iov[0].iov_base = buf;
iov[0].iov_len = sizeof(buf);
ret = recvmsg(sfd, &msg, 0);
printf("[tcp client]recvmsg, ret=%d\n", ret);
EXPECT_EQ(ret, len * strlen(g_srvMsg));
ret = shutdown(sfd, SHUT_RDWR);
printf("[tcp client]shutdown, ret=%d\n", ret);
EXPECT_EQ(ret, 0);
ret = close(sfd);
EXPECT_NE(ret, LWIP_TEST_FAIL);
return nullptr;
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0100
* @tc.name : test upd
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
HWTEST_F(ActsLwipTest, testUdp, TestSize.Level2)
{
int sfd;
int ret;
int len = 2;
struct msghdr msg = {0};
struct iovec iov[2] = {0};
struct sockaddr_in srvAddr = {0};
struct sockaddr_in clnAddr = {0};
socklen_t clnAddrLen = sizeof(clnAddr);
sfd = socket(AF_INET, SOCK_DGRAM, 0);
EXPECT_NE(sfd, LWIP_TEST_FAIL);
srvAddr.sin_family = AF_INET;
srvAddr.sin_addr.s_addr = inet_addr(g_localHost);
srvAddr.sin_port = htons(STACK_PORT);
ret = ::bind(sfd, (struct sockaddr*)&srvAddr, sizeof(srvAddr));
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(g_buf, BUF_SIZE, g_udpMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = sendto(sfd, g_buf, strlen(g_udpMsg), 0, (struct sockaddr*)&clnAddr, (socklen_t)sizeof(clnAddr));
EXPECT_NE(ret, LWIP_TEST_FAIL);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = recvfrom(sfd, g_buf, sizeof(g_buf), 0, (struct sockaddr*)&clnAddr, &clnAddrLen);
EXPECT_EQ(ret, strlen(g_udpMsg));
clnAddr.sin_family = AF_INET;
clnAddr.sin_addr.s_addr = inet_addr(g_localHost);
clnAddr.sin_port = htons(PEER_PORT);
memset_s(g_buf, BUF_SIZE, 0, BUF_SIZE);
ret = strcpy_s(g_buf, BUF_SIZE, g_udpMsg);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
msg.msg_name = &clnAddr;
msg.msg_namelen = sizeof(clnAddr);
msg.msg_iov = iov;
msg.msg_iovlen = len;
iov[0].iov_base = g_buf;
iov[0].iov_len = strlen(g_udpMsg);
iov[1].iov_base = g_buf;
iov[1].iov_len = strlen(g_udpMsg);
ret = sendmsg(sfd, &msg, 0);
EXPECT_EQ(ret, len*strlen(g_udpMsg));
ret = close(sfd);
EXPECT_NE(ret, LWIP_TEST_FAIL);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0200
* @tc.name : test socket operation
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
HWTEST_F(ActsLwipTest, testSocketOpt, TestSize.Level2)
{
int ret;
struct timeval timeout;
socklen_t len;
int fd;
fd = socket(AF_INET, SOCK_STREAM, 0);
EXPECT_NE(fd, LWIP_TEST_FAIL);
int error = -1;
len = sizeof(error);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
EXPECT_EQ(error, LWIP_TEST_SUCCESS);
len = sizeof(timeout);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
timeout.tv_sec = 1000;
len = sizeof(timeout);
ret = setsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, len);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
memset_s(&timeout, len, 0, len);
ret = getsockopt(fd, SOL_SOCKET, SO_RCVTIMEO, &timeout, &len);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
error = -1;
len = sizeof(error);
ret = getsockopt(fd, SOL_SOCKET, SO_ERROR, &error, &len);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
EXPECT_EQ(error, LWIP_TEST_SUCCESS);
int flag = 1;
ret = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof(flag));
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = close(fd);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0300
* @tc.name : test inet conversion
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
HWTEST_F(ActsLwipTest, testInetConv, TestSize.Level2)
{
int ret;
struct in_addr in;
ret = inet_pton(AF_INET, "300.10.10.10", &in);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = inet_pton(AF_INET, "10.11.12.13", &in);
EXPECT_EQ(ret, 1);
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
EXPECT_EQ(in.s_addr, 0x0d0c0b0a);
#else
EXPECT_EQ(in.s_addr, 0x0a0b0c0d);
#endif
const char *p = inet_ntoa(in);
EXPECT_EQ(strcmp(p, "10.11.12.13"), 0);
int bufLen = 32;
char buf[bufLen];
p = inet_ntop(AF_INET, &in, buf, sizeof(buf));
EXPECT_EQ(strcmp(p, "10.11.12.13"), 0);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0400
* @tc.name : test tcp
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
HWTEST_F(ActsLwipTest, testTcp, TestSize.Level2)
{
int ret;
pthread_t srv;
pthread_t cli;
ret = pthread_barrier_init(&g_barrier, 0, 2);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = pthread_create(&srv, nullptr, SampleTcpServerTask, nullptr);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = pthread_create(&cli, nullptr, SampleTcpClientTask, nullptr);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = pthread_join(cli, nullptr);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = pthread_join(srv, nullptr);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
ret = pthread_barrier_destroy(&g_barrier);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
}
/**
* @tc.number : SUB_COMMUNICATION_LWIP_SDK_0500
* @tc.name : test invalid parameter
* @tc.desc : [C- SOFTWARE -0200]
* @tc.size : MEDIUM
* @tc.type : FUNC
* @tc.level : Level 2
*/
HWTEST_F(ActsLwipTest, testInvalidParameter, TestSize.Level2)
{
int ret;
int fdFail = -1;
int fdSuccess = -1;
fdFail = socket(0, 0, 0);
EXPECT_EQ(fdFail, LWIP_TEST_FAIL);
fdSuccess = socket(AF_INET, SOCK_STREAM, 0);
EXPECT_NE(fdSuccess, LWIP_TEST_FAIL);
ret = ::bind(fdFail, nullptr, sizeof(struct sockaddr_in));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = ::bind(fdSuccess, nullptr, sizeof(struct sockaddr_in));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = connect(fdFail, nullptr, sizeof(struct sockaddr));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = connect(fdSuccess, nullptr, sizeof(struct sockaddr));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = accept(fdFail, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = accept(fdSuccess, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getsockname(fdFail, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getsockname(fdSuccess, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getpeername(fdFail, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getpeername(fdSuccess, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = send(fdFail, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = send(fdSuccess, nullptr, strlen(g_srvMsg), 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = sendto(fdFail, nullptr, strlen(g_srvMsg), 0, nullptr, (socklen_t)sizeof(struct sockaddr_in));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = sendto(fdSuccess, nullptr, strlen(g_srvMsg), 0, nullptr, (socklen_t)sizeof(struct sockaddr_in));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = recv(fdFail, nullptr, sizeof(g_srvMsg), 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = recv(fdSuccess, nullptr, sizeof(g_srvMsg), 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
struct msghdr msg = {0};
ret = recvmsg(fdFail, &msg, 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = recvmsg(fdSuccess, &msg, 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = recvfrom(fdFail, nullptr, sizeof(g_srvMsg), 0, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = recvfrom(fdSuccess, nullptr, sizeof(g_srvMsg), 0, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = setsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t)sizeof(struct timeval));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = setsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t)sizeof(struct timeval));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getsockopt(fdFail, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t*)sizeof(struct timeval));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = getsockopt(fdSuccess, SOL_SOCKET, SO_RCVTIMEO, nullptr, (socklen_t*)sizeof(struct timeval));
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = sendmsg(fdFail, nullptr, 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = sendmsg(fdSuccess, nullptr, 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = listen(fdFail, 0);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = select(fdFail, nullptr, nullptr, nullptr, nullptr);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = shutdown(fdFail, SHUT_RD);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = shutdown(fdSuccess, -1);
EXPECT_EQ(ret, LWIP_TEST_FAIL);
ret = close(fdSuccess);
EXPECT_EQ(ret, LWIP_TEST_SUCCESS);
}
# 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("//test/xts/tools/build/suite_lite.gni")
hctest_suite("ActsSoftBusTest") {
suite_name = "acts"
sources = [
"src/softbus_func_test.c",
]
defines = ["HOS_DISCOVERY_3861_BOARD"]
include_dirs = [
"//vendor/hisi/hi3861/hi3861/include",
"//vendor/hisi/hi3861/hi3861/components/lwip_sack/include",
"//vendor/hisi/hi3861/hi3861/third_party/cjson",
"//third_party/bounds_checking_function/include",
"//kernel/liteos_m/components/cmsis",
"//kernel/liteos_m/components/cmsis/2.0",
"//foundation/communication/interfaces/kits/wifi_lite/wifiservice",
"//foundation/communication/frameworks/wifi_lite/wifiservice/source",
"//foundation/communication/services/softbus_lite/discovery/discovery_service/include",
"//foundation/communication/services/softbus_lite/discovery/include",
"//foundation/communication/interfaces/kits/softbus_lite/discovery",
"//foundation/communication/interfaces/kits/softbus_lite/transport"
]
deps = [
"//foundation/communication/services/softbus_lite:softbus",
]
cflags = [ "-Wno-error" ]
}
{
"description": "Config for $module test cases",
"environment": [
{
"type": "device",
"label": "wifiiot"
}
],
"kits": [
{
"type": "DeployKit",
"timeout": "20000",
"burn_file": "$subsystem/$module.bin"
}
],
"driver": {
"type": "CTestLite"
}
}
\ No newline at end of file
此差异已折叠。
# 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("//test/xts/tools/build/suite_lite.gni")
hcpptest_suite("ActsSoftBusTest") {
suite_name = "acts"
sources = [
"src/ActsSoftBusTest.cpp",
]
include_dirs = [
"//foundation/communication/services/softbus_lite/discovery/coap/include",
"//foundation/communication/services/softbus_lite/os_adapter/include",
"//foundation/communication/interfaces/kits/softbus_lite/discovery",
"//foundation/communication/interfaces/kits/softbus_lite/transport",
"//foundation/communication/services/softbus_lite/discovery/discovery_service/include",
"//foundation/communication/services/softbus_lite/authmanager/include",
"//foundation/communication/services/softbus_lite/trans_service/include/libdistbus",
"//foundation/communication/services/softbus_lite/trans_service/include/utils",
"//foundation/communication/services/softbus_lite/trans_service/source/libdistbus",
"//foundation/communication/services/softbus_lite/trans_service/source/utils",
"//third_party/cJSON",
"//third_party/mbedtls/include",
"//third_party/bounds_checking_function/include",
"//kernel/liteos_a/lib/libsec/include",
"//vendor/hisi/hi3861/hi3861/include",
"//vendor/hisi/hi3861/hi3861/third_party/lwip_sack/include",
"//vendor/hisi/hi3861/hi3861/third_party/cjson",
"//vendor/hisi/hi3861/hi3861/third_party/mbedtls/include",
"//base/startup/interfaces/kits/syspara_lite/include",
"//base/security/interfaces/innerkits/hichainsdk_lite",
"//base/security/services/hichainsdk_lite/source/huks_adapter/",
]
defines = [
"_GNU_SOURCE"
]
deps = [
"//foundation/communication/services/softbus_lite:softbus_lite",
"//base/security/frameworks/huks_lite/source:huks",
"//test/xts/tools/hcpptest:hcpptest",
]
cflags = [ "-Wno-error" ]
}
{
"description": "Config for hcpptest demo test cases",
"environment": [
{
"type": "device",
"label": "ipcamera"
}
],
"kits": [
{
"type": "MountKit",
"server": "NfsServer",
"mount": [
{
"source": "testcases/communication",
"target": "/test_root/communication"
}
]
}
],
"driver": {
"type": "CppTestLite",
"execute": "/test_root/communication/ActsSoftBusTest.bin"
}
}
\ No newline at end of file
# 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("//test/xts/tools/build/suite_lite.gni")
hctest_suite("ActsWifiServiceTest") {
suite_name = "acts"
sources = [
"src/wifiservice_func_test.c",
]
include_dirs = [
"//foundation/communication/interfaces/kits/wifi_lite/wifiservice",
"//vendor/hisi/hi3861/hi3861/third_party/lwip_sack/include",
"//kernel/liteos_m/components/cmsis",
"//kernel/liteos_m/components/cmsis/2.0",
]
cflags = [ "-Wno-error" ]
}
{
"description": "Config for $module test cases",
"environment": [
{
"type": "device",
"label": "wifiiot"
}
],
"kits": [
{
"type": "DeployKit",
"timeout": "20000",
"burn_file": "$subsystem/$module.bin"
}
],
"driver": {
"type": "CTestLite"
}
}
\ No newline at end of file
# 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("//test/xts/tools/build/suite_lite.gni")
hctest_suite("ActsSamgrTest") {
suite_name = "acts"
sources = [
"utils/samgr_maintenance.c",
"src/service_func_test.c",
"src/feature_func_test.c",
"src/defaultfeatureapi_func_test.c",
"src/featureapi_func_test.c",
"src/iunknown_func_test.c",
"src/sendrequest_func_test.c",
"src/sendresponse_func_test.c",
"src/sendsharerequest_func_test.c",
"src/broadcast_subscribe_func_test.c",
"src/broadcast_publish_func_test.c",
"src/taskpool_notask_func_test.c",
"src/taskpool_singletask_func_test.c",
"src/taskpool_specifiedtask_func_test.c",
"src/taskpool_sharedtask_func_test.c",
"src/common_func_test.c",
]
include_dirs = [
"//test/xts/tools/hctest/include",
"//third_party/unity/src",
"//kernel/liteos_m/components/cmsis",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/communication/broadcast",
"//foundation/distributedschedule/services/samgr_lite/samgr/adapter",
"//foundation/distributedschedule/services/samgr_lite/samgr/source",
"//vendor/hisi/hi3861/hi3861/include",
"//vendor/hisi/hi3861/hi3861/components/lwip_sack/include",
"//kernel/liteos_m/components/cmsis/2.0",
"src",
"utils",
]
deps = [
"//test/xts/tools/hctest:hctest",
]
public_deps = [
"//foundation/distributedschedule/services/samgr_lite/samgr/adapter:samgr_adapter",
]
defines = [
"UNITY_INCLUDE_CONFIG_H",
]
cflags = [ "-Wno-error" ]
}
{
"description": "Config for $module test cases",
"environment": [
{
"type": "device",
"label": "wifiiot"
}
],
"kits": [
{
"type": "DeployKit",
"timeout": "20000",
"burn_file": "$subsystem/$module.bin"
}
],
"driver": {
"type": "CTestLite"
}
}
\ No newline at end of file
/*
* 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 "samgr_maintenance.h"
#include <stdio.h>
#include "service_impl.h"
#include "samgr_lite_inner.h"
void SAMGR_PrintServices(void)
{
SamgrLiteImpl *samgr = GET_OBJECT(SAMGR_GetInstance(), SamgrLiteImpl, vtbl);
int16 num = VECTOR_Num(&samgr->services);
printf("[hctest][Maintenance]Print Services(%d) Information:\n", num);
if (num == 0) {
return;
}
MUTEX_Lock(samgr->mutex);
int16 size = VECTOR_Size(&(samgr->services));
int i;
for (i = 0; i < size; ++i) {
ServiceImpl *impl = VECTOR_At(&(samgr->services), i);
if (impl == NULL) {
continue;
}
MUTEX_Unlock(samgr->mutex);
const char *name = impl->service->GetName(impl->service);
printf("[hctest][Service:%d]<status:%d, name:%s, default:%p, features:%d, task:%p>\n",
impl->serviceId, impl->inited, name, impl->defaultApi, VECTOR_Num(&impl->features), impl->taskPool);
TaskPool *pool = impl->taskPool;
if (pool != NULL) {
printf("[hctest][TaskPool:%p]<tid:%p, qid:%p, ref:%d, pri:%d, stack:0x%x>\n",
pool, pool->tasks[0], pool->queueId, pool->ref, pool->priority, pool->stackSize);
}
int16 featureSize = VECTOR_Size(&impl->features);
int j;
for (j = 0; j < featureSize; ++j) {
FeatureImpl *feature = VECTOR_At(&impl->features, j);
if (feature == NULL) {
continue;
}
name = feature->feature->GetName(feature->feature);
printf("[hctest][Feature:%d]<name:%s, api:%p>\n", j, name, feature->iUnknown);
}
MUTEX_Lock(samgr->mutex);
}
MUTEX_Unlock(samgr->mutex);
}
\ No newline at end of file
/*
* 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.
*/
#ifndef OHOS_LITE_SAMGR_MAINTENANCE_H
#define OHOS_LITE_SAMGR_MAINTENANCE_H
#ifdef __cplusplus
#if __cplusplus
extern "C" {
#endif
#endif
void SAMGR_PrintServices(void);
#ifdef __cplusplus
#if __cplusplus
}
#endif
#endif
#endif // OHOS_LITE_SAMGR_MAINTENANCE_H
# 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("//test/xts/tools/build/suite_lite.gni")
hcpptest_suite("ActsSamgrTest") {
suite_name = "acts"
sources = [ ]
if (ohos_kernel_type == "liteos_a") {
sources += [
"src/utils/SamgrTestBase.cpp",
"src/ServiceTest.cpp",
"src/FeatureTest.cpp",
"src/DefaultFeatureApiTest.cpp",
"src/FeatureApiTest.cpp",
"src/IUnknownTest.cpp",
"src/SendRequestTest.cpp",
"src/SendResponseTest.cpp",
"src/SendShareRequestTest.cpp",
"src/BroadcastSubscribeTest.cpp",
"src/BroadcastPublishTest.cpp",
"src/TaskpoolNoTaskTest.cpp",
"src/TaskpoolSingleTaskTest.cpp",
"src/TaskpoolSpecifiedTaskTest.cpp",
"src/TaskpoolSharedTaskTest.cpp",
"src/CommonTest.cpp",
"src/LiteIPCClientTest.cpp",
"src/LiteIPCFeatureTest.cpp",
"src/LiteIPCServiceTest.cpp",
]
} else if (ohos_kernel_type == "linux") {
sources += [
"src/utils/SamgrTestBase.cpp",
"src/ServiceTest.cpp",
"src/FeatureTest.cpp",
"src/DefaultFeatureApiTest.cpp",
"src/FeatureApiTest.cpp",
"src/IUnknownTest.cpp",
"src/SendRequestTest.cpp",
"src/SendResponseTest.cpp",
"src/SendShareRequestTest.cpp",
"src/BroadcastSubscribeTest.cpp",
"src/BroadcastPublishTest.cpp",
"src/TaskpoolNoTaskTest.cpp",
"src/TaskpoolSingleTaskTest.cpp",
"src/TaskpoolSpecifiedTaskTest.cpp",
"src/TaskpoolSharedTaskTest.cpp",
"src/CommonTest.cpp",
# "src/LiteIPCClientTest.cpp",
"src/LiteIPCFeatureTest.cpp",
"src/LiteIPCServiceTest.cpp",
]
} else { }
include_dirs = [
"src",
"src/utils",
"include",
"//utils/native/liteos/include",
"//third_party/bounds_checking_function/include",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/registry",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/samgr",
"//foundation/distributedschedule/interfaces/kits/samgr_lite/communication/broadcast",
]
deps = [
"//foundation/distributedschedule/services/samgr_lite/samgr:samgr",
"//foundation/distributedschedule/services/samgr_lite/communication/broadcast:broadcast",
"//foundation/communication/frameworks/ipc_lite:liteipc_adapter",
"//base/hiviewdfx/frameworks/hilog_lite/featured:hilog_shared",
"//third_party/bounds_checking_function:libsec_shared",
]
cflags = [ "-Wno-error" ]
ldflags = [
"-lstdc++",
"-lm",
"-lpthread"
]
}
{
"description": "Config for hcpptest demo test cases",
"environment": [
{
"type": "device",
"label": "ipcamera"
}
],
"kits": [
{
"type": "MountKit",
"server": "NfsServer",
"mount": [
{
"source": "testcases/distributedschedule",
"target": "/test_root/distributedschedule"
}
]
}
],
"driver": {
"type": "CppTestLite",
"execute": "/test_root/distributedschedule/ActsSamgrTest.bin"
}
}
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册