blob: cb0aa1e4c29f364a47a197a67e65ce91bed9669d [file] [log] [blame]
Moritz Pflanzer80fffae2017-07-05 11:02:37 +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_PRINTER
25#define ARM_COMPUTE_TEST_PRINTER
26
Moritz Pflanzera09de0c2017-09-01 20:41:12 +010027#include "tests/framework/Profiler.h"
Moritz Pflanzer80fffae2017-07-05 11:02:37 +010028
29#include <fstream>
30#include <iostream>
31#include <ostream>
Moritz Pflanzer24a82462017-08-04 11:34:44 +010032#include <stdexcept>
Moritz Pflanzer80fffae2017-07-05 11:02:37 +010033
34namespace arm_compute
35{
36namespace test
37{
38namespace framework
39{
Moritz Pflanzer542002c2017-07-26 16:03:58 +010040struct TestInfo;
41
Moritz Pflanzer80fffae2017-07-05 11:02:37 +010042/** Abstract printer class used by the @ref Framework to present output. */
43class Printer
44{
45public:
46 /** Default constructor.
47 *
48 * Prints values to std::cout.
49 * */
50 Printer() = default;
51
52 /** Construct printer with given output stream.
53 *
54 * @param[out] stream Output stream.
55 */
56 Printer(std::ostream &stream);
57
58 Printer(const Printer &) = delete;
59 Printer &operator=(const Printer &) = delete;
60 Printer(Printer &&) = default;
61 Printer &operator=(Printer &&) = default;
62
63 virtual ~Printer() = default;
64
65 /** Print given string.
66 *
67 * @param[in] str String.
68 */
69 void print(const std::string &str);
70
71 /** Print an entry consisting of a (name, value) pair.
72 *
73 * @param[in] name Description of the value.
74 * @param[in] value Value.
75 */
76 virtual void print_entry(const std::string &name, const std::string &value) = 0;
77
78 /** Print global header. */
79 virtual void print_global_header() = 0;
80
81 /** Print global footer. */
82 virtual void print_global_footer() = 0;
83
84 /** Print header before running all tests. */
85 virtual void print_run_header() = 0;
86
87 /** Print footer after running all tests. */
88 virtual void print_run_footer() = 0;
89
90 /** Print header before a test.
91 *
Moritz Pflanzer542002c2017-07-26 16:03:58 +010092 * @param[in] info Test info.
Moritz Pflanzer80fffae2017-07-05 11:02:37 +010093 */
Moritz Pflanzer542002c2017-07-26 16:03:58 +010094 virtual void print_test_header(const TestInfo &info) = 0;
Moritz Pflanzer80fffae2017-07-05 11:02:37 +010095
96 /** Print footer after a test. */
97 virtual void print_test_footer() = 0;
98
Moritz Pflanzer24a82462017-08-04 11:34:44 +010099 /** Print header before errors. */
100 virtual void print_errors_header() = 0;
101
102 /** Print footer after errors. */
103 virtual void print_errors_footer() = 0;
104
Anthony Barbierdbfb31c2017-11-24 11:24:45 +0000105 /** Print the list of all the tests
106 *
107 * @param[in] infos List of tests to print
108 */
109 virtual void print_list_tests(const std::vector<TestInfo> &infos) = 0;
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100110 /** Print test error.
111 *
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100112 * @param[in] error Description of the error.
113 * @param[in] expected Whether the error was expected or not.
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100114 */
Moritz Pflanzer5b61fd32017-09-12 15:51:33 +0100115 virtual void print_error(const std::exception &error, bool expected) = 0;
Moritz Pflanzer24a82462017-08-04 11:34:44 +0100116
steniu01172c58d2017-08-31 13:49:08 +0100117 /** Print test log info.
118 *
119 * @param[in] info Description of the log.
120 */
121 virtual void print_info(const std::string &info) = 0;
122
Moritz Pflanzer80fffae2017-07-05 11:02:37 +0100123 /** Print measurements for a test.
124 *
125 * @param[in] measurements Measurements as collected by a @ref Profiler.
126 */
127 virtual void print_measurements(const Profiler::MeasurementsMap &measurements) = 0;
128
129 /** Set the output stream.
130 *
131 * @param[out] stream Output stream.
132 */
133 void set_stream(std::ostream &stream);
134
135protected:
136 std::ostream *_stream{ &std::cout };
137};
138} // namespace framework
139} // namespace test
140} // namespace arm_compute
141#endif /* ARM_COMPUTE_TEST_PRINTER */