Skip to content

Commit e575785

Browse files
committed
test: Add warning level logging to the test framework
We add another level of logging between ERRORS and INFO/DEBUG because we print skipped tests with INFO level logging and they don't appear in CI. Reporting if they're skipped or not is useful when trying to understand if the CI is running the correct set of tests or not on a given hardware. INFO level debugging is too heavy for CI output because it prints every tensor value mismatch if there are failing tests and this could be miliions, thus it's not a good option. After this commit, we'll also change test skip reports to warning level in various places and also change the CI to log at warning level instead of error level. Change-Id: I4de2859b6987778d9b228fd96c2336c4ce056079 Signed-off-by: Gunes Bayir <gunes.bayir@arm.com>
1 parent 823f75e commit e575785

11 files changed

Lines changed: 128 additions & 15 deletions

File tree

tests/framework/Asserts.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2022, 2025 Arm Limited.
2+
* Copyright (c) 2017-2022, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -68,13 +68,28 @@ inline void ARM_COMPUTE_PRINT_INFO()
6868
arm_compute::test::framework::Framework::get().clear_test_info();
6969
}
7070

71+
inline void ARM_COMPUTE_PRINT_WARNING()
72+
{
73+
std::stringstream msg;
74+
arm_compute::test::framework::Framework::get().print_test_warning(msg);
75+
arm_compute::test::framework::Framework::get().log_warning(msg.str());
76+
arm_compute::test::framework::Framework::get().clear_test_warning();
77+
}
78+
7179
#define ARM_COMPUTE_TEST_INFO(INFO) \
7280
{ \
7381
std::stringstream info; \
7482
info << INFO; \
7583
arm_compute::test::framework::Framework::get().add_test_info(info.str()); \
7684
}
7785

86+
#define ARM_COMPUTE_TEST_WARNING(WARNING) \
87+
{ \
88+
std::stringstream warning; \
89+
warning << WARNING; \
90+
arm_compute::test::framework::Framework::get().add_test_warning(warning.str()); \
91+
}
92+
7893
namespace detail
7994
{
8095
#define ARM_COMPUTE_TEST_COMP_FACTORY(SEVERITY, SEVERITY_NAME, COMP, COMP_NAME, ERROR_CALL) \

tests/framework/Exceptions.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017, 2025 Arm Limited.
2+
* Copyright (c) 2017, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -36,8 +36,13 @@ namespace framework
3636
LogLevel log_level_from_name(const std::string &name)
3737
{
3838
static const std::map<std::string, LogLevel> levels = {
39-
{"none", LogLevel::NONE}, {"config", LogLevel::CONFIG}, {"tests", LogLevel::TESTS},
40-
{"errors", LogLevel::ERRORS}, {"debug", LogLevel::DEBUG}, {"measurements", LogLevel::MEASUREMENTS},
39+
{"none", LogLevel::NONE},
40+
{"config", LogLevel::CONFIG},
41+
{"tests", LogLevel::TESTS},
42+
{"errors", LogLevel::ERRORS},
43+
{"warnings", LogLevel::WARNINGS},
44+
{"debug", LogLevel::DEBUG},
45+
{"measurements", LogLevel::MEASUREMENTS},
4146
{"all", LogLevel::ALL},
4247
};
4348

@@ -75,6 +80,9 @@ ::std::ostream &operator<<(::std::ostream &stream, LogLevel level)
7580
case LogLevel::ERRORS:
7681
stream << "ERRORS";
7782
break;
83+
case LogLevel::WARNINGS:
84+
stream << "WARNINGS";
85+
break;
7886
case LogLevel::DEBUG:
7987
stream << "DEBUG";
8088
break;

tests/framework/Exceptions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2018, 2025 Arm Limited.
2+
* Copyright (c) 2017-2018, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -42,6 +42,7 @@ namespace framework
4242
* NONE == Only for filtering. Not used to tag information.
4343
* CONFIG == Configuration info.
4444
* TESTS == Information about the tests.
45+
* WARNINGS == Warnings, such as skipped tests.
4546
* ERRORS == Violated assertions/expectations.
4647
* DEBUG == More violated assertions/expectations.
4748
* MEASUREMENTS == Information about measurements.
@@ -53,6 +54,7 @@ enum class LogLevel
5354
CONFIG,
5455
TESTS,
5556
ERRORS,
57+
WARNINGS,
5658
DEBUG,
5759
MEASUREMENTS,
5860
ALL,

tests/framework/Framework.cpp

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2021, 2023-2025 Arm Limited.
2+
* Copyright (c) 2017-2021, 2023-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -230,6 +230,34 @@ void Framework::print_test_info(std::ostream &os) const
230230
}
231231
}
232232

233+
void Framework::add_test_warning(std::string warning)
234+
{
235+
_test_warning.emplace_back(std::move(warning));
236+
}
237+
238+
void Framework::clear_test_warning()
239+
{
240+
_test_warning.clear();
241+
}
242+
243+
bool Framework::has_test_warning() const
244+
{
245+
return !_test_warning.empty();
246+
}
247+
248+
void Framework::print_test_warning(std::ostream &os) const
249+
{
250+
if (!_test_warning.empty())
251+
{
252+
os << "CONTEXT:\n";
253+
254+
for (const auto &str : _test_warning)
255+
{
256+
os << " " << str << "\n";
257+
}
258+
}
259+
}
260+
233261
template <typename F>
234262
void Framework::func_on_all_printers(F &&func)
235263
{
@@ -290,6 +318,14 @@ void Framework::log_info(const std::string &info)
290318
}
291319
}
292320

321+
void Framework::log_warning(const std::string &warning)
322+
{
323+
if (_log_level >= LogLevel::WARNINGS)
324+
{
325+
func_on_all_printers([&](Printer *p) { p->print_warning(warning); });
326+
}
327+
}
328+
293329
int Framework::num_iterations() const
294330
{
295331
return _num_iterations;

tests/framework/Framework.h

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2021, 2023-2025 Arm Limited.
2+
* Copyright (c) 2017-2021, 2023-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -176,6 +176,27 @@ class Framework final
176176
*/
177177
void print_test_info(std::ostream &os) const;
178178

179+
/** Add warning string for the next expectation/assertion.
180+
*
181+
* @param[in] info Warning string.
182+
*/
183+
void add_test_warning(std::string warning);
184+
185+
/** Clear the collected test warning. */
186+
void clear_test_warning();
187+
188+
/** Check if any warning has been registered.
189+
*
190+
* @return True if there is test warning.
191+
*/
192+
bool has_test_warning() const;
193+
194+
/** Print test warning.
195+
*
196+
* @param[out] os Output stream.
197+
*/
198+
void print_test_warning(std::ostream &os) const;
199+
179200
/** Tell the framework that execution of a test starts.
180201
*
181202
* @param[in] info Test info.
@@ -206,6 +227,12 @@ class Framework final
206227
*/
207228
void log_info(const std::string &info);
208229

230+
/** Print the warnings that has already been logged
231+
*
232+
* @param[in] info Description of the log warning.
233+
*/
234+
void log_warning(const std::string &warning);
235+
209236
/** Number of iterations per test case.
210237
*
211238
* @return Number of iterations per test case.
@@ -406,6 +433,7 @@ class Framework final
406433
const TestInfo *_current_test_info{nullptr};
407434
TestResult *_current_test_result{nullptr};
408435
std::vector<std::string> _test_info{};
436+
std::vector<std::string> _test_warning{};
409437
};
410438

411439
template <typename T>

tests/framework/command_line/CommonOptions.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2018-2020,2024-2025 Arm Limited.
2+
* Copyright (c) 2018-2020,2024-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -74,8 +74,8 @@ CommonOptions::CommonOptions(CommandLineParser &parser)
7474
};
7575

7676
std::set<LogLevel> supported_log_levels{
77-
LogLevel::NONE, LogLevel::CONFIG, LogLevel::TESTS, LogLevel::ERRORS,
78-
LogLevel::DEBUG, LogLevel::MEASUREMENTS, LogLevel::ALL,
77+
LogLevel::NONE, LogLevel::CONFIG, LogLevel::TESTS, LogLevel::ERRORS,
78+
LogLevel::WARNINGS, LogLevel::DEBUG, LogLevel::MEASUREMENTS, LogLevel::ALL,
7979
};
8080

8181
instruments = parser.add_option<EnumListOption<InstrumentsDescription>>(

tests/framework/printers/JSONPrinter.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019,2021, 2025 Arm Limited.
2+
* Copyright (c) 2017-2019,2021, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -132,6 +132,7 @@ void JSONPrinter::print_errors_header()
132132
{
133133
_errors.clear();
134134
_expected_errors.clear();
135+
_warnings.clear();
135136
_infos.clear();
136137
}
137138

@@ -147,6 +148,10 @@ void JSONPrinter::print_errors_footer()
147148
print_strings(_expected_errors.begin(), _expected_errors.end());
148149
*_stream << "]";
149150

151+
*_stream << R"(, "warnings" : [)";
152+
print_strings(_warnings.begin(), _warnings.end());
153+
*_stream << "]";
154+
150155
*_stream << R"(, "infos" : [)";
151156
print_strings(_infos.begin(), _infos.end());
152157
*_stream << "]";
@@ -164,6 +169,11 @@ void JSONPrinter::print_error(const std::exception &error, bool expected)
164169
}
165170
}
166171

172+
void JSONPrinter::print_warning(const std::string &warning)
173+
{
174+
_warnings.push_back(warning);
175+
}
176+
167177
void JSONPrinter::print_info(const std::string &info)
168178
{
169179
_infos.push_back(info);

tests/framework/printers/JSONPrinter.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017,2021, 2025 Arm Limited.
2+
* Copyright (c) 2017,2021, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -49,6 +49,7 @@ class JSONPrinter : public Printer
4949
void print_errors_header() override;
5050
void print_errors_footer() override;
5151
void print_error(const std::exception &error, bool expected) override;
52+
void print_warning(const std::string &warning) override;
5253
void print_info(const std::string &info) override;
5354
void print_profiler_header(const std::string &header_data) override;
5455
void print_measurements(const Profiler::MeasurementsMap &measurements) override;
@@ -60,6 +61,7 @@ class JSONPrinter : public Printer
6061
void print_strings(T &&first, T &&last);
6162

6263
std::list<std::string> _infos{};
64+
std::list<std::string> _warnings{};
6365
std::list<std::string> _errors{};
6466
std::list<std::string> _expected_errors{};
6567

tests/framework/printers/PrettyPrinter.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017-2019,2021, 2025 Arm Limited.
2+
* Copyright (c) 2017-2019,2021, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -102,6 +102,11 @@ void PrettyPrinter::print_info(const std::string &info)
102102
*_stream << begin_color("1") << "INFO: " << info << end_color() << "\n";
103103
}
104104

105+
void PrettyPrinter::print_warning(const std::string &warning)
106+
{
107+
*_stream << begin_color("1") << "WARNING: " << warning << end_color() << "\n";
108+
}
109+
105110
void PrettyPrinter::print_error(const std::exception &error, bool expected)
106111
{
107112
std::string prefix = expected ? "EXPECTED ERROR: " : "ERROR: ";

tests/framework/printers/PrettyPrinter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2017,2021, 2025 Arm Limited.
2+
* Copyright (c) 2017,2021, 2025-2026 Arm Limited.
33
*
44
* SPDX-License-Identifier: MIT
55
*
@@ -54,6 +54,7 @@ class PrettyPrinter : public Printer
5454
void print_errors_header() override;
5555
void print_errors_footer() override;
5656
void print_error(const std::exception &error, bool expected) override;
57+
void print_warning(const std::string &warning) override;
5758
void print_info(const std::string &info) override;
5859
void print_profiler_header(const std::string &header_data) override;
5960
void print_measurements(const Profiler::MeasurementsMap &measurements) override;

0 commit comments

Comments
 (0)