| // Copyright 2020 The Android Open Source Project |
| // |
| // Licensed under the Apache License, Version 2.0 (the "License"); |
| // you may not use this file except in compliance with the License. |
| // You may obtain a copy of the License at |
| // |
| // http://www.apache.org/licenses/LICENSE-2.0 |
| // |
| // Unless required by applicable law or agreed to in writing, software |
| // distributed under the License is distributed on an "AS IS" BASIS, |
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| // See the License for the specific language governing permissions and |
| // limitations under the License. |
| |
| #include "android/opengl/gpuinfo.h" |
| |
| #include "android/base/testing/TestSystem.h" |
| #include "android/base/testing/TestTempDir.h" |
| |
| #include <gtest/gtest.h> |
| |
| static const char win_noinstalleddrivers[] = |
| "\r\n" |
| "\r\n" |
| "AcceleratorCapabilities=\r\n" |
| "AdapterCompatibility=RealVNC\r\n" |
| "AdapterDACType=\r\n" |
| "AdapterRAM=\r\n" |
| "Availability=8\r\n" |
| "CapabilityDescriptions=\r\n" |
| "Caption=VNC Mirror Driver\r\n" |
| "ColorTableEntries=\r\n" |
| "ConfigManagerErrorCode=0\r\n" |
| "ConfigManagerUserConfig=FALSE\r\n" |
| "CreationClassName=Win32_VideoController\r\n" |
| "CurrentBitsPerPixel=\r\n" |
| "CurrentHorizontalResolution=\r\n" |
| "CurrentNumberOfColors=\r\n" |
| "CurrentNumberOfColumns=\r\n" |
| "CurrentNumberOfRows=\r\n" |
| "CurrentRefreshRate=\r\n" |
| "CurrentScanMode=\r\n" |
| "CurrentVerticalResolution=\r\n" |
| "Description=VNC Mirror Driver\r\n" |
| "DeviceID=VideoController1\r\n" |
| "DeviceSpecificPens=\r\n" |
| "DitherType=\r\n" |
| "DriverDate=20080314000000.000000-000\r\n" |
| "DriverVersion=1.8.0.0\r\n" |
| "ErrorCleared=\r\n" |
| "ErrorDescription=\r\n" |
| "ICMIntent=\r\n" |
| "ICMMethod=\r\n" |
| "InfFilename=oem24.inf\r\n" |
| "InfSection=vncmirror\r\n" |
| "InstallDate=\r\n" |
| "InstalledDisplayDrivers=\r\n" |
| "LastErrorCode=\r\n" |
| "MaxMemorySupported=\r\n" |
| "MaxNumberControlled=\r\n" |
| "MaxRefreshRate=\r\n" |
| "MinRefreshRate=\r\n" |
| "Monochrome=FALSE\r\n" |
| "Name=VNC Mirror Driver\r\n" |
| "NumberOfColorPlanes=\r\n" |
| "NumberOfVideoPages=\r\n" |
| "PNPDeviceID=ROOT\\DISPLAY\\0000\r\n" |
| "PowerManagementCapabilities=\r\n" |
| "PowerManagementSupported=\r\n" |
| "ProtocolSupported=\r\n" |
| "ReservedSystemPaletteEntries=\r\n" |
| "SpecificationVersion=\r\n" |
| "Status=Degraded\r\n" |
| "StatusInfo=\r\n" |
| "SystemCreationClassName=Win32_ComputerSystem\r\n" |
| "SystemName=ANDREW-PC\r\n" |
| "SystemPaletteEntries=\r\n" |
| "TimeOfLastReset=\r\n" |
| "VideoArchitecture=5\r\n" |
| "VideoMemoryType=2\r\n" |
| "VideoMode=\r\n" |
| "VideoModeDescription=\r\n" |
| "VideoProcessor=\r\n" |
| "\r\n" |
| "\r\n" |
| "AcceleratorCapabilities=\r\n" |
| "AdapterCompatibility=NVIDIA\r\n" |
| "AdapterDACType=Integrated RAMDAC\r\n" |
| "AdapterRAM=2147483648\r\n" |
| "Availability=3\r\n" |
| "CapabilityDescriptions=\r\n" |
| "Caption=NVIDIA GeForce GTX 660M \r\n" |
| "ColorTableEntries=\r\n" |
| "ConfigManagerErrorCode=0\r\n" |
| "ConfigManagerUserConfig=FALSE\r\n" |
| "CreationClassName=Win32_VideoController\r\n" |
| "CurrentBitsPerPixel=32\r\n" |
| "CurrentHorizontalResolution=1600\r\n" |
| "CurrentNumberOfColors=4294967296\r\n" |
| "CurrentNumberOfColumns=0\r\n" |
| "CurrentNumberOfRows=0\r\n" |
| "CurrentRefreshRate=60\r\n" |
| "CurrentScanMode=4\r\n" |
| "CurrentVerticalResolution=900\r\n" |
| "Description=NVIDIA GeForce GTX 660M \r\n" |
| "DeviceID=VideoController2\r\n" |
| "DeviceSpecificPens=\r\n" |
| "DitherType=0\r\n" |
| "DriverDate=20160321000000.000000-000\r\n" |
| "DriverVersion=10.18.13.6472\r\n" |
| "ErrorCleared=\r\n" |
| "ErrorDescription=\r\n" |
| "ICMIntent=\r\n" |
| "ICMMethod=\r\n" |
| "InfFilename=oem65.inf\r\n" |
| "InfSection=Section031\r\n" |
| "InstallDate=\r\n" |
| "InstalledDisplayDrivers=nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um,nvwgf2um\r\n" |
| "LastErrorCode=\r\n" |
| "MaxMemorySupported=\r\n" |
| "MaxNumberControlled=\r\n" |
| "MaxRefreshRate=60\r\n" |
| "MinRefreshRate=60\r\n" |
| "Monochrome=FALSE\r\n" |
| "Name=NVIDIA GeForce GTX 660M \r\n" |
| "NumberOfColorPlanes=\r\n" |
| "NumberOfVideoPages=\r\n" |
| "PNPDeviceID=PCI\\VEN_10DE&DEV_0FD4&SUBSYS_21151043&REV_A1\\4&169534F2&0&0008\r\n" |
| "PowerManagementCapabilities=\r\n" |
| "PowerManagementSupported=\r\n" |
| "ProtocolSupported=\r\n" |
| "ReservedSystemPaletteEntries=\r\n" |
| "SpecificationVersion=\r\n" |
| "Status=OK\r\n" |
| "StatusInfo=\r\n" |
| "SystemCreationClassName=Win32_ComputerSystem\r\n" |
| "SystemName=ANDREW-PC\r\n" |
| "SystemPaletteEntries=\r\n" |
| "TimeOfLastReset=\r\n" |
| "VideoArchitecture=5\r\n" |
| "VideoMemoryType=2\r\n" |
| "VideoMode=\r\n" |
| "VideoModeDescription=1600 x 900 x 4294967296 colors\r\n" |
| "VideoProcessor=GeForce GTX 660M\r\n"; |
| |
| static const char win_single_gpu[] = |
| "\r\n" |
| "\r\n" |
| "AcceleratorCapabilities=\r\n" |
| "AdapterCompatibility=NVIDIA\r\n" |
| "AdapterDACType=Integrated RAMDAC\r\n" |
| "AdapterRAM=1073741824\r\n" |
| "Availability=3\r\n" |
| "CapabilityDescriptions=\r\n" |
| "Caption=NVIDIA Quadro K600\r\n" |
| "ColorTableEntries=\r\n" |
| "ConfigManagerErrorCode=0\r\n" |
| "ConfigManagerUserConfig=FALSE\r\n" |
| "CreationClassName=Win32_VideoController\r\n" |
| "CurrentBitsPerPixel=32\r\n" |
| "CurrentHorizontalResolution=2560\r\n" |
| "CurrentNumberOfColors=4294967296\r\n" |
| "CurrentNumberOfColumns=0\r\n" |
| "CurrentNumberOfRows=0\r\n" |
| "CurrentRefreshRate=59\r\n" |
| "CurrentScanMode=4\r\n" |
| "CurrentVerticalResolution=1600\r\n" |
| "Description=NVIDIA Quadro K600\r\n" |
| "DeviceID=VideoController1\r\n" |
| "DeviceSpecificPens=\r\n" |
| "DitherType=0\r\n" |
| "DriverDate=20130830000000.000000-000\r\n" |
| "DriverVersion=9.18.13.2086\r\n" |
| "ErrorCleared=\r\n" |
| "ErrorDescription=\r\n" |
| "ICMIntent=\r\n" |
| "ICMMethod=\r\n" |
| "InfFilename=oem39.inf\r\n" |
| "InfSection=Section078\r\n" |
| "InstallDate=\r\n" |
| "InstalledDisplayDrivers=nvd3dumx.dll,nvwgf2umx.dll,nvwgf2umx.dll,nvd3dum,nvwgf2um,nvwgf2um\r\n" |
| "LastErrorCode=\r\n" |
| "MaxMemorySupported=\r\n" |
| "MaxNumberControlled=\r\n" |
| "MaxRefreshRate=60\r\n" |
| "MinRefreshRate=50\r\n" |
| "Monochrome=FALSE\r\n" |
| "Name=NVIDIA Quadro K600\r\n" |
| "NumberOfColorPlanes=\r\n" |
| "NumberOfVideoPages=\r\n" |
| "PNPDeviceID=PCI\\VEN_10DE&DEV_0FFA&SUBSYS_094B103C&REV_A1\\4&16C9E9F9&0&0010\r\n" |
| "PowerManagementCapabilities=\r\n" |
| "PowerManagementSupported=\r\n" |
| "ProtocolSupported=\r\n" |
| "ReservedSystemPaletteEntries=\r\n" |
| "SpecificationVersion=\r\n" |
| "Status=OK\r\n" |
| "StatusInfo=\r\n" |
| "SystemCreationClassName=Win32_ComputerSystem\r\n" |
| "SystemPaletteEntries=\r\n" |
| "TimeOfLastReset=\r\n" |
| "VideoArchitecture=5\r\n" |
| "VideoMemoryType=2\r\n" |
| "VideoMode=\r\n" |
| "VideoModeDescription=2560 x 1600 x 4294967296 colors\r\n" |
| "VideoProcessor=Quadro K600\r\n"; |
| |
| static const char win_dual_gpu[] = |
| "AcceleratorCapabilities=\r\n" |
| "AdapterCompatibility=Advanced Micro Devices, Inc.\r\n" |
| "AdapterDACType=Internal DAC(400MHz)\r\n" |
| "AdapterRAM=4293918720\r\n" |
| "Availability=8\r\n" |
| "CapabilityDescriptions=\r\n" |
| "Caption=AMD Radeon (TM) R5 M335\r\n" |
| "ColorTableEntries=\r\n" |
| "ConfigManagerErrorCode=0\r\n" |
| "ConfigManagerUserConfig=FALSE\r\n" |
| "CreationClassName=Win32_VideoController\r\n" |
| "CurrentBitsPerPixel=\r\n" |
| "CurrentHorizontalResolution=\r\n" |
| "CurrentNumberOfColors=\r\n" |
| "CurrentNumberOfColumns=\r\n" |
| "CurrentNumberOfRows=\r\n" |
| "CurrentRefreshRate=\r\n" |
| "CurrentScanMode=\r\n" |
| "CurrentVerticalResolution=\r\n" |
| "Description=AMD Radeon (TM) R5 M335\r\n" |
| "DeviceID=VideoController1\r\n" |
| "DeviceSpecificPens=\r\n" |
| "DitherType=\r\n" |
| "DriverDate=20151204000000.000000-000\r\n" |
| "DriverVersion=15.300.1025.1001\r\n" |
| "ErrorCleared=\r\n" |
| "ErrorDescription=\r\n" |
| "ICMIntent=\r\n" |
| "ICMMethod=\r\n" |
| "InfFilename=oem27.inf\r\n" |
| "InfSection=ati2mtag_R503\r\n" |
| "InstallDate=\r\n" |
| "InstalledDisplayDrivers=aticfx64.dll,aticfx64.dll,aticfx64.dll,amdxc64.dll,aticfx32,aticfx32,aticfx32,amdxc32,atiumd64.dll,atidxx64.dll,atidxx64.dll,atiumdag,atidxx32,atidxx32,atiumdva,atiumd6a.cap,atitmm64.dll\r\n" |
| "LastErrorCode=\r\n" |
| "MaxMemorySupported=\r\n" |
| "MaxNumberControlled=\r\n" |
| "MaxRefreshRate=\r\n" |
| "MinRefreshRate=\r\n" |
| "Monochrome=FALSE\r\n" |
| "Name=AMD Radeon (TM) R5 M335\r\n" |
| "NumberOfColorPlanes=\r\n" |
| "NumberOfVideoPages=\r\n" |
| "PNPDeviceID=PCI\\VEN_1002&DEV_6660&SUBSYS_06B21028&REV_81\\4&2370267D&0&00E0\r\n" |
| "PowerManagementCapabilities=\r\n" |
| "PowerManagementSupported=\r\n" |
| "ProtocolSupported=\r\n" |
| "ReservedSystemPaletteEntries=\r\n" |
| "SpecificationVersion=\r\n" |
| "Status=OK\r\n" |
| "StatusInfo=\r\n" |
| "SystemCreationClassName=Win32_ComputerSystem\r\n" |
| "SystemName=DESKTOP-Q7BG33N\r\n" |
| "SystemPaletteEntries=\r\n" |
| "TimeOfLastReset=\r\n" |
| "VideoArchitecture=5\r\n" |
| "VideoMemoryType=2\r\n" |
| "VideoMode=\r\n" |
| "VideoModeDescription=\r\n" |
| "VideoProcessor=AMD Radeon Graphics Processor (0x6660)\r\n" |
| "\r\n" |
| "\r\n" |
| "AcceleratorCapabilities=\r\n" |
| "AdapterCompatibility=Intel Corporation\r\n" |
| "AdapterDACType=Internal\r\n" |
| "AdapterRAM=1073741824\r\n" |
| "Availability=3\r\n" |
| "CapabilityDescriptions=\r\n" |
| "Caption=Intel(R) HD Graphics 520\r\n" |
| "ColorTableEntries=\r\n" |
| "ConfigManagerErrorCode=0\r\n" |
| "ConfigManagerUserConfig=FALSE\r\n" |
| "CreationClassName=Win32_VideoController\r\n" |
| "CurrentBitsPerPixel=32\r\n" |
| "CurrentHorizontalResolution=1920\r\n" |
| "CurrentNumberOfColors=4294967296\r\n" |
| "CurrentNumberOfColumns=0\r\n" |
| "CurrentNumberOfRows=0\r\n" |
| "CurrentRefreshRate=59\r\n" |
| "CurrentScanMode=4\r\n" |
| "CurrentVerticalResolution=1080\r\n" |
| "Description=Intel(R) HD Graphics 520\r\n" |
| "DeviceID=VideoController2\r\n" |
| "DeviceSpecificPens=\r\n" |
| "DitherType=0\r\n" |
| "DriverDate=20150831000000.000000-000\r\n" |
| "DriverVersion=10.18.15.4281\r\n" |
| "ErrorCleared=\r\n" |
| "ErrorDescription=\r\n" |
| "ICMIntent=\r\n" |
| "ICMMethod=\r\n" |
| "InfFilename=oem6.inf\r\n" |
| "InfSection=iSKLD_w10\r\n" |
| "InstallDate=\r\n" |
| "InstalledDisplayDrivers=igdumdim64.dll,igd10iumd64.dll,igd10iumd64.dll,igd12umd64.dll,igdumdim32,igd10iumd32,igd10iumd32,igd12umd32\r\n" |
| "LastErrorCode=\r\n" |
| "MaxMemorySupported=\r\n" |
| "MaxNumberControlled=\r\n" |
| "MaxRefreshRate=59\r\n" |
| "MinRefreshRate=48\r\n" |
| "Monochrome=FALSE\r\n" |
| "Name=Intel(R) HD Graphics 520\r\n" |
| "NumberOfColorPlanes=\r\n" |
| "NumberOfVideoPages=\r\n" |
| "PNPDeviceID=PCI\\VEN_8086&DEV_1916&SUBSYS_06B21028&REV_07\\3&11583659&0&10\r\n" |
| "PowerManagementCapabilities=\r\n" |
| "PowerManagementSupported=\r\n" |
| "ProtocolSupported=\r\n" |
| "ReservedSystemPaletteEntries=\r\n" |
| "SpecificationVersion=\r\n" |
| "Status=OK\r\n" |
| "StatusInfo=\r\n" |
| "SystemCreationClassName=Win32_ComputerSystem\r\n" |
| "SystemPaletteEntries=\r\n" |
| "TimeOfLastReset=\r\n" |
| "VideoArchitecture=5\r\n" |
| "VideoMemoryType=2\r\n" |
| "VideoMode=\r\n" |
| "VideoModeDescription=1920 x 1080 x 4294967296 colors\r\n" |
| "VideoProcessor=Intel(R) HD Graphics Family\r\n"; |
| |
| static const char linux_single_gpu[] = |
| "Rev: 05\n" |
| "\n" |
| "Device: 04:00.0\n" |
| "Class: VGA compatible controller [0300]\n" |
| "Vendor: NVIDIA Corporation [10de]\n" |
| "Device: GM107GL [Quadro K2200] [13ba]\n" |
| "SVendor: Hewlett-Packard Company [103c]\n" |
| "SDevice: Device [1097]\n" |
| "PhySlot: 2\n" |
| "Rev: a2\n" |
| "\n" |
| "Device: 04:00.1\n" |
| "\n" |
| "\n" |
| "\n" |
| "\n" |
| "OpenGL version string: 4.4.0 NVIDIA 340.96\n" |
| "OpenGL shading language version string: 4.40 NVIDIA via Cg compiler\n" |
| "OpenGL context flags: (none)\n" |
| "\n"; |
| |
| static const char linux_mesadri[] = |
| "Rev: 05\n" |
| "\n" |
| "Device: 04:00.0\n" |
| "Class: VGA compatible controller [0300]\n" |
| "Vendor: NVIDIA Corporation [10de]\n" |
| "Device: GM107GL [Quadro K2200] [13ba]\n" |
| "SVendor: Hewlett-Packard Company [103c]\n" |
| "SDevice: Device [1097]\n" |
| "PhySlot: 2\n" |
| "Rev: a2\n" |
| "\n" |
| "Device: 04:00.1\n" |
| "\n" |
| "\n" |
| "\n" |
| "\n" |
| "OpenGL version string: 3.0 Mesa 10.4.2 (git-)\n" |
| "\n"; |
| |
| static const char linux_2[] = |
| "Rev: 05\n" |
| "\n" |
| "Device: 04:00.0\n" |
| "Class: VGA compatible controller [0300]\n" |
| "Vendor: NVIDIA Corporation [10de]\n" |
| "Device: GM107GL [Quadro K2200] [13ba]\n" |
| "SVendor: Hewlett-Packard Company [103c]\n" |
| "SDevice: Device [1097]\n" |
| "PhySlot: 2\n" |
| "Rev: a2\n" |
| "\n" |
| "Device: 04:00.1\n" |
| "\n" |
| "\n" |
| "\n" |
| "\n" |
| "\n"; |
| |
| #ifdef _WIN32 |
| |
| TEST(parse_gpu_info_list_windows, WinNoInstalledDriversContinueCase) { |
| std::string contents(win_noinstalleddrivers); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_windows(contents, &gpulist); |
| |
| EXPECT_EQ(2, (int)gpulist.infos.size()); |
| } |
| |
| TEST(parse_gpu_info_list_windows, SingleGpu) { |
| std::string contents(win_single_gpu); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_windows(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 1); |
| |
| GpuInfo& nvidia_info = gpulist.infos[0]; |
| |
| EXPECT_FALSE(nvidia_info.current_gpu); |
| EXPECT_STREQ("10de", nvidia_info.make.c_str()); |
| EXPECT_STREQ("NVIDIA Quadro K600", nvidia_info.model.c_str()); |
| EXPECT_STREQ("0ffa", nvidia_info.device_id.c_str()); |
| EXPECT_TRUE(nvidia_info.revision_id.empty()); |
| EXPECT_STREQ("9.18.13.2086", nvidia_info.version.c_str()); |
| EXPECT_TRUE(nvidia_info.renderer.empty()); |
| |
| EXPECT_TRUE(nvidia_info.dlls.size() == 8); |
| EXPECT_STREQ("nvd3dumx.dll", nvidia_info.dlls[0].c_str()); |
| EXPECT_STREQ("nvwgf2umx.dll", nvidia_info.dlls[1].c_str()); |
| EXPECT_STREQ("nvwgf2umx.dll", nvidia_info.dlls[2].c_str()); |
| EXPECT_STREQ("nvd3dum", nvidia_info.dlls[3].c_str()); |
| EXPECT_STREQ("nvwgf2um", nvidia_info.dlls[4].c_str()); |
| EXPECT_STREQ("nvwgf2um", nvidia_info.dlls[5].c_str()); |
| EXPECT_STREQ("nvoglv32.dll", nvidia_info.dlls[6].c_str()); |
| EXPECT_STREQ("nvoglv64.dll", nvidia_info.dlls[7].c_str()); |
| } |
| |
| TEST(parse_gpu_info_list_windows, DualGpu) { |
| std::string contents(win_dual_gpu); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_windows(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 2); |
| |
| GpuInfo& ati_info = gpulist.infos[0]; |
| EXPECT_FALSE(ati_info.current_gpu); |
| EXPECT_STREQ("1002", ati_info.make.c_str()); |
| EXPECT_STREQ("AMD Radeon (TM) R5 M335", ati_info.model.c_str()); |
| EXPECT_STREQ("6660", ati_info.device_id.c_str()); |
| EXPECT_TRUE(ati_info.revision_id.empty()); |
| EXPECT_STREQ("15.300.1025.1001", ati_info.version.c_str()); |
| EXPECT_TRUE(ati_info.renderer.empty()); |
| |
| EXPECT_TRUE(ati_info.dlls.size() == 19); |
| EXPECT_STREQ("aticfx64.dll", ati_info.dlls[0].c_str()); |
| EXPECT_STREQ("aticfx64.dll", ati_info.dlls[1].c_str()); |
| EXPECT_STREQ("aticfx64.dll", ati_info.dlls[2].c_str()); |
| EXPECT_STREQ("amdxc64.dll", ati_info.dlls[3].c_str()); |
| EXPECT_STREQ("aticfx32", ati_info.dlls[4].c_str()); |
| EXPECT_STREQ("aticfx32", ati_info.dlls[5].c_str()); |
| EXPECT_STREQ("aticfx32", ati_info.dlls[6].c_str()); |
| EXPECT_STREQ("amdxc32", ati_info.dlls[7].c_str()); |
| EXPECT_STREQ("atiumd64.dll", ati_info.dlls[8].c_str()); |
| EXPECT_STREQ("atidxx64.dll", ati_info.dlls[9].c_str()); |
| EXPECT_STREQ("atidxx64.dll", ati_info.dlls[10].c_str()); |
| EXPECT_STREQ("atiumdag", ati_info.dlls[11].c_str()); |
| EXPECT_STREQ("atidxx32", ati_info.dlls[12].c_str()); |
| EXPECT_STREQ("atidxx32", ati_info.dlls[13].c_str()); |
| EXPECT_STREQ("atiumdva", ati_info.dlls[14].c_str()); |
| EXPECT_STREQ("atiumd6a.cap", ati_info.dlls[15].c_str()); |
| EXPECT_STREQ("atitmm64.dll", ati_info.dlls[16].c_str()); |
| EXPECT_STREQ("atioglxx.dll", ati_info.dlls[17].c_str()); |
| EXPECT_STREQ("atig6txx.dll", ati_info.dlls[18].c_str()); |
| |
| GpuInfo& intel_info = gpulist.infos[1]; |
| EXPECT_FALSE(intel_info.current_gpu); |
| EXPECT_STREQ("8086", intel_info.make.c_str()); |
| EXPECT_STREQ("Intel(R) HD Graphics 520", intel_info.model.c_str()); |
| EXPECT_STREQ("1916", intel_info.device_id.c_str()); |
| EXPECT_TRUE(intel_info.revision_id.empty()); |
| EXPECT_STREQ("10.18.15.4281", intel_info.version.c_str()); |
| EXPECT_TRUE(intel_info.renderer.empty()); |
| |
| EXPECT_TRUE(intel_info.dlls.size() == 8); |
| EXPECT_STREQ("igdumdim64.dll", intel_info.dlls[0].c_str()); |
| EXPECT_STREQ("igd10iumd64.dll", intel_info.dlls[1].c_str()); |
| EXPECT_STREQ("igd10iumd64.dll", intel_info.dlls[2].c_str()); |
| EXPECT_STREQ("igd12umd64.dll", intel_info.dlls[3].c_str()); |
| EXPECT_STREQ("igdumdim32", intel_info.dlls[4].c_str()); |
| EXPECT_STREQ("igd10iumd32", intel_info.dlls[5].c_str()); |
| EXPECT_STREQ("igd10iumd32", intel_info.dlls[6].c_str()); |
| EXPECT_STREQ("igd12umd32", intel_info.dlls[7].c_str()); |
| } |
| |
| #elif defined(__linux__) |
| |
| TEST(parse_gpu_info_list_linux, EmptyStr) { |
| std::string contents; |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 0); |
| } |
| |
| TEST(parse_gpu_info_list_linux, NoGlxInfo) { |
| std::string contents(linux_2); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 1); |
| } |
| |
| TEST(parse_gpu_info_list_linux, Nolspci) { |
| std::string contents("\n"); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 0); |
| } |
| |
| TEST(parse_gpu_info_list_linux, SingleGpu) { |
| std::string contents(linux_single_gpu); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 1); |
| GpuInfo& nvidia_info = gpulist.infos[0]; |
| EXPECT_FALSE(nvidia_info.current_gpu); |
| EXPECT_STREQ("10de", nvidia_info.make.c_str()); |
| EXPECT_TRUE(nvidia_info.model.empty()); |
| EXPECT_STREQ("13ba", nvidia_info.device_id.c_str()); |
| EXPECT_TRUE(nvidia_info.revision_id.empty()); |
| EXPECT_TRUE(nvidia_info.version.empty()); |
| EXPECT_STREQ("OpenGL version string: 4.4.0 NVIDIA 340.96", |
| nvidia_info.renderer.c_str()); |
| EXPECT_TRUE(nvidia_info.dlls.empty()); |
| } |
| |
| TEST(parse_gpu_info_list_linux, MesaDRI) { |
| std::string contents(linux_mesadri); |
| |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| |
| EXPECT_TRUE(gpulist.infos.size() == 1); |
| GpuInfo& nvidia_info = gpulist.infos[0]; |
| EXPECT_FALSE(nvidia_info.current_gpu); |
| EXPECT_STREQ("10de", nvidia_info.make.c_str()); |
| EXPECT_TRUE(nvidia_info.model.empty()); |
| EXPECT_STREQ("13ba", nvidia_info.device_id.c_str()); |
| EXPECT_TRUE(nvidia_info.revision_id.empty()); |
| EXPECT_TRUE(nvidia_info.version.empty()); |
| EXPECT_STREQ("OpenGL version string: 3.0 Mesa 10.4.2 (git-)", |
| nvidia_info.renderer.c_str()); |
| EXPECT_TRUE(nvidia_info.dlls.empty()); |
| } |
| |
| |
| TEST(gpuinfo_query_blacklist, testBlacklist_Pos) { |
| const BlacklistEntry test_list[] = { |
| {"10de", nullptr, "13ba", nullptr, nullptr, nullptr, nullptr} |
| }; |
| |
| int test_list_len = sizeof(test_list) / sizeof(BlacklistEntry); |
| |
| std::string contents(linux_single_gpu); |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| bool on_blacklist = gpuinfo_query_blacklist(&gpulist, |
| test_list, |
| test_list_len); |
| |
| EXPECT_TRUE(on_blacklist); |
| } |
| |
| TEST(gpuinfo_query_blacklist, testBlacklist_Neg) { |
| const BlacklistEntry test_list[] = { |
| {"10dd", nullptr, "13ba", nullptr, nullptr, nullptr, nullptr}, |
| {"ATI", "NVIDIA Quadro K600", nullptr, nullptr, nullptr, nullptr, nullptr}, |
| {"ASDF", "Intel Iris Pro", nullptr, nullptr, nullptr, nullptr, nullptr} |
| }; |
| |
| int test_list_len = sizeof(test_list) / sizeof(BlacklistEntry); |
| |
| std::string contents(linux_2); |
| GpuInfoList gpulist; |
| parse_gpu_info_list_linux(contents, &gpulist); |
| bool on_blacklist = gpuinfo_query_blacklist(&gpulist, |
| test_list, |
| test_list_len); |
| |
| EXPECT_FALSE(on_blacklist); |
| } |
| |
| #endif // __linux__ |