mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Pass Drm to ioctl helper ctor
Related-To: NEO-6999 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
115761b4a5
commit
c9e2b4bc32
@@ -1077,8 +1077,12 @@ TEST(DrmQueryTest, givenUapiPrelimVersionWithInvalidPathThenReturnEmptyString) {
|
||||
}
|
||||
|
||||
TEST(DrmTest, givenInvalidUapiPrelimVersionThenFallbackToBasePrelim) {
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
const auto productFamily = defaultHwInfo->platform.eProductFamily;
|
||||
std::unique_ptr<IoctlHelper> ioctlHelper(IoctlHelper::get(productFamily, "-1", "unk"));
|
||||
std::unique_ptr<IoctlHelper> ioctlHelper(IoctlHelper::get(productFamily, "-1", "unk", drm));
|
||||
EXPECT_NE(nullptr, ioctlHelper.get());
|
||||
}
|
||||
|
||||
@@ -1227,6 +1231,7 @@ TEST(DrmWrapperTest, WhenGettingRevisionParamValueThenIoctlHelperIsNotNeeded) {
|
||||
|
||||
class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
public:
|
||||
using IoctlHelperPrelim20::IoctlHelperPrelim20;
|
||||
unsigned int getIoctlRequestValue(DrmIoctl ioctlRequest) const override {
|
||||
return ioctlRequestValue;
|
||||
};
|
||||
@@ -1240,7 +1245,11 @@ class MockIoctlHelper : public IoctlHelperPrelim20 {
|
||||
};
|
||||
|
||||
TEST(DrmWrapperTest, whenGettingDrmParamOrIoctlRequestValueThenUseIoctlHelperWhenAvailable) {
|
||||
MockIoctlHelper ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
DrmMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
MockIoctlHelper ioctlHelper{drm};
|
||||
EXPECT_EQ(getIoctlRequestValue(DrmIoctl::Getparam, &ioctlHelper), ioctlHelper.ioctlRequestValue);
|
||||
EXPECT_NE(getIoctlRequestValue(DrmIoctl::Getparam, nullptr), getIoctlRequestValue(DrmIoctl::Getparam, &ioctlHelper));
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ class IoctlHelperPrelimFixture : public ::testing::Test {
|
||||
executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
drm = std::make_unique<DrmPrelimMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
drm->ioctlHelper = std::make_unique<IoctlHelperPrelim20>();
|
||||
drm->ioctlHelper = std::make_unique<IoctlHelperPrelim20>(*drm);
|
||||
}
|
||||
|
||||
std::unique_ptr<ExecutionEnvironment> executionEnvironment;
|
||||
@@ -57,7 +57,7 @@ TEST(IoctlHelperPrelimTest, whenGettingVmBindAvailabilityThenProperValueIsReturn
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
IoctlHelperPrelim20 ioctlHelper{};
|
||||
IoctlHelperPrelim20 ioctlHelper{drm};
|
||||
|
||||
for (auto &ioctlValue : {0, EINVAL}) {
|
||||
drm.context.vmBindQueryReturn = ioctlValue;
|
||||
@@ -79,7 +79,7 @@ TEST(IoctlHelperPrelimTest, whenVmBindIsCalledThenProperValueIsReturnedBasedOnIo
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
IoctlHelperPrelim20 ioctlHelper{};
|
||||
IoctlHelperPrelim20 ioctlHelper{drm};
|
||||
|
||||
VmBindParams vmBindParams{};
|
||||
|
||||
@@ -95,7 +95,7 @@ TEST(IoctlHelperPrelimTest, whenVmUnbindIsCalledThenProperValueIsReturnedBasedOn
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
IoctlHelperPrelim20 ioctlHelper{};
|
||||
IoctlHelperPrelim20 ioctlHelper{drm};
|
||||
|
||||
VmBindParams vmBindParams{};
|
||||
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
*/
|
||||
|
||||
#include "shared/source/helpers/string.h"
|
||||
#include "shared/source/os_interface/linux/drm_neo.h"
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
#include "third_party/uapi/prelim/drm/i915_drm.h"
|
||||
@@ -18,7 +20,9 @@ extern std::vector<uint8_t> getRegionInfo(const std::vector<MemoryRegion> &input
|
||||
extern std::vector<uint8_t> getEngineInfo(const std::vector<EngineCapabilities> &inputEngines);
|
||||
|
||||
struct IoctlPrelimHelperTests : ::testing::Test {
|
||||
IoctlHelperPrelim20 ioctlHelper{};
|
||||
MockExecutionEnvironment executionEnvironment{};
|
||||
std::unique_ptr<Drm> drm{Drm::create(std::make_unique<HwDeviceIdDrm>(0, ""), *executionEnvironment.rootDeviceEnvironments[0])};
|
||||
IoctlHelperPrelim20 ioctlHelper{*drm};
|
||||
};
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
|
||||
@@ -113,11 +117,6 @@ TEST_F(IoctlPrelimHelperTests, givenPrelimsWhenTranslateToMemoryRegionsThenRetur
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, whenCloneIsCalledThenValidPtrIsReturned) {
|
||||
std::unique_ptr<IoctlHelper> cloned(ioctlHelper.clone());
|
||||
EXPECT_NE(nullptr, cloned);
|
||||
}
|
||||
|
||||
TEST_F(IoctlPrelimHelperTests, givenEmptyRegionInstanceClassWhenCreatingVmControlRegionExtThenNullptrIsReturned) {
|
||||
std::optional<MemoryClassInstance> regionInstanceClass{};
|
||||
|
||||
|
||||
@@ -15,14 +15,16 @@
|
||||
using namespace NEO;
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingVmBindAvailabilityThenFalseIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_FALSE(ioctlHelper.isVmBindAvailable(drm.get()));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingIoctlRequestValueThenPropertValueIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::Getparam), static_cast<unsigned int>(DRM_IOCTL_I915_GETPARAM));
|
||||
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::GemExecbuffer2), static_cast<unsigned int>(DRM_IOCTL_I915_GEM_EXECBUFFER2));
|
||||
EXPECT_EQ(ioctlHelper.getIoctlRequestValue(DrmIoctl::GemWait), static_cast<unsigned int>(DRM_IOCTL_I915_GEM_WAIT));
|
||||
@@ -50,7 +52,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingIoctlRequestValueThenPropertValueIsRetu
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingDrmParamValueThenPropertValueIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassCompute), 4);
|
||||
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassRender), static_cast<int>(I915_ENGINE_CLASS_RENDER));
|
||||
EXPECT_EQ(ioctlHelper.getDrmParamValue(DrmParam::EngineClassCopy), static_cast<int>(I915_ENGINE_CLASS_COPY));
|
||||
@@ -82,7 +86,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingDrmParamValueThenPropertValueIsReturned
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenCreatingVmControlRegionExtThenNullptrIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
std::optional<MemoryClassInstance> regionInstanceClass = MemoryClassInstance{};
|
||||
|
||||
EXPECT_TRUE(regionInstanceClass.has_value());
|
||||
@@ -94,7 +100,9 @@ TEST(IoctlHelperUpstreamTest, whenCreatingVmControlRegionExtThenNullptrIsReturne
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmCreateThenZeroIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
for (auto &disableScratch : ::testing::Bool()) {
|
||||
for (auto &enablePageFault : ::testing::Bool()) {
|
||||
for (auto &useVmBind : ::testing::Bool()) {
|
||||
@@ -106,7 +114,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmCreateThenZeroIsReturned) {
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmBindThenZeroIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
for (auto &bindCapture : ::testing::Bool()) {
|
||||
for (auto &bindImmediate : ::testing::Bool()) {
|
||||
for (auto &bindMakeResident : ::testing::Bool()) {
|
||||
@@ -118,7 +128,9 @@ TEST(IoctlHelperUpstreamTest, whenGettingFlagsForVmBindThenZeroIsReturned) {
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingVmBindExtFromHandlesThenNullptrIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
StackVec<uint32_t, 2> bindExtHandles;
|
||||
bindExtHandles.push_back(1u);
|
||||
bindExtHandles.push_back(2u);
|
||||
@@ -301,7 +313,7 @@ TEST(IoctlHelperTestsUpstream, whenCreateContextWithAccessCountersIsCalledThenEr
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
GemContextCreateExt gcc{};
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createContextWithAccessCounters(drm.get(), gcc));
|
||||
}
|
||||
@@ -312,19 +324,23 @@ TEST(IoctlHelperTestsUpstream, whenCreateCooperativeContexIsCalledThenErrorIsRet
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
GemContextCreateExt gcc{};
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createCooperativeContext(drm.get(), gcc));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenFillVmBindSetPatThenNothingThrows) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
VmBindExtSetPatT vmBindExtSetPat{};
|
||||
EXPECT_NO_THROW(ioctlHelper.fillVmBindExtSetPat(vmBindExtSetPat, 0u, 0u));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenFillVmBindUserFenceThenNothingThrows) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
VmBindExtUserFenceT vmBindExtUserFence{};
|
||||
EXPECT_NO_THROW(ioctlHelper.fillVmBindExtUserFence(vmBindExtUserFence, 0u, 0u, 0u));
|
||||
}
|
||||
@@ -335,7 +351,7 @@ TEST(IoctlHelperTestsUpstream, whenVmBindIsCalledThenZeroIsReturned) {
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
VmBindParams vmBindParams{};
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(0, ioctlHelper.vmBind(drm.get(), vmBindParams));
|
||||
}
|
||||
|
||||
@@ -344,19 +360,23 @@ TEST(IoctlHelperTestsUpstream, whenVmUnbindIsCalledThenZeroIsReturned) {
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
VmBindParams vmBindParams{};
|
||||
EXPECT_EQ(0, ioctlHelper.vmUnbind(drm.get(), vmBindParams));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallPropertiesThenFailureIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
std::array<uint64_t, 12u> properties = {};
|
||||
EXPECT_FALSE(ioctlHelper.getEuStallProperties(properties, 0x101, 0x102, 0x103, 1, 1));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, givenUpstreamWhenGettingEuStallFdParameterThenZeroIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(0u, ioctlHelper.getEuStallFdParameter());
|
||||
}
|
||||
|
||||
@@ -364,7 +384,7 @@ TEST(IoctlHelperTestsUpstream, whenRegisterUuidIsCalledThenReturnNullHandle) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
|
||||
{
|
||||
const auto [retVal, handle] = ioctlHelper.registerUuid(drm.get(), "", 0, 0, 0);
|
||||
@@ -383,7 +403,7 @@ TEST(IoctlHelperTestsUpstream, whenUnregisterUuidIsCalledThenZeroIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(0, ioctlHelper.unregisterUuid(drm.get(), 0));
|
||||
}
|
||||
|
||||
@@ -391,7 +411,7 @@ TEST(IoctlHelperTestsUpstream, whenIsContextDebugSupportedIsCalledThenFalseIsRet
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(false, ioctlHelper.isContextDebugSupported(drm.get()));
|
||||
}
|
||||
|
||||
@@ -399,6 +419,6 @@ TEST(IoctlHelperTestsUpstream, whenSetContextDebugFlagIsCalledThenZeroIsReturned
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
IoctlHelperUpstream ioctlHelper{*drm};
|
||||
EXPECT_EQ(0, ioctlHelper.setContextDebugFlag(drm.get(), 0));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user