Skip to content

Commit 5d4771a

Browse files
Add param to print number of tests
Related-To: NEO-6407 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 9dabc2d commit 5d4771a

File tree

5 files changed

+62
-2
lines changed

5 files changed

+62
-2
lines changed

level_zero/core/test/unit_tests/main.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "shared/test/common/mocks/mock_gmm_client_context.h"
2222
#include "shared/test/common/mocks/mock_sip.h"
2323
#include "shared/test/unit_test/base_ult_config_listener.h"
24+
#include "shared/test/unit_test/test_stats.h"
2425

2526
#include "level_zero/core/source/cmdlist/cmdlist.h"
2627
#include "level_zero/core/source/compiler_interface/l0_reg_path.h"
@@ -146,6 +147,7 @@ void applyWorkarounds() {
146147
int main(int argc, char **argv) {
147148
bool useDefaultListener = false;
148149
bool setupFeatureTableAndWorkaroundTable = testMode == TestMode::AubTests ? true : false;
150+
bool showTestStats = false;
149151
applyWorkarounds();
150152

151153
testing::InitGoogleMock(&argc, argv);
@@ -230,9 +232,16 @@ int main(int argc, char **argv) {
230232
}
231233
} else if (!strcmp("--enable_default_listener", argv[i])) {
232234
useDefaultListener = true;
235+
} else if (!strcmp("--show_test_stats", argv[i])) {
236+
showTestStats = true;
233237
}
234238
}
235239

240+
if (showTestStats) {
241+
std::cout << getTestStats() << std::endl;
242+
return 0;
243+
}
244+
236245
productFamily = hwInfoForTests.platform.eProductFamily;
237246
renderCoreFamily = hwInfoForTests.platform.eRenderCoreFamily;
238247
uint32_t threadsPerEu = hwInfoConfigFactory[productFamily]->threadsPerEu;

opencl/test/unit_test/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "shared/test/common/mocks/mock_gmm_client_context.h"
2323
#include "shared/test/common/mocks/mock_sip.h"
2424
#include "shared/test/common/test_macros/test_checks_shared.h"
25+
#include "shared/test/unit_test/test_stats.h"
2526
#include "shared/test/unit_test/tests_configuration.h"
2627

2728
#include "opencl/source/os_interface/ocl_reg_path.h"
@@ -195,7 +196,7 @@ int main(int argc, char **argv) {
195196
bool enable_alarm = true;
196197
bool enable_abrt = true;
197198
bool setupFeatureTableAndWorkaroundTable = testMode == TestMode::AubTests ? true : false;
198-
199+
bool showTestStats = false;
199200
applyWorkarounds();
200201

201202
#if defined(__linux__)
@@ -242,6 +243,8 @@ int main(int argc, char **argv) {
242243
useDefaultListener = true;
243244
} else if (!strcmp("--disable_alarm", argv[i])) {
244245
enable_alarm = false;
246+
} else if (!strcmp("--show_test_stats", argv[i])) {
247+
showTestStats = true;
245248
} else if (!strcmp("--disable_pagefaulting_tests", argv[i])) { //disable tests which raise page fault signal during execution
246249
NEO::PagaFaultManagerTestConfig::disabled = true;
247250
} else if (!strcmp("--tbx", argv[i])) {
@@ -323,6 +326,11 @@ int main(int argc, char **argv) {
323326
}
324327
}
325328

329+
if (showTestStats) {
330+
std::cout << getTestStats() << std::endl;
331+
return 0;
332+
}
333+
326334
productFamily = hwInfoForTests.platform.eProductFamily;
327335
renderCoreFamily = hwInfoForTests.platform.eRenderCoreFamily;
328336
uint32_t threadsPerEu = hwInfoConfigFactory[productFamily]->threadsPerEu;

opencl/test/unit_test/offline_compiler/main.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "shared/source/os_interface/os_library.h"
99
#include "shared/test/common/helpers/custom_event_listener.h"
1010
#include "shared/test/common/helpers/test_files.h"
11+
#include "shared/test/unit_test/test_stats.h"
1112

1213
#include "environment.h"
1314
#include "limits.h"
@@ -37,6 +38,8 @@ std::string getRunPath() {
3738
int main(int argc, char **argv) {
3839
int retVal = 0;
3940
bool useDefaultListener = false;
41+
bool showTestStats = false;
42+
4043
std::string devicePrefix("skl");
4144
std::string familyNameWithType("Gen9core");
4245
std::string revId("0");
@@ -76,10 +79,17 @@ int main(int argc, char **argv) {
7679
} else if (strcmp("--rev_id", argv[i]) == 0) {
7780
++i;
7881
revId = argv[i];
82+
} else if (!strcmp("--show_test_stats", argv[i])) {
83+
showTestStats = true;
7984
}
8085
}
8186
}
8287

88+
if (showTestStats) {
89+
std::cout << getTestStats() << std::endl;
90+
return 0;
91+
}
92+
8393
for (unsigned int productId = 0; productId < IGFX_MAX_PRODUCT; ++productId) {
8494
if (NEO::hardwarePrefix[productId] && (0 == strcmp(devicePrefix.c_str(), NEO::hardwarePrefix[productId]))) {
8595
if (NEO::hardwareInfoTable[productId]) {

shared/test/unit_test/main.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "shared/test/common/mocks/mock_sip.h"
2525
#include "shared/test/common/test_macros/test_checks_shared.h"
2626
#include "shared/test/unit_test/base_ult_config_listener.h"
27+
#include "shared/test/unit_test/test_stats.h"
2728
#include "shared/test/unit_test/tests_configuration.h"
2829

2930
#include "gmock/gmock.h"
@@ -180,7 +181,7 @@ int main(int argc, char **argv) {
180181
bool useDefaultListener = false;
181182
bool enable_alarm = true;
182183
bool setupFeatureTableAndWorkaroundTable = testMode == TestMode::AubTests ? true : false;
183-
184+
bool showTestStats = false;
184185
applyWorkarounds();
185186

186187
#if defined(__linux__)
@@ -220,6 +221,8 @@ int main(int argc, char **argv) {
220221
useDefaultListener = true;
221222
} else if (!strcmp("--disable_alarm", argv[i])) {
222223
enable_alarm = false;
224+
} else if (!strcmp("--show_test_stats", argv[i])) {
225+
showTestStats = true;
223226
} else if (!strcmp("--disable_pagefaulting_tests", argv[i])) { //disable tests which raise page fault signal during execution
224227
NEO::PagaFaultManagerTestConfig::disabled = true;
225228
} else if (!strcmp("--tbx", argv[i])) {
@@ -301,6 +304,11 @@ int main(int argc, char **argv) {
301304
}
302305
}
303306

307+
if (showTestStats) {
308+
std::cout << getTestStats() << std::endl;
309+
return 0;
310+
}
311+
304312
productFamily = hwInfoForTests.platform.eProductFamily;
305313
renderCoreFamily = hwInfoForTests.platform.eRenderCoreFamily;
306314
uint32_t threadsPerEu = hwInfoConfigFactory[productFamily]->threadsPerEu;

shared/test/unit_test/test_stats.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (C) 2021 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: MIT
5+
*
6+
*/
7+
8+
#pragma once
9+
#include "gmock/gmock.h"
10+
11+
#include <sstream>
12+
#include <string>
13+
14+
std::string getTestStats() {
15+
std::string output;
16+
std::stringstream stream;
17+
18+
stream << "Total test count: " << ::testing::UnitTest::GetInstance()->total_test_count() << std::endl;
19+
stream << "Test to run count: " << ::testing::UnitTest::GetInstance()->test_to_run_count() << std::endl;
20+
stream << "Reportable test count: " << ::testing::UnitTest::GetInstance()->reportable_test_count() << std::endl;
21+
stream << "Disabled test count: " << ::testing::UnitTest::GetInstance()->disabled_test_count() << std::endl;
22+
stream << "Reportable disabled test count: " << ::testing::UnitTest::GetInstance()->reportable_disabled_test_count() << std::endl;
23+
24+
return stream.str();
25+
}

0 commit comments

Comments
 (0)