1 #include <gtest/gtest.h> 2 3 #include <cpuinfo.h> 4 5 6 TEST(CURRENT_PROCESSOR, not_null) { 7 ASSERT_TRUE(cpuinfo_initialize()); 8 9 ASSERT_TRUE(cpuinfo_get_current_processor()); 10 } 11 12 TEST(CURRENT_PROCESSOR, within_bounds) { 13 ASSERT_TRUE(cpuinfo_initialize()); 14 15 const struct cpuinfo_processor* current_processor = cpuinfo_get_current_processor(); 16 const struct cpuinfo_processor* processors_begin = cpuinfo_get_processors(); 17 const struct cpuinfo_processor* processors_end = processors_begin + cpuinfo_get_processors_count(); 18 ASSERT_GE(current_processor, processors_begin); 19 ASSERT_LT(current_processor, processors_end); 20 } 21 22 TEST(CURRENT_CORE, not_null) { 23 ASSERT_TRUE(cpuinfo_initialize()); 24 25 ASSERT_TRUE(cpuinfo_get_current_core()); 26 } 27 28 TEST(CURRENT_CORE, within_bounds) { 29 ASSERT_TRUE(cpuinfo_initialize()); 30 31 const struct cpuinfo_core* current_core = cpuinfo_get_current_core(); 32 const struct cpuinfo_core* cores_begin = cpuinfo_get_cores(); 33 const struct cpuinfo_core* cores_end = cores_begin + cpuinfo_get_cores_count(); 34 ASSERT_GE(current_core, cores_begin); 35 ASSERT_LT(current_core, cores_end); 36 } 37