mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
Refine srs_update_system_time in time unit
This commit is contained in:
parent
9b7c0802a9
commit
6c12aa0eca
26 changed files with 123 additions and 108 deletions
|
@ -1867,6 +1867,14 @@ VOID TEST(ConfigUnitTest, CheckDefaultValues)
|
|||
EXPECT_EQ(10 * SRS_UTIME_SECONDS, conf.get_dvr_duration("v"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF));
|
||||
EXPECT_EQ(0, conf.get_hls_dispose(""));
|
||||
|
||||
EXPECT_TRUE(ERROR_SUCCESS == conf.parse(_MIN_OK_CONF"vhost v{hls{hls_dispose 10;}}"));
|
||||
EXPECT_EQ(10 * SRS_UTIME_SECONDS, conf.get_hls_dispose("v"));
|
||||
}
|
||||
|
||||
if (true) {
|
||||
srs_utime_t t0 = srs_update_system_time();
|
||||
srs_usleep(10 * SRS_UTIME_MILLISECONDS);
|
||||
|
@ -1874,5 +1882,13 @@ VOID TEST(ConfigUnitTest, CheckDefaultValues)
|
|||
|
||||
EXPECT_TRUE(t1 - t0 >= 10 * SRS_UTIME_MILLISECONDS);
|
||||
}
|
||||
|
||||
if (true) {
|
||||
srs_utime_t t0 = srs_get_system_time();
|
||||
srs_utime_t t1 = srs_update_system_time();
|
||||
|
||||
EXPECT_TRUE(t0 > 0);
|
||||
EXPECT_TRUE(t1 >= t0);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1482,15 +1482,14 @@ VOID TEST(KernelBufferTest, CoverAll)
|
|||
*/
|
||||
VOID TEST(KernelUtilityTest, UtilityTime)
|
||||
{
|
||||
int64_t time = srs_get_system_time_ms();
|
||||
srs_utime_t time = srs_get_system_time();
|
||||
EXPECT_TRUE(time > 0);
|
||||
|
||||
int64_t time1 = srs_get_system_time_ms();
|
||||
srs_utime_t time1 = srs_get_system_time();
|
||||
EXPECT_EQ(time, time1);
|
||||
|
||||
usleep(1000);
|
||||
srs_update_system_time();
|
||||
time1 = srs_get_system_time_ms();
|
||||
usleep(1 * SRS_UTIME_MILLISECONDS);
|
||||
time1 = srs_update_system_time();
|
||||
EXPECT_TRUE(time1 > time);
|
||||
}
|
||||
|
||||
|
@ -1499,15 +1498,15 @@ VOID TEST(KernelUtilityTest, UtilityTime)
|
|||
*/
|
||||
VOID TEST(KernelUtilityTest, UtilityStartupTime)
|
||||
{
|
||||
int64_t time = srs_get_system_startup_time_ms();
|
||||
srs_utime_t time = srs_get_system_startup_time();
|
||||
EXPECT_TRUE(time > 0);
|
||||
|
||||
int64_t time1 = srs_get_system_startup_time_ms();
|
||||
srs_utime_t time1 = srs_get_system_startup_time();
|
||||
EXPECT_EQ(time, time1);
|
||||
|
||||
usleep(1000);
|
||||
usleep(1 * SRS_UTIME_MILLISECONDS);
|
||||
srs_update_system_time();
|
||||
time1 = srs_get_system_startup_time_ms();
|
||||
time1 = srs_get_system_startup_time();
|
||||
EXPECT_EQ(time, time1);
|
||||
}
|
||||
|
||||
|
@ -3182,7 +3181,7 @@ VOID TEST(KernelUtilityTest, CoverTimeUtilityAll)
|
|||
{
|
||||
_srs_system_time_us_cache = 0;
|
||||
_srs_system_time_startup_time = 0;
|
||||
EXPECT_TRUE(srs_get_system_startup_time_ms() > 0);
|
||||
EXPECT_TRUE(srs_get_system_startup_time() > 0);
|
||||
|
||||
_srs_system_time_us_cache -= 300*1000 * 1000 + 1;
|
||||
EXPECT_TRUE(srs_update_system_time() > 0);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue