test: reduce file system usage in L0 tools/sysman tests

Signed-off-by: Mateusz Jablonski <mateusz.jablonski@intel.com>
This commit is contained in:
Mateusz Jablonski
2025-07-04 13:07:20 +00:00
committed by Compute-Runtime-Automation
parent a4ba6a2131
commit 689839143c
4 changed files with 18 additions and 11 deletions

View File

@@ -441,8 +441,10 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupSu
pPublicLinuxDiagnosticsImp->pLinuxSysmanImp = pMockDiagLinuxSysmanImp.get();
pMockDiagProcfsAccess->ourDevicePid = getpid();
pMockDiagLinuxSysmanImp->ourDevicePid = getpid();
pMockDiagLinuxSysmanImp->ourDeviceFd = NEO::SysCalls::open("/dev/null", 0);
constexpr auto deviceFd = 0xF00;
pMockDiagLinuxSysmanImp->ourDeviceFd = deviceFd;
EXPECT_EQ(ZE_RESULT_SUCCESS, pPublicLinuxDiagnosticsImp->pLinuxSysmanImp->gpuProcessCleanup(true));
EXPECT_EQ(deviceFd, NEO::SysCalls::closeFuncArgPassed);
}
TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupFailsThenWaitForQuiescentCompletionsFails) {

View File

@@ -1003,8 +1003,10 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
// Pretend we have the device open
pProcfsAccess->ourDevicePid = getpid();
pProcfsAccess->ourDeviceFd = ::open("/dev/null", 0);
constexpr auto deviceFd = 0xF00;
pProcfsAccess->ourDeviceFd = deviceFd;
NEO::SysCalls::closeFuncCalled = 0u;
// The first time we get the process list, include our own process, that has the file open
// Reset should close the file (we verify after reset). On subsequent calls, return
// the process list without our process
@@ -1015,9 +1017,8 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
ze_result_t result = zesDeviceReset(device, false);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
// Check that reset closed the device
// If the device is already closed, then close will fail with errno of EBADF
EXPECT_NE(0, ::close(pProcfsAccess->ourDevicePid));
EXPECT_EQ(errno, EBADF);
EXPECT_LT(0u, NEO::SysCalls::closeFuncCalled);
EXPECT_EQ(deviceFd, NEO::SysCalls::closeFuncArgPassed);
}
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {

View File

@@ -500,8 +500,10 @@ TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupSu
pMockDiagProcfsAccess->ourDevicePid = getpid();
pMockDiagLinuxSysmanImp->ourDevicePid = getpid();
pMockDiagLinuxSysmanImp->ourDeviceFd = ::open("/dev/null", 0);
constexpr auto deviceFd = 0xF00;
pMockDiagLinuxSysmanImp->ourDeviceFd = deviceFd;
EXPECT_EQ(ZE_RESULT_SUCCESS, pPublicLinuxDiagnosticsImp->pLinuxSysmanImp->gpuProcessCleanup(true));
EXPECT_EQ(deviceFd, NEO::SysCalls::closeFuncArgPassed);
}
TEST_F(ZesDiagnosticsFixture, GivenValidDiagnosticsHandleWhenGPUProcessCleanupFailsThenWaitForQuiescentCompletionsFails) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2020-2024 Intel Corporation
* Copyright (C) 2020-2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
@@ -906,8 +906,11 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
// Pretend we have the device open
pProcfsAccess->ourDevicePid = getpid();
pProcfsAccess->ourDeviceFd = ::open("/dev/null", 0);
constexpr auto deviceFd = 0xF00;
pProcfsAccess->ourDeviceFd = deviceFd;
NEO::SysCalls::closeFuncCalled = 0u;
// The first time we get the process list, include our own process, that has the file open
// Reset should close the file (we verify after reset). On subsequent calls, return
// the process list without our process
@@ -918,9 +921,8 @@ TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenDeviceNotInUseWhenCallingRe
ze_result_t result = zesDeviceReset(device, false);
EXPECT_EQ(ZE_RESULT_SUCCESS, result);
// Check that reset closed the device
// If the device is already closed, then close will fail with errno of EBADF
EXPECT_NE(0, ::close(pProcfsAccess->ourDevicePid));
EXPECT_EQ(errno, EBADF);
EXPECT_LT(0u, NEO::SysCalls::closeFuncCalled);
EXPECT_EQ(deviceFd, NEO::SysCalls::closeFuncArgPassed);
}
TEST_F(SysmanGlobalOperationsIntegratedFixture, GivenForceTrueAndDeviceInUseWhenCallingResetThenSuccessIsReturned) {