mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-24 21:18:24 +08:00
Add ioctl helper function to check vm bind availability
Related-To: NEO-6591 Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
964596e514
commit
12e2670b9a
@@ -35,14 +35,15 @@ class DrmCommandStreamTestL0 : public ::testing::Test {
|
||||
|
||||
//make sure this is disabled, we don't want to test this now
|
||||
DebugManager.flags.EnableForcePin.set(false);
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
|
||||
mock = new ::testing::NiceMock<DrmMockImpl>(mockFd, *executionEnvironment.rootDeviceEnvironments[0]);
|
||||
mock->setupIoctlHelper(hwInfo->platform.eProductFamily);
|
||||
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface = std::make_unique<OSInterface>();
|
||||
executionEnvironment.rootDeviceEnvironments[0]->osInterface->setDriverModel(std::unique_ptr<DriverModel>(mock));
|
||||
executionEnvironment.rootDeviceEnvironments[0]->memoryOperationsInterface = DrmMemoryOperationsHandler::create(*mock, 0u);
|
||||
|
||||
auto hwInfo = executionEnvironment.rootDeviceEnvironments[0]->getHardwareInfo();
|
||||
mock->createVirtualMemoryAddressSpace(HwHelper::getSubDevicesCount(hwInfo));
|
||||
osContext = std::make_unique<OsContextLinux>(*mock, 0u,
|
||||
EngineDescriptorHelper::getDefaultDescriptor(HwHelper::get(hwInfo->platform.eRenderCoreFamily).getGpgpuEngineInstances(*hwInfo)[0],
|
||||
@@ -98,4 +99,4 @@ HWTEST_TEMPLATED_F(DrmCommandStreamTestL0, givenL0ApiConfigWhenCreatingDrmCsrThe
|
||||
VariableBackup<ApiSpecificConfig::ApiType> backup(&apiTypeForUlts, ApiSpecificConfig::L0);
|
||||
MockDrmCsrL0<FamilyType> csr(executionEnvironment, 0, 1, gemCloseWorkerMode::gemCloseWorkerInactive);
|
||||
EXPECT_EQ(DispatchMode::ImmediateDispatch, csr.dispatchMode);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,12 +5,13 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#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/libult/linux/drm_mock.h"
|
||||
#include "shared/test/common/libult/linux/drm_query_mock.h"
|
||||
#include "shared/test/common/mocks/linux/mock_drm_allocation.h"
|
||||
#include "shared/test/common/mocks/mock_execution_environment.h"
|
||||
#include "shared/test/common/test_macros/test.h"
|
||||
|
||||
using namespace NEO;
|
||||
@@ -50,6 +51,28 @@ class IoctlHelperPrelimFixture : public ::testing::Test {
|
||||
std::unique_ptr<DrmPrelimMock> drm;
|
||||
};
|
||||
|
||||
TEST(IoctlHelperPrelimTest, whenGettingVmBindAvailabilityThenProperValueIsReturnedBasedOnIoctlResult) {
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
DrmQueryMock drm{*executionEnvironment->rootDeviceEnvironments[0]};
|
||||
|
||||
IoctlHelperPrelim20 ioctlHelper{};
|
||||
|
||||
for (auto &ioctlValue : {0, EINVAL}) {
|
||||
drm.context.vmBindQueryReturn = ioctlValue;
|
||||
for (auto &hasVmBind : ::testing::Bool()) {
|
||||
drm.context.vmBindQueryValue = hasVmBind;
|
||||
drm.context.vmBindQueryCalled = 0u;
|
||||
|
||||
if (ioctlValue == 0) {
|
||||
EXPECT_EQ(hasVmBind, ioctlHelper.isVmBindAvailable(&drm));
|
||||
} else {
|
||||
EXPECT_FALSE(ioctlHelper.isVmBindAvailable(&drm));
|
||||
}
|
||||
EXPECT_EQ(1u, drm.context.vmBindQueryCalled);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(IoctlHelperPrelimFixture, givenPrelimsWhenCreateGemExtThenReturnSuccess) {
|
||||
auto ioctlHelper = drm->getIoctlHelper();
|
||||
uint32_t handle = 0;
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "shared/source/execution_environment/execution_environment.h"
|
||||
#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"
|
||||
@@ -17,6 +16,13 @@ using namespace NEO;
|
||||
extern std::map<unsigned long, const char *> ioctlCodeStringMap;
|
||||
extern std::map<int, const char *> ioctlParamCodeStringMap;
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, whenGettingVmBindAvailabilityThenFalseIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
auto executionEnvironment = std::make_unique<MockExecutionEnvironment>();
|
||||
auto drm = std::make_unique<DrmTipMock>(*executionEnvironment->rootDeviceEnvironments[0]);
|
||||
EXPECT_FALSE(ioctlHelper.isVmBindAvailable(drm.get()));
|
||||
}
|
||||
|
||||
TEST(IoctlHelperUpstreamTest, givenIoctlWhenParseToStringThenProperStringIsReturned) {
|
||||
IoctlHelperUpstream ioctlHelper{};
|
||||
for (auto ioctlCodeString : ioctlCodeStringMap) {
|
||||
|
||||
Reference in New Issue
Block a user