Skip to content

Commit ede9b95

Browse files
committed
Fix fuzz test failing to create a device
Changes from 019551c in urDeviceGet validation resulted in a failure to create devices successfully in fuzz tests.
1 parent f11823e commit ede9b95

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

test/fuzz/urFuzz.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,19 @@ int ur_device_get(TestState &state) {
3838
return -1;
3939
}
4040

41-
ur_result_t res = urDeviceGet(state.platforms[state.platform_num],
42-
state.device_type, state.num_entries,
43-
state.devices.data(), &state.num_devices);
41+
ur_result_t res = UR_RESULT_SUCCESS;
42+
if (state.devices.size() == 0) {
43+
res = urDeviceGet(state.platforms[state.platform_num],
44+
state.device_type, 0, nullptr, &state.num_devices);
45+
state.devices.resize(state.num_devices);
46+
} else {
47+
res =
48+
urDeviceGet(state.platforms[state.platform_num], state.device_type,
49+
state.num_entries, state.devices.data(), nullptr);
50+
}
4451
if (res != UR_RESULT_SUCCESS) {
4552
return -1;
4653
}
47-
if (state.devices.size() != state.num_devices) {
48-
state.devices.resize(state.num_devices);
49-
}
5054

5155
return 0;
5256
}

0 commit comments

Comments
 (0)