Skip to content

Commit bb55f09

Browse files
Added two tests for filter_string property
The property should be able to reconstruct the same parent device that produced it, serving as a device identifier
1 parent 5a60bd0 commit bb55f09

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

dpctl/tests/test_sycl_device.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -572,3 +572,32 @@ def test_invalid_filter_selectors(invalid_filter):
572572
"""
573573
with pytest.raises(ValueError):
574574
dpctl.SyclDevice(invalid_filter)
575+
576+
577+
def test_filter_string(valid_filter):
578+
"""
579+
Test that filter_string reconstructs the same device.
580+
"""
581+
device = None
582+
try:
583+
device = dpctl.SyclDevice(valid_filter)
584+
except ValueError:
585+
pytest.skip("Failed to create device with supported filter")
586+
dev_id = device.filter_string
587+
assert (
588+
dpctl.SyclDevice(dev_id) == device
589+
), "Reconstructed device is different, ({}, {})".format(
590+
valid_filter, dev_id
591+
)
592+
593+
594+
def test_filter_string2():
595+
"""
596+
Test that filter_string reconstructs the same device.
597+
"""
598+
devices = dpctl.get_devices()
599+
for d in devices:
600+
if d.default_selector_score > 0:
601+
dev_id = d.filter_string
602+
d_r = dpctl.SyclDevice(dev_id)
603+
assert d == d_r

0 commit comments

Comments
 (0)