From a0f434c1d2c5cace601f8d0fc13342b0f490640c Mon Sep 17 00:00:00 2001 From: Yangosoft Date: Wed, 22 Jan 2025 21:20:09 +0100 Subject: [PATCH] More test --- src/include/cpputils2/linux/thread/thread.hpp | 9 +++++++++ src/test/cpputils2_tests.cpp | 7 +++++++ 2 files changed, 16 insertions(+) diff --git a/src/include/cpputils2/linux/thread/thread.hpp b/src/include/cpputils2/linux/thread/thread.hpp index 01cda07..0d93be2 100644 --- a/src/include/cpputils2/linux/thread/thread.hpp +++ b/src/include/cpputils2/linux/thread/thread.hpp @@ -44,6 +44,15 @@ namespace CppUtils2 } }; + struct DeadLineThreadConfig : public ThreadConfig + { + DeadLineThreadConfig() + { + policy = SCHED_DEADLINE; + priority = 0; + } + }; + Result set_thread_sched_policy(std::thread &thread, const int policy, const int priority) { struct sched_param param; diff --git a/src/test/cpputils2_tests.cpp b/src/test/cpputils2_tests.cpp index 2a3107f..87bf346 100644 --- a/src/test/cpputils2_tests.cpp +++ b/src/test/cpputils2_tests.cpp @@ -147,11 +147,18 @@ namespace TEST(ThreadMng, ThreadMng) { CppUtils2::BestEffortThreadConfig config; + std::thread t([&config]() { }); auto ret = CppUtils2::set_thread_sched_policy(t, config); EXPECT_EQ(ret, CppUtils2::Result::RET_OK); + + auto exp_config = CppUtils2::get_thread_sched_policy(t); + EXPECT_TRUE(exp_config.has_value()); + EXPECT_EQ(exp_config.value().policy, config.policy); + EXPECT_EQ(exp_config.value().priority, config.priority); + t.join(); }