Skip to content

Commit

Permalink
Sysman init EnumFreqDomain CTS (#72)
Browse files Browse the repository at this point in the history
* Sysman EnumFreq CTS

* seperate binary for init cases

Signed-off-by: Kunder, Shreyas <[email protected]>

* minor rename

Signed-off-by: Kunder, Shreyas <[email protected]>

* Update level_zero_utils

* minor change

* Sysman EnumFreq CTS

* test: sysman init tests from core and sysman handle

Signed-off-by: Shreyas Kunder <[email protected]>

* test: sysman init tests from core and sysman handle

Signed-off-by: Shreyas Kunder <[email protected]>

* test: sysman init tests from core and sysman handle

Signed-off-by: Shreyas Kunder <[email protected]>

* test: sysman init tests from core and sysman handle

Signed-off-by: Shreyas Kunder <[email protected]>

* test: sysman init tests from core and sysman handle

Related-To: VLCLJ-2273

Signed-off-by: Shreyas Kunder <[email protected]>

* test: sysman init tests from core and sysman handle

Related-To: VLCLJ-2273

Signed-off-by: Shreyas Kunder <[email protected]>

---------

Signed-off-by: Kunder, Shreyas <[email protected]>
Signed-off-by: Shreyas Kunder <[email protected]>
  • Loading branch information
shreyaskunder authored Nov 5, 2024
1 parent ef3e3c6 commit 92223ce
Show file tree
Hide file tree
Showing 4 changed files with 156 additions and 0 deletions.
24 changes: 24 additions & 0 deletions conformance_tests/sysman/test_sysman_init/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,30 @@ add_lzt_test(
src/main.cpp
LINK_LIBRARIES level_zero_tests::logging level_zero_tests::utils)

add_lzt_test(
NAME test_init_sysman_enum_freq_with_core_handle
GROUP "/conformance_tests/tools/sysman"
SOURCES
src/test_init_sysman_enum_freq_with_core_handle.cpp
src/main.cpp
LINK_LIBRARIES level_zero_tests::logging level_zero_tests::utils)

add_lzt_test(
NAME test_init_sysman_enum_freq_with_sysman_handle
GROUP "/conformance_tests/tools/sysman"
SOURCES
src/test_init_sysman_enum_freq_with_sysman_handle.cpp
src/main.cpp
LINK_LIBRARIES level_zero_tests::logging level_zero_tests::utils)

add_lzt_test(
NAME test_init_sysman_no_env_with_core_handle
GROUP "/conformance_tests/tools/sysman"
SOURCES
src/test_init_sysman_no_env_with_core_handle.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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* 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,
GivenSysmanInitializationDoneUsingZesInitFollowedByZeInitAlongWithSysmanFlagEnabledThenWhenSysmanApiZesDeviceEnumFrequencyDomainsIsCalledWithCoreHandleThenUninitializedErrorIsReturned) {
static char sys_env[] = "ZES_ENABLE_SYSMAN=1";
putenv(sys_env);

ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0));
ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0));

uint32_t driver_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&driver_count, nullptr));
ASSERT_GT(driver_count, 0);
std::vector<zes_driver_handle_t> drivers(driver_count);
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&driver_count, drivers.data()));

uint32_t device_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &device_count, nullptr));
std::vector<zes_device_handle_t> devices(device_count);
ASSERT_EQ(ZE_RESULT_SUCCESS,
zeDeviceGet(drivers[0], &device_count, devices.data()));

uint32_t count = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED,
zesDeviceEnumFrequencyDomains(devices[0], &count, nullptr));
}

} // namespace
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
*
* 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,
GivenSysmanInitializationDoneUsingZesInitFollowedByZeInitAlongWithSysmanFlagEnabledThenWhenSysmanApiZesDeviceEnumFrequencyDomainsIsCalledWithSysmanHandleThenSuccessIsReturned) {
static char sys_env[] = "ZES_ENABLE_SYSMAN=1";
putenv(sys_env);

ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0));
ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0));

uint32_t driver_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&driver_count, nullptr));
ASSERT_GT(driver_count, 0);
std::vector<zes_driver_handle_t> drivers(driver_count);
ASSERT_EQ(ZE_RESULT_SUCCESS, zesDriverGet(&driver_count, drivers.data()));

uint32_t device_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS,
zesDeviceGet(drivers[0], &device_count, nullptr));
std::vector<zes_device_handle_t> devices(device_count);
ASSERT_EQ(ZE_RESULT_SUCCESS,
zesDeviceGet(drivers[0], &device_count, devices.data()));

uint32_t count = 0;
EXPECT_EQ(ZE_RESULT_SUCCESS,
zesDeviceEnumFrequencyDomains(devices[0], &count, nullptr));
}

} // namespace
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
*
* 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,
GivenSysmanInitializationDoneUsingZesInitFollowedByZeInitAlongWithSysmanFlagDisabledThenWhenSysmanApiZesDeviceEnumFrequencyDomainsIsCalledWithCoreHandleThenUninitializedErrorIsReturned) {
static char sys_env[] = "ZES_ENABLE_SYSMAN=0";
putenv(sys_env);

ASSERT_EQ(ZE_RESULT_SUCCESS, zesInit(0));
ASSERT_EQ(ZE_RESULT_SUCCESS, zeInit(0));

uint32_t driver_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&driver_count, nullptr));
ASSERT_GT(driver_count, 0);
std::vector<zes_driver_handle_t> drivers(driver_count);
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDriverGet(&driver_count, drivers.data()));

uint32_t device_count = 0;
ASSERT_EQ(ZE_RESULT_SUCCESS, zeDeviceGet(drivers[0], &device_count, nullptr));
std::vector<zes_device_handle_t> devices(device_count);
ASSERT_EQ(ZE_RESULT_SUCCESS,
zeDeviceGet(drivers[0], &device_count, devices.data()));

uint32_t count = 0;
EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED,
zesDeviceEnumFrequencyDomains(devices[0], &count, nullptr));
}

} // namespace

0 comments on commit 92223ce

Please sign in to comment.