• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #include <gtest/gtest.h>
2 
3 #include <cpuinfo.h>
4 
5 
TEST(CURRENT_PROCESSOR,within_bounds)6 TEST(CURRENT_PROCESSOR, within_bounds) {
7 	ASSERT_TRUE(cpuinfo_initialize());
8 
9 	const struct cpuinfo_processor* current_processor = cpuinfo_get_current_processor();
10 	if (current_processor == nullptr) {
11 		GTEST_SKIP();
12 	}
13 
14 	const struct cpuinfo_processor* processors_begin = cpuinfo_get_processors();
15 	const struct cpuinfo_processor* processors_end = processors_begin + cpuinfo_get_processors_count();
16 	ASSERT_GE(current_processor, processors_begin);
17 	ASSERT_LT(current_processor, processors_end);
18 }
19 
TEST(CURRENT_CORE,within_bounds)20 TEST(CURRENT_CORE, within_bounds) {
21 	ASSERT_TRUE(cpuinfo_initialize());
22 
23 	const struct cpuinfo_core* current_core = cpuinfo_get_current_core();
24 	if (current_core == nullptr) {
25 		GTEST_SKIP();
26 	}
27 
28 	const struct cpuinfo_core* cores_begin = cpuinfo_get_cores();
29 	const struct cpuinfo_core* cores_end = cores_begin + cpuinfo_get_cores_count();
30 	ASSERT_GE(current_core, cores_begin);
31 	ASSERT_LT(current_core, cores_end);
32 }
33 
TEST(CURRENT_UARCH_INDEX,within_bounds)34 TEST(CURRENT_UARCH_INDEX, within_bounds) {
35 	ASSERT_TRUE(cpuinfo_initialize());
36 
37 	ASSERT_LT(cpuinfo_get_current_uarch_index(), cpuinfo_get_uarchs_count());
38 }
39 
TEST(CURRENT_UARCH_INDEX_WITH_DEFAULT,within_bounds)40 TEST(CURRENT_UARCH_INDEX_WITH_DEFAULT, within_bounds) {
41 	ASSERT_TRUE(cpuinfo_initialize());
42 
43 	ASSERT_LE(cpuinfo_get_current_uarch_index_with_default(cpuinfo_get_uarchs_count()), cpuinfo_get_uarchs_count());
44 }
45