-
Notifications
You must be signed in to change notification settings - Fork 133
Expand file tree
/
Copy pathconftest.py
More file actions
74 lines (55 loc) · 1.9 KB
/
Copy pathconftest.py
File metadata and controls
74 lines (55 loc) · 1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
##
# Copyright (C) 2026 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
##
import os
import sys
from ctypes import byref, c_uint32
import pytest
CTS_TESTS_DIR = os.path.dirname(os.path.abspath(__file__))
SOURCE_DIR = os.path.abspath(os.path.join(CTS_TESTS_DIR, ".."))
if SOURCE_DIR not in sys.path:
sys.path.insert(0, SOURCE_DIR)
@pytest.fixture(scope="session")
def pyzes_module():
try:
import pyzes as pz
except (ImportError, OSError) as exc:
pytest.skip(f"pyzes is not available for CTS validation: {exc}")
return pz
@pytest.fixture(scope="session")
def sysman_devices(pyzes_module):
pz = pyzes_module
rc = pz.zesInit(0)
if rc != pz.ZE_RESULT_SUCCESS:
pytest.skip(f"zesInit failed with ze_result_t={rc}")
driver_count = c_uint32(0)
rc = pz.zesDriverGet(byref(driver_count), None)
if rc != pz.ZE_RESULT_SUCCESS:
pytest.skip(f"zesDriverGet(count) failed with ze_result_t={rc}")
if driver_count.value == 0:
pytest.skip("No Sysman drivers available")
DriverArray = pz.zes_driver_handle_t * driver_count.value
drivers = DriverArray()
rc = pz.zesDriverGet(byref(driver_count), drivers)
if rc != pz.ZE_RESULT_SUCCESS:
pytest.skip(f"zesDriverGet(handles) failed with ze_result_t={rc}")
devices = []
for driver in drivers:
device_count = c_uint32(0)
rc = pz.zesDeviceGet(driver, byref(device_count), None)
if rc != pz.ZE_RESULT_SUCCESS:
continue
if device_count.value == 0:
continue
DeviceArray = pz.zes_device_handle_t * device_count.value
driver_devices = DeviceArray()
rc = pz.zesDeviceGet(driver, byref(device_count), driver_devices)
if rc != pz.ZE_RESULT_SUCCESS:
continue
devices.extend(driver_devices)
if not devices:
pytest.skip("No Sysman devices available")
return devices