Skip to content

Commit 1d7ee7d

Browse files
author
Diptorup Deb
committed
Add negative test cases.
1 parent 72c6ba5 commit 1d7ee7d

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

dpctl/tests/test_sycl_device.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
list_of_invalid_filter_selectors = [
4848
"-1",
4949
"opencl:gpu:-1",
50-
"level_zero:cpu:0",
50+
"cuda:cpu:0",
5151
"abc",
5252
]
5353

dpctl/tests/test_sycl_platform.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
"1",
3838
]
3939

40+
list_of_invalid_filter_selectors = [
41+
"-1",
42+
"opencl:gpu:-1",
43+
"cuda:cpu:0",
44+
"abc",
45+
]
46+
4047

4148
def check_name(platform):
4249
try:
@@ -87,6 +94,11 @@ def valid_filter(request):
8794
return request.param
8895

8996

97+
@pytest.fixture(params=list_of_invalid_filter_selectors)
98+
def invalid_filter(request):
99+
return request.param
100+
101+
90102
@pytest.fixture(params=list_of_checks)
91103
def check(request):
92104
return request.param
@@ -104,6 +116,14 @@ def test_platform_creation(valid_filter, check):
104116
check(platform)
105117

106118

119+
def test_invalid_platform_creation(invalid_filter, check):
120+
"""Tests if we can create a SyclPlatform using a supported filter selector
121+
string.
122+
"""
123+
with pytest.raises(ValueError):
124+
platform = dpctl.SyclPlatform(invalid_filter)
125+
126+
107127
def test_lsplatform():
108128
try:
109129
dpctl.lsplatform()

0 commit comments

Comments
 (0)