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-07-26 15:54:40 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
30ebba0673b76c39d542d4b1cc4e62bd7984ce2e
30ebba06
1 parent
ebf9e560
add config check utest
显示空白字符变更
内嵌
并排对比
正在显示
4 个修改的文件
包含
144 行增加
和
20 行删除
trunk/conf/full.conf
trunk/src/app/srs_app_config.hpp
trunk/src/utest/srs_utest.cpp
trunk/src/utest/srs_utest_config.cpp
trunk/conf/full.conf
查看文件 @
30ebba0
...
...
@@ -36,7 +36,7 @@ srs_log_level trace;
srs_log_file
./
objs
/
srs
.
log
;
# the max connections.
# if exceed the max connections, server will drop the new connection.
# default: 1
2345
# default: 1
000
max_connections
1000
;
# whether start as deamon
# @remark: donot support reload.
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
30ebba0
...
...
@@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf"
#define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs"
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1
2345
#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1
000
#define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html"
#define SRS_CONF_DEFAULT_HLS_FRAGMENT 10
#define SRS_CONF_DEFAULT_HLS_WINDOW 60
...
...
trunk/src/utest/srs_utest.cpp
查看文件 @
30ebba0
...
...
@@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <srs_app_log.hpp>
// kernel module.
ISrsLog
*
_srs_log
=
new
MockEmptyLog
(
SrsLogLevel
::
Disabled
);
ISrsLog
*
_srs_log
=
new
MockEmptyLog
(
SrsLogLevel
::
Warn
);
ISrsThreadContext
*
_srs_context
=
new
ISrsThreadContext
();
// app module.
SrsConfig
*
_srs_config
=
NULL
;
...
...
trunk/src/utest/srs_utest_config.cpp
查看文件 @
30ebba0
...
...
@@ -29,6 +29,8 @@ using namespace std;
#include <srs_kernel_error.hpp>
#include <srs_app_source.hpp>
#define _MIN_OK_CONF "listen 1935; "
// full.conf
std
::
string
__full_conf
=
""
"# all config for srs
\n
"
...
...
@@ -1787,13 +1789,11 @@ VOID TEST(ConfigMainTest, ParseEmpty)
VOID
TEST
(
ConfigMainTest
,
ParseMinConf
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
"listen 1935; max_connections 1000;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
));
vector
<
string
>
listens
=
conf
.
get_listen
();
EXPECT_EQ
(
1
,
(
int
)
listens
.
size
());
EXPECT_STREQ
(
"1935"
,
listens
.
at
(
0
).
c_str
());
EXPECT_EQ
(
1000
,
conf
.
get_max_connections
());
}
VOID
TEST
(
ConfigMainTest
,
ParseInvalidDirective
)
...
...
@@ -4348,6 +4348,11 @@ VOID TEST(ConfigMainTest, CheckConf_listen)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"listens 1935;"
));
}
...
...
@@ -4371,7 +4376,7 @@ VOID TEST(ConfigMainTest, CheckConf_pid)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"pids ./objs/srs.pid;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"pids ./objs/srs.pid;"
));
}
}
...
...
@@ -4379,37 +4384,42 @@ VOID TEST(ConfigMainTest, CheckConf_chunk_size)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_sizes
60000;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"chunk_size
60000;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size
0;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_sizes 6000
0;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size 1
;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size 0
;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size 127
;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size 1
;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size -1
;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size 127
;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size -4096
;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size -1
;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"chunk_size 65536;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size -4096;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"chunk_size 65537;"
));
}
}
...
...
@@ -4417,7 +4427,12 @@ VOID TEST(ConfigMainTest, CheckConf_ff_log_dir)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"ff_log_dirs ./objs;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"ff_log_dir ./objs;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"ff_log_dirs ./objs;"
));
}
}
...
...
@@ -4425,7 +4440,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_level)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"srs_log_levels trace;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"srs_log_level trace;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"srs_log_levels trace;"
));
}
}
...
...
@@ -4433,7 +4453,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_file)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"srs_log_files ./objs/srs.log;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"srs_log_file ./objs/srs.log;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"srs_log_files ./objs/srs.log;"
));
}
}
...
...
@@ -4441,12 +4466,106 @@ VOID TEST(ConfigMainTest, CheckConf_max_connections)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"max_connectionss 1000;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"max_connections 1000;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"max_connectionss 1000;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"max_connections 0;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"max_connections 1000000;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"max_connections -1;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"max_connections -1024;"
));
}
}
VOID
TEST
(
ConfigMainTest
,
CheckConf_daemon
)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"daemon on;"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"daemons on;"
));
}
}
VOID
TEST
(
ConfigMainTest
,
CheckConf_heartbeat
)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeats{}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{enableds on;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{intervals 9;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"max_connections 0;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{urls http://127.0.0.1:8085/api/v1/servers;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{device_ids 0;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{device_indexs 0;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{device_index -1;}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"heartbeat{summariess on;}"
));
}
}
VOID
TEST
(
ConfigMainTest
,
CheckConf_http_api
)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
"http_api{}"
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"http_apis{}"
));
}
}
...
...
@@ -4454,6 +4573,11 @@ VOID TEST(ConfigMainTest, CheckConf_)
{
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
"listens 1935;"
));
EXPECT_TRUE
(
ERROR_SUCCESS
==
conf
.
parse
(
_MIN_OK_CONF
""
));
}
if
(
true
)
{
MockSrsConfig
conf
;
EXPECT_TRUE
(
ERROR_SUCCESS
!=
conf
.
parse
(
_MIN_OK_CONF
"http_apis{}"
));
}
}
...
...
请
注册
或
登录
后发表评论