Skip to content

Commit c7daa7a

Browse files
test: add per test case timeout
fail unit test when takes more than 5s fail aub test when takes more than 20s add mechanism to control timeout per aub/mt/unit test disable tests with fstream Related-To: NEO-7006 Signed-off-by: Mateusz Jablonski <[email protected]>
1 parent 8c8bb23 commit c7daa7a

File tree

12 files changed

+110
-12
lines changed

12 files changed

+110
-12
lines changed

opencl/test/unit_test/event/event_tracker_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@ TEST(EventsTracker, givenTwoEventsWithCommonParentEventThenDumpingProperGraph) {
441441
uEvent.setStatus(0);
442442
}
443443

444-
TEST(EventsTracker, whenCalingCreateDumpStreamThenGettingValidFstreamInstance) {
444+
TEST(EventsTracker, DISABLED_whenCalingCreateDumpStreamThenGettingValidFstreamInstance) {
445445
std::string testFileName("EventsTracker_testfile.gv");
446446
std::shared_ptr<std::ostream> stream = EventsTracker::getEventsTracker().createDumpStream(testFileName);
447447

opencl/test/unit_test/linux/main_linux_dll.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,9 +818,9 @@ TEST(SysCalls, WhenSysCallsGetNumThreadsCalledThenCallIsRedirectedToOs) {
818818
EXPECT_GT(result, 0u);
819819
}
820820

821+
bool enableAlarm = true;
821822
int main(int argc, char **argv) {
822823
bool useDefaultListener = false;
823-
bool enableAlarm = true;
824824

825825
::testing::InitGoogleTest(&argc, argv);
826826

opencl/test/unit_test/mt_tests/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ add_executable(igdrcl_mt_tests EXCLUDE_FROM_ALL
1717
$<TARGET_OBJECTS:neo_libult_cs>
1818
$<TARGET_OBJECTS:neo_libult>
1919
$<TARGET_OBJECTS:neo_shared_mocks>
20-
$<TARGET_OBJECTS:neo_unit_tests_config>
20+
$<TARGET_OBJECTS:neo_mt_tests_config>
2121
$<TARGET_OBJECTS:igdrcl_libult_env>
2222
$<TARGET_OBJECTS:mock_gmm>
2323
$<TARGET_OBJECTS:${BUILTINS_SOURCES_LIB_NAME}>
2424
)
2525

2626
target_include_directories(igdrcl_mt_tests PRIVATE
27-
${NEO_SHARED_TEST_DIRECTORY}/common/test_configuration/unit_tests
27+
${NEO_SHARED_TEST_DIRECTORY}/common/test_configuration/mt_tests
2828
${NEO_SHARED_TEST_DIRECTORY}/common/test_macros/header${BRANCH_DIR_SUFFIX}
2929
${NEO_SHARED_TEST_DIRECTORY}/common/helpers/includes${BRANCH_DIR_SUFFIX}
3030
${NEO_SOURCE_DIR}/opencl/source/gen_common

shared/test/common/base_ult_config_listener.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,26 @@
1212

1313
#include "aubstream/aubstream.h"
1414

15-
void NEO::BaseUltConfigListener::OnTestStart(const ::testing::TestInfo &) {
15+
extern bool enableAlarm;
16+
17+
namespace NEO {
18+
19+
extern unsigned int testCaseMaxTimeInMs;
20+
21+
void BaseUltConfigListener::OnTestStart(const ::testing::TestInfo &) {
1622
debugVarSnapshot = DebugManager.flags;
1723
injectFcnSnapshot = DebugManager.injectFcn;
1824

1925
referencedHwInfo = *defaultHwInfo;
26+
testStart = std::chrono::steady_clock::now();
2027
}
2128

22-
void NEO::BaseUltConfigListener::OnTestEnd(const ::testing::TestInfo &) {
29+
void BaseUltConfigListener::OnTestEnd(const ::testing::TestInfo &) {
30+
auto testEnd = std::chrono::steady_clock::now();
31+
32+
if (enableAlarm) {
33+
EXPECT_LT(std::chrono::duration_cast<std::chrono::milliseconds>(testEnd - testStart).count(), testCaseMaxTimeInMs);
34+
}
2335
aub_stream::injectMMIOList(aub_stream::MMIOList{});
2436

2537
#undef DECLARE_DEBUG_VARIABLE
@@ -44,3 +56,4 @@ void NEO::BaseUltConfigListener::OnTestEnd(const ::testing::TestInfo &) {
4456
EXPECT_EQ(1, referencedHwInfo.workaroundTable.asHash() == defaultHwInfo->workaroundTable.asHash());
4557
EXPECT_EQ(1, referencedHwInfo.capabilityTable == defaultHwInfo->capabilityTable);
4658
}
59+
} // namespace NEO

shared/test/common/base_ult_config_listener.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2020-2022 Intel Corporation
2+
* Copyright (C) 2020-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -11,6 +11,8 @@
1111

1212
#include "gtest/gtest.h"
1313

14+
#include <chrono>
15+
1416
namespace NEO {
1517

1618
class BaseUltConfigListener : public ::testing::EmptyTestEventListener {
@@ -22,6 +24,7 @@ class BaseUltConfigListener : public ::testing::EmptyTestEventListener {
2224
DebugVariables debugVarSnapshot;
2325
void *injectFcnSnapshot = nullptr;
2426
HardwareInfo referencedHwInfo;
27+
std::chrono::steady_clock::time_point testStart{};
2528
};
2629

2730
} // namespace NEO

shared/test/common/common_main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,11 @@ void applyCommonWorkarounds() {
133133
}
134134
}
135135

136+
bool enableAlarm = true;
136137
int main(int argc, char **argv) {
137138
int retVal = 0;
138139
bool useDefaultListener = false;
139140
bool enableAbrt = true;
140-
bool enableAlarm = true;
141141
bool enableSegv = true;
142142
bool showTestStats = false;
143143
bool dumpTestStats = false;

shared/test/common/test_configuration/aub_tests/aub_tests_configuration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2018-2021 Intel Corporation
2+
* Copyright (C) 2018-2023 Intel Corporation
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -10,6 +10,7 @@
1010
namespace NEO {
1111
// max time per single test iteration
1212
unsigned int ultIterationMaxTime = 180;
13+
unsigned int testCaseMaxTimeInMs = 20000;
1314
bool useMockGmm = false;
1415
const char *executionDirectorySuffix = "_aub";
1516
const char *executionName = "AUB";
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (C) 2021-2023 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
7+
set(NEO_SHARED_mt_tests_configurations
8+
${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
9+
${CMAKE_CURRENT_SOURCE_DIR}/mt_test_configuration.cpp
10+
${CMAKE_CURRENT_SOURCE_DIR}/test_mode.h
11+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/mock_gmm_resource_info_common.cpp
12+
)
13+
if(WIN32)
14+
list(APPEND NEO_SHARED_mt_tests_configurations
15+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/gmm_memory${BRANCH_DIR_SUFFIX}mock_gmm_memory.h
16+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/mock_gmm_memory_base.cpp
17+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/mock_gmm_memory_base.h
18+
${NEO_SHARED_TEST_DIRECTORY}/common/os_interface/windows/os_memory_virtual_alloc_ult.cpp
19+
)
20+
elseif(UNIX AND NOT DISABLE_WDDM_LINUX)
21+
list(APPEND NEO_SHARED_mt_tests_configurations
22+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/gmm_memory/mock_gmm_memory.h
23+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/mock_gmm_memory_base.cpp
24+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/mock_gmm_memory_base.h
25+
)
26+
endif()
27+
list(APPEND NEO_SHARED_mt_tests_configurations
28+
${NEO_SHARED_TEST_DIRECTORY}/common/aub_stream_mocks/aub_stream_interface_mock.cpp
29+
)
30+
add_library(neo_mt_tests_config OBJECT EXCLUDE_FROM_ALL ${NEO_SHARED_mt_tests_configurations})
31+
32+
set_target_properties(neo_mt_tests_config PROPERTIES POSITION_INDEPENDENT_CODE ON)
33+
set_target_properties(neo_mt_tests_config PROPERTIES FOLDER ${SHARED_TEST_PROJECTS_FOLDER})
34+
set_property(TARGET neo_mt_tests_config APPEND_STRING PROPERTY COMPILE_FLAGS ${ASAN_FLAGS} ${TSAN_FLAGS})
35+
target_include_directories(neo_mt_tests_config PRIVATE
36+
$<TARGET_PROPERTY:${NEO_SHARED_MOCKABLE_LIB_NAME},INTERFACE_INCLUDE_DIRECTORIES>
37+
$<TARGET_PROPERTY:gmock-gtest,INTERFACE_INCLUDE_DIRECTORIES>
38+
)
39+
if(WIN32)
40+
target_include_directories(neo_mt_tests_config PRIVATE
41+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/gmm_memory${BRANCH_DIR_SUFFIX}
42+
)
43+
elseif(NOT DISABLE_WDDM_LINUX)
44+
target_include_directories(neo_mt_tests_config PRIVATE
45+
${NEO_SHARED_TEST_DIRECTORY}/common/mocks/windows/gmm_memory
46+
)
47+
endif()
48+
target_compile_definitions(neo_mt_tests_config PRIVATE $<TARGET_PROPERTY:${NEO_SHARED_MOCKABLE_LIB_NAME},INTERFACE_COMPILE_DEFINITIONS>)
49+
create_project_source_tree(neo_mt_tests_config)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* Copyright (C) 2018-2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#include "test_mode.h"
9+
10+
namespace NEO {
11+
unsigned int ultIterationMaxTime = 45;
12+
unsigned int testCaseMaxTimeInMs = 5000;
13+
bool useMockGmm = true;
14+
const char *executionDirectorySuffix = "";
15+
const char *executionName = "MT";
16+
TestMode testMode = defaultTestMode;
17+
} // namespace NEO
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (C) 2019-2023 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
10+
#include "shared/test/common/tests_configuration.h"
11+
12+
namespace NEO {
13+
inline constexpr TestMode defaultTestMode = TestMode::UnitTests;
14+
} // namespace NEO

0 commit comments

Comments
 (0)