Skip to content

Commit

Permalink
New CTS cases for Sysman device mapping APIs (#54)
Browse files Browse the repository at this point in the history
Related-To: VLCLJ-2236
  • Loading branch information
aviralni committed Jul 29, 2024
1 parent efcb119 commit 0d90d15
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020-2023 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand Down Expand Up @@ -143,6 +143,51 @@ TEST_F(
run_device_hierarchy_child_process();
}

TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDeviceWhenRetrievingSubDevicePropertiesThenValidPropertiesAreReturned) {
for (auto device : devices) {
auto device_properties = lzt::get_sysman_device_properties(device);
uint32_t sub_devices_count = device_properties.numSubdevices;

if (sub_devices_count > 0) {
uint32_t num_sub_devices = 0;
auto sub_device_properties =
lzt::get_sysman_subdevice_properties(device, num_sub_devices);
EXPECT_EQ(sub_devices_count, num_sub_devices);
for (uint32_t sub_device_index = 0; sub_device_index < num_sub_devices;
sub_device_index++) {
EXPECT_LT(sub_device_properties[sub_device_index].subdeviceId,
num_sub_devices);
EXPECT_GT(sub_device_properties[sub_device_index].uuid.id[0], 0);
}
}
}
}

TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDriverWhenRetrievingDeviceHandleFromUUIDThenReturnedDeviceHandleShouldMatchCurrentDeviceHandle) {
zes_driver_handle_t driver = lzt::get_default_zes_driver();
for (auto device : devices) {
auto properties = lzt::get_sysman_device_properties(device);
uint32_t sub_devices_count = properties.numSubdevices;
zes_uuid_t uuid = {};
for (uint32_t i = 0; i < sizeof(properties.core.uuid.id); i++) {
uuid.id[i] = properties.core.uuid.id[i];
}
ze_bool_t on_sub_device = false;
uint32_t sub_device_id = 0;
zes_device_handle_t device_handle_from_uuid =
lzt::get_sysman_device_by_uuid(driver, uuid, on_sub_device,
sub_device_id);
EXPECT_EQ(device_handle_from_uuid, device);
if (on_sub_device == true) {
EXPECT_LT(sub_device_id, sub_devices_count);
}
}
}

TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDeviceWhenRetrievingSysmanDevicePropertiesThenValidPropertiesAreReturned) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -19,6 +19,14 @@ void sysman_device_reset(zes_device_handle_t device);
zes_device_properties_t
get_sysman_device_properties(zes_device_handle_t device);

std::vector<zes_subdevice_exp_properties_t>
get_sysman_subdevice_properties(zes_device_handle_t device, uint32_t &count);

zes_device_handle_t get_sysman_device_by_uuid(zes_driver_handle_t driver,
zes_uuid_t uuid,
ze_bool_t &on_sub_device,
uint32_t &sub_device_id);

uint32_t get_processes_count(zes_device_handle_t device);

zes_device_state_t get_device_state(zes_device_handle_t device);
Expand Down
28 changes: 25 additions & 3 deletions utils/test_harness/sysman/src/test_harness_sysman_device.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2020 Intel Corporation
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -24,12 +24,34 @@ zes_device_properties_t
get_sysman_device_properties(zes_device_handle_t device) {
zes_device_properties_t properties = {ZES_STRUCTURE_TYPE_DEVICE_PROPERTIES,
nullptr};

EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetProperties(device, &properties));

return properties;
}

std::vector<zes_subdevice_exp_properties_t>
get_sysman_subdevice_properties(zes_device_handle_t device, uint32_t &count) {
if (count == 0) {
EXPECT_EQ(ZE_RESULT_SUCCESS,
zesDeviceGetSubDevicePropertiesExp(device, &count, nullptr));
}
std::vector<zes_subdevice_exp_properties_t> sub_device_properties(count);
EXPECT_EQ(ZE_RESULT_SUCCESS,
zesDeviceGetSubDevicePropertiesExp(device, &count,
sub_device_properties.data()));
return sub_device_properties;
}

zes_device_handle_t get_sysman_device_by_uuid(zes_driver_handle_t driver,
zes_uuid_t uuid,
ze_bool_t &on_sub_device,
uint32_t &sub_device_id) {
zes_device_handle_t device = {};
EXPECT_EQ(ZE_RESULT_SUCCESS,
zesDriverGetDeviceByUuidExp(driver, uuid, &device, &on_sub_device,
&sub_device_id));
return device;
}

uint32_t get_processes_count(zes_device_handle_t device) {
uint32_t count = 0;
EXPECT_EQ(ZE_RESULT_SUCCESS,
Expand Down

0 comments on commit 0d90d15

Please sign in to comment.