diff --git a/conformance_tests/sysman/CMakeLists.txt b/conformance_tests/sysman/CMakeLists.txt index 136b132e..5ff2afaf 100755 --- a/conformance_tests/sysman/CMakeLists.txt +++ b/conformance_tests/sysman/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020-2022 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -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) diff --git a/conformance_tests/sysman/test_sysman_driver/CMakeLists.txt b/conformance_tests/sysman/test_sysman_driver/CMakeLists.txt new file mode 100644 index 00000000..1f143ab7 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_driver/CMakeLists.txt @@ -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 +) \ No newline at end of file diff --git a/conformance_tests/sysman/test_sysman_driver/README.md b/conformance_tests/sysman/test_sysman_driver/README.md new file mode 100644 index 00000000..8c727e86 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_driver/README.md @@ -0,0 +1,17 @@ +# testSysmanDriver + +## Description + +This test suite is for validating driver Extension APIs provided in Sysman. + +### zesDriverGetExtensionProperties + +* `GivenValidDriverHandleWhileRetrievingExtensionPropertiesThenValidExtensionPropertiesIsReturned`: + 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. diff --git a/conformance_tests/sysman/test_sysman_driver/src/main.cpp b/conformance_tests/sysman/test_sysman_driver/src/main.cpp new file mode 100644 index 00000000..9401ac02 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_driver/src/main.cpp @@ -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 + +int main(int argc, char **argv) { + ::testing::InitGoogleMock(&argc, argv); + std::vector 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(); +} diff --git a/conformance_tests/sysman/test_sysman_driver/src/test_sysman_driver.cpp b/conformance_tests/sysman/test_sysman_driver/src/test_sysman_driver.cpp new file mode 100644 index 00000000..440c059f --- /dev/null +++ b/conformance_tests/sysman/test_sysman_driver/src/test_sysman_driver.cpp @@ -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 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 ext_functions = { + "zesPowerSetLimitsExt", + "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 \ No newline at end of file diff --git a/scripts/level_zero_report_utils.py b/scripts/level_zero_report_utils.py index 042a11d4..a56b6c57 100644 --- a/scripts/level_zero_report_utils.py +++ b/scripts/level_zero_report_utils.py @@ -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 @@ -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": diff --git a/utils/test_harness/CMakeLists.txt b/utils/test_harness/CMakeLists.txt index 10ed007f..6dc776b1 100755 --- a/utils/test_harness/CMakeLists.txt +++ b/utils/test_harness/CMakeLists.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2020 Intel Corporation +# Copyright (C) 2020-2024 Intel Corporation # # SPDX-License-Identifier: MIT # @@ -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" diff --git a/utils/test_harness/sysman/include/test_harness_sysman.hpp b/utils/test_harness/sysman/include/test_harness_sysman.hpp index cf6821fb..d012dcd3 100755 --- a/utils/test_harness/sysman/include/test_harness_sysman.hpp +++ b/utils/test_harness/sysman/include/test_harness_sysman.hpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2020 Intel Corporation + * Copyright (C) 2020-2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -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" diff --git a/utils/test_harness/sysman/include/test_harness_sysman_driver.hpp b/utils/test_harness/sysman/include/test_harness_sysman_driver.hpp new file mode 100644 index 00000000..58d82a26 --- /dev/null +++ b/utils/test_harness/sysman/include/test_harness_sysman_driver.hpp @@ -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 +#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 &ext_properties); + +void get_driver_ext_function_address(zes_driver_handle_t driver, + const char *function_name); +} // namespace level_zero_tests + +#endif \ No newline at end of file diff --git a/utils/test_harness/sysman/src/test_harness_sysman_driver.cpp b/utils/test_harness/sysman/src/test_harness_sysman_driver.cpp new file mode 100644 index 00000000..5af8f865 --- /dev/null +++ b/utils/test_harness/sysman/src/test_harness_sysman_driver.cpp @@ -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 &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 \ No newline at end of file