aboutsummaryrefslogtreecommitdiff
path: root/components/service/test_runner/provider/backend/mock/mock_test_runner.c
blob: 4b6cde851b9e173987179e8eebc12a95a92178be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
 * Copyright (c) 2021, Arm Limited and Contributors. All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#include <service/test_runner/provider/backend/simple_c/simple_c_test_runner.h>
#include <stdbool.h>
#include <string.h>

/* Mock test test functions */
static bool test_that_passes(void)  { return true; }
static bool test_that_fails(void)   { return false; }

/**
 * The mock backend is a test_runner that provides some mock test cases
 * that can be used for testing the test_runner service iteslf.  It uses
 * the simple_c test runner.
 */
const struct simple_c_test_case platform_tests[] = {
    {.name = "Trng", .test_func = test_that_passes},
    {.name = "CheckIOmap", .test_func = test_that_passes}
};

const struct simple_c_test_group platform_test_group =
{
    .group = "PlatformTests",
    .num_test_cases = sizeof(platform_tests)/sizeof(struct simple_c_test_case),
    .test_cases = platform_tests
};

const struct simple_c_test_case config_tests[] = {
    {.name = "ValidateConfig", .test_func = test_that_fails},
    {.name = "ApplyConfig", .test_func = test_that_passes}
};

const struct simple_c_test_group config_test_group =
{
    .group = "ConfigTests",
    .num_test_cases = sizeof(config_tests)/sizeof(struct simple_c_test_case),
    .test_cases = config_tests
};



void test_runner_register_default_backend(struct test_runner_provider *context)
{
    simple_c_test_runner_init(context);

    simple_c_test_runner_register_group(&platform_test_group);
    simple_c_test_runner_register_group(&config_test_group);
}