Mistake on this page?
Report an issue in GitHub or email us
utest_harness.h
1 /****************************************************************************
2  * Copyright (c) 2015, ARM Limited, All Rights Reserved
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License"); you may
6  * not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  ****************************************************************************
17  */
18 
19 #ifndef UTEST_HARNESS_H
20 #define UTEST_HARNESS_H
21 
22 #include <stdint.h>
23 #include <stdbool.h>
24 #include <stdio.h>
25 
26 #include "utest/utest_types.h"
27 #include "utest/utest_case.h"
28 #include "utest/utest_default_handlers.h"
29 #include "utest/utest_specification.h"
30 #include "utest/utest_scheduler.h"
31 
32 
33 namespace utest {
34 /** \addtogroup frameworks */
35 /** @{*/
36 namespace v1 {
37 
38  /** Test Harness.
39  *
40  * This class runs a test specification for you and calls all required handlers.
41  * The harness executes the test specification in an asynchronous fashion, therefore
42  * `run()` returns immediately.
43  *
44  * @note In case of an test abort, the harness will busy-wait and never finish.
45  */
46  class Harness
47  {
48  public:
49  /// Runs a test specification
50  /// @retval `true` if the specification can be run
51  /// @retval `false` if another specification is currently running
52  static bool run(const Specification& specification);
53 
54  /// @cond
55  __deprecated_message("Start case selection is done by returning the index from the test setup handler!")
56  static bool run(const Specification& specification, size_t start_case);
57  /// @endcond
58 
59  /// @returns `true` if a test specification is being executed, `false` otherwise
60  static bool is_busy();
61 
62  /// Sets the scheduler to be used.
63  /// @return `true` if scheduler is properly specified (all functions non-null).
64  static bool set_scheduler(utest_v1_scheduler_t scheduler);
65 
66  /** Call this function in the asynchronous callback that you have been waiting for.
67  *
68  * You can only validate a callback once, calling this function when no callback is expected
69  * has no side effects.
70  * After callback validation, the next test case is scheduled.
71  *
72  * You may specify additional test case attributes with this callback.
73  * So for example, you may delay the decision to repeat an asynchronous test case until the callback
74  * needs to be validated.
75  *
76  * However, be aware, that only the repeat attributes can be modified and the usual arbitration rules apply.
77  * The modified case attributes are only valid until the case handler returns updated attributes.
78  *
79  * @param control the test case attribute to be added to the existing attributes.
80  */
81  static void validate_callback(const control_t control = control_t());
82 
83  /// Raising a failure causes the failure to be counted and the failure handler to be called.
84  /// Further action then depends on its return state.
85  static void raise_failure(const failure_reason_t reason);
86 
87  protected:
88  static void run_next_case();
89  static void handle_timeout();
90  static void schedule_next_case();
91  private:
92  static void notify_testcases();
93  };
94 
95 } // namespace v1
96 } // namespace utest
97 
98 #endif // UTEST_HARNESS_H
99 
100 /** @}*/
Control class for specifying test case attributes.
Definition: utest_types.h:174
Test Harness.
Definition: utest_harness.h:46
static bool set_scheduler(utest_v1_scheduler_t scheduler)
Sets the scheduler to be used.
The scheduler interface consists out of the post and cancel functions, which you must implement to us...
static void validate_callback(const control_t control=control_t())
Call this function in the asynchronous callback that you have been waiting for.
failure_reason_t
failure_reason_t
Definition: utest_types.h:59
Test specification containing the setup and teardown handlers and test cases.
static bool is_busy()
static void raise_failure(const failure_reason_t reason)
Raising a failure causes the failure to be counted and the failure handler to be called.
static bool run(const Specification &specification)
Runs a test specification.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.