提交 cd703ba6 编写于 作者: O openharmony_ci 提交者: Gitee

!202 修复内核子系统time_posix模块不稳定用例:SleepTest.cpp#testUsleepAccuracy

Merge pull request !202 from 南先森/kernel_lite_20210517_2
...@@ -48,7 +48,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1) ...@@ -48,7 +48,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1)
int rt = usleep(interval); int rt = usleep(interval);
clock_gettime(CLOCK_MONOTONIC, &time2); clock_gettime(CLOCK_MONOTONIC, &time2);
EXPECT_EQ(rt, 0); EXPECT_EQ(rt, 0);
duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000);
LOG("testloop %d, actual usleep duration: %ld us", i, duration); LOG("testloop %d, actual usleep duration: %ld us", i, duration);
d += duration; d += duration;
} }
...@@ -58,7 +58,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1) ...@@ -58,7 +58,7 @@ HWTEST_P(UsleepParamTest, testUsleepAccuracy, Performance | SmallTest | Level1)
ASSERT_NEAR(d, interval, SLEEP_ACCURACY) << "usleep accuracy check fail\n"; ASSERT_NEAR(d, interval, SLEEP_ACCURACY) << "usleep accuracy check fail\n";
} }
INSTANTIATE_TEST_CASE_P(SleepTest, UsleepParamTest, INSTANTIATE_TEST_CASE_P(SleepTest, UsleepParamTest,
testing::Values(100, 1000, 10*1000, 20*1000, 30*1000, 300*1000, 3000*1000)); testing::Values(1000, 10*1000, 20*1000, 30*1000, 300*1000, 3000*1000));
/** /**
* @tc.number SUB_KERNEL_TIME_API_SLEEP_0100 * @tc.number SUB_KERNEL_TIME_API_SLEEP_0100
...@@ -107,7 +107,7 @@ HWTEST_F(SleepTest, testNanosleepAccuracy, Performance | SmallTest | Level2) ...@@ -107,7 +107,7 @@ HWTEST_F(SleepTest, testNanosleepAccuracy, Performance | SmallTest | Level2)
int rt = nanosleep(&req, &rem); int rt = nanosleep(&req, &rem);
clock_gettime(CLOCK_MONOTONIC, &time2); clock_gettime(CLOCK_MONOTONIC, &time2);
EXPECT_EQ(rt, 0); EXPECT_EQ(rt, 0);
duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000);
LOG("testloop %d, actual sleep duration: %.1f s", i, duration); LOG("testloop %d, actual sleep duration: %.1f s", i, duration);
d += duration; d += duration;
} }
...@@ -134,7 +134,7 @@ HWTEST_F(SleepTest, testClockNanosleepAccuracy, Performance | SmallTest | Level2 ...@@ -134,7 +134,7 @@ HWTEST_F(SleepTest, testClockNanosleepAccuracy, Performance | SmallTest | Level2
int rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem); int rt = clock_nanosleep(CLOCK_REALTIME, 0, &req, &rem);
clock_gettime(CLOCK_MONOTONIC, &time2); clock_gettime(CLOCK_MONOTONIC, &time2);
EXPECT_EQ(rt, 0); EXPECT_EQ(rt, 0);
duration = (time2.tv_sec - time1.tv_sec)*1000000 + (time2.tv_nsec - time1.tv_nsec)/1000; duration = (time2.tv_sec*1000000 + time2.tv_nsec/1000) - (time1.tv_sec*1000000 + time1.tv_nsec/1000);
LOG("testloop %d, actual sleep duration: %.1f s", i, duration); LOG("testloop %d, actual sleep duration: %.1f s", i, duration);
d += duration; d += duration;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册