1 //
2 // Copyright 2014 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6
7 // angle_test_instantiate.cpp: Adds support for filtering parameterized
8 // tests by platform, so we skip unsupported configs.
9
10 #include "test_utils/angle_test_instantiate.h"
11
12 #include <algorithm>
13 #include <array>
14 #include <iostream>
15 #include <map>
16
17 #include "angle_gl.h"
18 #include "common/debug.h"
19 #include "common/platform.h"
20 #include "common/system_utils.h"
21 #include "common/third_party/base/anglebase/no_destructor.h"
22 #include "gpu_info_util/SystemInfo.h"
23 #include "test_utils/angle_test_configs.h"
24 #include "util/EGLWindow.h"
25 #include "util/OSWindow.h"
26 #include "util/test_utils.h"
27
28 #if defined(ANGLE_PLATFORM_WINDOWS)
29 # include <VersionHelpers.h>
30 # include "util/windows/WGLWindow.h"
31 #endif // defined(ANGLE_PLATFORM_WINDOWS)
32
33 #if defined(ANGLE_PLATFORM_APPLE)
34 # include "test_utils/angle_test_instantiate_apple.h"
35 #endif
36
37 namespace angle
38 {
39 namespace
40 {
IsAngleEGLConfigSupported(const PlatformParameters & param,OSWindow * osWindow)41 bool IsAngleEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
42 {
43 std::unique_ptr<angle::Library> eglLibrary;
44
45 #if defined(ANGLE_USE_UTIL_LOADER)
46 eglLibrary.reset(
47 angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ModuleDir));
48 #endif
49
50 EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
51 ConfigParameters configParams;
52 bool result =
53 eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::AngleEGL,
54 param.eglParameters, configParams);
55 eglWindow->destroyGL();
56 EGLWindow::Delete(&eglWindow);
57 return result;
58 }
59
IsSystemWGLConfigSupported(const PlatformParameters & param,OSWindow * osWindow)60 bool IsSystemWGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
61 {
62 #if defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
63 std::unique_ptr<angle::Library> openglLibrary(
64 angle::OpenSharedLibrary("opengl32", angle::SearchType::SystemDir));
65
66 WGLWindow *wglWindow = WGLWindow::New(param.majorVersion, param.minorVersion);
67 ConfigParameters configParams;
68 bool result =
69 wglWindow->initializeGL(osWindow, openglLibrary.get(), angle::GLESDriverType::SystemWGL,
70 param.eglParameters, configParams);
71 wglWindow->destroyGL();
72 WGLWindow::Delete(&wglWindow);
73 return result;
74 #else
75 return false;
76 #endif // defined(ANGLE_PLATFORM_WINDOWS) && defined(ANGLE_USE_UTIL_LOADER)
77 }
78
IsSystemEGLConfigSupported(const PlatformParameters & param,OSWindow * osWindow)79 bool IsSystemEGLConfigSupported(const PlatformParameters ¶m, OSWindow *osWindow)
80 {
81 #if defined(ANGLE_USE_UTIL_LOADER)
82 std::unique_ptr<angle::Library> eglLibrary;
83
84 eglLibrary.reset(OpenSharedLibraryWithExtension(GetNativeEGLLibraryNameWithExtension(),
85 SearchType::SystemDir));
86
87 EGLWindow *eglWindow = EGLWindow::New(param.majorVersion, param.minorVersion);
88 ConfigParameters configParams;
89 bool result =
90 eglWindow->initializeGL(osWindow, eglLibrary.get(), angle::GLESDriverType::SystemEGL,
91 param.eglParameters, configParams);
92 eglWindow->destroyGL();
93 EGLWindow::Delete(&eglWindow);
94 return result;
95 #else
96 return false;
97 #endif
98 }
99
IsAndroidDevice(const std::string & deviceName)100 bool IsAndroidDevice(const std::string &deviceName)
101 {
102 if (!IsAndroid())
103 {
104 return false;
105 }
106 SystemInfo *systemInfo = GetTestSystemInfo();
107 if (systemInfo->machineModelName == deviceName)
108 {
109 return true;
110 }
111 return false;
112 }
113
IsAndroid9OrNewer()114 bool IsAndroid9OrNewer()
115 {
116 if (!IsAndroid())
117 {
118 return false;
119 }
120 SystemInfo *systemInfo = GetTestSystemInfo();
121 if (systemInfo->androidSdkLevel >= 28)
122 {
123 return true;
124 }
125 return false;
126 }
127
GetActiveGPUDeviceInfo()128 GPUDeviceInfo *GetActiveGPUDeviceInfo()
129 {
130 SystemInfo *systemInfo = GetTestSystemInfo();
131 // Unfortunately sometimes GPU info collection can fail.
132 if (systemInfo->gpus.empty())
133 {
134 return nullptr;
135 }
136 return &systemInfo->gpus[systemInfo->activeGPUIndex];
137 }
138
HasSystemVendorID(VendorID vendorID)139 bool HasSystemVendorID(VendorID vendorID)
140 {
141 GPUDeviceInfo *gpuInfo = GetActiveGPUDeviceInfo();
142
143 return gpuInfo && gpuInfo->vendorId == vendorID;
144 }
145
HasSystemDeviceID(VendorID vendorID,DeviceID deviceID)146 bool HasSystemDeviceID(VendorID vendorID, DeviceID deviceID)
147 {
148 GPUDeviceInfo *gpuInfo = GetActiveGPUDeviceInfo();
149
150 return gpuInfo && gpuInfo->vendorId == vendorID && gpuInfo->deviceId == deviceID;
151 }
152
153 using ParamAvailabilityCache = std::map<PlatformParameters, bool>;
154
GetAvailabilityCache()155 ParamAvailabilityCache &GetAvailabilityCache()
156 {
157 static angle::base::NoDestructor<std::unique_ptr<ParamAvailabilityCache>>
158 sParamAvailabilityCache(new ParamAvailabilityCache());
159 return **sParamAvailabilityCache;
160 }
161
162 constexpr size_t kMaxConfigNameLen = 100;
163 std::array<char, kMaxConfigNameLen> gSelectedConfig;
164 } // namespace
165
166 bool gEnableANGLEPerTestCaptureLabel = false;
167
IsConfigSelected()168 bool IsConfigSelected()
169 {
170 return gSelectedConfig[0] != 0;
171 }
172
173 #if !defined(ANGLE_PLATFORM_APPLE)
174 // For Apple platform, see angle_test_instantiate_apple.mm
IsMetalTextureSwizzleAvailable()175 bool IsMetalTextureSwizzleAvailable()
176 {
177 return false;
178 }
179
IsMetalCompressedTexture3DAvailable()180 bool IsMetalCompressedTexture3DAvailable()
181 {
182 return false;
183 }
184 #endif
185
GetTestSystemInfo()186 SystemInfo *GetTestSystemInfo()
187 {
188 static SystemInfo *sSystemInfo = nullptr;
189 if (sSystemInfo == nullptr)
190 {
191 sSystemInfo = new SystemInfo;
192 if (!GetSystemInfo(sSystemInfo))
193 {
194 std::cerr << "Warning: incomplete system info collection.\n";
195 }
196
197 // On dual-GPU Macs we want the active GPU to always appear to be the
198 // high-performance GPU for tests.
199 // We can call the generic GPU info collector which selects the
200 // non-Intel GPU as the active one on dual-GPU machines.
201 if (IsOSX())
202 {
203 GetDualGPUInfo(sSystemInfo);
204 }
205
206 // Print complete system info when available.
207 // Seems to trip up Android test expectation parsing.
208 // Also don't print info when a config is selected to prevent test spam.
209 if (!IsAndroid() && !IsConfigSelected())
210 {
211 PrintSystemInfo(*sSystemInfo);
212 }
213 }
214 return sSystemInfo;
215 }
216
IsAndroid()217 bool IsAndroid()
218 {
219 #if defined(ANGLE_PLATFORM_ANDROID)
220 return true;
221 #else
222 return false;
223 #endif
224 }
225
IsLinux()226 bool IsLinux()
227 {
228 #if defined(ANGLE_PLATFORM_LINUX)
229 return true;
230 #else
231 return false;
232 #endif
233 }
234
IsOSX()235 bool IsOSX()
236 {
237 #if defined(ANGLE_PLATFORM_MACOS)
238 return true;
239 #else
240 return false;
241 #endif
242 }
243
IsIOS()244 bool IsIOS()
245 {
246 #if defined(ANGLE_PLATFORM_IOS)
247 return true;
248 #else
249 return false;
250 #endif
251 }
252
IsARM64()253 bool IsARM64()
254 {
255 // _M_ARM64 is Windows-specific, while __aarch64__ is for other platforms.
256 #if defined(_M_ARM64) || defined(__aarch64__)
257 return true;
258 #else
259 return false;
260 #endif
261 }
262
IsOzone()263 bool IsOzone()
264 {
265 #if defined(USE_OZONE) && (defined(USE_X11) || defined(ANGLE_USE_VULKAN_DISPLAY))
266 // We do not have a proper support for Ozone/Linux yet. Still, we need to figure out how to
267 // properly initialize tests and differentiate between X11 and Wayland. Probably, passing a
268 // command line argument could be sufficient. At the moment, run tests only for X11 backend
269 // as we don't have Wayland support in Angle. Yes, this is a bit weird to return false, but
270 // it makes it possible to continue angle tests with X11 regardless of the Chromium config
271 // for linux, which is use_x11 && use_ozone. Also, IsOzone is a bit vague now. It was only
272 // expected that angle could run with ozone/drm backend for ChromeOS. And returning true
273 // for desktop Linux when USE_OZONE && USE_X11 are both defined results in incorrect tests'
274 // expectations. We should also rework them and make IsOzone less vague.
275 //
276 // TODO(crbug.com/angleproject/4977): make it possible to switch between X11 and Wayland on
277 // Ozone/Linux builds. Probably, it's possible to identify the WAYLAND backend by checking
278 // the WAYLAND_DISPLAY or XDG_SESSION_TYPE env vars. And also make the IsOzone method less
279 // vague (read the comment above).
280 return false;
281 #elif defined(USE_OZONE)
282 return true;
283 #else
284 return false;
285 #endif
286 }
287
IsWindows()288 bool IsWindows()
289 {
290 #if defined(ANGLE_PLATFORM_WINDOWS)
291 return true;
292 #else
293 return false;
294 #endif
295 }
296
IsWindows7()297 bool IsWindows7()
298 {
299 #if defined(ANGLE_PLATFORM_WINDOWS)
300 return ::IsWindows7OrGreater() && !::IsWindows8OrGreater();
301 #else
302 return false;
303 #endif
304 }
305
IsFuchsia()306 bool IsFuchsia()
307 {
308 #if defined(ANGLE_PLATFORM_FUCHSIA)
309 return true;
310 #else
311 return false;
312 #endif
313 }
314
IsNexus5X()315 bool IsNexus5X()
316 {
317 return IsAndroidDevice("Nexus 5X");
318 }
319
IsNexus9()320 bool IsNexus9()
321 {
322 return IsAndroidDevice("Nexus 9");
323 }
324
IsPixelXL()325 bool IsPixelXL()
326 {
327 return IsAndroidDevice("Pixel XL");
328 }
329
IsPixel2()330 bool IsPixel2()
331 {
332 return IsAndroidDevice("Pixel 2");
333 }
334
IsPixel2XL()335 bool IsPixel2XL()
336 {
337 return IsAndroidDevice("Pixel 2 XL");
338 }
339
IsPixel4()340 bool IsPixel4()
341 {
342 return IsAndroidDevice("Pixel 4");
343 }
344
IsPixel4XL()345 bool IsPixel4XL()
346 {
347 return IsAndroidDevice("Pixel 4 XL");
348 }
349
IsNVIDIAShield()350 bool IsNVIDIAShield()
351 {
352 return IsAndroidDevice("SHIELD Android TV");
353 }
354
IsIntel()355 bool IsIntel()
356 {
357 return HasSystemVendorID(kVendorID_Intel);
358 }
359
IsIntelUHD630Mobile()360 bool IsIntelUHD630Mobile()
361 {
362 return HasSystemDeviceID(kVendorID_Intel, kDeviceID_UHD630Mobile);
363 }
364
IsAMD()365 bool IsAMD()
366 {
367 return HasSystemVendorID(kVendorID_AMD);
368 }
369
IsARM()370 bool IsARM()
371 {
372 return HasSystemVendorID(kVendorID_ARM);
373 }
374
IsSwiftshaderDevice()375 bool IsSwiftshaderDevice()
376 {
377 return HasSystemDeviceID(kVendorID_GOOGLE, kDeviceID_Swiftshader);
378 }
379
IsNVIDIA()380 bool IsNVIDIA()
381 {
382 #if defined(ANGLE_PLATFORM_ANDROID)
383 // NVIDIA Shield cannot detect vendor ID (http://anglebug.com/3541)
384 if (IsNVIDIAShield())
385 {
386 return true;
387 }
388 #endif
389 return HasSystemVendorID(kVendorID_NVIDIA);
390 }
391
IsQualcomm()392 bool IsQualcomm()
393 {
394 return IsNexus5X() || IsNexus9() || IsPixelXL() || IsPixel2() || IsPixel2XL() || IsPixel4() ||
395 IsPixel4XL();
396 }
397
Is64Bit()398 bool Is64Bit()
399 {
400 #if defined(ANGLE_IS_64_BIT_CPU)
401 return true;
402 #else
403 return false;
404 #endif // defined(ANGLE_IS_64_BIT_CPU)
405 }
406
IsConfigAllowlisted(const SystemInfo & systemInfo,const PlatformParameters & param)407 bool IsConfigAllowlisted(const SystemInfo &systemInfo, const PlatformParameters ¶m)
408 {
409 VendorID vendorID =
410 systemInfo.gpus.empty() ? 0 : systemInfo.gpus[systemInfo.activeGPUIndex].vendorId;
411
412 // We support the default and null back-ends on every platform.
413 if (param.driver == GLESDriverType::AngleEGL)
414 {
415 if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE)
416 return true;
417 if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE)
418 return true;
419 }
420
421 // TODO: http://crbug.com/swiftshader/145
422 // Swiftshader does not currently have all the robustness features
423 // we need for ANGLE. In particular, it is unable to detect and recover
424 // from infinitely looping shaders. That bug is the tracker for fixing
425 // that and when resolved we can remove the following code.
426 // This test will disable tests marked with the config WithRobustness
427 // when run with the swiftshader Vulkan driver and on Android.
428 if ((param.isSwiftshader() || IsSwiftshaderDevice()) &&
429 param.eglParameters.robustness == EGL_TRUE)
430 {
431 return false;
432 }
433
434 if (IsWindows())
435 {
436 switch (param.driver)
437 {
438 case GLESDriverType::AngleEGL:
439 switch (param.getRenderer())
440 {
441 case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
442 case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
443 return true;
444 case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
445 // Note we disable AMD OpenGL testing on Windows due to using a very old and
446 // outdated card with many driver bugs. See http://anglebug.com/5123
447 return !IsAMD();
448 case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
449 if (IsARM64())
450 {
451 return param.getDeviceType() ==
452 EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE;
453 }
454 return true;
455 case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
456 // ES 3.1+ back-end is not supported properly.
457 if (param.eglParameters.majorVersion == 3 &&
458 param.eglParameters.minorVersion > 0)
459 {
460 return false;
461 }
462
463 // Win ES emulation is currently only supported on NVIDIA.
464 return IsNVIDIA(vendorID);
465 default:
466 return false;
467 }
468 case GLESDriverType::SystemWGL:
469 // AMD does not support the ES compatibility extensions.
470 return !IsAMD(vendorID);
471 default:
472 return false;
473 }
474 }
475
476 #if defined(ANGLE_PLATFORM_APPLE)
477 if (IsOSX() || IsIOS())
478 {
479 // We do not support non-ANGLE bindings on OSX.
480 if (param.driver != GLESDriverType::AngleEGL)
481 {
482 return false;
483 }
484
485 switch (param.getRenderer())
486 {
487 case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
488 // ES 3.1+ back-end is not supported properly.
489 if (param.majorVersion == 3 && param.minorVersion > 0)
490 {
491 return false;
492 }
493 return true;
494 case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE:
495 if (!IsMetalRendererAvailable())
496 {
497 return false;
498 }
499 return true;
500 case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
501 // OSX does not support native vulkan
502 return param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE;
503 default:
504 return false;
505 }
506 }
507 #endif // #if defined(ANGLE_PLATFORM_APPLE)
508
509 if (IsFuchsia())
510 {
511 // We do not support non-ANGLE bindings on Fuchsia.
512 if (param.driver != GLESDriverType::AngleEGL)
513 {
514 return false;
515 }
516
517 // ES 3 configs do not work properly on Fuchsia ARM.
518 // TODO(anglebug.com/4352): Investigate missing features.
519 if (param.majorVersion > 2 && IsARM())
520 return false;
521
522 // Loading swiftshader is not brought up on Fuchsia.
523 // TODO(anglebug.com/4353): Support loading swiftshader vulkan ICD.
524 if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE)
525 return false;
526
527 // Currently we only support the Vulkan back-end on Fuchsia.
528 return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE);
529 }
530
531 if (IsOzone())
532 {
533 // We do not support non-ANGLE bindings on Ozone.
534 if (param.driver != GLESDriverType::AngleEGL)
535 return false;
536
537 // ES 3 configs do not work properly on Ozone.
538 if (param.majorVersion > 2)
539 return false;
540
541 // Currently we only support the GLES back-end on Ozone.
542 return (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE);
543 }
544
545 if (IsLinux() || IsAndroid())
546 {
547 // We do not support WGL bindings on Linux/Android. We do support system EGL.
548 switch (param.driver)
549 {
550 case GLESDriverType::SystemEGL:
551 return param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE;
552 case GLESDriverType::SystemWGL:
553 return false;
554 default:
555 break;
556 }
557 }
558
559 if (IsLinux())
560 {
561 ASSERT(param.driver == GLESDriverType::AngleEGL);
562
563 // Currently we support the OpenGL and Vulkan back-ends on Linux.
564 switch (param.getRenderer())
565 {
566 case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
567 return true;
568 case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
569 // http://issuetracker.google.com/173004081
570 return !IsIntel() || param.eglParameters.asyncCommandQueueFeatureVulkan != EGL_TRUE;
571 default:
572 return false;
573 }
574 }
575
576 if (IsAndroid())
577 {
578 ASSERT(param.driver == GLESDriverType::AngleEGL);
579
580 // Nexus Android devices don't support backing 3.2 contexts
581 if (param.eglParameters.majorVersion == 3 && param.eglParameters.minorVersion == 2)
582 {
583 if (IsNexus5X())
584 {
585 return false;
586 }
587 }
588
589 // Currently we support the GLES and Vulkan back-ends on Android.
590 switch (param.getRenderer())
591 {
592 case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
593 return true;
594 case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
595 // Swiftshader's vulkan frontend doesn't build on Android.
596 if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_SWIFTSHADER_ANGLE)
597 {
598 return false;
599 }
600 if (!IsAndroid9OrNewer())
601 {
602 return false;
603 }
604 if (param.eglParameters.supportsVulkanViewportFlip == EGL_FALSE)
605 {
606 return false;
607 }
608 return true;
609 default:
610 return false;
611 }
612 }
613
614 // Unknown platform.
615 return false;
616 }
617
IsConfigSupported(const PlatformParameters & param)618 bool IsConfigSupported(const PlatformParameters ¶m)
619 {
620 OSWindow *osWindow = OSWindow::New();
621 bool result = false;
622 if (osWindow->initialize("CONFIG_TESTER", 1, 1))
623 {
624 switch (param.driver)
625 {
626 case GLESDriverType::AngleEGL:
627 result = IsAngleEGLConfigSupported(param, osWindow);
628 break;
629 case GLESDriverType::SystemEGL:
630 result = IsSystemEGLConfigSupported(param, osWindow);
631 break;
632 case GLESDriverType::SystemWGL:
633 result = IsSystemWGLConfigSupported(param, osWindow);
634 break;
635 }
636
637 osWindow->destroy();
638 }
639
640 OSWindow::Delete(&osWindow);
641 return result;
642 }
643
IsPlatformAvailable(const PlatformParameters & param)644 bool IsPlatformAvailable(const PlatformParameters ¶m)
645 {
646 // Disable "null" device when not on ANGLE or in D3D9.
647 if (param.getDeviceType() == EGL_PLATFORM_ANGLE_DEVICE_TYPE_NULL_ANGLE)
648 {
649 if (param.driver != GLESDriverType::AngleEGL)
650 return false;
651 if (param.getRenderer() == EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE)
652 return false;
653 }
654
655 switch (param.getRenderer())
656 {
657 case EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE:
658 break;
659
660 case EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE:
661 #if !defined(ANGLE_ENABLE_D3D9)
662 return false;
663 #else
664 break;
665 #endif
666
667 case EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE:
668 #if !defined(ANGLE_ENABLE_D3D11)
669 return false;
670 #else
671 break;
672 #endif
673
674 case EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE:
675 case EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE:
676 #if !defined(ANGLE_ENABLE_OPENGL)
677 return false;
678 #else
679 break;
680 #endif
681
682 case EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE:
683 #if !defined(ANGLE_ENABLE_VULKAN)
684 return false;
685 #else
686 break;
687 #endif
688
689 case EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE:
690 #if !defined(ANGLE_ENABLE_METAL)
691 return false;
692 #else
693 break;
694 #endif
695
696 case EGL_PLATFORM_ANGLE_TYPE_NULL_ANGLE:
697 #if !defined(ANGLE_ENABLE_NULL)
698 return false;
699 #else
700 break;
701 #endif
702
703 default:
704 std::cout << "Unknown test platform: " << param << std::endl;
705 return false;
706 }
707
708 bool result = false;
709
710 auto iter = GetAvailabilityCache().find(param);
711 if (iter != GetAvailabilityCache().end())
712 {
713 result = iter->second;
714 }
715 else
716 {
717 if (IsConfigSelected())
718 {
719 std::stringstream strstr;
720 strstr << param;
721 if (strstr.str() == std::string(gSelectedConfig.data()))
722 {
723 result = true;
724 }
725 }
726 else
727 {
728 const SystemInfo *systemInfo = GetTestSystemInfo();
729
730 if (systemInfo)
731 {
732 result = IsConfigAllowlisted(*systemInfo, param);
733 }
734 else
735 {
736 result = IsConfigSupported(param);
737 }
738 }
739
740 GetAvailabilityCache()[param] = result;
741
742 // Enable this unconditionally to print available platforms.
743 if (IsConfigSelected())
744 {
745 if (result)
746 {
747 std::cout << "Test Config: " << param << "\n";
748 }
749 }
750 else if (!result)
751 {
752 std::cout << "Skipping tests using configuration " << param
753 << " because it is not available.\n";
754 }
755 }
756 return result;
757 }
758
GetAvailableTestPlatformNames()759 std::vector<std::string> GetAvailableTestPlatformNames()
760 {
761 std::vector<std::string> platformNames;
762
763 for (const auto &iter : GetAvailabilityCache())
764 {
765 if (iter.second)
766 {
767 std::stringstream strstr;
768 strstr << iter.first;
769 platformNames.push_back(strstr.str());
770 }
771 }
772
773 // Keep the list sorted.
774 std::sort(platformNames.begin(), platformNames.end());
775
776 return platformNames;
777 }
778
SetSelectedConfig(const char * selectedConfig)779 void SetSelectedConfig(const char *selectedConfig)
780 {
781 gSelectedConfig.fill(0);
782 strncpy(gSelectedConfig.data(), selectedConfig, kMaxConfigNameLen - 1);
783 }
784 } // namespace angle
785