From 53b68dcf985c624cf018239e018b369e98f3015e Mon Sep 17 00:00:00 2001 From: Kyungwook Tak Date: Tue, 7 Jun 2016 14:19:15 +0900 Subject: [PATCH] Fix bug: min core num definition missed Set minimun core num in internal test of cpu usage manager Change-Id: Ie4621885eed7faf3c05325e5d5d039882de67e9b Signed-off-by: Kyungwook Tak --- src/framework/service/core-usage.cpp | 2 ++ src/framework/service/core-usage.h | 2 +- test/internals/test-cpucore.cpp | 5 +++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/framework/service/core-usage.cpp b/src/framework/service/core-usage.cpp index 5632ee2..a2c473c 100644 --- a/src/framework/service/core-usage.cpp +++ b/src/framework/service/core-usage.cpp @@ -35,6 +35,8 @@ const int TotalCoreNum = ::sysconf(_SC_NPROCESSORS_ONLN); } // namespace anonymous +const int CpuUsageManager::MinCoreNum = 1; + void CpuUsageManager::set(const csr_cs_core_usage_e &cu) { switch (cu) { diff --git a/src/framework/service/core-usage.h b/src/framework/service/core-usage.h index 17b55c9..84aaaa4 100644 --- a/src/framework/service/core-usage.h +++ b/src/framework/service/core-usage.h @@ -32,7 +32,7 @@ public: static void set(const csr_cs_core_usage_e &cu); static void reset(void); - static const int MinCoreNum = 1; + static const int MinCoreNum; private: static void setRunningCores(int num); diff --git a/test/internals/test-cpucore.cpp b/test/internals/test-cpucore.cpp index 004c9df..ab353e4 100644 --- a/test/internals/test-cpucore.cpp +++ b/test/internals/test-cpucore.cpp @@ -21,6 +21,7 @@ */ #include "service/core-usage.h" +#include #include #include @@ -68,9 +69,9 @@ BOOST_AUTO_TEST_CASE(half) { EXCEPTION_GUARD_START - int total = ::getRunningCores(); + int expected = std::max(::getRunningCores() / 2, Csr::CpuUsageManager::MinCoreNum); - coreNumTest(CSR_CS_CORE_USAGE_HALF, total / 2); + coreNumTest(CSR_CS_CORE_USAGE_HALF, expected); EXCEPTION_GUARD_END } -- 2.7.4