diff --git a/dbms/src/Common/tests/gtest_cpu_affinity_manager.cpp b/dbms/src/Common/tests/gtest_cpu_affinity_manager.cpp index af4502ac97a..c9627dcdd3d 100644 --- a/dbms/src/Common/tests/gtest_cpu_affinity_manager.cpp +++ b/dbms/src/Common/tests/gtest_cpu_affinity_manager.cpp @@ -24,8 +24,10 @@ #include #include +#include #include #include +#include #include #include @@ -82,6 +84,15 @@ TEST(CPUAffinityManagerTest, CPUAffinityManager) int ret = sched_getaffinity(0, sizeof(cpu_set), &cpu_set); ASSERT_EQ(ret, 0) << strerror(errno); + auto n_cpu = std::thread::hardware_concurrency(); + auto cpu_cores = cpu_affinity.cpuSetToVec(cpu_set); + if (n_cpu != cpu_cores.size()) + { + LOG_INFO(Logger::get(), "n_cpu = {}, cpu_cores = {}, CPU number and CPU cores not match, don't not check CPUAffinityManager", n_cpu, cpu_cores); + return; + } + LOG_DEBUG(Logger::get(), "n_cpu = {}, cpu_cores = {}", n_cpu, cpu_cores); + cpu_affinity.bindSelfQueryThread(); cpu_set_t cpu_set0; ret = sched_getaffinity(0, sizeof(cpu_set0), &cpu_set0);