正在显示
4 个修改的文件
包含
144 行增加
和
20 行删除
@@ -36,7 +36,7 @@ srs_log_level trace; | @@ -36,7 +36,7 @@ srs_log_level trace; | ||
36 | srs_log_file ./objs/srs.log; | 36 | srs_log_file ./objs/srs.log; |
37 | # the max connections. | 37 | # the max connections. |
38 | # if exceed the max connections, server will drop the new connection. | 38 | # if exceed the max connections, server will drop the new connection. |
39 | -# default: 12345 | 39 | +# default: 1000 |
40 | max_connections 1000; | 40 | max_connections 1000; |
41 | # whether start as deamon | 41 | # whether start as deamon |
42 | # @remark: donot support reload. | 42 | # @remark: donot support reload. |
@@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -44,7 +44,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
44 | #define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf" | 44 | #define SRS_CONF_DEFAULT_COFNIG_FILE "conf/srs.conf" |
45 | #define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs" | 45 | #define SRS_CONF_DEFAULT_FF_LOG_DIR "./objs" |
46 | 46 | ||
47 | -#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 12345 | 47 | +#define SRS_CONF_DEFAULT_MAX_CONNECTIONS 1000 |
48 | #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" | 48 | #define SRS_CONF_DEFAULT_HLS_PATH "./objs/nginx/html" |
49 | #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 | 49 | #define SRS_CONF_DEFAULT_HLS_FRAGMENT 10 |
50 | #define SRS_CONF_DEFAULT_HLS_WINDOW 60 | 50 | #define SRS_CONF_DEFAULT_HLS_WINDOW 60 |
@@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | @@ -30,7 +30,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
30 | #include <srs_app_log.hpp> | 30 | #include <srs_app_log.hpp> |
31 | 31 | ||
32 | // kernel module. | 32 | // kernel module. |
33 | -ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Disabled); | 33 | +ISrsLog* _srs_log = new MockEmptyLog(SrsLogLevel::Warn); |
34 | ISrsThreadContext* _srs_context = new ISrsThreadContext(); | 34 | ISrsThreadContext* _srs_context = new ISrsThreadContext(); |
35 | // app module. | 35 | // app module. |
36 | SrsConfig* _srs_config = NULL; | 36 | SrsConfig* _srs_config = NULL; |
@@ -29,6 +29,8 @@ using namespace std; | @@ -29,6 +29,8 @@ using namespace std; | ||
29 | #include <srs_kernel_error.hpp> | 29 | #include <srs_kernel_error.hpp> |
30 | #include <srs_app_source.hpp> | 30 | #include <srs_app_source.hpp> |
31 | 31 | ||
32 | +#define _MIN_OK_CONF "listen 1935; " | ||
33 | + | ||
32 | // full.conf | 34 | // full.conf |
33 | std::string __full_conf = "" | 35 | std::string __full_conf = "" |
34 | "# all config for srs \n" | 36 | "# all config for srs \n" |
@@ -1787,13 +1789,11 @@ VOID TEST(ConfigMainTest, ParseEmpty) | @@ -1787,13 +1789,11 @@ VOID TEST(ConfigMainTest, ParseEmpty) | ||
1787 | VOID TEST(ConfigMainTest, ParseMinConf) | 1789 | VOID TEST(ConfigMainTest, ParseMinConf) |
1788 | { | 1790 | { |
1789 | MockSrsConfig conf; | 1791 | MockSrsConfig conf; |
1790 | - EXPECT_TRUE(ERROR_SUCCESS == conf.parse("listen 1935; max_connections 1000;")); | 1792 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF)); |
1791 | 1793 | ||
1792 | vector<string> listens = conf.get_listen(); | 1794 | vector<string> listens = conf.get_listen(); |
1793 | EXPECT_EQ(1, (int)listens.size()); | 1795 | EXPECT_EQ(1, (int)listens.size()); |
1794 | EXPECT_STREQ("1935", listens.at(0).c_str()); | 1796 | EXPECT_STREQ("1935", listens.at(0).c_str()); |
1795 | - | ||
1796 | - EXPECT_EQ(1000, conf.get_max_connections()); | ||
1797 | } | 1797 | } |
1798 | 1798 | ||
1799 | VOID TEST(ConfigMainTest, ParseInvalidDirective) | 1799 | VOID TEST(ConfigMainTest, ParseInvalidDirective) |
@@ -4348,6 +4348,11 @@ VOID TEST(ConfigMainTest, CheckConf_listen) | @@ -4348,6 +4348,11 @@ VOID TEST(ConfigMainTest, CheckConf_listen) | ||
4348 | { | 4348 | { |
4349 | if (true) { | 4349 | if (true) { |
4350 | MockSrsConfig conf; | 4350 | MockSrsConfig conf; |
4351 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF)); | ||
4352 | + } | ||
4353 | + | ||
4354 | + if (true) { | ||
4355 | + MockSrsConfig conf; | ||
4351 | EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listens 1935;")); | 4356 | EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listens 1935;")); |
4352 | } | 4357 | } |
4353 | 4358 | ||
@@ -4371,7 +4376,7 @@ VOID TEST(ConfigMainTest, CheckConf_pid) | @@ -4371,7 +4376,7 @@ VOID TEST(ConfigMainTest, CheckConf_pid) | ||
4371 | { | 4376 | { |
4372 | if (true) { | 4377 | if (true) { |
4373 | MockSrsConfig conf; | 4378 | MockSrsConfig conf; |
4374 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("pids ./objs/srs.pid;")); | 4379 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"pids ./objs/srs.pid;")); |
4375 | } | 4380 | } |
4376 | } | 4381 | } |
4377 | 4382 | ||
@@ -4379,37 +4384,42 @@ VOID TEST(ConfigMainTest, CheckConf_chunk_size) | @@ -4379,37 +4384,42 @@ VOID TEST(ConfigMainTest, CheckConf_chunk_size) | ||
4379 | { | 4384 | { |
4380 | if (true) { | 4385 | if (true) { |
4381 | MockSrsConfig conf; | 4386 | MockSrsConfig conf; |
4382 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_sizes 60000;")); | 4387 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"chunk_size 60000;")); |
4383 | } | 4388 | } |
4384 | 4389 | ||
4385 | if (true) { | 4390 | if (true) { |
4386 | MockSrsConfig conf; | 4391 | MockSrsConfig conf; |
4387 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 0;")); | 4392 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_sizes 60000;")); |
4388 | } | 4393 | } |
4389 | 4394 | ||
4390 | if (true) { | 4395 | if (true) { |
4391 | MockSrsConfig conf; | 4396 | MockSrsConfig conf; |
4392 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 1;")); | 4397 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size 0;")); |
4393 | } | 4398 | } |
4394 | 4399 | ||
4395 | if (true) { | 4400 | if (true) { |
4396 | MockSrsConfig conf; | 4401 | MockSrsConfig conf; |
4397 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 127;")); | 4402 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size 1;")); |
4398 | } | 4403 | } |
4399 | 4404 | ||
4400 | if (true) { | 4405 | if (true) { |
4401 | MockSrsConfig conf; | 4406 | MockSrsConfig conf; |
4402 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size -1;")); | 4407 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size 127;")); |
4403 | } | 4408 | } |
4404 | 4409 | ||
4405 | if (true) { | 4410 | if (true) { |
4406 | MockSrsConfig conf; | 4411 | MockSrsConfig conf; |
4407 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size -4096;")); | 4412 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size -1;")); |
4408 | } | 4413 | } |
4409 | 4414 | ||
4410 | if (true) { | 4415 | if (true) { |
4411 | MockSrsConfig conf; | 4416 | MockSrsConfig conf; |
4412 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("chunk_size 65536;")); | 4417 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size -4096;")); |
4418 | + } | ||
4419 | + | ||
4420 | + if (true) { | ||
4421 | + MockSrsConfig conf; | ||
4422 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"chunk_size 65537;")); | ||
4413 | } | 4423 | } |
4414 | } | 4424 | } |
4415 | 4425 | ||
@@ -4417,7 +4427,12 @@ VOID TEST(ConfigMainTest, CheckConf_ff_log_dir) | @@ -4417,7 +4427,12 @@ VOID TEST(ConfigMainTest, CheckConf_ff_log_dir) | ||
4417 | { | 4427 | { |
4418 | if (true) { | 4428 | if (true) { |
4419 | MockSrsConfig conf; | 4429 | MockSrsConfig conf; |
4420 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("ff_log_dirs ./objs;")); | 4430 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"ff_log_dir ./objs;")); |
4431 | + } | ||
4432 | + | ||
4433 | + if (true) { | ||
4434 | + MockSrsConfig conf; | ||
4435 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"ff_log_dirs ./objs;")); | ||
4421 | } | 4436 | } |
4422 | } | 4437 | } |
4423 | 4438 | ||
@@ -4425,7 +4440,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_level) | @@ -4425,7 +4440,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_level) | ||
4425 | { | 4440 | { |
4426 | if (true) { | 4441 | if (true) { |
4427 | MockSrsConfig conf; | 4442 | MockSrsConfig conf; |
4428 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("srs_log_levels trace;")); | 4443 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_level trace;")); |
4444 | + } | ||
4445 | + | ||
4446 | + if (true) { | ||
4447 | + MockSrsConfig conf; | ||
4448 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"srs_log_levels trace;")); | ||
4429 | } | 4449 | } |
4430 | } | 4450 | } |
4431 | 4451 | ||
@@ -4433,7 +4453,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_file) | @@ -4433,7 +4453,12 @@ VOID TEST(ConfigMainTest, CheckConf_srs_log_file) | ||
4433 | { | 4453 | { |
4434 | if (true) { | 4454 | if (true) { |
4435 | MockSrsConfig conf; | 4455 | MockSrsConfig conf; |
4436 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("srs_log_files ./objs/srs.log;")); | 4456 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"srs_log_file ./objs/srs.log;")); |
4457 | + } | ||
4458 | + | ||
4459 | + if (true) { | ||
4460 | + MockSrsConfig conf; | ||
4461 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"srs_log_files ./objs/srs.log;")); | ||
4437 | } | 4462 | } |
4438 | } | 4463 | } |
4439 | 4464 | ||
@@ -4441,12 +4466,106 @@ VOID TEST(ConfigMainTest, CheckConf_max_connections) | @@ -4441,12 +4466,106 @@ VOID TEST(ConfigMainTest, CheckConf_max_connections) | ||
4441 | { | 4466 | { |
4442 | if (true) { | 4467 | if (true) { |
4443 | MockSrsConfig conf; | 4468 | MockSrsConfig conf; |
4444 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("max_connectionss 1000;")); | 4469 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"max_connections 1000;")); |
4470 | + } | ||
4471 | + | ||
4472 | + if (true) { | ||
4473 | + MockSrsConfig conf; | ||
4474 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connectionss 1000;")); | ||
4475 | + } | ||
4476 | + | ||
4477 | + if (true) { | ||
4478 | + MockSrsConfig conf; | ||
4479 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections 0;")); | ||
4480 | + } | ||
4481 | + | ||
4482 | + if (true) { | ||
4483 | + MockSrsConfig conf; | ||
4484 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections 1000000;")); | ||
4485 | + } | ||
4486 | + | ||
4487 | + if (true) { | ||
4488 | + MockSrsConfig conf; | ||
4489 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections -1;")); | ||
4490 | + } | ||
4491 | + | ||
4492 | + if (true) { | ||
4493 | + MockSrsConfig conf; | ||
4494 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"max_connections -1024;")); | ||
4495 | + } | ||
4496 | +} | ||
4497 | + | ||
4498 | +VOID TEST(ConfigMainTest, CheckConf_daemon) | ||
4499 | +{ | ||
4500 | + if (true) { | ||
4501 | + MockSrsConfig conf; | ||
4502 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"daemon on;")); | ||
4503 | + } | ||
4504 | + | ||
4505 | + if (true) { | ||
4506 | + MockSrsConfig conf; | ||
4507 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"daemons on;")); | ||
4508 | + } | ||
4509 | +} | ||
4510 | + | ||
4511 | +VOID TEST(ConfigMainTest, CheckConf_heartbeat) | ||
4512 | +{ | ||
4513 | + if (true) { | ||
4514 | + MockSrsConfig conf; | ||
4515 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"heartbeat{}")); | ||
4516 | + } | ||
4517 | + | ||
4518 | + if (true) { | ||
4519 | + MockSrsConfig conf; | ||
4520 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeats{}")); | ||
4521 | + } | ||
4522 | + | ||
4523 | + if (true) { | ||
4524 | + MockSrsConfig conf; | ||
4525 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{enableds on;}")); | ||
4526 | + } | ||
4527 | + | ||
4528 | + if (true) { | ||
4529 | + MockSrsConfig conf; | ||
4530 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{intervals 9;}")); | ||
4445 | } | 4531 | } |
4446 | 4532 | ||
4447 | if (true) { | 4533 | if (true) { |
4448 | MockSrsConfig conf; | 4534 | MockSrsConfig conf; |
4449 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("max_connections 0;")); | 4535 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{urls http://127.0.0.1:8085/api/v1/servers;}")); |
4536 | + } | ||
4537 | + | ||
4538 | + if (true) { | ||
4539 | + MockSrsConfig conf; | ||
4540 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{device_ids 0;}")); | ||
4541 | + } | ||
4542 | + | ||
4543 | + if (true) { | ||
4544 | + MockSrsConfig conf; | ||
4545 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{device_indexs 0;}")); | ||
4546 | + } | ||
4547 | + | ||
4548 | + if (true) { | ||
4549 | + MockSrsConfig conf; | ||
4550 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{device_index -1;}")); | ||
4551 | + } | ||
4552 | + | ||
4553 | + if (true) { | ||
4554 | + MockSrsConfig conf; | ||
4555 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"heartbeat{summariess on;}")); | ||
4556 | + } | ||
4557 | +} | ||
4558 | + | ||
4559 | +VOID TEST(ConfigMainTest, CheckConf_http_api) | ||
4560 | +{ | ||
4561 | + if (true) { | ||
4562 | + MockSrsConfig conf; | ||
4563 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"http_api{}")); | ||
4564 | + } | ||
4565 | + | ||
4566 | + if (true) { | ||
4567 | + MockSrsConfig conf; | ||
4568 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"http_apis{}")); | ||
4450 | } | 4569 | } |
4451 | } | 4570 | } |
4452 | 4571 | ||
@@ -4454,6 +4573,11 @@ VOID TEST(ConfigMainTest, CheckConf_) | @@ -4454,6 +4573,11 @@ VOID TEST(ConfigMainTest, CheckConf_) | ||
4454 | { | 4573 | { |
4455 | if (true) { | 4574 | if (true) { |
4456 | MockSrsConfig conf; | 4575 | MockSrsConfig conf; |
4457 | - EXPECT_TRUE(ERROR_SUCCESS != conf.parse("listens 1935;")); | 4576 | + EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"")); |
4577 | + } | ||
4578 | + | ||
4579 | + if (true) { | ||
4580 | + MockSrsConfig conf; | ||
4581 | + EXPECT_TRUE(ERROR_SUCCESS != conf.parse(_MIN_OK_CONF"http_apis{}")); | ||
4458 | } | 4582 | } |
4459 | } | 4583 | } |
-
请 注册 或 登录 后发表评论