From 505cfa1e53a1cbecd8ad0ceb5f2226f8b68999db Mon Sep 17 00:00:00 2001 From: obdev Date: Thu, 12 Oct 2023 13:09:42 +0000 Subject: [PATCH] fix unstable ut: test_tg_mgr --- deps/oblib/src/lib/thread/thread_mgr.h | 2 +- deps/oblib/unittest/lib/thread/test_tg_mgr.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/deps/oblib/src/lib/thread/thread_mgr.h b/deps/oblib/src/lib/thread/thread_mgr.h index 7e087360b..51021c398 100644 --- a/deps/oblib/src/lib/thread/thread_mgr.h +++ b/deps/oblib/src/lib/thread/thread_mgr.h @@ -276,8 +276,8 @@ public: void logical_stop() { if (nullptr != th_) { - th_->runnable_->set_stop(true); th_->logical_stop(); + th_->runnable_->set_stop(true); } } void logical_wait() diff --git a/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp b/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp index a440c4651..48f186c1a 100644 --- a/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp +++ b/deps/oblib/unittest/lib/thread/test_tg_mgr.cpp @@ -26,7 +26,7 @@ public: { running_ = true; ++task_run_count_; - ::usleep(50000); + ::usleep(500000); running_ = false; } @@ -41,9 +41,9 @@ TEST(TG, timer) // start ASSERT_EQ(OB_SUCCESS, TG_START(tg_id)); ASSERT_EQ(OB_SUCCESS, TG_SCHEDULE(tg_id, task, 0, true)); - ::usleep(40000); + ::usleep(250000); ASSERT_TRUE(task.running_); - ::usleep(60000); + ::usleep(750000); ASSERT_EQ(1, task.task_run_count_); ASSERT_EQ(OB_SUCCESS, TG_STOP_R(tg_id)); TG_WAIT_ONLY(tg_id); @@ -55,9 +55,9 @@ TEST(TG, timer) // restart ASSERT_EQ(OB_SUCCESS, TG_START(tg_id)); ASSERT_EQ(OB_SUCCESS, TG_SCHEDULE(tg_id, task, 0, true)); - ::usleep(40000); + ::usleep(250000); ASSERT_TRUE(task.running_); - ::usleep(60000); + ::usleep(750000); ASSERT_EQ(2, task.task_run_count_); ASSERT_EQ(OB_SUCCESS, TG_STOP_R(tg_id)); ASSERT_EQ(OB_SUCCESS, TG_WAIT_R(tg_id));