1 // Copyright 2020 The Android Open Source Project
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "android/opengl/emugl_config.h"
16 #include "android/opengl/EmuglBackendList.h"
17 #include "android/opengl/gpuinfo.h"
18
19 #include "android/base/testing/TestSystem.h"
20 #include "android/base/testing/TestTempDir.h"
21
22 #include <gtest/gtest.h>
23
24 namespace android {
25 namespace base {
26
27 #if defined(_WIN32)
28 # define LIB_NAME(x) x ".dll"
29 #elif defined(__APPLE__)
30 # define LIB_NAME(x) "lib" x ".dylib"
31 #else
32 # define LIB_NAME(x) "lib" x ".so"
33 #endif
34
makeLibSubPath(const char * name)35 static std::string makeLibSubPath(const char* name) {
36 return StringFormat("%s/%s/%s",
37 System::get()->getLauncherDirectory().c_str(),
38 System::kLibSubDir, name);
39 }
40
makeLibSubDir(TestTempDir * dir,const char * name)41 static void makeLibSubDir(TestTempDir* dir, const char* name) {
42 dir->makeSubDir(makeLibSubPath(name).c_str());
43 }
44
makeLibSubFile(TestTempDir * dir,const char * name)45 static void makeLibSubFile(TestTempDir* dir, const char* name) {
46 dir->makeSubFile(makeLibSubPath(name).c_str());
47 }
48
TEST(EmuglConfig,init)49 TEST(EmuglConfig, init) {
50 TestSystem testSys("foo", System::kProgramBitness, "/");
51 TestTempDir* myDir = testSys.getTempRoot();
52 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
53 makeLibSubDir(myDir, "");
54
55 makeLibSubDir(myDir, "gles_mesa");
56 makeLibSubFile(myDir, "gles_mesa/libGLES.so");
57
58 makeLibSubDir(myDir, "gles_vendor");
59 makeLibSubFile(myDir, "gles_vendor/" LIB_NAME("EGL"));
60 makeLibSubFile(myDir, "gles_vendor/" LIB_NAME("GLESv2"));
61
62 {
63 EmuglConfig config;
64 EXPECT_TRUE(emuglConfig_init(
65 &config, false, "host", NULL, 0, false, false, false,
66 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
67 EXPECT_FALSE(config.enabled);
68 EXPECT_STREQ("GPU emulation is disabled", config.status);
69 }
70
71 {
72 EmuglConfig config;
73 EXPECT_TRUE(emuglConfig_init(
74 &config, true, "host", NULL, 0, false, false, false,
75 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
76 EXPECT_TRUE(config.enabled);
77 EXPECT_STREQ("host", config.backend);
78 EXPECT_STREQ("GPU emulation enabled using 'host' mode", config.status);
79 }
80
81 // Check that "host" mode is available with -no-window if explicitly
82 // specified on command line.
83 {
84 EmuglConfig config;
85 EXPECT_TRUE(emuglConfig_init(
86 &config, true, "host", "host", 0, true, false, false,
87 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
88 EXPECT_TRUE(config.enabled);
89 EXPECT_STREQ("host", config.backend);
90 EXPECT_STREQ("GPU emulation enabled using 'host' mode", config.status);
91 }
92
93 {
94 EmuglConfig config;
95 EXPECT_TRUE(emuglConfig_init(
96 &config, true, "mesa", NULL, 0, false, false, false,
97 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
98 EXPECT_TRUE(config.enabled);
99 EXPECT_STREQ("mesa", config.backend);
100 EXPECT_STREQ("GPU emulation enabled using 'mesa' mode", config.status);
101 }
102
103 {
104 EmuglConfig config;
105 EXPECT_TRUE(emuglConfig_init(
106 &config, true, "host", "off", 0, false, false, false,
107 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
108 EXPECT_FALSE(config.enabled);
109 EXPECT_STREQ("GPU emulation is disabled", config.status);
110 }
111
112 {
113 EmuglConfig config;
114 EXPECT_TRUE(emuglConfig_init(
115 &config, true, "host", "disable", 0, false, false, false,
116 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
117 EXPECT_FALSE(config.enabled);
118 EXPECT_STREQ("GPU emulation is disabled", config.status);
119 }
120
121 {
122 EmuglConfig config;
123 EXPECT_TRUE(emuglConfig_init(
124 &config, false, "host", "on", 0, false, false, false,
125 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
126 EXPECT_TRUE(config.enabled);
127 EXPECT_STREQ("host", config.backend);
128 EXPECT_STREQ("GPU emulation enabled using 'host' mode", config.status);
129 }
130
131 {
132 EmuglConfig config;
133 EXPECT_TRUE(emuglConfig_init(
134 &config, false, NULL, "on", 0, false, false, false,
135 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
136 EXPECT_TRUE(config.enabled);
137 EXPECT_STREQ("host", config.backend);
138 EXPECT_STREQ("GPU emulation enabled using 'host' mode", config.status);
139 }
140
141 {
142 EmuglConfig config;
143 EXPECT_TRUE(emuglConfig_init(
144 &config, false, "mesa", "enable", 0, false, false, false,
145 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
146 EXPECT_TRUE(config.enabled);
147 EXPECT_STREQ("mesa", config.backend);
148 EXPECT_STREQ("GPU emulation enabled using 'mesa' mode", config.status);
149 }
150
151 {
152 EmuglConfig config;
153 EXPECT_TRUE(emuglConfig_init(
154 &config, false, "vendor", "auto", 0, false, false, false,
155 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
156 EXPECT_FALSE(config.enabled);
157 EXPECT_STREQ("GPU emulation is disabled", config.status);
158 }
159
160 {
161 EmuglConfig config;
162 EXPECT_TRUE(emuglConfig_init(
163 &config, true, "host", "vendor", 0, false, false, false,
164 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
165 EXPECT_TRUE(config.enabled);
166 EXPECT_STREQ("vendor", config.backend);
167 EXPECT_STREQ("GPU emulation enabled using 'vendor' mode", config.status);
168 }
169
170 {
171 EmuglConfig config;
172 EXPECT_TRUE(emuglConfig_init(
173 &config, true, "guest", "auto", 0, false, false, false,
174 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
175 EXPECT_FALSE(config.enabled);
176 EXPECT_STREQ("GPU emulation is disabled", config.status);
177 }
178
179 {
180 EmuglConfig config;
181 EXPECT_TRUE(emuglConfig_init(
182 &config, false, "guest", "auto", 0, false, false, false,
183 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
184 EXPECT_FALSE(config.enabled);
185 EXPECT_STREQ("GPU emulation is disabled", config.status);
186 }
187
188 {
189 EmuglConfig config;
190 EXPECT_TRUE(emuglConfig_init(
191 &config, true, "host", "guest", 0, false, false, false,
192 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
193 EXPECT_FALSE(config.enabled);
194 }
195
196 }
197
TEST(EmuglConfig,initFromUISetting)198 TEST(EmuglConfig, initFromUISetting) {
199 TestSystem testSys("foo", System::kProgramBitness, "/");
200 TestTempDir* myDir = testSys.getTempRoot();
201 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
202 makeLibSubDir(myDir, "");
203
204 makeLibSubDir(myDir, "gles_mesa");
205 makeLibSubFile(myDir, "gles_mesa/libGLES.so");
206
207 makeLibSubDir(myDir, "gles_angle");
208 makeLibSubFile(myDir, "gles_angle/" LIB_NAME("EGL"));
209 makeLibSubFile(myDir, "gles_angle/" LIB_NAME("GLESv2"));
210
211 makeLibSubDir(myDir, "gles_angle9");
212 makeLibSubFile(myDir, "gles_angle9/" LIB_NAME("EGL"));
213 makeLibSubFile(myDir, "gles_angle9/" LIB_NAME("GLESv2"));
214
215 makeLibSubDir(myDir, "gles_swiftshader");
216 makeLibSubFile(myDir, "gles_swiftshader/" LIB_NAME("EGL"));
217 makeLibSubFile(myDir, "gles_swiftshader/" LIB_NAME("GLESv2"));
218
219 // If the gpu command line option is specified, the UI setting is overridden.
220 for (int i = 0; i < 10; i++) {
221 {
222 EmuglConfig config;
223 EXPECT_TRUE(emuglConfig_init(
224 &config, false, "host", "on", 0, false, false, false,
225 (enum WinsysPreferredGlesBackend)i, false));
226 EXPECT_TRUE(config.enabled);
227 EXPECT_STREQ("host", config.backend);
228 EXPECT_STREQ("GPU emulation enabled using 'host' mode", config.status);
229 }
230
231 {
232 EmuglConfig config;
233 EXPECT_TRUE(emuglConfig_init(
234 &config, false, "guest", "auto", 0, false, false, false,
235 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
236 EXPECT_FALSE(config.enabled);
237 EXPECT_STREQ("GPU emulation is disabled", config.status);
238 }
239 }
240
241 // If the UI setting is not "auto", and there is no gpu command line option,
242 // then use the UI setting, regardless of the AVD config.
243 for (int i = 1; i < 5; i++) {
244 EmuglConfig config;
245 EXPECT_TRUE(emuglConfig_init(
246 &config, false, "host", NULL, 0, false, false, false,
247 (enum WinsysPreferredGlesBackend)i, false));
248
249 EXPECT_TRUE(config.enabled);
250 switch (i) {
251 case 0:
252 EXPECT_STREQ("host", config.backend);
253 break;
254 case 1:
255 EXPECT_STREQ("angle_indirect", config.backend);
256 break;
257 case 2:
258 EXPECT_STREQ("angle_indirect", config.backend);
259 break;
260 case 3:
261 EXPECT_STREQ("swiftshader_indirect", config.backend);
262 break;
263 case 4:
264 EXPECT_STREQ("host", config.backend);
265 break;
266 default:
267 break;
268 }
269 }
270 }
271
TEST(EmuglConfig,initGLESv2Only)272 TEST(EmuglConfig, initGLESv2Only) {
273 TestSystem testSys("foo", System::kProgramBitness, "/");
274 TestTempDir* myDir = testSys.getTempRoot();
275 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
276 makeLibSubDir(myDir, "");
277
278 makeLibSubDir(myDir, "gles_angle");
279
280 #ifdef _WIN32
281 const char* kEglLibName = "libEGL.dll";
282 const char* kGLESv1LibName = "libGLES_CM.dll";
283 const char* kGLESv2LibName = "libGLESv2.dll";
284 #elif defined(__APPLE__)
285 const char* kEglLibName = "libEGL.dylib";
286 const char* kGLESv1LibName = "libGLES_CM.dylib";
287 const char* kGLESv2LibName = "libGLESv2.dylib";
288 #else
289 const char* kEglLibName = "libEGL.so";
290 const char* kGLESv1LibName = "libGLES_CM.so";
291 const char* kGLESv2LibName = "libGLESv2.so";
292 #endif
293
294 std::string eglLibPath = StringFormat("gles_angle/%s", kEglLibName);
295 std::string GLESv1LibPath = StringFormat("gles_angle/%s", kGLESv1LibName);
296 std::string GLESv2LibPath = StringFormat("gles_angle/%s", kGLESv2LibName);
297
298 makeLibSubFile(myDir, eglLibPath.c_str());
299 makeLibSubFile(myDir, GLESv2LibPath.c_str());
300
301 {
302 EmuglConfig config;
303 EXPECT_TRUE(emuglConfig_init(
304 &config, true, "angle", "auto", 0, false, false, false,
305 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
306 EXPECT_TRUE(config.enabled);
307 EXPECT_STREQ("angle_indirect", config.backend);
308 EXPECT_STREQ("GPU emulation enabled using 'angle_indirect' mode",
309 config.status);
310 emuglConfig_setupEnv(&config);
311 }
312 }
313
TEST(EmuglConfig,initNxWithSwiftshader)314 TEST(EmuglConfig, initNxWithSwiftshader) {
315 TestSystem testSys("foo", System::kProgramBitness, "/");
316 TestTempDir* myDir = testSys.getTempRoot();
317 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
318 makeLibSubDir(myDir, "");
319
320 makeLibSubDir(myDir, "gles_swiftshader");
321 makeLibSubFile(myDir, "gles_swiftshader/libEGL.so");
322 makeLibSubFile(myDir, "gles_swiftshader/libGLES_CM.so");
323 makeLibSubFile(myDir, "gles_swiftshader/libGLESv2.so");
324
325 testSys.setRemoteSessionType("NX");
326
327 EmuglConfig config;
328 EXPECT_TRUE(emuglConfig_init(
329 &config, true, "auto", NULL, 0, false, false, false,
330 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
331 EXPECT_TRUE(config.enabled);
332 EXPECT_STREQ("swiftshader_indirect", config.backend);
333 EXPECT_STREQ("GPU emulation enabled using 'swiftshader_indirect' mode",
334 config.status);
335 }
336
TEST(EmuglConfig,initNxWithoutSwiftshader)337 TEST(EmuglConfig, initNxWithoutSwiftshader) {
338 TestSystem testSys("foo", System::kProgramBitness);
339 TestTempDir* myDir = testSys.getTempRoot();
340 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
341 makeLibSubDir(myDir, "");
342
343 testSys.setRemoteSessionType("NX");
344
345 EmuglConfig config;
346 EXPECT_TRUE(emuglConfig_init(
347 &config, true, "auto", NULL, 0, false, false, false,
348 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
349 EXPECT_FALSE(config.enabled);
350 EXPECT_STREQ("GPU emulation is disabled under NX without Swiftshader", config.status);
351 }
352
TEST(EmuglConfig,initChromeRemoteDesktopWithSwiftshader)353 TEST(EmuglConfig, initChromeRemoteDesktopWithSwiftshader) {
354 TestSystem testSys("foo", System::kProgramBitness, "/");
355 TestTempDir* myDir = testSys.getTempRoot();
356 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
357 makeLibSubDir(myDir, "");
358
359 makeLibSubDir(myDir, "gles_swiftshader");
360 makeLibSubFile(myDir, "gles_swiftshader/libEGL.so");
361 makeLibSubFile(myDir, "gles_swiftshader/libGLES_CM.so");
362 makeLibSubFile(myDir, "gles_swiftshader/libGLESv2.so");
363
364 testSys.setRemoteSessionType("Chrome Remote Desktop");
365
366 EmuglConfig config;
367 EXPECT_TRUE(emuglConfig_init(
368 &config, true, "auto", NULL, 0, false, false, false,
369 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
370 EXPECT_TRUE(config.enabled);
371 EXPECT_STREQ("swiftshader_indirect", config.backend);
372 EXPECT_STREQ("GPU emulation enabled using 'swiftshader_indirect' mode",
373 config.status);
374 }
375
TEST(EmuglConfig,initChromeRemoteDesktopWithoutSwiftshader)376 TEST(EmuglConfig, initChromeRemoteDesktopWithoutSwiftshader) {
377 TestSystem testSys("foo", System::kProgramBitness, "/");
378 TestTempDir* myDir = testSys.getTempRoot();
379 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
380 makeLibSubDir(myDir, "");
381
382 testSys.setRemoteSessionType("Chrome Remote Desktop");
383
384 EmuglConfig config;
385 EXPECT_TRUE(emuglConfig_init(
386 &config, true, "auto", NULL, 0, false, false, false,
387 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
388 EXPECT_FALSE(config.enabled);
389 EXPECT_STREQ("GPU emulation is disabled under Chrome Remote Desktop without Swiftshader", config.status);
390 }
391
TEST(EmuglConfig,initNoWindowWithSwiftshader)392 TEST(EmuglConfig, initNoWindowWithSwiftshader) {
393 TestSystem testSys("foo", System::kProgramBitness, "/");
394 TestTempDir* myDir = testSys.getTempRoot();
395 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
396 makeLibSubDir(myDir, "");
397
398 makeLibSubDir(myDir, "gles_swiftshader");
399 makeLibSubFile(myDir, "gles_swiftshader/libEGL.so");
400 makeLibSubFile(myDir, "gles_swiftshader/libGLES_CM.so");
401 makeLibSubFile(myDir, "gles_swiftshader/libGLESv2.so");
402
403 EmuglConfig config;
404 EXPECT_TRUE(emuglConfig_init(
405 &config, true, "auto", NULL, 0, true, false, false,
406 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
407 EXPECT_TRUE(config.enabled);
408 EXPECT_STREQ("swiftshader_indirect", config.backend);
409 EXPECT_STREQ("GPU emulation enabled using 'swiftshader_indirect' mode",
410 config.status);
411 }
412
TEST(EmuglConfig,initWithSwiftshaderCheckVulkanEnvVar)413 TEST(EmuglConfig, initWithSwiftshaderCheckVulkanEnvVar) {
414 TestSystem testSys("foo", System::kProgramBitness, "/");
415 TestTempDir* myDir = testSys.getTempRoot();
416 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
417 makeLibSubDir(myDir, "");
418
419 makeLibSubDir(myDir, "gles_swiftshader");
420 makeLibSubFile(myDir, "gles_swiftshader/libEGL.so");
421 makeLibSubFile(myDir, "gles_swiftshader/libGLES_CM.so");
422 makeLibSubFile(myDir, "gles_swiftshader/libGLESv2.so");
423
424 // Do not force use host vulkan
425 {
426 EmuglConfig config;
427 EXPECT_TRUE(emuglConfig_init(
428 &config, true, "auto", NULL, 0, true, false, false,
429 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
430 emuglConfig_setupEnv(&config);
431 EXPECT_STREQ("swiftshader",
432 System::get()->envGet("ANDROID_EMU_VK_ICD").c_str());
433 }
434
435 // Force use host vulkan
436 {
437 EmuglConfig config;
438 EXPECT_TRUE(emuglConfig_init(
439 &config, true, "auto", NULL, 0, true, false, false,
440 WINSYS_GLESBACKEND_PREFERENCE_AUTO, true));
441 emuglConfig_setupEnv(&config);
442 EXPECT_STREQ("",
443 System::get()->envGet("ANDROID_EMU_VK_ICD").c_str());
444 }
445 }
446
TEST(EmuglConfig,initNoWindowWithoutSwiftshader)447 TEST(EmuglConfig, initNoWindowWithoutSwiftshader) {
448 TestSystem testSys("foo", System::kProgramBitness, "/");
449 TestTempDir* myDir = testSys.getTempRoot();
450 myDir->makeSubDir(System::get()->getLauncherDirectory().c_str());
451 makeLibSubDir(myDir, "");
452
453 EmuglConfig config;
454 EXPECT_TRUE(emuglConfig_init(
455 &config, true, "auto", NULL, 0, true, false, false,
456 WINSYS_GLESBACKEND_PREFERENCE_AUTO, false));
457 EXPECT_FALSE(config.enabled);
458 EXPECT_STREQ("GPU emulation is disabled (-no-window without Swiftshader)",
459 config.status);
460 }
461
TEST(EmuglConfig,setupEnv)462 TEST(EmuglConfig, setupEnv) {
463 }
464
TEST(EmuglConfig,hostGpuProps)465 TEST(EmuglConfig, hostGpuProps) {
466 TestSystem testSys("/usr", 32);
467 testSys.setLiveUnixTime(true);
468 GpuInfoList* gpulist = const_cast<GpuInfoList*>(&globalGpuInfoList());
469 gpulist->clear();
470 EXPECT_TRUE(gpulist->infos.size() == 0);
471 gpulist->addGpu();
472 gpulist->currGpu().make = "TEST GPU0 MAKE";
473 gpulist->currGpu().model = "TEST GPU0 MODEL";
474 gpulist->currGpu().device_id = "TEST GPU0 DEVICEID";
475 gpulist->currGpu().revision_id = "TEST GPU0 REVISIONID";
476 gpulist->currGpu().version = "TEST GPU0 VERSION";
477 gpulist->currGpu().renderer = "TEST GPU0 RENDERER";
478 gpulist->addGpu();
479 gpulist->currGpu().make = "TEST GPU1 MAKE";
480 gpulist->currGpu().model = "TEST GPU1 MODEL";
481 gpulist->currGpu().device_id = "TEST GPU1 DEVICEID";
482 gpulist->currGpu().revision_id = "TEST GPU1 REVISIONID";
483 gpulist->currGpu().version = "TEST GPU1 VERSION";
484 gpulist->currGpu().renderer = "TEST GPU1 RENDERER";
485 gpulist->addGpu();
486 gpulist->currGpu().make = "TEST GPU2 MAKE";
487 gpulist->currGpu().model = "TEST GPU2 MODEL";
488 gpulist->currGpu().device_id = "TEST GPU2 DEVICEID";
489 gpulist->currGpu().revision_id = "TEST GPU2 REVISIONID";
490 gpulist->currGpu().version = "TEST GPU2 VERSION";
491 gpulist->currGpu().renderer = "TEST GPU2 RENDERER";
492 gpulist->addGpu();
493 gpulist->currGpu().make = "TEST GPU3 MAKE";
494 gpulist->currGpu().model = "TEST GPU3 MODEL";
495 gpulist->currGpu().device_id = "TEST GPU3 DEVICEID";
496 gpulist->currGpu().revision_id = "TEST GPU3 REVISIONID";
497 gpulist->currGpu().version = "TEST GPU3 VERSION";
498 gpulist->currGpu().renderer = "TEST GPU3 RENDERER";
499
500 emugl_host_gpu_prop_list gpu_props = emuglConfig_get_host_gpu_props();
501 EXPECT_TRUE(gpu_props.num_gpus == 4);
502
503 EXPECT_STREQ("TEST GPU0 MAKE", gpu_props.props[0].make);
504 EXPECT_STREQ("TEST GPU1 MAKE", gpu_props.props[1].make);
505 EXPECT_STREQ("TEST GPU2 MAKE", gpu_props.props[2].make);
506 EXPECT_STREQ("TEST GPU3 MAKE", gpu_props.props[3].make);
507
508 EXPECT_STREQ("TEST GPU0 MODEL", gpu_props.props[0].model);
509 EXPECT_STREQ("TEST GPU1 MODEL", gpu_props.props[1].model);
510 EXPECT_STREQ("TEST GPU2 MODEL", gpu_props.props[2].model);
511 EXPECT_STREQ("TEST GPU3 MODEL", gpu_props.props[3].model);
512
513 EXPECT_STREQ("TEST GPU0 DEVICEID", gpu_props.props[0].device_id);
514 EXPECT_STREQ("TEST GPU1 DEVICEID", gpu_props.props[1].device_id);
515 EXPECT_STREQ("TEST GPU2 DEVICEID", gpu_props.props[2].device_id);
516 EXPECT_STREQ("TEST GPU3 DEVICEID", gpu_props.props[3].device_id);
517
518 EXPECT_STREQ("TEST GPU0 REVISIONID", gpu_props.props[0].revision_id);
519 EXPECT_STREQ("TEST GPU1 REVISIONID", gpu_props.props[1].revision_id);
520 EXPECT_STREQ("TEST GPU2 REVISIONID", gpu_props.props[2].revision_id);
521 EXPECT_STREQ("TEST GPU3 REVISIONID", gpu_props.props[3].revision_id);
522
523 EXPECT_STREQ("TEST GPU0 VERSION", gpu_props.props[0].version);
524 EXPECT_STREQ("TEST GPU1 VERSION", gpu_props.props[1].version);
525 EXPECT_STREQ("TEST GPU2 VERSION", gpu_props.props[2].version);
526 EXPECT_STREQ("TEST GPU3 VERSION", gpu_props.props[3].version);
527
528 EXPECT_STREQ("TEST GPU0 RENDERER", gpu_props.props[0].renderer);
529 EXPECT_STREQ("TEST GPU1 RENDERER", gpu_props.props[1].renderer);
530 EXPECT_STREQ("TEST GPU2 RENDERER", gpu_props.props[2].renderer);
531 EXPECT_STREQ("TEST GPU3 RENDERER", gpu_props.props[3].renderer);
532
533 free_emugl_host_gpu_props(gpu_props);
534 }
535
TEST(EmuglConfig,hostGpuProps_empty)536 TEST(EmuglConfig, hostGpuProps_empty) {
537 TestSystem testSys("/usr", 32);
538 testSys.setLiveUnixTime(true);
539 GpuInfoList* gpulist = const_cast<GpuInfoList*>(&globalGpuInfoList());
540 gpulist->clear();
541 EXPECT_TRUE(gpulist->infos.size() == 0);
542
543 emugl_host_gpu_prop_list gpu_props = emuglConfig_get_host_gpu_props();
544 EXPECT_TRUE(gpu_props.num_gpus == 0);
545 free_emugl_host_gpu_props(gpu_props);
546 }
547
548 } // namespace base
549 } // namespace android
550