Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-11-06 12:50:27 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f8f18fffa75fc18fe1d29ceab1b8383c89aafbd3
f8f18fff
1 parent
0f293802
research st: update test for st.
隐藏空白字符变更
内嵌
并排对比
正在显示
1 个修改的文件
包含
56 行增加
和
0 行删除
trunk/research/st/srs.c
trunk/research/st/srs.c
查看文件 @
f8f18ff
...
...
@@ -147,6 +147,8 @@ void* io_client(void* arg)
return
NULL
;
}
st_netfd_close
(
stfd
);
return
NULL
;
}
...
...
@@ -211,10 +213,59 @@ int io_test()
}
srs_trace
(
"9. server io completed."
);
st_netfd_close
(
stfd
);
st_netfd_close
(
client_stfd
);
srs_trace
(
"io test: end"
);
return
0
;
}
int
pipe_test
()
{
srs_trace
(
"==================================================="
);
srs_trace
(
"pipe test: start"
);
int
fds
[
2
];
if
(
pipe
(
fds
)
<
0
)
{
srs_trace
(
"pipe failed"
);
return
-
1
;
}
srs_trace
(
"1. pipe ok, %d=>%d"
,
fds
[
1
],
fds
[
0
]);
st_netfd_t
fdw
;
if
((
fdw
=
st_netfd_open_socket
(
fds
[
1
]))
==
NULL
)
{
srs_trace
(
"st_netfd_open_socket open socket failed."
);
return
-
1
;
}
srs_trace
(
"2. open write fd ok"
);
st_netfd_t
fdr
;
if
((
fdr
=
st_netfd_open_socket
(
fds
[
0
]))
==
NULL
)
{
srs_trace
(
"st_netfd_open_socket open socket failed."
);
return
-
1
;
}
srs_trace
(
"3. open read fd ok"
);
char
buf
[
1024
];
if
(
st_write
(
fdw
,
buf
,
sizeof
(
buf
),
ST_UTIME_NO_TIMEOUT
)
<
0
)
{
srs_trace
(
"st_write socket failed."
);
return
-
1
;
}
srs_trace
(
"4. write to pipe ok"
);
if
(
st_read
(
fdr
,
buf
,
sizeof
(
buf
),
ST_UTIME_NO_TIMEOUT
)
<
0
)
{
srs_trace
(
"st_read socket failed."
);
return
-
1
;
}
srs_trace
(
"5. read from pipe ok"
);
st_netfd_close
(
fdw
);
st_netfd_close
(
fdr
);
srs_trace
(
"pipe test: end"
);
return
0
;
}
int
main
(
int
argc
,
char
**
argv
)
{
if
(
st_set_eventsys
(
ST_EVENTSYS_ALT
)
<
0
)
{
...
...
@@ -237,6 +288,11 @@ int main(int argc, char** argv)
return
-
1
;
}
if
(
pipe_test
()
<
0
)
{
srs_trace
(
"pipe_test failed"
);
return
-
1
;
}
// cleanup.
st_thread_exit
(
NULL
);
...
...
请
注册
或
登录
后发表评论