TestSanitizeRenderer.cpp (10507B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* This Source Code Form is subject to the terms of the Mozilla Public 3 * License, v. 2.0. If a copy of the MPL was not distributed with this file, 4 * You can obtain one at http://mozilla.org/MPL/2.0/. */ 5 6 #include "gtest/gtest.h" 7 8 namespace mozilla::webgl { 9 std::string SanitizeRenderer(const std::string&); 10 } // namespace mozilla::webgl 11 12 TEST(SanitizeRenderer, TestLinuxRadeon) 13 { 14 const std::string renderer( 15 "AMD Radeon RX 5700 (NAVI10, DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)"); 16 const std::string expectation("Radeon R9 200 Series, or similar"); 17 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 18 EXPECT_EQ(sanitized, expectation); 19 } 20 21 TEST(SanitizeRenderer, TestLinuxRadeonTM) 22 { 23 const std::string renderer( 24 "AMD Radeon (TM) RX 460 Graphics (POLARIS11, DRM 3.35.0, " 25 "5.4.0-65-generic, LLVM 11.0.0)"); 26 const std::string expectation("Radeon R9 200 Series, or similar"); 27 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 28 EXPECT_EQ(sanitized, expectation); 29 } 30 31 TEST(SanitizeRenderer, TestLinuxRadeonWithoutGeneration) 32 { 33 const std::string renderer( 34 "AMD Radeon RX 5700 (DRM 3.35.0, 5.4.0-65-generic, LLVM 11.0.0)"); 35 const std::string expectation("Radeon R9 200 Series, or similar"); 36 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 37 EXPECT_EQ(sanitized, expectation); 38 } 39 40 TEST(SanitizeRenderer, TestLinuxRenoir) 41 { 42 const std::string renderer( 43 "AMD RENOIR (DRM 3.41.0, 5.13.4-1-default, LLVM 11.1.0)"); 44 const std::string expectation("Radeon R9 200 Series, or similar"); 45 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 46 EXPECT_EQ(sanitized, expectation); 47 } 48 49 TEST(SanitizeRenderer, TestWindowsVega) 50 { 51 const std::string renderer("Radeon RX Vega"); 52 const std::string expectation("Radeon R9 200 Series, or similar"); 53 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 54 EXPECT_EQ(sanitized, expectation); 55 } 56 57 TEST(SanitizeRenderer, TestMacAmd) 58 { 59 const std::string renderer("AMD Radeon Pro 5300M OpenGL Engine"); 60 const std::string expectation("Radeon R9 200 Series, or similar"); 61 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 62 EXPECT_EQ(sanitized, expectation); 63 } 64 65 TEST(SanitizeRenderer, TestLinuxAruba) 66 { 67 const std::string renderer( 68 "AMD ARUBA (DRM 2.50.0 / 5.10.42-calculate, LLVM 12.0.1)"); 69 const std::string expectation("Radeon HD 5850, or similar"); 70 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 71 EXPECT_EQ(sanitized, expectation); 72 } 73 74 TEST(SanitizeRenderer, TestLinuxRembrandt) 75 { 76 const std::string renderer( 77 "REMBRANDT (rembrandt, LLVM 14.0.6, DRM 3.49, 6.2.9)"); 78 const std::string expectation("Radeon R9 200 Series, or similar"); 79 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 80 EXPECT_EQ(sanitized, expectation); 81 } 82 83 TEST(SanitizeRenderer, TestLinuxIntel620) 84 { 85 const std::string renderer("Mesa Intel(R) UHD Graphics 620 (KBL GT2)"); 86 const std::string expectation("Intel(R) HD Graphics 400, or similar"); 87 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 88 EXPECT_EQ(sanitized, expectation); 89 } 90 TEST(SanitizeRenderer, TestLinuxIntel4000) 91 { 92 const std::string renderer("Mesa DRI Intel(R) HD Graphics 4000 (IVB GT2)"); 93 const std::string expectation("Intel(R) HD Graphics, or similar"); 94 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 95 EXPECT_EQ(sanitized, expectation); 96 } 97 98 TEST(SanitizeRenderer, TestMacIntel) 99 { 100 const std::string renderer("Intel(R) HD Graphics 530"); 101 const std::string expectation("Intel(R) HD Graphics 400, or similar"); 102 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 103 EXPECT_EQ(sanitized, expectation); 104 } 105 106 TEST(SanitizeRenderer, TestMacApple) 107 { 108 const std::string renderer("Apple M1"); 109 const std::string expectation("Apple M1, or similar"); 110 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 111 EXPECT_EQ(sanitized, expectation); 112 } 113 114 TEST(SanitizeRenderer, TestPipe) 115 { 116 const std::string renderer("llvmpipe (LLVM 11.0.0, 128 bits)"); 117 const std::string expectation("llvmpipe, or similar"); 118 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 119 EXPECT_EQ(sanitized, expectation); 120 } 121 122 // - 123 124 TEST(SanitizeRenderer, TestAngleVega) 125 { 126 const std::string renderer( 127 "ANGLE (AMD, Radeon RX Vega Direct3D11 vs_5_0 ps_5_0, " 128 "D3D11-27.20.22025.1006)"); 129 const std::string expectation( 130 "ANGLE (AMD, Radeon R9 200 Series Direct3D11 vs_5_0 ps_5_0), or similar"); 131 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 132 EXPECT_EQ(sanitized, expectation); 133 } 134 135 TEST(SanitizeRenderer, TestAngleRadeon) 136 { 137 const std::string renderer( 138 "ANGLE (AMD, AMD Radeon(TM) Graphics Direct3D11 vs_5_0 ps_5_0, " 139 "D3D11-27.20.1020.2002)"); 140 const std::string expectation( 141 "ANGLE (AMD, Radeon HD 3200 Graphics Direct3D11 vs_5_0 ps_5_0), or " 142 "similar"); 143 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 144 EXPECT_EQ(sanitized, expectation); 145 } 146 147 TEST(SanitizeRenderer, TestAngleWarp) 148 { 149 const std::string renderer( 150 "ANGLE (Unknown, Microsoft Basic Render Driver Direct3D11 vs_5_0 ps_5_0, " 151 "D3D11-10.0.22000.1)"); 152 const std::string expectation = 153 "ANGLE (Unknown, Microsoft Basic Render Driver Direct3D11 vs_5_0 " 154 "ps_5_0), or similar"; 155 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 156 EXPECT_EQ(sanitized, expectation); 157 } 158 159 TEST(SanitizeRenderer, TestAngle3070) 160 { 161 const std::string renderer( 162 "ANGLE (NVIDIA, NVIDIA GeForce RTX 3070 Direct3D11 vs_5_0 ps_5_0, " 163 "D3D11-10.0.22000.1)"); 164 const std::string expectation( 165 "ANGLE (NVIDIA, NVIDIA GeForce GTX 980 Direct3D11 vs_5_0 ps_5_0), or " 166 "similar"); 167 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 168 EXPECT_EQ(sanitized, expectation); 169 } 170 171 TEST(SanitizeRenderer, TestWindows3070) 172 { 173 const std::string renderer("GeForce RTX 3070/PCIe/SSE2"); 174 const std::string expectation("GeForce GTX 980, or similar"); 175 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 176 EXPECT_EQ(sanitized, expectation); 177 } 178 179 TEST(SanitizeRenderer, TestAngleK600) 180 { 181 const std::string renderer( 182 "ANGLE (NVIDIA, NVIDIA Quadro K600 Direct3D11 vs_5_0 ps_5_0, somethig " 183 "like D3D11-10.0.22000.1)"); 184 const std::string expectation( 185 "ANGLE (NVIDIA, NVIDIA GeForce GTX 480 Direct3D11 vs_5_0 ps_5_0), or " 186 "similar"); 187 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 188 EXPECT_EQ(sanitized, expectation); 189 } 190 191 TEST(SanitizeRenderer, TestAngleSamsungVulkan) 192 { 193 const std::string renderer("ANGLE (Samsung Xclipse 940) on Vulkan 1.3.264"); 194 const std::string expectation( 195 "ANGLE (Samsung Xclipse 920) on Vulkan, or similar"); 196 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 197 EXPECT_EQ(sanitized, expectation); 198 } 199 200 TEST(SanitizeRenderer, TestAngleSamsungVulkanAlt) 201 { 202 const std::string renderer("ANGLE ((Samsung Xclipse 940) on Vulkan 1.3.279)"); 203 const std::string expectation( 204 "ANGLE (Samsung Xclipse 920) on Vulkan, or similar"); 205 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 206 EXPECT_EQ(sanitized, expectation); 207 } 208 209 TEST(SanitizeRenderer, TestLinuxK600) 210 { 211 const std::string renderer("NVE7"); 212 const std::string expectation("GeForce GTX 480, or similar"); 213 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 214 EXPECT_EQ(sanitized, expectation); 215 } 216 217 TEST(SanitizeRenderer, TestLinux980) 218 { 219 const std::string renderer("NV124"); 220 const std::string expectation("GeForce GTX 980, or similar"); 221 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 222 EXPECT_EQ(sanitized, expectation); 223 } 224 225 TEST(SanitizeRenderer, TestAdreno512) 226 { 227 const std::string renderer("Adreno (TM) 512"); 228 const std::string expectation("Adreno (TM) 540, or similar"); 229 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 230 EXPECT_EQ(sanitized, expectation); 231 } 232 233 TEST(SanitizeRenderer, TestIntelArcWindowsAngle) 234 { 235 const std::string renderer( 236 "ANGLE (Intel, Intel(R) Arc(TM) A770 Graphics Direct3D11 vs_5_0 ps_5_0, " 237 "D3D11-31.0.101.5084)"); 238 const std::string expectation( 239 "ANGLE (Intel, Intel(R) Arc(TM) A750 Graphics Direct3D11 vs_5_0 ps_5_0), " 240 "or similar"); 241 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 242 EXPECT_EQ(sanitized, expectation); 243 } 244 TEST(SanitizeRenderer, TestIntelArcWindowsGl) 245 { 246 const std::string renderer("Intel(R) Arc(TM) A770 Graphics"); 247 const std::string expectation("Intel(R) Arc(TM) A750 Graphics, or similar"); 248 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 249 EXPECT_EQ(sanitized, expectation); 250 } 251 252 // - 253 // Keep gtests for our known CI RENDERER strings (see 254 // test_renderer_strings.html) otherwise the first time we know we messed up is 255 // in CI results after an hour, instead of after running gtests locally. 256 257 TEST(SanitizeRenderer, TestCiAndroid) 258 { 259 const std::string renderer("Adreno (TM) 540"); 260 const std::string expectation("Adreno (TM) 540, or similar"); 261 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 262 EXPECT_EQ(sanitized, expectation); 263 } 264 265 TEST(SanitizeRenderer, TestCiLinux) 266 { 267 const std::string renderer("llvmpipe (LLVM 10.0.0, 256 bits)"); 268 const std::string expectation("llvmpipe, or similar"); 269 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 270 EXPECT_EQ(sanitized, expectation); 271 } 272 273 TEST(SanitizeRenderer, TestCiMac) 274 { 275 const std::string renderer("Intel(R) UHD Graphics 630"); 276 const std::string expectation("Intel(R) HD Graphics 400, or similar"); 277 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 278 EXPECT_EQ(sanitized, expectation); 279 } 280 281 TEST(SanitizeRenderer, TestCiMac2) 282 { 283 const std::string renderer("Apple M1"); 284 const std::string expectation("Apple M1, or similar"); 285 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 286 EXPECT_EQ(sanitized, expectation); 287 } 288 289 TEST(SanitizeRenderer, TestCiWindows) 290 { 291 const std::string renderer( 292 "ANGLE (NVIDIA, NVIDIA Tesla M60 Direct3D11 vs_5_0 ps_5_0, " 293 "D3D11-23.21.13.9181)"); 294 const std::string expectation( 295 "ANGLE (NVIDIA, NVIDIA GeForce 8800 GTX Direct3D11 vs_5_0 ps_5_0), or " 296 "similar"); 297 const auto sanitized = mozilla::webgl::SanitizeRenderer(renderer); 298 EXPECT_EQ(sanitized, expectation); 299 }