blob: 25486f8e09923c0021b2b0389436f4f36ec7697b [file] [log] [blame]
Marat Dukhanac576322017-05-08 13:08:25 +00001#include <gtest/gtest.h>
2
3#include <cpuinfo.h>
4#include <cpuinfo-mock.h>
5
6
7TEST(PROCESSORS, count) {
8 ASSERT_EQ(4, cpuinfo_processors_count);
9}
10
11TEST(PROCESSORS, non_null) {
12 ASSERT_TRUE(cpuinfo_processors);
13}
14
15TEST(PROCESSORS, vendor_qualcomm) {
16 for (uint32_t i = 0; i < cpuinfo_processors_count; i++) {
17 ASSERT_EQ(cpuinfo_vendor_qualcomm, cpuinfo_processors[i].vendor);
18 }
19}
20
21TEST(PROCESSORS, uarch_krait) {
22 for (uint32_t i = 0; i < cpuinfo_processors_count; i++) {
23 ASSERT_EQ(cpuinfo_uarch_krait, cpuinfo_processors[i].uarch);
24 }
25}
26
27TEST(ISA, thumb) {
28 ASSERT_TRUE(cpuinfo_isa.thumb);
29}
30
31TEST(ISA, thumb2) {
32 ASSERT_TRUE(cpuinfo_isa.thumb2);
33}
34
35TEST(ISA, thumbee) {
36 ASSERT_FALSE(cpuinfo_isa.thumbee);
37}
38
39TEST(ISA, jazelle) {
40 ASSERT_FALSE(cpuinfo_isa.jazelle);
41}
42
43TEST(ISA, armv5e) {
44 ASSERT_TRUE(cpuinfo_isa.armv5e);
45}
46
47TEST(ISA, armv6) {
48 ASSERT_TRUE(cpuinfo_isa.armv6);
49}
50
51TEST(ISA, armv6k) {
52 ASSERT_TRUE(cpuinfo_isa.armv6k);
53}
54
55TEST(ISA, armv7) {
56 ASSERT_TRUE(cpuinfo_isa.armv7);
57}
58
59TEST(ISA, armv7mp) {
60 ASSERT_TRUE(cpuinfo_isa.armv7mp);
61}
62
63TEST(ISA, idiv) {
64 ASSERT_TRUE(cpuinfo_isa.idiv);
65}
66
67TEST(ISA, vfpv2) {
68 ASSERT_FALSE(cpuinfo_isa.vfpv2);
69}
70
71TEST(ISA, vfpv3) {
72 ASSERT_TRUE(cpuinfo_isa.vfpv3);
73}
74
75TEST(ISA, d32) {
76 ASSERT_TRUE(cpuinfo_isa.d32);
77}
78
79TEST(ISA, fp16) {
80 ASSERT_TRUE(cpuinfo_isa.fp16);
81}
82
83TEST(ISA, fma) {
84 ASSERT_TRUE(cpuinfo_isa.fma);
85}
86
87TEST(ISA, wmmx) {
88 ASSERT_FALSE(cpuinfo_isa.wmmx);
89}
90
91TEST(ISA, wmmx2) {
92 ASSERT_FALSE(cpuinfo_isa.wmmx2);
93}
94
95TEST(ISA, neon) {
96 ASSERT_TRUE(cpuinfo_isa.neon);
97}
98
99TEST(ISA, aes) {
100 ASSERT_FALSE(cpuinfo_isa.aes);
101}
102
103TEST(ISA, sha1) {
104 ASSERT_FALSE(cpuinfo_isa.sha1);
105}
106
107TEST(ISA, sha2) {
108 ASSERT_FALSE(cpuinfo_isa.sha2);
109}
110
111TEST(ISA, pmull) {
112 ASSERT_FALSE(cpuinfo_isa.pmull);
113}
114
115TEST(ISA, crc32) {
116 ASSERT_FALSE(cpuinfo_isa.crc32);
117}
118
119TEST(L1I, count) {
120 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
121 ASSERT_EQ(4, l1i.count);
122}
123
124TEST(L1I, non_null) {
125 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
126 ASSERT_TRUE(l1i.instances);
127}
128
129TEST(L1I, size) {
130 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
131 for (uint32_t k = 0; k < l1i.count; k++) {
132 ASSERT_EQ(16 * 1024, l1i.instances[k].size);
133 }
134}
135
136TEST(L1I, associativity) {
137 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
138 for (uint32_t k = 0; k < l1i.count; k++) {
139 ASSERT_EQ(4, l1i.instances[k].associativity);
140 }
141}
142
143TEST(L1I, sets) {
144 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
145 for (uint32_t k = 0; k < l1i.count; k++) {
146 ASSERT_EQ(64, l1i.instances[k].sets);
147 }
148}
149
150TEST(L1I, partitions) {
151 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
152 for (uint32_t k = 0; k < l1i.count; k++) {
153 ASSERT_EQ(1, l1i.instances[k].partitions);
154 }
155}
156
157TEST(L1I, line_size) {
158 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
159 for (uint32_t k = 0; k < l1i.count; k++) {
160 ASSERT_EQ(64, l1i.instances[k].line_size);
161 }
162}
163
164TEST(L1I, flags) {
165 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
166 for (uint32_t k = 0; k < l1i.count; k++) {
167 ASSERT_EQ(0, l1i.instances[k].flags);
168 }
169}
170
171TEST(L1I, processors) {
172 cpuinfo_caches l1i = cpuinfo_get_l1i_cache();
173 for (uint32_t k = 0; k < l1i.count; k++) {
174 ASSERT_EQ(k, l1i.instances[k].thread_start);
175 ASSERT_EQ(1, l1i.instances[k].thread_count);
176 }
177}
178
179TEST(L1D, count) {
180 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
181 ASSERT_EQ(4, l1d.count);
182}
183
184TEST(L1D, non_null) {
185 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
186 ASSERT_TRUE(l1d.instances);
187}
188
189TEST(L1D, size) {
190 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
191 for (uint32_t k = 0; k < l1d.count; k++) {
192 ASSERT_EQ(16 * 1024, l1d.instances[k].size);
193 }
194}
195
196TEST(L1D, associativity) {
197 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
198 for (uint32_t k = 0; k < l1d.count; k++) {
199 ASSERT_EQ(4, l1d.instances[k].associativity);
200 }
201}
202
203TEST(L1D, sets) {
204 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
205 for (uint32_t k = 0; k < l1d.count; k++) {
206 ASSERT_EQ(64, l1d.instances[k].sets);
207 }
208}
209
210TEST(L1D, partitions) {
211 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
212 for (uint32_t k = 0; k < l1d.count; k++) {
213 ASSERT_EQ(1, l1d.instances[k].partitions);
214 }
215}
216
217TEST(L1D, line_size) {
218 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
219 for (uint32_t k = 0; k < l1d.count; k++) {
220 ASSERT_EQ(64, l1d.instances[k].line_size);
221 }
222}
223
224TEST(L1D, flags) {
225 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
226 for (uint32_t k = 0; k < l1d.count; k++) {
227 ASSERT_EQ(0, l1d.instances[k].flags);
228 }
229}
230
231TEST(L1D, processors) {
232 cpuinfo_caches l1d = cpuinfo_get_l1d_cache();
233 for (uint32_t k = 0; k < l1d.count; k++) {
234 ASSERT_EQ(k, l1d.instances[k].thread_start);
235 ASSERT_EQ(1, l1d.instances[k].thread_count);
236 }
237}
238
239TEST(L2, count) {
240 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
241 ASSERT_EQ(1, l2.count);
242}
243
244TEST(L2, non_null) {
245 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
246 ASSERT_TRUE(l2.instances);
247}
248
249TEST(L2, size) {
250 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
251 for (uint32_t k = 0; k < l2.count; k++) {
252 ASSERT_EQ(2 * 1024 * 1024, l2.instances[k].size);
253 }
254}
255
256TEST(L2, associativity) {
257 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
258 for (uint32_t k = 0; k < l2.count; k++) {
259 ASSERT_EQ(8, l2.instances[k].associativity);
260 }
261}
262
263TEST(L2, sets) {
264 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
265 for (uint32_t k = 0; k < l2.count; k++) {
266 ASSERT_EQ(2048, l2.instances[k].sets);
267 }
268}
269
270TEST(L2, partitions) {
271 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
272 for (uint32_t k = 0; k < l2.count; k++) {
273 ASSERT_EQ(1, l2.instances[k].partitions);
274 }
275}
276
277TEST(L2, line_size) {
278 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
279 for (uint32_t k = 0; k < l2.count; k++) {
280 ASSERT_EQ(128, l2.instances[k].line_size);
281 }
282}
283
284TEST(L2, flags) {
285 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
286 for (uint32_t k = 0; k < l2.count; k++) {
287 ASSERT_EQ(0, l2.instances[k].flags);
288 }
289}
290
291TEST(L2, processors) {
292 cpuinfo_caches l2 = cpuinfo_get_l2_cache();
293 for (uint32_t k = 0; k < l2.count; k++) {
294 ASSERT_EQ(0, l2.instances[k].thread_start);
295 ASSERT_EQ(4, l2.instances[k].thread_count);
296 }
297}
298
299TEST(L3, none) {
300 cpuinfo_caches l3 = cpuinfo_get_l3_cache();
301 ASSERT_EQ(0, l3.count);
302 ASSERT_FALSE(l3.instances);
303}
304
305TEST(L4, none) {
306 cpuinfo_caches l4 = cpuinfo_get_l4_cache();
307 ASSERT_EQ(0, l4.count);
308 ASSERT_FALSE(l4.instances);
309}
310
Marat Dukhan079ccbd2017-08-09 17:00:32 -0700311#include <nexus4.h>
312
Marat Dukhanac576322017-05-08 13:08:25 +0000313int main(int argc, char* argv[]) {
Marat Dukhan079ccbd2017-08-09 17:00:32 -0700314 cpuinfo_mock_filesystem(filesystem);
Marat Dukhanac576322017-05-08 13:08:25 +0000315 cpuinfo_initialize();
316 ::testing::InitGoogleTest(&argc, argv);
317 return RUN_ALL_TESTS();
318}