mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-03 06:49:52 +08:00
Move createDrmContextExt to drm_neo.cpp
add ioctl helper functions to create dedicated drm contexts createContextWithAccessCounters createCooperativeContext Related-To: NEO-6591 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
1e6a38035e
commit
cf27583264
@@ -313,3 +313,61 @@ TEST_F(IoctlHelperPrelimFixture, givenPrelimWhenQueryEngineInfoAndFailIoctlThenF
|
||||
|
||||
EXPECT_EQ(nullptr, engineInfo);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateContextWithAccessCountersIsCalledThenErrorIsReturned) {
|
||||
drm->ioctlRetVal = EINVAL;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper->createContextWithAccessCounters(drm.get(), gcc));
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlSuccessWhenCreateContextWithAccessCountersIsCalledThenSuccessIsReturned) {
|
||||
drm->ioctlRetVal = 0;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
EXPECT_EQ(0u, ioctlHelper->createContextWithAccessCounters(drm.get(), gcc));
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlFailureWhenCreateCooperativeContexIsCalledThenErrorIsReturned) {
|
||||
drm->ioctlRetVal = EINVAL;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper->createCooperativeContext(drm.get(), gcc));
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenIoctlSuccessWhenCreateCooperativeContexIsCalledThenSuccessIsReturned) {
|
||||
drm->ioctlRetVal = 0u;
|
||||
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
EXPECT_EQ(0u, ioctlHelper->createCooperativeContext(drm.get(), gcc));
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, whenCreateDrmContextExtIsCalledThenIoctlIsCalledOnlyOnce) {
|
||||
drm->ioctlRetVal = 0u;
|
||||
|
||||
DebugManagerStateRestore stateRestore;
|
||||
|
||||
for (auto &cooperativeContextRequested : {-1, 0, 1}) {
|
||||
DebugManager.flags.ForceRunAloneContext.set(cooperativeContextRequested);
|
||||
for (auto &accessCountersRequested : {-1, 0, 1}) {
|
||||
DebugManager.flags.CreateContextWithAccessCounters.set(accessCountersRequested);
|
||||
for (auto vmId = 0u; vmId < 3; vmId++) {
|
||||
drm->ioctlCallsCount = 0u;
|
||||
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
|
||||
drm->createDrmContextExt(gcc, vmId, true);
|
||||
|
||||
EXPECT_EQ(1u, drm->ioctlCallsCount);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "shared/source/os_interface/linux/ioctl_helper.h"
|
||||
#include "shared/test/common/helpers/debug_manager_state_restore.h"
|
||||
#include "shared/test/common/helpers/default_hw_info.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
#include "shared/test/unit_test/os_interface/linux/drm_mock_impl.h"
|
||||
|
||||
@@ -200,3 +201,25 @@ TEST(IoctlHelperTestsUpstream, givenUpstreamWhenQueryEngineInfoWithDeviceMemoryA
|
||||
ASSERT_NE(nullptr, engineInfo);
|
||||
EXPECT_EQ(totalEnginesCount, engines.size());
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenCreateContextWithAccessCountersIsCalledThenErrorIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createContextWithAccessCounters(drm.get(), gcc));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperTestsUpstream, whenCreateCooperativeContexIsCalledThenErrorIsReturned) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
ASSERT_NE(nullptr, drm);
|
||||
|
||||
drm_i915_gem_context_create_ext gcc{};
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
|
||||
EXPECT_EQ(static_cast<uint32_t>(EINVAL), ioctlHelper.createCooperativeContext(drm.get(), gcc));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user