Close fd after each drm ioctl prime fd to handle

Signed-off-by: Slawomir Milczarek <slawomir.milczarek@intel.com>
This commit is contained in:
Slawomir Milczarek
2020-11-13 00:39:45 +01:00
committed by Compute-Runtime-Automation
parent 9c1739c095
commit 8323ddbb3b
4 changed files with 23 additions and 1 deletions

View File

@@ -19,6 +19,8 @@
namespace NEO {
off_t lseekReturn = 4096u;
std::atomic<int> lseekCalledCount(0);
int closeInputFd = 0;
std::atomic<int> closeCalledCount(0);
TestedDrmMemoryManager::TestedDrmMemoryManager(ExecutionEnvironment &executionEnvironment) : MemoryManagerCreate(gemCloseWorkerMode::gemCloseWorkerInactive,
false,
@@ -30,6 +32,8 @@ TestedDrmMemoryManager::TestedDrmMemoryManager(ExecutionEnvironment &executionEn
this->closeFunction = &closeMock;
lseekReturn = 4096;
lseekCalledCount = 0;
closeInputFd = 0;
closeCalledCount = 0;
hostPtrManager.reset(new MockHostPtrManager);
};
@@ -47,6 +51,8 @@ TestedDrmMemoryManager::TestedDrmMemoryManager(bool enableLocalMemory,
this->closeFunction = &closeMock;
lseekReturn = 4096;
lseekCalledCount = 0;
closeInputFd = 0;
closeCalledCount = 0;
}
void TestedDrmMemoryManager::injectPinBB(BufferObject *newPinBB, uint32_t rootDeviceIndex) {

View File

@@ -15,6 +15,8 @@
namespace NEO {
extern off_t lseekReturn;
extern std::atomic<int> lseekCalledCount;
extern int closeInputFd;
extern std::atomic<int> closeCalledCount;
inline void *mmapMock(void *addr, size_t length, int prot, int flags, int fd, off_t offset) noexcept {
if (addr) {
@@ -38,7 +40,9 @@ inline off_t lseekMock(int fd, off_t offset, int whence) noexcept {
lseekCalledCount++;
return lseekReturn;
}
inline int closeMock(int) {
inline int closeMock(int fd) {
closeInputFd = fd;
closeCalledCount++;
return 0;
}