Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Kernel Liteos A
提交
0257a0a1
K
Kernel Liteos A
项目概览
OpenHarmony
/
Kernel Liteos A
1 年多 前同步成功
通知
461
Star
414
Fork
55
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
4
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
K
Kernel Liteos A
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
4
Issue
4
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
0257a0a1
编写于
1月 22, 2022
作者:
O
openharmony_ci
提交者:
Gitee
1月 22, 2022
浏览文件
操作
浏览文件
下载
差异文件
!714 Fix : 修改了与musl库net模块中新增测试API相关的测试用例
Merge pull request !714 from yinjiaming/yjm-kernel-net-20211124
上级
046d8def
3d00a7d2
变更
22
隐藏空白更改
内联
并排
Showing
22 changed file
with
491 addition
and
82 deletion
+491
-82
testsuites/unittest/net/netdb/config.gni
testsuites/unittest/net/netdb/config.gni
+0
-1
testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp
+12
-0
testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp
+15
-5
testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp
+11
-0
testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp
+12
-0
testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp
+12
-0
testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp
+12
-0
testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp
+15
-2
testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp
+21
-5
testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp
+0
-48
testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp
+0
-4
testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp
+18
-0
testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp
+12
-0
testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp
+34
-4
testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp
+34
-9
testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp
+30
-1
testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp
+14
-1
testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp
testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp
+14
-1
testsuites/unittest/net/netdb/lt_net_netdb.h
testsuites/unittest/net/netdb/lt_net_netdb.h
+0
-1
testsuites/unittest/net/netdb/net_netdb_test.cpp
testsuites/unittest/net/netdb/net_netdb_test.cpp
+201
-0
testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp
testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp
+12
-0
testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp
testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp
+12
-0
未找到文件。
testsuites/unittest/net/netdb/config.gni
浏览文件 @
0257a0a1
...
@@ -49,7 +49,6 @@ netdb_sources_full = [
...
@@ -49,7 +49,6 @@ netdb_sources_full = [
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_010.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_010.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_011.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_011.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_012.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_012.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_014.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_015.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_015.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_016.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_016.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_017.cpp",
"$TEST_UNITTEST_DIR/net/netdb/full/net_netdb_test_017.cpp",
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_002.cpp
浏览文件 @
0257a0a1
...
@@ -35,6 +35,17 @@
...
@@ -35,6 +35,17 @@
static
int
AddrInfoTest
(
void
)
static
int
AddrInfoTest
(
void
)
{
{
// Prerequisite: correct DNS servers must be configured.
// Prerequisite: correct DNS servers must be configured.
char
host_file
[]
=
"127.0.0.2 example.com
\n
"
,
serv_file
[]
=
"ftp 21/tcp
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
,
"/etc/services"
};
char
*
streamList
[]
=
{
host_file
,
serv_file
};
int
streamLen
[]
=
{
sizeof
(
host_file
),
sizeof
(
serv_file
)};
const
int
file_number
=
2
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
addrinfo
*
addr
=
NULL
;
struct
addrinfo
*
addr
=
NULL
;
int
ret
=
getaddrinfo
(
"example.com"
,
"ftp"
,
NULL
,
&
addr
);
int
ret
=
getaddrinfo
(
"example.com"
,
"ftp"
,
NULL
,
&
addr
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
...
@@ -50,6 +61,7 @@ static int AddrInfoTest(void)
...
@@ -50,6 +61,7 @@ static int AddrInfoTest(void)
const
char
*
p
=
gai_strerror
(
EAI_AGAIN
);
const
char
*
p
=
gai_strerror
(
EAI_AGAIN
);
ICUNIT_ASSERT_NOT_EQUAL
(
p
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
p
,
NULL
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_004.cpp
浏览文件 @
0257a0a1
...
@@ -34,8 +34,19 @@
...
@@ -34,8 +34,19 @@
static
int
GetHostByAddrTest
(
void
)
static
int
GetHostByAddrTest
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost
\n
100.0.0.0 example.com example
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
host_file
};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
in_addr
ia
;
struct
in_addr
ia
;
int
length
=
4
;
int
length
=
4
;
// the address length is 4;
ia
.
s_addr
=
inet_addr
(
"127.0.0.1"
);
ia
.
s_addr
=
inet_addr
(
"127.0.0.1"
);
struct
hostent
*
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
struct
hostent
*
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
...
@@ -43,19 +54,18 @@ static int GetHostByAddrTest(void)
...
@@ -43,19 +54,18 @@ static int GetHostByAddrTest(void)
ICUNIT_ASSERT_STRING_EQUAL
(
addr
->
h_name
,
"localhost"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
addr
->
h_name
,
"localhost"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
addr
->
h_length
,
length
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
addr
->
h_length
,
length
,
-
1
);
ia
.
s_addr
=
inet_addr
(
"100.
109.180.184
"
);
ia
.
s_addr
=
inet_addr
(
"100.
0.0.0
"
);
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
addr
->
h_addrtype
,
AF_INET
,
addr
->
h_addrtype
);
ICUNIT_ASSERT_EQUAL
(
addr
->
h_addrtype
,
AF_INET
,
addr
->
h_addrtype
);
ICUNIT_ASSERT_STRING_EQUAL
(
addr
->
h_name
,
"szvphisprb93341"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
addr
->
h_name
,
"example.com"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
addr
->
h_aliases
[
0
],
"szvphisprb93341"
,
-
1
);
errno
=
0
;
errno
=
0
;
ia
.
s_addr
=
inet_addr
(
"127.0.0.0"
);
ia
.
s_addr
=
inet_addr
(
"127.0.0.0"
);
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
addr
=
gethostbyaddr
(
&
ia
,
sizeof
ia
,
AF_INET
);
ICUNIT_ASSERT_EQUAL
(
errno
,
EINVAL
,
errno
);
ICUNIT_ASSERT_EQUAL
(
errno
,
EINVAL
,
errno
);
return
ICUNIT_SUCCESS
;
RecoveryFileEnv
(
pathList
,
file_number
)
;
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_006.cpp
浏览文件 @
0257a0a1
...
@@ -34,6 +34,16 @@
...
@@ -34,6 +34,16 @@
static
int
GetHostByNameTest
(
void
)
static
int
GetHostByNameTest
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
host_file
};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
1
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
1
);
return
-
1
;
}
struct
hostent
*
addr
=
gethostbyname
(
"localhost"
);
struct
hostent
*
addr
=
gethostbyname
(
"localhost"
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
addr
->
h_name
,
"localhost"
),
0
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
addr
->
h_name
,
"localhost"
),
0
,
-
1
);
...
@@ -49,6 +59,7 @@ static int GetHostByNameTest(void)
...
@@ -49,6 +59,7 @@ static int GetHostByNameTest(void)
addr
=
gethostbyname
(
"lo"
);
addr
=
gethostbyname
(
"lo"
);
ICUNIT_ASSERT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
addr
,
NULL
,
-
1
);
RecoveryFileEnv
(
pathList
,
1
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_007.cpp
浏览文件 @
0257a0a1
...
@@ -34,6 +34,17 @@
...
@@ -34,6 +34,17 @@
static
int
GetHostByNameRTest
(
void
)
static
int
GetHostByNameRTest
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
host_file
)};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
hostent
addr
,
*
result
=
NULL
;
struct
hostent
addr
,
*
result
=
NULL
;
char
buf
[
1024
];
char
buf
[
1024
];
char
buf1
[
1
];
char
buf1
[
1
];
...
@@ -60,6 +71,7 @@ static int GetHostByNameRTest(void)
...
@@ -60,6 +71,7 @@ static int GetHostByNameRTest(void)
ret
=
gethostbyname_r
(
"lo"
,
&
addr
,
buf
,
sizeof
buf
,
&
result
,
&
err
);
ret
=
gethostbyname_r
(
"lo"
,
&
addr
,
buf
,
sizeof
buf
,
&
result
,
&
err
);
ICUNIT_ASSERT_NOT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_NOT_EQUAL
(
ret
,
0
,
ret
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_008.cpp
浏览文件 @
0257a0a1
...
@@ -34,6 +34,17 @@
...
@@ -34,6 +34,17 @@
static
int
GetHostByName2Test
(
void
)
static
int
GetHostByName2Test
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
host_file
)};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
hostent
*
addr
=
gethostbyname2
(
"localhost"
,
AF_INET
);
struct
hostent
*
addr
=
gethostbyname2
(
"localhost"
,
AF_INET
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
addr
->
h_name
,
"localhost"
),
0
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
addr
->
h_name
,
"localhost"
),
0
,
-
1
);
...
@@ -51,6 +62,7 @@ static int GetHostByName2Test(void)
...
@@ -51,6 +62,7 @@ static int GetHostByName2Test(void)
addr
=
gethostbyname2
(
"localh"
,
AF_INET
);
addr
=
gethostbyname2
(
"localh"
,
AF_INET
);
ICUNIT_ASSERT_EQUAL
(
addr
,
NULL
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
addr
,
NULL
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_009.cpp
浏览文件 @
0257a0a1
...
@@ -33,6 +33,17 @@
...
@@ -33,6 +33,17 @@
static
int
GetHostByName2RTest
(
void
)
static
int
GetHostByName2RTest
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost
\n
"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
host_file
};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
hostent
addr
,
*
result
=
NULL
;
struct
hostent
addr
,
*
result
=
NULL
;
char
buf
[
1024
];
char
buf
[
1024
];
char
buf1
[
1
];
char
buf1
[
1
];
...
@@ -59,6 +70,7 @@ static int GetHostByName2RTest(void)
...
@@ -59,6 +70,7 @@ static int GetHostByName2RTest(void)
ret
=
gethostbyname2_r
(
"lo"
,
AF_INET
,
&
addr
,
buf
,
sizeof
buf
,
&
result
,
&
err
);
ret
=
gethostbyname2_r
(
"lo"
,
AF_INET
,
&
addr
,
buf
,
sizeof
buf
,
&
result
,
&
err
);
ICUNIT_ASSERT_NOT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_NOT_EQUAL
(
ret
,
0
,
ret
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_011.cpp
浏览文件 @
0257a0a1
...
@@ -35,16 +35,29 @@
...
@@ -35,16 +35,29 @@
static
int
GetServByPortTest
(
void
)
static
int
GetServByPortTest
(
void
)
{
{
// refer to the `/etc/services' file.
// refer to the `/etc/services' file.
char
serv_file
[]
=
"ssh 22/tcp
\n
"
;
char
*
pathList
[]
=
{
"/etc/services"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
serv_file
)};
int
streamLen
[]
=
{
sizeof
(
serv_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
const
int
test_port_no
=
22
;
// ssh port number is 22
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se
=
getservbyport
(
htons
(
22
),
"tcp"
);
struct
servent
*
se
=
getservbyport
(
htons
(
test_port_no
),
"tcp"
);
ICUNIT_ASSERT_NOT_EQUAL
(
se
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se
,
NULL
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_aliases
[
0
],
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
->
s_aliases
[
0
],
"ssh"
,
-
1
);
se1
=
getservbyport
(
htons
(
22
),
"tp"
);
se1
=
getservbyport
(
htons
(
test_port_no
),
"tp"
);
ICUNIT_ASSERT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
,
nullptr
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_012.cpp
浏览文件 @
0257a0a1
...
@@ -35,26 +35,42 @@
...
@@ -35,26 +35,42 @@
static
int
GetServByPortRTest
(
void
)
static
int
GetServByPortRTest
(
void
)
{
{
// refer to the `/etc/services' file.
// refer to the `/etc/services' file.
char
serv_file
[]
=
"ssh 22/tcp
\n
"
;
char
*
pathList
[]
=
{
"/etc/services"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
serv_file
)};
int
streamLen
[]
=
{
sizeof
(
serv_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
servent
se
,
*
result
=
NULL
;
struct
servent
se
,
*
result
=
NULL
;
char
buf
[
1024
];
char
buf
[
1024
];
char
buf1
[
2
];
char
buf1
[
2
];
int
ret
=
getservbyport_r
(
htons
(
22
),
"udp"
,
&
se
,
buf
,
sizeof
buf
,
&
result
);
const
int
test_port_no
=
22
;
// ssh port number is 22
int
ret
=
getservbyport_r
(
htons
(
test_port_no
),
"tcp"
,
&
se
,
buf
,
sizeof
buf
,
&
result
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_NOT_EQUAL
(
result
,
NULL
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
result
,
NULL
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_proto
,
"
ud
p"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_proto
,
"
tc
p"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_aliases
[
0
],
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se
.
s_aliases
[
0
],
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_name
,
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_proto
,
"
ud
p"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_proto
,
"
tc
p"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_aliases
[
0
],
"ssh"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
result
->
s_aliases
[
0
],
"ssh"
,
-
1
);
ret
=
getservbyport_r
(
htons
(
22
),
"udp"
,
&
se
,
buf1
,
sizeof
buf1
,
&
result
);
ret
=
getservbyport_r
(
htons
(
test_port_no
),
"udp"
,
&
se
,
buf
,
sizeof
buf
,
&
result
);
ICUNIT_ASSERT_EQUAL
(
ret
,
ENOENT
,
-
1
);
ret
=
getservbyport_r
(
htons
(
test_port_no
),
"udp"
,
&
se
,
buf1
,
sizeof
buf1
,
&
result
);
ICUNIT_ASSERT_EQUAL
(
ret
,
ERANGE
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
ERANGE
,
ret
);
ret
=
getservbyport_r
(
htons
(
22
),
"ud"
,
&
se
,
buf
,
sizeof
buf
,
&
result
);
ret
=
getservbyport_r
(
htons
(
test_port_no
),
"ud"
,
&
se
,
buf
,
sizeof
buf
,
&
result
);
ICUNIT_ASSERT_EQUAL
(
ret
,
EINVAL
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
EINVAL
,
ret
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_014.cpp
已删除
100644 → 0
浏览文件 @
046d8def
/*
* Copyright (c) 2013-2019 Huawei Technologies Co., Ltd. All rights reserved.
* Copyright (c) 2020-2021 Huawei Device Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "lt_net_netdb.h"
#include <net/if.h>
static
int
IfNameIndexTest
(
void
)
{
struct
if_nameindex
*
idx
=
if_nameindex
();
ICUNIT_ASSERT_NOT_EQUAL
(
idx
,
NULL
,
-
1
);
if_freenameindex
(
idx
);
return
ICUNIT_SUCCESS
;
}
void
NetNetDbTest014
(
void
)
{
TEST_ADD_CASE
(
__FUNCTION__
,
IfNameIndexTest
,
TEST_POSIX
,
TEST_TCP
,
TEST_LEVEL0
,
TEST_FUNCTION
);
}
testsuites/unittest/net/netdb/full/net_netdb_test_015.cpp
浏览文件 @
0257a0a1
...
@@ -44,10 +44,6 @@ static int IfNameToIndexTest(void)
...
@@ -44,10 +44,6 @@ static int IfNameToIndexTest(void)
ICUNIT_ASSERT_NOT_EQUAL
(
str
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
str
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
if_name
,
"lo"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
if_name
,
"lo"
,
-
1
);
str
=
if_indextoname
(
3
,
if_name
);
ICUNIT_ASSERT_EQUAL
(
str
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
errno
,
ENXIO
,
errno
);
ret
=
if_nametoindex
(
"eth1"
);
ret
=
if_nametoindex
(
"eth1"
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
ret
);
ICUNIT_ASSERT_EQUAL
(
errno
,
ENODEV
,
errno
);
ICUNIT_ASSERT_EQUAL
(
errno
,
ENODEV
,
errno
);
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_016.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,23 @@
...
@@ -32,6 +32,23 @@
static
int
GetServByNameTest
(
void
)
static
int
GetServByNameTest
(
void
)
{
{
char
serv_file
[]
=
"echo 7/tcp
\n
"
"echo 7/udp
\n
"
"discard 9/tcp sink null
\n
"
"discard 9/udp sink null
\n
"
"systat 11/tcp users
\n
"
"ssh 22/tcp
\n
"
;
char
*
pathList
[]
=
{
"/etc/services"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
serv_file
)};
int
streamLen
[]
=
{
sizeof
(
serv_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se2
=
nullptr
;
struct
servent
*
se2
=
nullptr
;
...
@@ -53,6 +70,7 @@ static int GetServByNameTest(void)
...
@@ -53,6 +70,7 @@ static int GetServByNameTest(void)
se2
=
getservbyname
(
"systat"
,
"udp"
);
se2
=
getservbyname
(
"systat"
,
"udp"
);
ICUNIT_ASSERT_EQUAL
(
se2
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se2
,
nullptr
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_017.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,17 @@
...
@@ -32,6 +32,17 @@
static
int
GetServByNameRTest
(
void
)
static
int
GetServByNameRTest
(
void
)
{
{
char
serv_file
[]
=
"ssh 22/tcp
\n
"
;
char
*
pathList
[]
=
{
"/etc/services"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
serv_file
)};
int
streamLen
[]
=
{
sizeof
(
serv_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
servent
se
;
struct
servent
se
;
struct
servent
*
result
=
NULL
;
struct
servent
*
result
=
NULL
;
char
buf1
[
1024
]
=
{
0
};
char
buf1
[
1024
]
=
{
0
};
...
@@ -58,6 +69,7 @@ static int GetServByNameRTest(void)
...
@@ -58,6 +69,7 @@ static int GetServByNameRTest(void)
ret
=
getservbyname_r
(
"sh"
,
"tcp"
,
&
se
,
buf1
,
sizeof
buf1
,
&
result
);
ret
=
getservbyname_r
(
"sh"
,
"tcp"
,
&
se
,
buf1
,
sizeof
buf1
,
&
result
);
ICUNIT_ASSERT_EQUAL
(
ret
,
ENOENT
,
ret
);
ICUNIT_ASSERT_EQUAL
(
ret
,
ENOENT
,
ret
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_018.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,28 @@
...
@@ -32,6 +32,28 @@
static
int
GetServEntTest
(
void
)
static
int
GetServEntTest
(
void
)
{
{
char
serv_file
[]
=
"tcpmux 1/tcp # TCP port service multiplexer
\n
"
"echo 7/tcp
\n
"
"echo 7/udp
\n
"
"discard 9/tcp sink null
\n
"
"ssh 100000/tcp
\n
"
"ssh /tcp
\n
"
"ssh 22/"
;
char
*
pathList
[]
=
{
"/etc/services"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
serv_file
)};
int
streamLen
[]
=
{
sizeof
(
serv_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
/* tcpmux,echo,discard port number is 1,7,9 */
const
int
tcpmux_port_no
=
1
;
const
int
echo_port_no
=
7
;
const
int
discard_port_no
=
9
;
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se1
=
nullptr
;
struct
servent
*
se2
=
nullptr
;
struct
servent
*
se2
=
nullptr
;
struct
servent
*
se3
=
nullptr
;
struct
servent
*
se3
=
nullptr
;
...
@@ -40,7 +62,7 @@ static int GetServEntTest(void)
...
@@ -40,7 +62,7 @@ static int GetServEntTest(void)
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
s_name
,
"tcpmux"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
s_name
,
"tcpmux"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
s_port
,
ntohs
(
1
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
s_port
,
ntohs
(
tcpmux_port_no
),
-
1
);
endservent
();
endservent
();
se2
=
getservent
();
se2
=
getservent
();
...
@@ -60,20 +82,28 @@ static int GetServEntTest(void)
...
@@ -60,20 +82,28 @@ static int GetServEntTest(void)
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"echo"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"echo"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
7
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
echo_port_no
),
-
1
);
se3
=
getservent
();
se3
=
getservent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"echo"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"echo"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"udp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"udp"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
7
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
echo_port_no
),
-
1
);
se3
=
getservent
();
se3
=
getservent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"discard"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_name
,
"discard"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_proto
,
"tcp"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
9
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_port
,
ntohs
(
discard_port_no
),
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_aliases
[
0
],
"sink"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_aliases
[
0
],
"sink"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
s_aliases
[
1
],
"null"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
s_aliases
[
2
],
nullptr
,
-
1
);
se3
=
getservent
();
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
endservent
();
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_019.cpp
浏览文件 @
0257a0a1
...
@@ -29,21 +29,37 @@
...
@@ -29,21 +29,37 @@
*/
*/
#include "lt_net_netdb.h"
#include "lt_net_netdb.h"
#include<arpa/nameser.h>
static
int
GetHostEntTest
(
void
)
static
int
GetHostEntTest
(
void
)
{
{
char
host_file
[]
=
"127.0.0.1 localhost #localhost
\n
"
"::1 ip6-localhost
\n
"
"10.0.0.0 example example.com example.cn
\n
"
"10.0.0.0
\n
"
"10.0.0 example.com"
;
char
*
pathList
[]
=
{
"/etc/hosts"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
host_file
)};
int
streamLen
[]
=
{
sizeof
(
host_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
hostent
*
se1
=
nullptr
;
struct
hostent
*
se1
=
nullptr
;
struct
hostent
*
se2
=
nullptr
;
struct
hostent
*
se2
=
nullptr
;
struct
hostent
*
se3
=
nullptr
;
struct
hostent
*
se3
=
nullptr
;
int
type
=
2
;
char
addr
[
INET6_ADDRSTRLEN
];
int
length1
=
4
;
int
length2
=
16
;
se1
=
gethostent
();
se1
=
gethostent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
h_name
,
"localhost"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
h_name
,
"localhost"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
h_addrtype
,
type
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
h_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
h_length
,
length1
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
h_length
,
INADDRSZ
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
"127.0.0.1"
,
inet_ntop
(
AF_INET
,
se1
->
h_addr_list
[
0
],
addr
,
INET_ADDRSTRLEN
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
h_aliases
[
0
],
nullptr
,
-
1
);
endhostent
();
endhostent
();
se2
=
gethostent
();
se2
=
gethostent
();
...
@@ -62,15 +78,24 @@ static int GetHostEntTest(void)
...
@@ -62,15 +78,24 @@ static int GetHostEntTest(void)
se3
=
gethostent
();
se3
=
gethostent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_addrtype
,
AF_INET6
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_addrtype
,
AF_INET6
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_name
,
"localhost"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_name
,
"ip6-localhost"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_length
,
length2
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_length
,
IN6ADDRSZ
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
"::1"
,
inet_ntop
(
AF_INET6
,
se3
->
h_addr_list
[
0
],
addr
,
INET6_ADDRSTRLEN
),
-
1
);
se3
=
gethostent
();
se3
=
gethostent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_name
,
"szvphisprb93341"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_name
,
"example"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_aliases
[
0
],
"szvphisprb93341.huawei.com"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
"10.0.0.0"
,
inet_ntop
(
AF_INET
,
se3
->
h_addr_list
[
0
],
addr
,
INET_ADDRSTRLEN
),
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_aliases
[
0
],
"example.com"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se3
->
h_aliases
[
1
],
"example.cn"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
->
h_aliases
[
2
],
nullptr
,
-
1
);
se3
=
gethostent
();
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
endhostent
();
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_020.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,20 @@
...
@@ -32,6 +32,20 @@
static
int
GetNetEntTest
(
void
)
static
int
GetNetEntTest
(
void
)
{
{
char
network_file
[]
=
"# symbolic names for networks, see networks(5) for more information
\n
"
"link-local 169.254.0.0
\n
"
"example 192.168.1.0 network example-network
\n
"
"test1"
;
char
*
pathList
[]
=
{
"/etc/networks"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
network_file
)};
int
streamLen
[]
=
{
sizeof
(
network_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
...
@@ -39,8 +53,9 @@ static int GetNetEntTest(void)
...
@@ -39,8 +53,9 @@ static int GetNetEntTest(void)
se1
=
getnetent
();
se1
=
getnetent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
2
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_aliases
[
0
],
nullptr
,
-
1
);
endnetent
();
endnetent
();
se2
=
getnetent
();
se2
=
getnetent
();
...
@@ -56,6 +71,20 @@ static int GetNetEntTest(void)
...
@@ -56,6 +71,20 @@ static int GetNetEntTest(void)
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
se3
->
n_addrtype
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
se3
->
n_addrtype
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
se3
->
n_net
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
se3
->
n_net
,
-
1
);
se1
=
getnetent
();
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"example"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"192.168.1.0"
),
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_aliases
[
0
],
"network"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_aliases
[
1
],
"example-network"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_aliases
[
2
],
nullptr
,
-
1
);
se1
=
getnetent
();
ICUNIT_ASSERT_EQUAL
(
se1
,
nullptr
,
-
1
);
endnetent
();
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_021.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,18 @@
...
@@ -32,6 +32,18 @@
static
int
GetNetBynametTest
(
void
)
static
int
GetNetBynametTest
(
void
)
{
{
char
network_file
[]
=
"# symbolic names for networks, see networks(5) for more information
\n
"
"link-local 169.254.0.0
\n
"
;
char
*
pathList
[]
=
{
"/etc/networks"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
network_file
)};
int
streamLen
[]
=
{
sizeof
(
network_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
...
@@ -39,7 +51,7 @@ static int GetNetBynametTest(void)
...
@@ -39,7 +51,7 @@ static int GetNetBynametTest(void)
se1
=
getnetbyname
(
"link-local"
);
se1
=
getnetbyname
(
"link-local"
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
2
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
se2
=
getnetbyname
(
"link"
);
se2
=
getnetbyname
(
"link"
);
...
@@ -48,6 +60,7 @@ static int GetNetBynametTest(void)
...
@@ -48,6 +60,7 @@ static int GetNetBynametTest(void)
se3
=
getnetbyname
(
"hs"
);
se3
=
getnetbyname
(
"hs"
);
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/full/net_netdb_test_022.cpp
浏览文件 @
0257a0a1
...
@@ -32,6 +32,18 @@
...
@@ -32,6 +32,18 @@
static
int
GetNetByAddrtTest
(
void
)
static
int
GetNetByAddrtTest
(
void
)
{
{
char
network_file
[]
=
"# symbolic names for networks, see networks(5) for more information
\n
"
"link-local 169.254.0.0
\n
"
;
char
*
pathList
[]
=
{
"/etc/networks"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
network_file
)};
int
streamLen
[]
=
{
sizeof
(
network_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se1
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se2
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
struct
netent
*
se3
=
nullptr
;
...
@@ -39,7 +51,7 @@ static int GetNetByAddrtTest(void)
...
@@ -39,7 +51,7 @@ static int GetNetByAddrtTest(void)
se1
=
getnetbyaddr
(
inet_network
(
"169.254.0.0"
),
AF_INET
);
se1
=
getnetbyaddr
(
inet_network
(
"169.254.0.0"
),
AF_INET
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_NOT_EQUAL
(
se1
,
nullptr
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_STRING_EQUAL
(
se1
->
n_name
,
"link-local"
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
2
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_addrtype
,
AF_INET
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
ICUNIT_ASSERT_EQUAL
(
se1
->
n_net
,
inet_network
(
"169.254.0.0"
),
-
1
);
se2
=
getnetbyaddr
(
inet_network
(
"169.254.0.1"
),
AF_INET
);
se2
=
getnetbyaddr
(
inet_network
(
"169.254.0.1"
),
AF_INET
);
...
@@ -48,6 +60,7 @@ static int GetNetByAddrtTest(void)
...
@@ -48,6 +60,7 @@ static int GetNetByAddrtTest(void)
se3
=
getnetbyaddr
(
inet_network
(
"169.254.0.1"
),
AF_INET6
);
se3
=
getnetbyaddr
(
inet_network
(
"169.254.0.1"
),
AF_INET6
);
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
se3
,
nullptr
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/netdb/lt_net_netdb.h
浏览文件 @
0257a0a1
...
@@ -52,7 +52,6 @@ void NetNetDbTest010(void);
...
@@ -52,7 +52,6 @@ void NetNetDbTest010(void);
void
NetNetDbTest011
(
void
);
void
NetNetDbTest011
(
void
);
void
NetNetDbTest012
(
void
);
void
NetNetDbTest012
(
void
);
void
NetNetDbTest013
(
void
);
void
NetNetDbTest013
(
void
);
void
NetNetDbTest014
(
void
);
void
NetNetDbTest015
(
void
);
void
NetNetDbTest015
(
void
);
void
NetNetDbTest016
(
void
);
void
NetNetDbTest016
(
void
);
void
NetNetDbTest017
(
void
);
void
NetNetDbTest017
(
void
);
...
...
testsuites/unittest/net/netdb/net_netdb_test.cpp
浏览文件 @
0257a0a1
...
@@ -72,5 +72,206 @@ HWTEST_F(NetDbTest, NetNetDbTest013, TestSize.Level0)
...
@@ -72,5 +72,206 @@ HWTEST_F(NetDbTest, NetNetDbTest013, TestSize.Level0)
NetNetDbTest013
();
NetNetDbTest013
();
}
}
#endif
#if defined(LOSCFG_USER_TEST_FULL)
/* *
* @tc.name: NetNetDbTest018
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest018
,
TestSize
.
Level0
)
{
NetNetDbTest018
();
}
/* *
* @tc.name: NetNetDbTest002
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest002
,
TestSize
.
Level0
)
{
NetNetDbTest002
();
}
/* *
* @tc.name: NetNetDbTest003
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest003
,
TestSize
.
Level0
)
{
NetNetDbTest003
();
}
/* *
* @tc.name: NetNetDbTest004
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest004
,
TestSize
.
Level0
)
{
NetNetDbTest004
();
}
/* *
* @tc.name: NetNetDbTest006
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest006
,
TestSize
.
Level0
)
{
NetNetDbTest006
();
}
/* *
* @tc.name: NetNetDbTest007
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest007
,
TestSize
.
Level0
)
{
NetNetDbTest007
();
}
/* *
* @tc.name: NetNetDbTest008
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest008
,
TestSize
.
Level0
)
{
NetNetDbTest008
();
}
/* *
* @tc.name: NetNetDbTest009
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest009
,
TestSize
.
Level0
)
{
NetNetDbTest009
();
}
/* *
* @tc.name: NetNetDbTest010
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest010
,
TestSize
.
Level0
)
{
NetNetDbTest010
();
}
/* *
* @tc.name: NetNetDbTest011
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest011
,
TestSize
.
Level0
)
{
NetNetDbTest011
();
}
/* *
* @tc.name: NetNetDbTest012
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest012
,
TestSize
.
Level0
)
{
NetNetDbTest012
();
}
/* *
* @tc.name: NetNetDbTest015
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest015
,
TestSize
.
Level0
)
{
NetNetDbTest015
();
}
/* *
* @tc.name: NetNetDbTest016
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest016
,
TestSize
.
Level0
)
{
NetNetDbTest016
();
}
/* *
* @tc.name: NetNetDbTest017
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest017
,
TestSize
.
Level0
)
{
NetNetDbTest017
();
}
/* *
* @tc.name: NetNetDbTest019
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest019
,
TestSize
.
Level0
)
{
NetNetDbTest019
();
}
/* *
* @tc.name: NetNetDbTest020
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest020
,
TestSize
.
Level0
)
{
NetNetDbTest020
();
}
/* *
* @tc.name: NetNetDbTest021
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest021
,
TestSize
.
Level0
)
{
NetNetDbTest021
();
}
/* *
* @tc.name: NetNetDbTest022
* @tc.desc: function for NetDbTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
HWTEST_F
(
NetDbTest
,
NetNetDbTest022
,
TestSize
.
Level0
)
{
NetNetDbTest022
();
}
#endif
#endif
}
}
testsuites/unittest/net/resolv/full/net_resolv_test_004.cpp
浏览文件 @
0257a0a1
...
@@ -34,6 +34,17 @@
...
@@ -34,6 +34,17 @@
static
int
EtherHosttonTest
(
void
)
static
int
EtherHosttonTest
(
void
)
{
{
// suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
// suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
char
ether_file
[]
=
"0:0:0:0:0:0 localhost"
;
char
*
pathList
[]
=
{
"/etc/ethers"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
ether_file
)};
int
streamLen
[]
=
{
sizeof
(
ether_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
ether_addr
addr
,
*
eaddr
=
&
addr
;
struct
ether_addr
addr
,
*
eaddr
=
&
addr
;
int
ret
=
ether_hostton
(
"localhost"
,
eaddr
);
int
ret
=
ether_hostton
(
"localhost"
,
eaddr
);
...
@@ -45,6 +56,7 @@ static int EtherHosttonTest(void)
...
@@ -45,6 +56,7 @@ static int EtherHosttonTest(void)
ICUNIT_ASSERT_EQUAL
(
eaddr
->
ether_addr_octet
[
4
],
0x00
,
eaddr
->
ether_addr_octet
[
4
]);
ICUNIT_ASSERT_EQUAL
(
eaddr
->
ether_addr_octet
[
4
],
0x00
,
eaddr
->
ether_addr_octet
[
4
]);
ICUNIT_ASSERT_EQUAL
(
eaddr
->
ether_addr_octet
[
5
],
0x00
,
eaddr
->
ether_addr_octet
[
5
]);
ICUNIT_ASSERT_EQUAL
(
eaddr
->
ether_addr_octet
[
5
],
0x00
,
eaddr
->
ether_addr_octet
[
5
]);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
testsuites/unittest/net/resolv/full/net_resolv_test_008.cpp
浏览文件 @
0257a0a1
...
@@ -35,6 +35,17 @@
...
@@ -35,6 +35,17 @@
static
int
EtherNtohostTest
(
void
)
static
int
EtherNtohostTest
(
void
)
{
{
// suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
// suppose "0:0:0:0:0:0 localhost" in `/etc/ethers' file.
char
ether_file
[]
=
"0:0:0:0:0:0 localhost"
;
char
*
pathList
[]
=
{
"/etc/ethers"
};
char
*
streamList
[]
=
{
static_cast
<
char
*>
(
ether_file
)};
int
streamLen
[]
=
{
sizeof
(
ether_file
)};
const
int
file_number
=
1
;
int
flag
=
PrepareFileEnv
(
pathList
,
streamList
,
streamLen
,
file_number
);
if
(
flag
!=
0
)
{
RecoveryFileEnv
(
pathList
,
file_number
);
return
-
1
;
}
struct
ether_addr
addr
=
{{
0
,
0
,
0
,
0
,
0
,
0
}},
*
eaddr
=
&
addr
;
struct
ether_addr
addr
=
{{
0
,
0
,
0
,
0
,
0
,
0
}},
*
eaddr
=
&
addr
;
char
buf
[
100
];
char
buf
[
100
];
int
ret
=
ether_ntohost
(
buf
,
eaddr
);
int
ret
=
ether_ntohost
(
buf
,
eaddr
);
...
@@ -42,6 +53,7 @@ static int EtherNtohostTest(void)
...
@@ -42,6 +53,7 @@ static int EtherNtohostTest(void)
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
ret
,
0
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
"localhost"
,
buf
),
0
,
-
1
);
ICUNIT_ASSERT_EQUAL
(
strcmp
(
"localhost"
,
buf
),
0
,
-
1
);
RecoveryFileEnv
(
pathList
,
file_number
);
return
ICUNIT_SUCCESS
;
return
ICUNIT_SUCCESS
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录