Add getter in Drm for memoryInfo

Related-To: NEO-3014

Change-Id: I56c0e13b88d27f7c6b3816bf24342cdb04108dac
Signed-off-by: Mateusz Hoppe <mateusz.hoppe@intel.com>
This commit is contained in:
Mateusz Hoppe
2019-04-10 14:32:41 +02:00
committed by sys_ocldev
parent 20985f426e
commit 115d700f49
3 changed files with 20 additions and 6 deletions

View File

@ -72,6 +72,10 @@ class Drm {
bool getSimplifiedMocsTableUsage() const;
void queryMemoryInfo();
MemoryInfo *getMemoryInfo() {
return memoryInfo.get();
}
protected:
bool useSimplifiedMocsTable = false;
bool preemptionSupported = false;

View File

@ -12,6 +12,11 @@
using namespace NEO;
struct MemoryInfoImpl : public NEO::MemoryInfo {
MemoryInfoImpl() {}
~MemoryInfoImpl() override{};
};
TEST(DrmTest, whenQueryingMemoryInfoThenMemoryInfoIsNotCreatedAndNoIoctlIsCalled) {
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>();
EXPECT_NE(nullptr, drm);
@ -22,11 +27,15 @@ TEST(DrmTest, whenQueryingMemoryInfoThenMemoryInfoIsNotCreatedAndNoIoctlIsCalled
EXPECT_EQ(0u, drm->ioctlCallsCount);
}
TEST(MemoryInfo, givenMemoryInfoImplementationWhenDestructingThenDestructorIsCalled) {
struct MemoryInfoImpl : public NEO::MemoryInfo {
MemoryInfoImpl() {}
~MemoryInfoImpl() override{};
};
TEST(DrmTest, givenMemoryInfoWhenGetMemoryInfoIsCalledThenValidPtrIsReturned) {
std::unique_ptr<DrmMock> drm = std::make_unique<DrmMock>();
EXPECT_NE(nullptr, drm);
drm->memoryInfo.reset(new MemoryInfoImpl);
EXPECT_EQ(drm->memoryInfo.get(), drm->getMemoryInfo());
}
TEST(MemoryInfo, givenMemoryInfoImplementationWhenDestructingThenDestructorIsCalled) {
MemoryInfoImpl memoryInfoImpl;
}

View File

@ -23,7 +23,6 @@ using namespace NEO;
#define I915_PARAM_HAS_PREEMPTION 0x806
#endif
static const int mockFd = 33;
// Mock DRM class that responds to DRM_IOCTL_I915_GETPARAMs
class DrmMock : public Drm {
public:
@ -222,6 +221,8 @@ class DrmMock : public Drm {
void setDeviceID(int deviceId) { this->deviceId = deviceId; }
void setDeviceRevID(int revisionId) { this->revisionId = revisionId; }
static const int mockFd = 33;
int StoredEUVal = -1;
int StoredSSVal = -1;
int StoredDeviceID = 1;