1 /*
2  * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef TEST_RUNNER_BACKEND_H
8 #define TEST_RUNNER_BACKEND_H
9 
10 #include <stddef.h>
11 #include <service/test_runner/common/test_runner.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 struct test_runner_provider;
18 
19 /**
20  * Provides an abstract interface for a backend test runner. A
21  * concrete implementation will map methods to a test framework
22  * such as CppUtets.  test_runner objects may be linked to
23  * accommodate a mix of backend test frameworks.
24  */
25 struct test_runner_backend
26 {
27 	/* Return the number of tests that are qualified by the test spec */
28 	size_t (*count_tests)(const struct test_spec *spec);
29 
30 	/* Run a set of tests according to the provided test_spec */
31 	int (*run_tests)(const struct test_spec *spec,
32 		struct test_summary *summary, struct test_result *results, size_t result_limit);
33 
34 	/* List a set of tests according to the provided test_spec */
35 	void (*list_tests)(const struct test_spec *spec,
36 		struct test_summary *summary, struct test_result *results, size_t result_limit);
37 
38 	/* Used by the test_runner_provider to maintain a linked list */
39 	struct test_runner_backend *next;
40 };
41 
42 /**
43  * A concrete test_runner may provide an implementation of this function if it
44  * is to be the default test runner for a deployment.  Additional test runners
45  * may be registered but there can only be one default for a deployment.
46  */
47 void test_runner_register_default_backend(struct test_runner_provider *context);
48 
49 #ifdef __cplusplus
50 } /* extern "C" */
51 #endif
52 
53 #endif /* TEST_RUNNER_BACKEND_H */
54