8000 Add CTS for Sysman DriverExtension API's by vishnu-khanth · Pull Request #60 · oneapi-src/level-zero-tests · GitHub
[go: up one dir, main page]

Skip to content

Add CTS for Sysman DriverExtension API's #60

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion conformance_tests/sysman/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2020-2022 Intel Corporation
# Copyright (C) 2020-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
Expand All @@ -14,6 +14,7 @@ add_subdirectory(test_sysman_events)
add_subdirectory(test_sysman_memory)
add_subdirectory(test_sysman_fabric)
add_subdirectory(test_sysman_device)
add_subdirectory(test_sysman_driver)
add_subdirectory(test_sysman_psu)
add_subdirectory(test_sysman_fan)
add_subdirectory(test_sysman_led)
Expand Down
13 changes: 13 additions & 0 deletions conformance_tests/sysman/test_sysman_driver/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Copyright (C) 2024 Intel Corporation
# SPDX-License-Identifier: MIT

add_lzt_test(
NAME test_sysman_driver_zesinit
GROUP "/conformance_tests/tools/sysman"
SOURCES
src/test_sysman_driver.cpp
src/main.cpp
LINK_LIBRARIES
level_zero_tests::logging
level_zero_tests::utils
)
17 changes: 17 additions & 0 deletions conformance_tests/sysman/test_sysman_driver/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# testSysmanDriver

## Description

This test suite is for validating driver Extension APIs provided in Sysman.

### zesDriverGetExtensionProperties

* `GivenValidDriverHandleWhileRetrievingExtensionPropertiesThenValidExtensionPropertiesIsReturned`:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please share whether there is a plan to maintain this readme for every test that is going to be added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure. Since there are only two tests, i added it. In some other test suites like device, it was added in this format.

Test case checks whether zesDriverGetExtensionProperties API returns success and also retrieves valid Extension properties.
If the feature is not supported then the test will be skipped.

### zesDriverGetExtensionFunctionAddress

* `GivenValidDriverHandleWhileRetrievingExtensionFunctionAddressThenValidAddressIsReturned`:
Test case checks whether zesDriverGetExtensionFunctionAddress API returns success and
retrieves valid function pointer for all vendor-specific or experimental extensions Sysman API's which are listed in the L0 specification.
26 changes: 26 additions & 0 deletions conformance_tests/sysman/test_sysman_driver/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "gmock/gmock.h"
#include "logging/logging.hpp"
#include "utils/utils.hpp"
#include <stdlib.h>

int main(int argc, char **argv) {
::testing::InitGoogleMock(&argc, argv);
std::vector<std::string> command_line(argv + 1, argv + argc);
level_zero_tests::init_logging(command_line);

ze_result_t result = zesInit(0);
if (result) {
throw std::runtime_error("zesInit failed: " +
level_zero_tests::to_string(result));
}
LOG_TRACE << "Sysman initialized";
return RUN_ALL_TESTS();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "test_harness/test_harness.hpp"
#include "logging/logging.hpp"
#include "utils/utils.hpp"

namespace lzt = level_zero_tests;

namespace {

class SysmanDriverZesTest : public lzt::ZesSysmanCtsClass {};
#define SYSMAN_DRIVER_TEST SysmanDriverZesTest

TEST_F(
SYSMAN_DRIVER_TEST,
GivenValidDriverHandleWhileRetrievingExtensionPropertiesThenValidExtensionPropertiesIsReturned) {
zes_driver_handle_t driver = lzt::get_default_zes_driver();
for (auto device : devices) {
uint32_t count = 0;
ze_result_t result = lzt::get_driver_ext_properties(driver, &count);

if (result == ZE_RESULT_ERROR_UNSUPPORTED_FEATURE) {
LOG_INFO
<< "Skipping test as zesDriverGetExtensionProperties is Unsupported";
GTEST_SKIP();
}
EXPECT_EQ(result, ZE_RESULT_SUCCESS);
EXPECT_GE(count, 0);

std::vector<zes_driver_extension_properties_t> ext_properties(count);
lzt::get_driver_ext_properties(driver, &count, ext_properties);
for (auto ext_property : ext_properties) {
EXPECT_LE(strlen(ext_property.name), ZES_MAX_EXTENSION_NAME);
EXPECT_GT(ext_property.version, 0);
}
}
}

TEST_F(
SYSMAN_DRIVER_TEST,
GivenValidDriverHandleWhileRetrievingExtensionFunctionAddressThenValidAddressIsReturned) {
zes_driver_handle_t driver = lzt::get_default_zes_driver();
std::vector<const char *> ext_functions = {
"zesPowerSetLimitsExt",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are extension functions which are already part of the header file.
The query for function address would be done for "Driver-experimental" APIs which are not yet part of the L0 spec and an application would like to use them.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By referring the Core API, the extension API's are in both header and extension API's. we can have a look at it.

"zesPowerGetLimitsExt",
"zesEngineGetActivityExt",
"zesRasGetStateExp",
"zesRasClearStateExp",
"zesFirmwareGetSecurityVersionExp",
"zesFirmwareSetSecurityVersionExp",
"zesDriverGetDeviceByUuidExp",
"zesDeviceGetSubDevicePropertiesExp",
"zesDeviceEnumActiveVFExp",
"zesVFManagementGetVFPropertiesExp",
"zesVFManagementGetVFMemoryUtilizationExp",
"zesVFManagementGetVFEngineUtilizationExp",
"zesVFManagementSetVFTelemetryModeExp",
"zesVFManagementSetVFTelemetrySamplingIntervalExp"};

for (auto device : devices) {
for (auto ext_function : ext_functions) {
lzt::get_driver_ext_function_address(driver, ext_function);
}
}
}

} // namespace
4 changes: 3 additions & 1 deletion scripts/level_zero_report_utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env python3
# Copyright (C) 2021-2023 Intel Corporation
# Copyright (C) 2021-2024 Intel Corporation
# SPDX-License-Identifier: MIT

import re
Expand Down Expand Up @@ -270,6 +270,8 @@ def assign_tool_test_feature(test_binary: str, test_name: str):
test_feature = "SysMan Device Properties"
elif test_binary == "test_sysman_device_hierarchy_helper_zesinit":
test_feature = "SysMan Device Properties"
elif test_binary == "test_sysman_driver_zesinit":
test_feature = "SysMan Driver Extensions"
elif test_binary == "test_sysman_events":
test_feature = "SysMan Events"
elif test_binary == "test_sysman_events_zesinit":
Expand Down
3 changes: 2 additions & 1 deletion utils/test_harness/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (C) 2020 Intel Corporation
# Copyright (C) 2020-2024 Intel Corporation
#
# SPDX-License-Identifier: MIT
#
Expand Down Expand Up @@ -29,6 +29,7 @@ add_core_library(test_harness
"sysman/src/test_harness_sysman_pci.cpp"
"sysman/src/test_harness_sysman_power.cpp"
"sysman/src/test_harness_sysman_diagnostics.cpp"
"sysman/src/test_harness_sysman_driver.cpp"
"sysman/src/test_harness_sysman_event.cpp"
"sysman/src/test_harness_sysman_memory.cpp"
"sysman/src/test_harness_sysman_fabric.cpp"
Expand Down
3 changes: 2 additions & 1 deletion utils/test_harness/sysman/include/test_harness_sysman.hpp
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 @@ -16,6 +16,7 @@
#include "test_harness_sysman_standby.hpp"
#include "test_harness_sysman_power.hpp"
#include "test_harness_sysman_diagnostics.hpp"
#include "test_harness_sysman_driver.hpp"
#include "test_harness_sysman_event.hpp"
#include "test_harness_sysman_memory.hpp"
#include "test_harness_sysman_fabric.hpp"
Expand Down
28 changes: 28 additions & 0 deletions utils/test_harness/sysman/include/test_harness_sysman_driver.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#ifndef level_zero_tests_ZE_TEST_HARNESS_SYSMAN_DRIVER_HPP
#define level_zero_tests_ZE_TEST_HARNESS_SYSMAN_DRIVER_HPP

#include <level_zero/zes_api.h>
#include "gtest/gtest.h"

namespace level_zero_tests {

ze_result_t get_driver_ext_properties(zes_driver_handle_t driver,
uint32_t *count);

void get_driver_ext_properties(
zes_driver_handle_t driver, uint32_t *count,
std::vector<zes_driver_extension_properties_t> &ext_properties);

void get_driver_ext_function_address(zes_driver_handle_t driver,
const char *function_name);
} // namespace level_zero_tests

#endif
31 changes: 31 additions & 0 deletions utils/test_harness/sysman/src/test_harness_sysman_driver.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
*
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/

#include "test_harness/test_harness.hpp"

namespace level_zero_tests {
ze_result_t get_driver_ext_properties(zes_driver_handle_t driver,
uint32_t *count) {
return zesDriverGetExtensionProperties(driver, count, nullptr);
}

void get_driver_ext_properties(
zes_driver_handle_t driver, uint32_t *count,
std::vector<zes_driver_extension_properties_t> &ext_properties) {
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverGetExtensionProperties(
driver, count, ext_properties.data()));
}

void get_driver_ext_function_address(zes_driver_handle_t driver,
const char *function_name) {
void *func_ptr = nullptr;
EXPECT_EQ(ZE_RESULT_SUCCESS, zesDriverGetExtensionFunctionAddress(
driver, function_name, &func_ptr));
EXPECT_NE(func_ptr, nullptr);
}
} // namespace level_zero_tests
0