|
|
|
@ -401,15 +401,30 @@ VOID TEST(ConfigDirectiveTest, ParseArgsSpace)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
vector <string> usecases;
|
|
|
|
|
usecases.push_back("include\rtest;");
|
|
|
|
|
usecases.push_back("include\ntest;");
|
|
|
|
|
usecases.push_back("include \r \n \r\n \n\rtest;");
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < (int)usecases.size(); i++) {
|
|
|
|
|
string usecase = usecases.at(i);
|
|
|
|
|
|
|
|
|
|
MockSrsConfigBuffer buf(usecase);
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
vector <string> usecases;
|
|
|
|
|
usecases.push_back("include test;");
|
|
|
|
|
usecases.push_back("include test;");
|
|
|
|
|
usecases.push_back("include test;");
|
|
|
|
|
usecases.push_back("include test;");;
|
|
|
|
|
usecases.push_back("include\rtest;");
|
|
|
|
|
usecases.push_back("include\ntest;");
|
|
|
|
|
usecases.push_back("include \r \n \r\n \n\rtest;");
|
|
|
|
|
|
|
|
|
|
MockSrsConfig config;
|
|
|
|
|
config.mock_include("test", "listen 1935;");
|
|
|
|
@ -433,6 +448,102 @@ VOID TEST(ConfigDirectiveTest, ParseArgsSpace)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VOID TEST(ConfigDirectiveTest, ParseInvalidEndOfLine)
|
|
|
|
|
{
|
|
|
|
|
srs_error_t err;
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 \narg0;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0\n arg0;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 arg0\n;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 \rarg0;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 arg0\r;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 \n { dir1 arg1; }");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 arg0;dir1\n arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int) conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int) conf.args.size());
|
|
|
|
|
EXPECT_EQ(1, (int) conf.directives.size());
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir0 = *conf.directives.at(0);
|
|
|
|
|
EXPECT_STREQ("dir0", dir0.name.c_str());
|
|
|
|
|
EXPECT_EQ(1, (int)dir0.args.size());
|
|
|
|
|
EXPECT_STREQ("arg0", dir0.arg0().c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir0.directives.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (true) {
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 arg0;dir1 arg1;");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_SUCCESS(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int)conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int)conf.args.size());
|
|
|
|
|
EXPECT_EQ(2, (int)conf.directives.size());
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir0 = *conf.directives.at(0);
|
|
|
|
|
EXPECT_STREQ("dir0", dir0.name.c_str());
|
|
|
|
|
EXPECT_EQ(1, (int)dir0.args.size());
|
|
|
|
|
EXPECT_STREQ("arg0", dir0.arg0().c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir0.directives.size());
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir1 = *conf.directives.at(1);
|
|
|
|
|
EXPECT_STREQ("dir1", dir1.name.c_str());
|
|
|
|
|
EXPECT_EQ(1, (int)dir1.args.size());
|
|
|
|
|
EXPECT_STREQ("arg1", dir1.arg0().c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir1.directives.size());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VOID TEST(ConfigDirectiveTest, Parse2SingleDirs)
|
|
|
|
|
{
|
|
|
|
|
srs_error_t err;
|
|
|
|
@ -829,30 +940,7 @@ VOID TEST(ConfigDirectiveTest, ParseLine4)
|
|
|
|
|
|
|
|
|
|
MockSrsConfigBuffer buf("dir0 {\n\ndir1 \n\narg0;dir2 arg1;}");
|
|
|
|
|
SrsConfDirective conf;
|
|
|
|
|
HELPER_ASSERT_SUCCESS(conf.parse(&buf));
|
|
|
|
|
EXPECT_EQ(0, (int)conf.name.length());
|
|
|
|
|
EXPECT_EQ(0, (int)conf.args.size());
|
|
|
|
|
EXPECT_EQ(1, (int)conf.directives.size());
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir0 = *conf.directives.at(0);
|
|
|
|
|
EXPECT_STREQ("dir0", dir0.name.c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir0.args.size());
|
|
|
|
|
EXPECT_EQ(2, (int)dir0.directives.size());
|
|
|
|
|
EXPECT_EQ(1, (int)dir0.conf_line);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir1 = *dir0.directives.at(0);
|
|
|
|
|
EXPECT_STREQ("dir1", dir1.name.c_str());
|
|
|
|
|
EXPECT_EQ(1, (int)dir1.args.size());
|
|
|
|
|
EXPECT_STREQ("arg0", dir1.arg0().c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir1.directives.size());
|
|
|
|
|
EXPECT_EQ(3, (int)dir1.conf_line);
|
|
|
|
|
|
|
|
|
|
SrsConfDirective& dir2 = *dir0.directives.at(1);
|
|
|
|
|
EXPECT_STREQ("dir2", dir2.name.c_str());
|
|
|
|
|
EXPECT_EQ(1, (int)dir2.args.size());
|
|
|
|
|
EXPECT_STREQ("arg1", dir2.arg0().c_str());
|
|
|
|
|
EXPECT_EQ(0, (int)dir2.directives.size());
|
|
|
|
|
EXPECT_EQ(5, (int)dir2.conf_line);
|
|
|
|
|
HELPER_ASSERT_FAILED(conf.parse(&buf));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
VOID TEST(ConfigDirectiveTest, ParseLineNormal)
|
|
|
|
|