mirror of
https://github.com/intel/compute-runtime.git
synced 2026-01-08 22:12:59 +08:00
Test: Refactor ioctl mock call to be more deterministic
Add flag forceExtraIoctlDuration for controlling duration in ioctl ULT call. Related-To: NEO-6537 Signed-off-by: Krzysztof Gibala <krzysztof.gibala@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
31b2433b2f
commit
f6dae5ecf2
@@ -256,21 +256,10 @@ TEST_F(DrmFailedIoctlTests, givenPrintIoctlEntriesWhenCallFailedIoctlThenExpecte
|
||||
TEST_F(DrmSimpleTests, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathered) {
|
||||
struct DrmMock : public Drm {
|
||||
using Drm::ioctlStatistics;
|
||||
|
||||
int ioctl(unsigned long request, void *arg) override {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
std::chrono::steady_clock::time_point end;
|
||||
|
||||
do {
|
||||
end = std::chrono::steady_clock::now();
|
||||
} while (std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count() == 0);
|
||||
|
||||
return Drm::ioctl(request, arg);
|
||||
}
|
||||
};
|
||||
|
||||
constexpr long long initialMin = std::numeric_limits<long long>::max();
|
||||
constexpr long long initialMax = 0;
|
||||
constexpr long long initialMax = std::numeric_limits<long long>::min();
|
||||
|
||||
auto executionEnvironment = std::make_unique<ExecutionEnvironment>();
|
||||
executionEnvironment->prepareRootDeviceEnvironments(1);
|
||||
@@ -278,6 +267,7 @@ TEST_F(DrmSimpleTests, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathere
|
||||
|
||||
DebugManagerStateRestore restorer;
|
||||
DebugManager.flags.PrintIoctlTimes.set(true);
|
||||
VariableBackup<decltype(forceExtraIoctlDuration)> backupForceExtraIoctlDuration(&forceExtraIoctlDuration, true);
|
||||
|
||||
EXPECT_TRUE(drm->ioctlStatistics.empty());
|
||||
|
||||
@@ -299,7 +289,8 @@ TEST_F(DrmSimpleTests, givenPrintIoctlTimesWhenCallIoctlThenStatisticsAreGathere
|
||||
EXPECT_EQ(2u, euTotalData->second.count);
|
||||
EXPECT_NE(0, euTotalData->second.totalTime);
|
||||
EXPECT_NE(initialMin, euTotalData->second.minTime);
|
||||
EXPECT_NE(initialMax, euTotalData->second.minTime);
|
||||
EXPECT_LE(euTotalData->second.minTime, euTotalData->second.maxTime);
|
||||
EXPECT_LE(initialMax, euTotalData->second.minTime);
|
||||
EXPECT_NE(initialMin, euTotalData->second.maxTime);
|
||||
EXPECT_NE(initialMax, euTotalData->second.maxTime);
|
||||
auto firstTime = euTotalData->second.totalTime;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -42,6 +42,7 @@ int failOnDrmVersion = 0;
|
||||
int accessCalledTimes = 0;
|
||||
int readLinkCalledTimes = 0;
|
||||
int fstatCalledTimes = 0;
|
||||
bool forceExtraIoctlDuration = 0;
|
||||
char providedDrmVersion[5] = {'i', '9', '1', '5', '\0'};
|
||||
uint64_t gpuTimestamp = 0;
|
||||
int ioctlSeq[8] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
@@ -270,6 +271,17 @@ int drmQueryItem(drm_i915_query *query) {
|
||||
}
|
||||
|
||||
int ioctl(int fd, unsigned long int request, ...) throw() {
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
if (forceExtraIoctlDuration) {
|
||||
auto start = std::chrono::steady_clock::now();
|
||||
std::chrono::steady_clock::time_point end;
|
||||
|
||||
do {
|
||||
end = std::chrono::steady_clock::now();
|
||||
} while ((end - start) == 0ns);
|
||||
}
|
||||
|
||||
int res;
|
||||
va_list vl;
|
||||
va_start(vl, request);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2018-2021 Intel Corporation
|
||||
* Copyright (C) 2018-2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -49,3 +49,4 @@ extern uint32_t entryIndex;
|
||||
extern int accessCalledTimes;
|
||||
extern int readLinkCalledTimes;
|
||||
extern int fstatCalledTimes;
|
||||
extern bool forceExtraIoctlDuration;
|
||||
|
||||
Reference in New Issue
Block a user