1 /*
2  * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef SIMPLE_C_TEST_RUNNER_H
8 #define SIMPLE_C_TEST_RUNNER_H
9 
10 #include <service/test_runner/common/test_runner.h>
11 #include <stdbool.h>
12 #include <stddef.h>
13 
14 /**
15  * A simple C code test runner.  Allows tests to be run in environments
16  * where C++ and hence use of cpputest is not supported.
17  */
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 struct test_runner_provider;
24 
25 /**
26  * Describes a test case.  Each test cases is a member of a test group.
27  */
28 struct simple_c_test_case
29 {
30 	/* The test name string */
31 	const char *name;
32 
33 	/* The test function that results true for a pass, false for a fail. */
34 	bool (*test_func)(struct test_failure *test_failure);
35 };
36 
37 /**
38  * Describes a test group consisting of [0..*] test cases.
39  */
40 struct simple_c_test_group
41 {
42 	/* The test group string */
43 	const char *group;
44 
45 	/* Number of test cases in the group */
46 	size_t num_test_cases;
47 
48 	/* Pointer to an array of test cases */
49 	const struct simple_c_test_case *test_cases;
50 };
51 
52 /**
53  * Initialise the test runner and register it as a backend to the
54  * test_runner_provider.  The simple_c test runner is a singleton.
55  */
56 void simple_c_test_runner_init(struct test_runner_provider *frontend);
57 
58 /**
59  * Registers a test group with the test runner.
60  */
61 void simple_c_test_runner_register_group(const struct simple_c_test_group *test_group);
62 
63 #ifdef __cplusplus
64 } /* extern "C" */
65 #endif
66 
67 #endif /* SIMPLE_C_TEST_RUNNER_H */
68