mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 20:01:56 +00:00
Fix utest fail
This commit is contained in:
parent
ef8f3d6189
commit
b095c15720
3 changed files with 30 additions and 13 deletions
|
@ -92,7 +92,8 @@ public:
|
|||
// Quit without error.
|
||||
bool quit;
|
||||
public:
|
||||
MockCoroutineHandler() : trd(NULL), err(srs_success), cid("0"), quit(false) {
|
||||
MockCoroutineHandler() : trd(NULL), err(srs_success), quit(false) {
|
||||
cid.set_value("0");
|
||||
running = srs_cond_new();
|
||||
exited = srs_cond_new();
|
||||
}
|
||||
|
@ -220,16 +221,17 @@ VOID TEST(AppCoroutineTest, Cycle)
|
|||
|
||||
if (true) {
|
||||
MockCoroutineHandler ch;
|
||||
SrsSTCoroutine sc("test", &ch, SrsContextId("250"));
|
||||
SrsContextId cid;
|
||||
SrsSTCoroutine sc("test", &ch, cid.set_value("250"));
|
||||
ch.trd = ≻
|
||||
EXPECT_TRUE(!sc.cid().compare(SrsContextId("250")));
|
||||
EXPECT_TRUE(!sc.cid().compare(cid));
|
||||
|
||||
EXPECT_TRUE(srs_success == sc.start());
|
||||
EXPECT_TRUE(srs_success == sc.pull());
|
||||
|
||||
// After running, the cid in cycle should equal to the thread.
|
||||
srs_cond_timedwait(ch.running, 100 * SRS_UTIME_MILLISECONDS);
|
||||
EXPECT_TRUE(!ch.cid.compare(SrsContextId("250")));
|
||||
EXPECT_TRUE(!ch.cid.compare(cid));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
|
|
|
@ -1183,7 +1183,7 @@ VOID TEST(KernelRTCTest, DefaultTrackStatus)
|
|||
|
||||
// Enable it by publisher.
|
||||
if (true) {
|
||||
SrsRtcConnection s(NULL, SrsContextId()); SrsRtcPublishStream publish(&s);
|
||||
SrsRtcConnection s(NULL, SrsContextId()); SrsRtcPublishStream publish(&s, SrsContextId());
|
||||
SrsRtcAudioRecvTrack* audio; SrsRtcVideoRecvTrack *video;
|
||||
|
||||
if (true) {
|
||||
|
|
|
@ -1382,19 +1382,34 @@ VOID TEST(TCPServerTest, ContextUtility)
|
|||
if (true) {
|
||||
SrsThreadContext ctx;
|
||||
|
||||
EXPECT_TRUE(!ctx.set_id(SrsContextId("100")).compare(SrsContextId("100")));
|
||||
EXPECT_TRUE(!ctx.set_id(SrsContextId("1000")).compare(SrsContextId("1000")));
|
||||
EXPECT_TRUE(!ctx.get_id().compare(SrsContextId("1000")));
|
||||
if (true) {
|
||||
SrsContextId cid;
|
||||
EXPECT_TRUE(!ctx.set_id(cid.set_value("100")).compare(cid));
|
||||
}
|
||||
if (true) {
|
||||
SrsContextId cid;
|
||||
EXPECT_TRUE(!ctx.set_id(cid.set_value("1000")).compare(cid));
|
||||
}
|
||||
if (true) {
|
||||
SrsContextId cid;
|
||||
EXPECT_TRUE(!ctx.get_id().compare(cid.set_value("1000")));
|
||||
}
|
||||
|
||||
ctx.clear_cid();
|
||||
EXPECT_TRUE(!ctx.set_id(SrsContextId("100")).compare(SrsContextId("100")));
|
||||
if (true) {
|
||||
SrsContextId cid;
|
||||
EXPECT_TRUE(!ctx.set_id(cid.set_value("100")).compare(cid));
|
||||
}
|
||||
}
|
||||
|
||||
SrsContextId cid;
|
||||
cid.set_value("100");
|
||||
|
||||
int base_size = 0;
|
||||
if (true) {
|
||||
errno = 0;
|
||||
int size = 0; char buf[1024]; HELPER_ARRAY_INIT(buf, 1024, 0);
|
||||
ASSERT_TRUE(srs_log_header(buf, 1024, true, true, "SRS", SrsContextId("100"), "Trace", &size));
|
||||
ASSERT_TRUE(srs_log_header(buf, 1024, true, true, "SRS", cid, "Trace", &size));
|
||||
base_size = size;
|
||||
EXPECT_TRUE(base_size > 0);
|
||||
}
|
||||
|
@ -1402,21 +1417,21 @@ VOID TEST(TCPServerTest, ContextUtility)
|
|||
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, "SRS", SrsContextId("100"), "Trace", &size));
|
||||
ASSERT_TRUE(srs_log_header(buf, 1024, false, true, "SRS", cid, "Trace", &size));
|
||||
EXPECT_EQ(base_size, 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, SrsContextId("100"), "Trace", &size));
|
||||
ASSERT_TRUE(srs_log_header(buf, 1024, false, true, NULL, cid, "Trace", &size));
|
||||
EXPECT_EQ(base_size - 5, 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, false, NULL, SrsContextId("100"), "Trace", &size));
|
||||
ASSERT_TRUE(srs_log_header(buf, 1024, false, false, NULL, cid, "Trace", &size));
|
||||
EXPECT_EQ(base_size - 8, size);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue