diff --git a/trunk/src/service/srs_service_log.cpp b/trunk/src/service/srs_service_log.cpp index dd45a3a89..af5cec2ff 100644 --- a/trunk/src/service/srs_service_log.cpp +++ b/trunk/src/service/srs_service_log.cpp @@ -82,6 +82,7 @@ void SrsThreadContext::clear_cid() } } +// LCOV_EXCL_START SrsConsoleLog::SrsConsoleLog(SrsLogLevel l, bool u) { level = l; @@ -208,6 +209,7 @@ void SrsConsoleLog::error(const char* tag, int context_id, const char* fmt, ...) fprintf(stderr, "%s\n", buffer); } +// LCOV_EXCL_STOP bool srs_log_header(char* buffer, int size, bool utc, bool dangerous, const char* tag, int cid, const char* level, int* psize) { diff --git a/trunk/src/service/srs_service_rtmp_conn.cpp b/trunk/src/service/srs_service_rtmp_conn.cpp index 57ec4c05f..01343eb51 100644 --- a/trunk/src/service/srs_service_rtmp_conn.cpp +++ b/trunk/src/service/srs_service_rtmp_conn.cpp @@ -33,12 +33,12 @@ using namespace std; #include #include -SrsBasicRtmpClient::SrsBasicRtmpClient(string u, srs_utime_t ctm, srs_utime_t stm) +SrsBasicRtmpClient::SrsBasicRtmpClient(string r, srs_utime_t ctm, srs_utime_t stm) { clk = new SrsWallClock(); kbps = new SrsKbps(clk); - url = u; + url = r; connect_timeout = ctm; stream_timeout = stm; diff --git a/trunk/src/service/srs_service_rtmp_conn.hpp b/trunk/src/service/srs_service_rtmp_conn.hpp index 6aed7e74d..2ade55f9f 100644 --- a/trunk/src/service/srs_service_rtmp_conn.hpp +++ b/trunk/src/service/srs_service_rtmp_conn.hpp @@ -60,10 +60,10 @@ private: int stream_id; public: // Constructor. - // @param u The RTMP url, for example, rtmp://ip:port/app/stream?domain=vhost + // @param r The RTMP url, for example, rtmp://ip:port/app/stream?domain=vhost // @param ctm The timeout in srs_utime_t to connect to server. // @param stm The timeout in srs_utime_t to delivery A/V stream. - SrsBasicRtmpClient(std::string u, srs_utime_t ctm, srs_utime_t stm); + SrsBasicRtmpClient(std::string r, srs_utime_t ctm, srs_utime_t stm); virtual ~SrsBasicRtmpClient(); public: // Connect, handshake and connect app to RTMP server. diff --git a/trunk/src/utest/srs_utest_service.cpp b/trunk/src/utest/srs_utest_service.cpp index 7cb9dcc28..ea15b6270 100644 --- a/trunk/src/utest/srs_utest_service.cpp +++ b/trunk/src/utest/srs_utest_service.cpp @@ -37,6 +37,7 @@ using namespace std; #include #include #include +#include #include #include @@ -1200,6 +1201,7 @@ VOID TEST(TCPServerTest, HTTPClientUtility) SrsHttpClient client; HELPER_ASSERT_SUCCESS(client.initialize("127.0.0.1", 8080, 1*SRS_UTIME_SECONDS)); client.set_recv_timeout(1 * SRS_UTIME_SECONDS); + client.set_header("agent", "srs"); ISrsHttpMessage* res = NULL; SrsAutoFree(ISrsHttpMessage, res); @@ -1218,3 +1220,64 @@ VOID TEST(TCPServerTest, HTTPClientUtility) } } +class MockConnectionManager : public IConnectionManager +{ +public: + MockConnectionManager() { + } + virtual ~MockConnectionManager() { + } +public: + virtual void remove(ISrsConnection* /*c*/) { + } +}; + +VOID TEST(TCPServerTest, ContextUtility) +{ + if (true) { + SrsThreadContext ctx; + + EXPECT_EQ(0, ctx.set_id(100)); + EXPECT_EQ(100, ctx.set_id(1000)); + EXPECT_EQ(1000, ctx.get_id()); + + ctx.clear_cid(); + EXPECT_EQ(0, ctx.set_id(100)); + } + + if (true) { + int size = 0; char buf[1024]; HELPER_ARRAY_INIT(buf, 1024, 0); + ASSERT_TRUE(srs_log_header(buf, 1024, true, true, "SRS", 100, "Trace", &size)); + EXPECT_EQ(53, size); + } + + if (true) { + int size = 0; char buf[1024]; HELPER_ARRAY_INIT(buf, 1024, 0); + ASSERT_TRUE(srs_log_header(buf, 1024, false, true, "SRS", 100, "Trace", &size)); + EXPECT_EQ(53, size); + } + + if (true) { + errno = 0; + int size = 0; char buf[1024]; HELPER_ARRAY_INIT(buf, 1024, 0); + ASSERT_TRUE(srs_log_header(buf, 1024, false, true, NULL, 100, "Trace", &size)); + EXPECT_EQ(48, size); + } + + if (true) { + int size = 0; char buf[1024]; HELPER_ARRAY_INIT(buf, 1024, 0); + ASSERT_TRUE(srs_log_header(buf, 1024, false, false, NULL, 100, "Trace", &size)); + EXPECT_EQ(45, size); + } + + if (true) { + MockConnectionManager cm; + cm.remove(NULL); + } + + if (true) { + srs_utime_t to = 1*SRS_UTIME_SECONDS; + SrsBasicRtmpClient rc("rtmp://127.0.0.1/live/livestream", to, to); + } +} +