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 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
/*
* Copyright (C) 2020-2024 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/os_interface/linux/drm_neo.h"
#include "shared/test/common/libult/linux/drm_mock.h"
#include "shared/test/common/mocks/mock_execution_environment.h"
#include "gtest/gtest.h"
using namespace NEO;
struct DrmDebugTest : public ::testing::Test {
public:
void SetUp() override {
executionEnvironment = std::make_unique<MockExecutionEnvironment>();
}
void TearDown() override {
}
protected:
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
};
TEST_F(DrmDebugTest, whenRegisterResourceClassesCalledWhenNoImplementationThenFalseIsReturned) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
auto result = drmMock.registerResourceClasses();
EXPECT_FALSE(result);
}
TEST_F(DrmDebugTest, whenRegisterResourceCalledThenImplementationIsEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock.ioctlCallsCount = 0;
auto handle = drmMock.registerResource(DrmResourceClass::maxSize, nullptr, 0);
EXPECT_EQ(0u, handle);
drmMock.unregisterResource(handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenRegisterIsaCookieCalledThenImplementationIsEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock.ioctlCallsCount = 0;
const uint32_t isaHandle = 2;
auto handle = drmMock.registerIsaCookie(isaHandle);
EXPECT_EQ(0u, handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenCheckingContextDebugSupportThenNoIoctlIsCalled) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock.ioctlCallsCount = 0;
drmMock.checkContextDebugSupport();
EXPECT_FALSE(drmMock.isContextDebugSupported());
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
TEST_F(DrmDebugTest, whenNotifyCommandQueueCreateDestroyAreCalledThenImplementationsAreEmpty) {
DrmMock drmMock(*executionEnvironment->rootDeviceEnvironments[0]);
drmMock.ioctlCallsCount = 0;
auto handle = drmMock.notifyFirstCommandQueueCreated(nullptr, 0);
EXPECT_EQ(0u, handle);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
drmMock.notifyLastCommandQueueDestroyed(0);
EXPECT_EQ(0u, drmMock.ioctlCallsCount);
}
|