Debian Codegraph @

level_zero/sysman/test/unit_tests/sources/windows/test_sysman_driver.cpp

raw
1 /*
2 * Copyright (C) 2023-2024 Intel Corporation
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 */
7
8 #include "level_zero/sysman/test/unit_tests/sources/windows/mock_sysman_driver.h"
9
10 #include "gtest/gtest.h"
11
12 #include <bitset>
13 #include <cstring>
14
15 namespace L0 {
16 namespace Sysman {
17 namespace ult {
18
19 TEST(zesInit, whenCallingZesInitThenInitializeOnDriverIsCalled) {
20 MockSysmanDriver driver;
21
22 auto result = zesInit(ZE_INIT_FLAG_GPU_ONLY);
23 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
24 EXPECT_EQ(1u, driver.initCalledCount);
25 }
26
27 TEST(zesInit, whenCallingZesInitWithNoFlagsThenInitializeOnDriverIsCalled) {
28 MockSysmanDriver driver;
29
30 auto result = zesInit(0);
31 EXPECT_EQ(ZE_RESULT_SUCCESS, result);
32 EXPECT_EQ(1u, driver.initCalledCount);
33 }
34
35 TEST(zesInit, whenCallingZesInitWithoutGpuOnlyFlagThenInitializeOnDriverIsNotCalled) {
36 MockSysmanDriver driver;
37
38 auto result = zesInit(ZE_INIT_FLAG_VPU_ONLY);
39 EXPECT_EQ(ZE_RESULT_ERROR_UNINITIALIZED, result);
40 EXPECT_EQ(0u, driver.initCalledCount);
41 }
42
43 TEST_F(SysmanDriverHandleTest,
44 givenInitializedDriverWhenZesDriverGetPropertiesIsCalledThenUnsupportedIsReturned) {
45 uint32_t pCount = 0;
46 EXPECT_EQ(ZE_RESULT_ERROR_UNSUPPORTED_FEATURE, zesDriverGetExtensionProperties(driverHandle->toHandle(), &pCount, nullptr));
47 }
48
49 TEST_F(SysmanDriverHandleTest,
50 givenDriverWhenGetExtensionFunctionAddressIsCalledWithValidAndInvalidFunctionNamesThenCorrectResultIsReturned) {
51 void *funPtr = nullptr;
52
53 auto result = zesDriverGetExtensionFunctionAddress(driverHandle->toHandle(), "zexDriverImportUnKnownPointer", &funPtr);
54 EXPECT_EQ(ZE_RESULT_ERROR_INVALID_ARGUMENT, result);
55 }
56
57 } // namespace ult
58 } // namespace Sysman
59 } // namespace L0