1 /*
2 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6 #include <service/test_runner/provider/backend/simple_c/simple_c_test_runner.h>
7 #include <stdbool.h>
8 #include <string.h>
9
10 /* Mock test test functions */
test_that_passes(struct test_failure * failure)11 static bool test_that_passes(struct test_failure *failure)
12 {
13 (void)failure;
14 return true;
15 }
16
test_that_fails(struct test_failure * failure)17 static bool test_that_fails(struct test_failure *failure)
18 {
19 failure->line_num = __LINE__;
20 failure->info = 27;
21 return false;
22 }
23
24 /**
25 * The mock backend is a test_runner that provides some mock test cases
26 * that can be used for testing the test_runner service iteslf. It uses
27 * the simple_c test runner.
28 */
29 const struct simple_c_test_case platform_tests[] = {
30 {.name = "Trng", .test_func = test_that_passes},
31 {.name = "CheckIOmap", .test_func = test_that_passes}
32 };
33
34 const struct simple_c_test_group platform_test_group =
35 {
36 .group = "PlatformTests",
37 .num_test_cases = sizeof(platform_tests)/sizeof(struct simple_c_test_case),
38 .test_cases = platform_tests
39 };
40
41 const struct simple_c_test_case config_tests[] = {
42 {.name = "ValidateConfig", .test_func = test_that_fails},
43 {.name = "ApplyConfig", .test_func = test_that_passes}
44 };
45
46 const struct simple_c_test_group config_test_group =
47 {
48 .group = "ConfigTests",
49 .num_test_cases = sizeof(config_tests)/sizeof(struct simple_c_test_case),
50 .test_cases = config_tests
51 };
52
53
54
test_runner_register_default_backend(struct test_runner_provider * context)55 void test_runner_register_default_backend(struct test_runner_provider *context)
56 {
57 simple_c_test_runner_init(context);
58
59 simple_c_test_runner_register_group(&platform_test_group);
60 simple_c_test_runner_register_group(&config_test_group);
61 }