Skip to content

Commit

Permalink
refactor : Sysman init CTS (#64)
Browse files Browse the repository at this point in the history
* refactor sysman init tests into separate executable for isolated
   testing.

Related-To: VLCLJ-2253

Signed-off-by: Vishnu Khanth <[email protected]>
  • Loading branch information
vishnu-khanth authored Aug 9, 2024
1 parent e27fdce commit ab306e0
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 37 deletions.
22 changes: 19 additions & 3 deletions conformance_tests/sysman/test_sysman_init/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

27 changes: 27 additions & 0 deletions conformance_tests/sysman/test_sysman_init/src/test_init_sysman.cpp
Original file line number Diff line number Diff line change
@@ -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 <level_zero/zes_api.h>

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
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
*
* Copyright (C) 2023 Intel Corporation
* Copyright (C) 2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
Expand All @@ -12,8 +12,6 @@
#include "utils/utils.hpp"
#include "test_harness/test_harness.hpp"

namespace lzt = level_zero_tests;

#include <level_zero/zes_api.h>

namespace {
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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 <level_zero/zes_api.h>

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
4 changes: 2 additions & 2 deletions scripts/level_zero_report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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":
Expand Down

0 comments on commit ab306e0

Please sign in to comment.