blob: de617602dc73de08f68fde0dfcf7331c37eccbf7 [file] [log] [blame]
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +01001/*
2 * Copyright (c) 2017 ARM Limited.
3 *
4 * SPDX-License-Identifier: MIT
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to
8 * deal in the Software without restriction, including without limitation the
9 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10 * sell copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included in all
14 * copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 * SOFTWARE.
23 */
24#ifndef ARM_COMPUTE_TEST_EXCEPTIONS
25#define ARM_COMPUTE_TEST_EXCEPTIONS
26
Moritz Pflanzer2ac50402017-07-24 15:52:54 +010027#include <istream>
28#include <ostream>
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010029#include <stdexcept>
Moritz Pflanzer2ac50402017-07-24 15:52:54 +010030#include <string>
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010031
32namespace arm_compute
33{
34namespace test
35{
36namespace framework
37{
Moritz Pflanzer2ac50402017-07-24 15:52:54 +010038/** Severity of the information.
39 *
40 * Each category includes the ones above it.
41 *
42 * NONE == Only for filtering. Not used to tag information.
43 * CONFIG == Configuration info.
44 * TESTS == Information about the tests.
45 * ERRORS == Violated assertions/expectations.
46 * DEBUG == More violated assertions/expectations.
47 * MEASUREMENTS == Information about measurements.
48 * ALL == Only for filtering. Not used to tag information.
49 */
50enum class LogLevel
51{
52 NONE,
53 CONFIG,
54 TESTS,
55 ERRORS,
56 DEBUG,
57 MEASUREMENTS,
58 ALL,
59};
60
61LogLevel log_level_from_name(const std::string &name);
62::std::istream &operator>>(::std::istream &stream, LogLevel &level);
63::std::ostream &operator<<(::std::ostream &stream, LogLevel level);
64std::string to_string(LogLevel level);
65
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010066/** Error class for failures during test execution. */
67class TestError : public std::runtime_error
68{
69public:
70 using std::runtime_error::runtime_error;
Moritz Pflanzer2ac50402017-07-24 15:52:54 +010071
72 /** Construct error with severity.
73 *
74 * @param[in] msg Error message.
75 * @param[in] level Severity level.
76 */
77 TestError(const std::string &msg, LogLevel level);
78
79 /** Severity of the error.
80 *
81 * @return Severity.
82 */
83 LogLevel level() const;
84
85private:
86 LogLevel _level{ LogLevel::ERRORS };
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +010087};
88} // namespace framework
89} // namespace test
90} // namespace arm_compute
91#endif /* ARM_COMPUTE_TEST_EXCEPTIONS */