Add session state 'discard'
This commit is contained in:
@@ -4,21 +4,36 @@
|
||||
|
||||
TEST(TIMESTAMP, GET)
|
||||
{
|
||||
uint64_t sec = 0;
|
||||
uint64_t msec = 0;
|
||||
uint64_t last_sec = 0;
|
||||
uint64_t last_msec = 0;
|
||||
uint64_t curr_sec = 0;
|
||||
uint64_t curr_msec = 0;
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
timestamp_update();
|
||||
sec = timestamp_get_sec();
|
||||
msec = timestamp_get_msec();
|
||||
timestamp_update();
|
||||
last_sec = timestamp_get_sec();
|
||||
last_msec = timestamp_get_msec();
|
||||
|
||||
printf("current ts in sec : %lu\n", sec);
|
||||
printf("current ts in msec : %lu\n", msec);
|
||||
EXPECT_TRUE(sec == msec / 1000);
|
||||
sleep(i);
|
||||
printf("sleep %ds\n", i);
|
||||
}
|
||||
usleep(1000); // 1ms
|
||||
timestamp_update();
|
||||
curr_sec = timestamp_get_sec();
|
||||
curr_msec = timestamp_get_msec();
|
||||
printf("After usleep(1000)\n");
|
||||
printf("last_sec: %lu, last_msec: %lu\n", last_sec, last_msec);
|
||||
printf("curr_sec: %lu, curr_msec: %lu\n", curr_sec, curr_msec);
|
||||
EXPECT_TRUE(curr_sec == last_sec);
|
||||
EXPECT_TRUE(curr_msec - last_msec >= 1 && curr_msec - last_msec <= 2);
|
||||
|
||||
usleep(1000 * 1000); // 1s
|
||||
timestamp_update();
|
||||
last_sec = curr_sec;
|
||||
last_msec = curr_msec;
|
||||
curr_sec = timestamp_get_sec();
|
||||
curr_msec = timestamp_get_msec();
|
||||
printf("After usleep(1000 * 1000)\n");
|
||||
printf("last_sec: %lu, last_msec: %lu\n", last_sec, last_msec);
|
||||
printf("curr_sec: %lu, curr_msec: %lu\n", curr_sec, curr_msec);
|
||||
EXPECT_TRUE(curr_sec - last_sec == 1);
|
||||
EXPECT_TRUE(curr_msec - last_msec >= 1000 && curr_msec - last_msec <= 1001);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
|
||||
Reference in New Issue
Block a user