Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
b0aa73bf
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
b0aa73bf
编写于
3月 19, 2013
作者:
D
David S. Miller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
net: Add socket() system call self test.
Signed-off-by:
N
David S. Miller
<
davem@davemloft.net
>
上级
b5fb82c4
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
121 addition
and
0 deletion
+121
-0
tools/testing/selftests/Makefile
tools/testing/selftests/Makefile
+1
-0
tools/testing/selftests/net-socket/Makefile
tools/testing/selftests/net-socket/Makefile
+16
-0
tools/testing/selftests/net-socket/run_netsocktests
tools/testing/selftests/net-socket/run_netsocktests
+12
-0
tools/testing/selftests/net-socket/socket.c
tools/testing/selftests/net-socket/socket.c
+92
-0
未找到文件。
tools/testing/selftests/Makefile
浏览文件 @
b0aa73bf
...
...
@@ -5,6 +5,7 @@ TARGETS += vm
TARGETS
+=
cpu-hotplug
TARGETS
+=
memory-hotplug
TARGETS
+=
efivarfs
TARGETS
+=
net-socket
all
:
for
TARGET
in
$(TARGETS)
;
do
\
...
...
tools/testing/selftests/net-socket/Makefile
0 → 100644
浏览文件 @
b0aa73bf
# Makefile for net-socket selftests
CC
=
$(CROSS_COMPILE)
gcc
CFLAGS
=
-Wall
NET_SOCK_PROGS
=
socket
all
:
$(NET_SOCK_PROGS)
%
:
%.c
$(CC)
$(CFLAGS)
-o
$@
$^
run_tests
:
all
@
/bin/sh ./run_netsocktests
||
echo
"vmtests: [FAIL]"
clean
:
$(RM)
$(NET_SOCK_PROGS)
tools/testing/selftests/net-socket/run_netsocktests
0 → 100644
浏览文件 @
b0aa73bf
#!/bin/bash
echo
"--------------------"
echo
"running socket test"
echo
"--------------------"
./socket
if
[
$?
-ne
0
]
;
then
echo
"[FAIL]"
else
echo
"[PASS]"
fi
tools/testing/selftests/net-socket/socket.c
0 → 100644
浏览文件 @
b0aa73bf
#include <stdio.h>
#include <errno.h>
#include <unistd.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
struct
socket_testcase
{
int
domain
;
int
type
;
int
protocol
;
/* 0 = valid file descriptor
* -foo = error foo
*/
int
expect
;
/* If non-zero, accept EAFNOSUPPORT to handle the case
* of the protocol not being configured into the kernel.
*/
int
nosupport_ok
;
};
static
struct
socket_testcase
tests
[]
=
{
{
AF_MAX
,
0
,
0
,
-
EAFNOSUPPORT
,
0
},
{
AF_INET
,
SOCK_STREAM
,
IPPROTO_TCP
,
0
,
1
},
{
AF_INET
,
SOCK_DGRAM
,
IPPROTO_TCP
,
-
EPROTONOSUPPORT
,
1
},
{
AF_INET
,
SOCK_DGRAM
,
IPPROTO_UDP
,
0
,
1
},
{
AF_INET
,
SOCK_STREAM
,
IPPROTO_UDP
,
-
EPROTONOSUPPORT
,
1
},
};
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
#define ERR_STRING_SZ 64
static
int
run_tests
(
void
)
{
char
err_string1
[
ERR_STRING_SZ
];
char
err_string2
[
ERR_STRING_SZ
];
int
i
,
err
;
err
=
0
;
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
i
++
)
{
struct
socket_testcase
*
s
=
&
tests
[
i
];
int
fd
;
fd
=
socket
(
s
->
domain
,
s
->
type
,
s
->
protocol
);
if
(
fd
<
0
)
{
if
(
s
->
nosupport_ok
&&
errno
==
EAFNOSUPPORT
)
continue
;
if
(
s
->
expect
<
0
&&
errno
==
-
s
->
expect
)
continue
;
strerror_r
(
-
s
->
expect
,
err_string1
,
ERR_STRING_SZ
);
strerror_r
(
errno
,
err_string2
,
ERR_STRING_SZ
);
fprintf
(
stderr
,
"socket(%d, %d, %d) expected "
"err (%s) got (%s)
\n
"
,
s
->
domain
,
s
->
type
,
s
->
protocol
,
err_string1
,
err_string2
);
err
=
-
1
;
break
;
}
else
{
close
(
fd
);
if
(
s
->
expect
<
0
)
{
strerror_r
(
errno
,
err_string1
,
ERR_STRING_SZ
);
fprintf
(
stderr
,
"socket(%d, %d, %d) expected "
"success got err (%s)
\n
"
,
s
->
domain
,
s
->
type
,
s
->
protocol
,
err_string1
);
err
=
-
1
;
break
;
}
}
}
return
err
;
}
int
main
(
void
)
{
int
err
=
run_tests
();
return
err
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录