From ab306e0813a9a7f7b5491a3cc3a6559262a56469 Mon Sep 17 00:00:00 2001 From: Vishnu Khanth Date: Fri, 9 Aug 2024 14:12:01 +0000 Subject: [PATCH] refactor : Sysman init CTS (#64) * refactor sysman init tests into separate executable for isolated testing. Related-To: VLCLJ-2253 Signed-off-by: Vishnu Khanth --- .../sysman/test_sysman_init/CMakeLists.txt | 22 +++++++++++-- .../test_sysman_init/src/test_init_sysman.cpp | 27 +++++++++++++++ ...it.cpp => test_init_sysman_after_core.cpp} | 33 +------------------ .../src/test_init_sysman_before_core.cpp | 30 +++++++++++++++++ scripts/level_zero_report_utils.py | 4 +-- 5 files changed, 79 insertions(+), 37 deletions(-) create mode 100644 conformance_tests/sysman/test_sysman_init/src/test_init_sysman.cpp rename conformance_tests/sysman/test_sysman_init/src/{test_init.cpp => test_init_sysman_after_core.cpp} (52%) create mode 100644 conformance_tests/sysman/test_sysman_init/src/test_init_sysman_before_core.cpp diff --git a/conformance_tests/sysman/test_sysman_init/CMakeLists.txt b/conformance_tests/sysman/test_sysman_init/CMakeLists.txt index 818cb43f..b3523e59 100644 --- a/conformance_tests/sysman/test_sysman_init/CMakeLists.txt +++ b/conformance_tests/sysman/test_sysman_init/CMakeLists.txt @@ -1,14 +1,30 @@ # -#Copyright(C) 2023 Intel Corporation +#Copyright(C) 2023-2024 Intel Corporation # #SPDX - License - Identifier : MIT # add_lzt_test( - NAME test_sysman_init + NAME test_init_sysman GROUP "/conformance_tests/tools/sysman" SOURCES - src/test_init.cpp + src/test_init_sysman.cpp src/main.cpp LINK_LIBRARIES level_zero_tests::logging level_zero_tests::utils) +add_lzt_test( + NAME test_init_sysman_after_core + GROUP "/conformance_tests/tools/sysman" + SOURCES + src/test_init_sysman_after_core.cpp + src/main.cpp + LINK_LIBRARIES level_zero_tests::logging level_zero_tests::utils) + +add_lzt_test( + NAME test_init_sysman_before_core + GROUP "/conformance_tests/tools/sysman" + SOURCES + src/test_init_sysman_before_core.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_init/src/test_init_sysman.cpp b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman.cpp new file mode 100644 index 00000000..a87c0d22 --- /dev/null +++ b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman.cpp @@ -0,0 +1,27 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "gtest/gtest.h" + +#include "logging/logging.hpp" +#include "utils/utils.hpp" +#include "test_harness/test_harness.hpp" + +#include + +namespace { + +TEST(SysmanInitTests, + GivenCoreNotInitializedWhenSysmanInitializedThenzesDriverGetWorks) { + ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0)); + uint32_t pCount = 0; + ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&pCount, nullptr)); + ASSERT_GT(pCount, 0); +} + +} // namespace diff --git a/conformance_tests/sysman/test_sysman_init/src/test_init.cpp b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman_after_core.cpp similarity index 52% rename from conformance_tests/sysman/test_sysman_init/src/test_init.cpp rename to conformance_tests/sysman/test_sysman_init/src/test_init_sysman_after_core.cpp index 7adf61ad..a14504a5 100644 --- a/conformance_tests/sysman/test_sysman_init/src/test_init.cpp +++ b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman_after_core.cpp @@ -1,6 +1,6 @@ /* * - * Copyright (C) 2023 Intel Corporation + * Copyright (C) 2024 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -12,8 +12,6 @@ #include "utils/utils.hpp" #include "test_harness/test_harness.hpp" -namespace lzt = level_zero_tests; - #include namespace { @@ -41,33 +39,4 @@ TEST( } } -TEST(SysmanInitTests, GivenSysmanInitializedThenCallingCoreInitSucceeds) { - ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0)); - uint32_t zesInitCount = 0; - ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&zesInitCount, nullptr)); - ASSERT_GT(zesInitCount, 0); - ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); - uint32_t zeInitCount = 0; - ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&zeInitCount, nullptr)); - ASSERT_GT(zeInitCount, 0); -} - -TEST(SysmanInitTests, - GivenCoreNotInitializedWhenSysmanInitializedThenzesDriverGetWorks) { - ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0)); - uint32_t pCount = 0; - ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&pCount, nullptr)); - ASSERT_GT(pCount, 0); -} - -TEST(SysmanInitTests, - GivenEnableSysmanEnvSetWhenCoreInitializedThenzesDriverGetWorks) { - static char sys_env[] = "ZES_ENABLE_SYSMAN=1"; - putenv(sys_env); - ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); - uint32_t pCount = 0; - ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&pCount, nullptr)); - ASSERT_GT(pCount, 0); -} - } // namespace diff --git a/conformance_tests/sysman/test_sysman_init/src/test_init_sysman_before_core.cpp b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman_before_core.cpp new file mode 100644 index 00000000..3e9eac0e --- /dev/null +++ b/conformance_tests/sysman/test_sysman_init/src/test_init_sysman_before_core.cpp @@ -0,0 +1,30 @@ +/* + * + * Copyright (C) 2024 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "gtest/gtest.h" + +#include "logging/logging.hpp" +#include "utils/utils.hpp" +#include "test_harness/test_harness.hpp" + +#include + +namespace { + +TEST(SysmanInitTests, GivenSysmanInitializedThenCallingCoreInitSucceeds) { + ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0)); + uint32_t zesInitCount = 0; + ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&zesInitCount, nullptr)); + ASSERT_GT(zesInitCount, 0); + ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0)); + uint32_t zeInitCount = 0; + ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&zeInitCount, nullptr)); + ASSERT_GT(zeInitCount, 0); +} + +} // namespace diff --git a/scripts/level_zero_report_utils.py b/scripts/level_zero_report_utils.py index 042a11d4..58e81fef 100644 --- a/scripts/level_zero_report_utils.py +++ b/scripts/level_zero_report_utils.py @@ -210,8 +210,8 @@ def assign_tool_test_feature(test_binary: str, test_name: str): test_feature = "SysMan Frequency" elif test_binary == "test_sysman_frequency_zesinit": test_feature = "SysMan Frequency" - elif test_binary == "test_sysman_init": - test_feature = "SysMan Device Properties" + elif (re.search('test_init_sysman', test_binary, re.IGNORECASE)): + test_feature = "SysMan Init" elif test_binary == "test_sysman_pci": test_feature = "SysMan PCIe" elif test_binary == "test_sysman_pci_zesinit":