Skip to content

Commit

Permalink
Add CTS for zesDriverGetDeviceByUuidExp API (#65)
Browse files Browse the repository at this point in the history
---------

Signed-off-by: Bagria, Narendra <narendra.bagria@intel.com>
  • Loading branch information
narenbagria authored Aug 27, 2024
1 parent aff2c28 commit 87f40ee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ TEST_F(
run_device_hierarchy_child_process();
}

#ifdef USE_ZESINIT
TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDeviceWhenRetrievingSubDevicePropertiesThenValidPropertiesAreReturned) {
Expand All @@ -189,12 +190,12 @@ TEST_F(
}
}

#ifdef USE_ZESINIT
TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDeviceWhenRetrievingSubDevicesThenEnsureNoSubDeviceUUIDMatchesDeviceUUID) {
for (auto device : devices) {
auto device_properties = lzt::get_sysman_device_properties(device);
auto device_uuid = lzt::get_sysman_device_uuid(device);
uint32_t sub_devices_count = device_properties.numSubdevices;
if (sub_devices_count > 0) {
uint32_t num_sub_devices = 0;
Expand All @@ -203,14 +204,12 @@ TEST_F(
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_FALSE(
is_uuid_pair_equal(sub_device_properties[sub_device_index].uuid.id,
device_properties.core.uuid.id));
EXPECT_FALSE(is_uuid_pair_equal(
device_uuid.id, sub_device_properties[sub_device_index].uuid.id));
}
}
}
}
#endif // USE_ZESINIT

TEST_F(
SYSMAN_DEVICE_TEST,
Expand All @@ -219,14 +218,11 @@ TEST_F(
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];
}
auto device_uuid = lzt::get_sysman_device_uuid(device);
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,
lzt::get_sysman_device_by_uuid(driver, device_uuid, on_sub_device,
sub_device_id);
EXPECT_EQ(device_handle_from_uuid, device);
if (on_sub_device == true) {
Expand All @@ -235,6 +231,37 @@ TEST_F(
}
}

TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDriverWhenRetrievingDeviceHandleFromUUIDThenEnsureFetchedOnSubDeviceAndSubDeviceIdAreValid) {
zes_driver_handle_t driver = lzt::get_default_zes_driver();
for (auto device : devices) {
auto device_properties = lzt::get_sysman_device_properties(device);
uint32_t num_sub_devices = device_properties.numSubdevices;
auto device_uuid = lzt::get_sysman_device_uuid(device);
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, device_uuid, on_sub_device,
sub_device_id);
EXPECT_FALSE(on_sub_device);
if (num_sub_devices) {
auto sub_device_properties =
lzt::get_sysman_subdevice_properties(device, num_sub_devices);
for (uint32_t sub_device_index = 0; sub_device_index < num_sub_devices;
sub_device_index++) {
auto sub_device_uuid = sub_device_properties[sub_device_index].uuid;
device_handle_from_uuid = lzt::get_sysman_device_by_uuid(
driver, sub_device_uuid, on_sub_device, sub_device_id);
EXPECT_TRUE(on_sub_device);
EXPECT_EQ(sub_device_properties[sub_device_index].subdeviceId,
sub_device_id);
}
}
}
}
#endif // USE_ZESINIT

TEST_F(
SYSMAN_DEVICE_TEST,
GivenValidDeviceWhenRetrievingSysmanDevicePropertiesThenValidPropertiesAreReturned) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ void sysman_device_reset(zes_device_handle_t device);
zes_device_properties_t
get_sysman_device_properties(zes_device_handle_t device);

zes_uuid_t get_sysman_device_uuid(zes_device_handle_t device);

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

Expand Down
9 changes: 9 additions & 0 deletions utils/test_harness/sysman/src/test_harness_sysman_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,15 @@ get_sysman_device_properties(zes_device_handle_t device) {
return properties;
}

zes_uuid_t get_sysman_device_uuid(zes_device_handle_t device) {
zes_device_properties_t properties = {ZES_STRUCTURE_TYPE_DEVICE_PROPERTIES};
zes_device_ext_properties_t ext_properties = {
ZES_STRUCTURE_TYPE_DEVICE_EXT_PROPERTIES};
properties.pNext = &ext_properties;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDeviceGetProperties(device, &properties));
return ext_properties.uuid;
}

std::vector<zes_subdevice_exp_properties_t>
get_sysman_subdevice_properties(zes_device_handle_t device, uint32_t &count) {
if (count == 0) {
Expand Down

0 comments on commit 87f40ee

Please sign in to comment.