Skip to content

Commit 6464fda

Browse files
Extract tests to windows directory
Related-To: NEO-3599 Change-Id: Ibb5be80ae0e1096e21de2e08d900e0e7f15666bc Signed-off-by: Maciej Dziuban <[email protected]>
1 parent 807a52f commit 6464fda

File tree

5 files changed

+111
-116
lines changed

5 files changed

+111
-116
lines changed
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (C) 2017-2018 Intel Corporation
2+
# Copyright (C) 2017-2020 Intel Corporation
33
#
44
# SPDX-License-Identifier: MIT
55
#
@@ -8,6 +8,8 @@ if(WIN32)
88
set(IGDRCL_SRCS_tests_context_gl
99
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
1010
${CMAKE_CURRENT_SOURCE_DIR}/context_gl_tests.cpp
11+
${CMAKE_CURRENT_SOURCE_DIR}/context_gl_tests.h
1112
)
1213
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_context_gl})
1314
endif()
15+
add_subdirectories()

unit_tests/context/gl/context_gl_tests.cpp

Lines changed: 7 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -5,125 +5,17 @@
55
*
66
*/
77

8-
#include "core/helpers/options.h"
9-
#include "core/unit_tests/helpers/debug_manager_state_restore.h"
10-
#include "runtime/context/context.h"
11-
#include "runtime/device/device.h"
12-
#include "runtime/device_queue/device_queue.h"
13-
#include "runtime/os_interface/windows/gl/gl_sharing_os.h"
14-
#include "runtime/sharings/gl/windows/gl_sharing.h"
15-
#include "unit_tests/fixtures/platform_fixture.h"
16-
#include "unit_tests/mocks/mock_context.h"
17-
#include "unit_tests/mocks/mock_deferred_deleter.h"
18-
#include "unit_tests/mocks/mock_device.h"
19-
#include "unit_tests/mocks/mock_memory_manager.h"
8+
#include "unit_tests/context/gl/context_gl_tests.h"
209

21-
#include "gtest/gtest.h"
22-
#include <GL/gl.h>
10+
#include "runtime/sharings/gl/gl_sharing.h"
2311

24-
using namespace NEO;
12+
namespace NEO {
2513

26-
// use mockGlSharing class for cl-gl sharing tests
27-
typedef bool (*MockGlIoctlFcn)();
28-
29-
struct ContextTest : public PlatformFixture, public ::testing::Test {
30-
31-
using PlatformFixture::SetUp;
32-
33-
void SetUp() override {
34-
PlatformFixture::SetUp();
35-
36-
cl_platform_id platform = pPlatform;
37-
properties = new cl_context_properties[3];
38-
properties[0] = CL_CONTEXT_PLATFORM;
39-
properties[1] = (cl_context_properties)platform;
40-
properties[2] = 0;
41-
42-
context = Context::create<MockContext>(properties, ClDeviceVector(devices, num_devices), nullptr, nullptr, retVal);
43-
ASSERT_NE(nullptr, context);
44-
}
45-
46-
void TearDown() override {
47-
delete[] properties;
48-
delete context;
49-
PlatformFixture::TearDown();
50-
}
51-
52-
cl_int retVal = CL_SUCCESS;
53-
MockContext *context = nullptr;
54-
cl_context_properties *properties = nullptr;
55-
};
56-
57-
TEST_F(ContextTest, GlSharingAreIstPresentByDefault) { ASSERT_EQ(context->getSharing<GLSharingFunctions>(), nullptr); }
58-
59-
TEST_F(ContextTest, GivenPropertiesWhenContextIsCreatedThenSuccess) {
60-
cl_device_id deviceID = devices[0];
61-
auto pPlatform = NEO::platform();
62-
cl_platform_id pid[1];
63-
pid[0] = pPlatform;
64-
65-
cl_context_properties validProperties[] = {CL_CONTEXT_PLATFORM, (cl_context_properties)pid[0], CL_GL_CONTEXT_KHR, 0x10000, 0};
66-
67-
auto context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
68-
EXPECT_EQ(CL_SUCCESS, retVal);
69-
ASSERT_NE(nullptr, context);
70-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
71-
delete context;
72-
73-
validProperties[2] = CL_EGL_DISPLAY_KHR;
74-
context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
75-
EXPECT_EQ(CL_SUCCESS, retVal);
76-
EXPECT_NE(nullptr, context);
77-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
78-
delete context;
79-
80-
validProperties[2] = CL_GLX_DISPLAY_KHR;
81-
context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
82-
EXPECT_EQ(CL_SUCCESS, retVal);
83-
EXPECT_NE(nullptr, context);
84-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
85-
delete context;
86-
87-
validProperties[2] = CL_WGL_HDC_KHR;
88-
context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
89-
EXPECT_EQ(CL_SUCCESS, retVal);
90-
EXPECT_NE(nullptr, context);
91-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
92-
delete context;
93-
}
94-
95-
TEST_F(ContextTest, GivenTwoGlPropertiesWhenContextIsCreatedThenSuccess) {
96-
cl_device_id deviceID = devices[0];
97-
auto pPlatform = NEO::platform();
98-
cl_platform_id pid[1];
99-
pid[0] = pPlatform;
100-
101-
cl_context_properties validProperties[] = {
102-
CL_CONTEXT_PLATFORM, (cl_context_properties)pid[0], CL_GL_CONTEXT_KHR, 0x10000, CL_GL_CONTEXT_KHR, 0x10000, 0};
103-
104-
validProperties[4] = CL_EGL_DISPLAY_KHR;
105-
auto context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
106-
EXPECT_EQ(CL_SUCCESS, retVal);
107-
ASSERT_NE(nullptr, context);
108-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
109-
delete context;
110-
111-
validProperties[4] = CL_GLX_DISPLAY_KHR;
112-
context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
113-
EXPECT_EQ(CL_SUCCESS, retVal);
114-
ASSERT_NE(nullptr, context);
115-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
116-
delete context;
117-
118-
validProperties[4] = CL_WGL_HDC_KHR;
119-
context = Context::create<Context>(validProperties, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal);
120-
EXPECT_EQ(CL_SUCCESS, retVal);
121-
ASSERT_NE(nullptr, context);
122-
EXPECT_FALSE(context->getInteropUserSyncEnabled());
123-
delete context;
14+
TEST_F(GlContextTest, GivenDefaultContextThenGlSharingIsDisabled) {
15+
ASSERT_EQ(context->getSharing<GLSharingFunctions>(), nullptr);
12416
}
12517

126-
TEST_F(ContextTest, GivenGlContextParamWhenCreateContextThenInitSharingFunctions) {
18+
TEST_F(GlContextTest, GivenGlContextParamWhenCreateContextThenInitSharingFunctions) {
12719
cl_device_id deviceID = devices[0];
12820
auto pPlatform = NEO::platform();
12921
cl_platform_id pid[1];
@@ -135,10 +27,10 @@ TEST_F(ContextTest, GivenGlContextParamWhenCreateContextThenInitSharingFunctions
13527
EXPECT_EQ(CL_SUCCESS, retVal);
13628
ASSERT_NE(nullptr, ctx);
13729

138-
//
13930
auto sharing = ctx->getSharing<GLSharingFunctions>();
14031
ASSERT_NE(nullptr, sharing);
14132
EXPECT_FALSE(context->getInteropUserSyncEnabled());
14233

14334
delete ctx;
14435
}
36+
} // namespace NEO
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "unit_tests/fixtures/platform_fixture.h"
11+
#include "unit_tests/mocks/mock_context.h"
12+
13+
#include "gtest/gtest.h"
14+
#include <GL/gl.h>
15+
16+
namespace NEO {
17+
18+
struct GlContextTest : public PlatformFixture, public ::testing::Test {
19+
20+
using PlatformFixture::SetUp;
21+
22+
void SetUp() override {
23+
PlatformFixture::SetUp();
24+
25+
properties[0] = CL_CONTEXT_PLATFORM;
26+
properties[1] = reinterpret_cast<cl_context_properties>(static_cast<cl_platform_id>(pPlatform));
27+
properties[2] = 0;
28+
29+
context = Context::create<MockContext>(properties, ClDeviceVector(devices, num_devices), nullptr, nullptr, retVal);
30+
ASSERT_NE(nullptr, context);
31+
}
32+
33+
void TearDown() override {
34+
delete context;
35+
PlatformFixture::TearDown();
36+
}
37+
38+
void testContextCreation(cl_context_properties contextType) {
39+
const cl_device_id deviceID = devices[0];
40+
const auto platformId = reinterpret_cast<cl_context_properties>(static_cast<cl_platform_id>(platform()));
41+
42+
const cl_context_properties propertiesOneContext[] = {CL_CONTEXT_PLATFORM, platformId, contextType, 0x10000, 0};
43+
auto context = std::unique_ptr<Context>(Context::create<Context>(propertiesOneContext, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal));
44+
EXPECT_EQ(CL_SUCCESS, retVal);
45+
ASSERT_NE(nullptr, context.get());
46+
EXPECT_FALSE(context->getInteropUserSyncEnabled());
47+
48+
const cl_context_properties propertiesTwoContexts[] = {CL_CONTEXT_PLATFORM, platformId, contextType, 0x10000, contextType, 0x10000, 0};
49+
context = std::unique_ptr<Context>(Context::create<Context>(propertiesTwoContexts, ClDeviceVector(&deviceID, 1), nullptr, nullptr, retVal));
50+
EXPECT_EQ(CL_SUCCESS, retVal);
51+
ASSERT_NE(nullptr, context.get());
52+
EXPECT_FALSE(context->getInteropUserSyncEnabled());
53+
}
54+
55+
cl_int retVal = CL_SUCCESS;
56+
MockContext *context = nullptr;
57+
cl_context_properties properties[3] = {};
58+
};
59+
60+
} // namespace NEO
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (C) 2020 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
if(WIN32)
8+
set(IGDRCL_SRCS_tests_context_gl_windows
9+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
10+
${CMAKE_CURRENT_SOURCE_DIR}/context_gl_tests_windows.cpp
11+
)
12+
target_sources(igdrcl_tests PRIVATE ${IGDRCL_SRCS_tests_context_gl_windows})
13+
endif()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2020 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "unit_tests/context/gl/context_gl_tests.h"
9+
10+
namespace NEO {
11+
12+
TEST_F(GlContextTest, GivenClGlContextWhenContextIsCreatedThenSuccess) {
13+
testContextCreation(CL_GL_CONTEXT_KHR);
14+
}
15+
16+
TEST_F(GlContextTest, GivenEglContextWhenContextIsCreatedThenSuccess) {
17+
testContextCreation(CL_EGL_DISPLAY_KHR);
18+
}
19+
20+
TEST_F(GlContextTest, GivenGlxContextWhenContextIsCreatedThenSuccess) {
21+
testContextCreation(CL_GLX_DISPLAY_KHR);
22+
}
23+
24+
TEST_F(GlContextTest, GivenWglContextWhenContextIsCreatedThenSuccess) {
25+
testContextCreation(CL_WGL_HDC_KHR);
26+
}
27+
28+
} // namespace NEO

0 commit comments

Comments
 (0)