File: drm_va_sharing_tests.cpp

package info (click to toggle)
intel-compute-runtime 25.48.36300.8-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 80,652 kB
  • sloc: cpp: 939,022; lisp: 2,090; sh: 722; makefile: 162; python: 21
file content (43 lines) | stat: -rw-r--r-- 1,723 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/*
 * Copyright (C) 2020-2025 Intel Corporation
 *
 * SPDX-License-Identifier: MIT
 *
 */

#include "shared/test/common/mocks/linux/mock_drm_memory_manager.h"
#include "shared/test/common/os_interface/linux/drm_memory_manager_fixture.h"
#include "shared/test/common/test_macros/hw_test.h"
#include "shared/test/common/test_macros/test.h"

#include "opencl/source/mem_obj/image.h"
#include "opencl/source/sharings/va/va_surface.h"
#include "opencl/test/unit_test/mocks/mock_cl_device.h"
#include "opencl/test/unit_test/mocks/mock_context.h"
#include "opencl/test/unit_test/sharings/va/mock_va_sharing.h"

namespace NEO {

using DrmVaSharingTest = Test<DrmMemoryManagerFixture>;

HWTEST_TEMPLATED_F(DrmVaSharingTest, givenDrmMemoryManagerWhenSharedVaSurfaceIsImportedWithDrmPrimeFdToHandleThenDrmPrimeFdCanBeClosed) {
    mock->ioctlExpected.total = -1;
    device->incRefInternal();
    MockClDevice clDevice{device};
    MockContext context(&clDevice);
    MockVaSharing vaSharing;
    VASurfaceID vaSurfaceId = 0u;

    vaSharing.updateAcquiredHandle(1);
    std::unique_ptr<Image> sharedImage1(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions,
                                                                         CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr));
    EXPECT_EQ(1, closeCalledCount);
    EXPECT_EQ(1, closeInputFd);

    vaSharing.updateAcquiredHandle(2);
    std::unique_ptr<Image> sharedImage2(VASurface::createSharedVaSurface(&context, &vaSharing.sharingFunctions,
                                                                         CL_MEM_READ_WRITE, 0, &vaSurfaceId, 0, nullptr));
    EXPECT_EQ(2, closeCalledCount);
    EXPECT_EQ(2, closeInputFd);
}
} // namespace NEO