|
16 | 16 | UnsupportedGpuWarning, |
17 | 17 | ) |
18 | 18 | from checks.resources import ( |
| 19 | + GPU_PROVIDER_INTEL_ARC, |
| 20 | + GPU_PROVIDER_INTEL_ARC_A, |
| 21 | + GPU_PROVIDER_INTEL_MAX, |
19 | 22 | SUPPORTED_NVIDIA_DRIVER_VERSION, |
| 23 | + _get_intel_gpus, |
20 | 24 | check_gpu_driver_version, |
21 | 25 | check_local_cpu, |
22 | 26 | check_local_disk, |
|
29 | 33 | from configuration_models.upgrade_config import UpgradeConfig |
30 | 34 | from texts.checks import ResourcesChecksTexts |
31 | 35 |
|
| 36 | +arc_xe_description = """ 03:00.0 Display controller [0380]: Intel Corporation Device [8086:e216] |
| 37 | + Subsystem: Intel Corporation Device [8086:1500] |
| 38 | + Kernel driver in use: xe |
| 39 | + Kernel modules: xe""" |
| 40 | + |
| 41 | +arc_i915_description = """ 03:00.0 Display controller [0380]: Intel Corporation Device [8086:e216] |
| 42 | + Subsystem: Intel Corporation Device [8086:1500] |
| 43 | + Kernel driver in use: i915 |
| 44 | + Kernel modules: i915""" |
| 45 | + |
| 46 | +igpu_description = """00:02.0 VGA compatible controller [0300]: Intel Corporation Raptor Lake-S GT1 [UHD Graphics 770] [8086:a780] (rev 04) |
| 47 | + DeviceName: Onboard IGD |
| 48 | + Subsystem: ASUSTeK Computer Inc. Raptor Lake-S GT1 [UHD Graphics 770] [1043:8882] |
| 49 | + Kernel driver in use: i915""" |
| 50 | + |
| 51 | +nvidia_description = """08:00.0 VGA compatible controller [0300]: NVIDIA Corporation GA102 [GeForce RTX 3090] [10de:2204] (rev a1) |
| 52 | + Subsystem: Gigabyte Technology Co., Ltd GA102 [GeForce RTX 3090] [1458:4043] |
| 53 | + Kernel driver in use: nouveau |
| 54 | + Kernel modules: nvidiafb, nouveau""" |
| 55 | + |
| 56 | +arc_xe_igpu_description = arc_xe_description + "\n--\n" + igpu_description |
| 57 | + |
| 58 | +arc_i915_igpu_description = arc_i915_description + "\n--\n" + igpu_description |
| 59 | + |
| 60 | +arc_xe_nvidia_description = arc_xe_description + "\n--\n" + nvidia_description |
| 61 | + |
| 62 | +nvidia_igpu_description = nvidia_description + "\n--\n" + igpu_description |
| 63 | + |
32 | 64 |
|
33 | 65 | def test_check_local_cpu(mocker): |
34 | 66 | """Check if the requirement for 12 physical cores passes successfully""" |
@@ -91,36 +123,113 @@ def test_check_local_nvidia_gpu_ok(get_gpus_mock): |
91 | 123 | assert install_config_mock.gpu_provider.value == "nvidia" |
92 | 124 |
|
93 | 125 |
|
94 | | -def test_check_local_intel_gpu_ok(get_gpus_mock, get_intel_gpus_mock): |
95 | | - get_gpus_mock.return_value = [] |
96 | | - get_intel_gpus_mock.return_value = "Device Name: Intel(R) Data Center GPU Max 1100" |
| 126 | +def test_get_intel_gpus_max_card(mocker): |
| 127 | + sub_process_mock = mocker.patch( |
| 128 | + "subprocess.check_output", return_value=ResourcesChecksTexts.intel_gpu_max_card.encode("utf-8") |
| 129 | + ) |
| 130 | + gpus, _ = _get_intel_gpus() |
| 131 | + |
| 132 | + assert GPU_PROVIDER_INTEL_MAX in gpus |
| 133 | + assert sub_process_mock.call_count == 1 |
| 134 | + |
| 135 | + |
| 136 | +def test_get_intel_gpus_arc_xe_card(mocker): |
| 137 | + sub_process_mock = mocker.patch("subprocess.check_output", return_value=arc_xe_description.encode("utf-8")) |
| 138 | + check_intel_gpu_driver_mock = mocker.patch("checks.resources._check_intel_gpu_driver", return_value=True) |
| 139 | + |
| 140 | + gpus, isdGPU = _get_intel_gpus() |
| 141 | + |
| 142 | + assert GPU_PROVIDER_INTEL_ARC in gpus |
| 143 | + assert isdGPU is True |
| 144 | + assert check_intel_gpu_driver_mock.call_count == 1 |
| 145 | + assert sub_process_mock.call_count == 2 |
| 146 | + |
| 147 | + |
| 148 | +def test_get_intel_gpus_arc_i915_card(mocker): |
| 149 | + sub_process_mock = mocker.patch("subprocess.check_output", return_value=arc_i915_description.encode("utf-8")) |
| 150 | + check_intel_gpu_driver_mock = mocker.patch("checks.resources._check_intel_gpu_driver", return_value=True) |
| 151 | + |
| 152 | + gpus, isdGPU = _get_intel_gpus() |
| 153 | + |
| 154 | + assert GPU_PROVIDER_INTEL_ARC_A in gpus |
| 155 | + assert isdGPU is True |
| 156 | + assert check_intel_gpu_driver_mock.call_count == 1 |
| 157 | + assert sub_process_mock.call_count == 2 |
| 158 | + |
| 159 | + |
| 160 | +def test_get_intel_gpus_arc_igpu_card(mocker): |
| 161 | + sub_process_mock = mocker.patch("subprocess.check_output", return_value=arc_i915_igpu_description.encode("utf-8")) |
| 162 | + check_intel_gpu_driver_mock = mocker.patch("checks.resources._check_intel_gpu_driver", return_value=True) |
| 163 | + |
| 164 | + gpus, isdPGU = _get_intel_gpus() |
| 165 | + |
| 166 | + assert GPU_PROVIDER_INTEL_ARC_A in gpus |
| 167 | + assert isdPGU is True |
| 168 | + assert check_intel_gpu_driver_mock.call_count == 1 |
| 169 | + assert sub_process_mock.call_count == 2 |
| 170 | + |
| 171 | + |
| 172 | +def test_get_intel_gpus_igpu_card(mocker): |
| 173 | + sub_process_mock = mocker.patch("subprocess.check_output", return_value=igpu_description.encode("utf-8")) |
| 174 | + check_intel_gpu_driver_mock = mocker.patch("checks.resources._check_intel_gpu_driver", return_value=True) |
| 175 | + |
| 176 | + gpus, isdPGU = _get_intel_gpus() |
| 177 | + |
| 178 | + assert GPU_PROVIDER_INTEL_ARC_A in gpus |
| 179 | + assert isdPGU is False |
| 180 | + assert check_intel_gpu_driver_mock.call_count == 1 |
| 181 | + assert sub_process_mock.call_count == 2 |
| 182 | + |
| 183 | + |
| 184 | +def test_check_local_nvidia_arc(mocker): |
| 185 | + get_intel_mock = mocker.patch("checks.resources._get_intel_gpus", return_value=(GPU_PROVIDER_INTEL_ARC, True)) |
| 186 | + get_nvidia_mock = mocker.patch( |
| 187 | + "checks.resources._get_nvidia_gpus", |
| 188 | + return_value=[ |
| 189 | + { |
| 190 | + "name": "NVIDIA GeForce RTX 3090", |
| 191 | + "memory_total": 24576, |
| 192 | + } |
| 193 | + ], |
| 194 | + ) |
| 195 | + |
97 | 196 | install_config_mock = InstallationConfig(interactive_mode=False, install_telemetry_stack=False) |
98 | 197 | install_config_mock.gpu_support.value = True |
99 | 198 | check_local_gpu(config=install_config_mock) |
100 | | - assert get_gpus_mock.call_count == 1 |
101 | | - assert get_intel_gpus_mock.call_count == 1 |
102 | | - assert install_config_mock.gpu_provider.value == "intel-max" |
103 | | - |
| 199 | + assert get_intel_mock.call_count == 1 |
| 200 | + assert get_nvidia_mock.call_count == 1 |
| 201 | + assert install_config_mock.gpu_provider.value == GPU_PROVIDER_INTEL_ARC |
| 202 | + |
| 203 | + |
| 204 | +def test_check_local_nvidia_igpu(mocker): |
| 205 | + get_intel_mock = mocker.patch("checks.resources._get_intel_gpus", return_value=(GPU_PROVIDER_INTEL_ARC, False)) |
| 206 | + get_nvidia_mock = mocker.patch( |
| 207 | + "checks.resources._get_nvidia_gpus", |
| 208 | + return_value=( |
| 209 | + [ |
| 210 | + { |
| 211 | + "name": "NVIDIA GeForce RTX 3090", |
| 212 | + "memory_total": 24576, |
| 213 | + } |
| 214 | + ] |
| 215 | + ), |
| 216 | + ) |
104 | 217 |
|
105 | | -def test_check_local_intel_gpu_arc_ok(get_gpus_mock, get_intel_gpus_mock): |
106 | | - get_gpus_mock.return_value = [] |
107 | | - get_intel_gpus_mock.return_value = "Device Name Intel(R) Graphics" |
108 | 218 | install_config_mock = InstallationConfig(interactive_mode=False, install_telemetry_stack=False) |
109 | 219 | install_config_mock.gpu_support.value = True |
110 | 220 | check_local_gpu(config=install_config_mock) |
111 | | - assert get_gpus_mock.call_count == 1 |
112 | | - assert get_intel_gpus_mock.call_count == 1 |
113 | | - assert install_config_mock.gpu_provider.value == "intel-arc" |
| 221 | + assert get_intel_mock.call_count == 1 |
| 222 | + assert get_nvidia_mock.call_count == 1 |
| 223 | + assert install_config_mock.gpu_provider.value == "nvidia" |
114 | 224 |
|
115 | 225 |
|
116 | | -def test_check_local_gpu_not_found(get_gpus_mock, get_intel_gpus_mock): |
117 | | - get_gpus_mock.return_value = [] |
118 | | - get_intel_gpus_mock.return_value = "" |
119 | | - with pytest.raises(ResourcesCheckWarning): |
120 | | - install_config_mock = InstallationConfig(interactive_mode=False, install_telemetry_stack=False) |
121 | | - check_local_gpu(config=install_config_mock) |
122 | | - assert get_gpus_mock.call_count == 1 |
123 | | - assert get_intel_gpus_mock.call_count == 1 |
| 226 | +def test_get_intel_gpus_no_card(mocker): |
| 227 | + sub_process_mock = mocker.patch("subprocess.check_output", return_value=b"lack of Intel gpu") |
| 228 | + |
| 229 | + gpus = _get_intel_gpus() |
| 230 | + |
| 231 | + assert not gpus[0] |
| 232 | + assert sub_process_mock.call_count == 2 |
124 | 233 |
|
125 | 234 |
|
126 | 235 | def test_check_local_gpu_not_supported(get_gpus_mock): |
|
0 commit comments