1 /*
2  * Copyright (c) 2020-2021, Arm Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #ifndef TEST_RUNNER_H
8 #define TEST_RUNNER_H
9 
10 #include <protocols/service/test_runner/packed-c/test_result.h>
11 #include <stdint.h>
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /**
18  * Constants
19  */
20 #define TEST_NAME_MAX_LEN		(30)
21 #define TEST_GROUP_MAX_LEN		(30)
22 
23 /**
24  * Specifies a set of tests for running or listing.
25  */
26 struct test_spec
27 {
28 	char name[TEST_NAME_MAX_LEN];
29 	char group[TEST_GROUP_MAX_LEN];
30 };
31 
32 /**
33  * A summary of a set of tests qualified by a test_spec.
34  */
35 struct test_summary
36 {
37 	unsigned int num_tests;		/* Number of qualifying tests */
38 	unsigned int num_results;	/* Number of available test result objects */
39 	unsigned int num_passed;	/* Number that ran and passed */
40 	unsigned int num_failed;	/* Number that ran and failed */
41 };
42 
43 /**
44  * The run state of a test case
45  */
46 enum test_run_state
47 {
48 	TEST_RUN_STATE_NOT_RUN = TS_TEST_RUNNER_TEST_RESULT_RUN_STATE_NOT_RUN,
49 	TEST_RUN_STATE_PASSED = TS_TEST_RUNNER_TEST_RESULT_RUN_STATE_PASSED,
50 	TEST_RUN_STATE_FAILED = TS_TEST_RUNNER_TEST_RESULT_RUN_STATE_FAILED
51 };
52 
53 /**
54  * Test failue to describe a failure
55  */
56 struct test_failure
57 {
58 	unsigned int line_num;		/* Source line where test assertion failed */
59 	uint64_t info;				/* Provides test specific information about the failure */
60 };
61 
62 /**
63  * The result for a particular test case.
64  */
65 struct test_result
66 {
67 	char name[TEST_NAME_MAX_LEN];
68 	char group[TEST_GROUP_MAX_LEN];
69 	enum test_run_state run_state;
70 	struct test_failure failure;
71 };
72 
73 #ifdef __cplusplus
74 } /* extern "C" */
75 #endif
76 
77 #endif /* TEST_RUNNER_H */
78