blob: 3c62041456360616776c07011455b5fc3b5c7ee6 [file] [log] [blame]
AlexeiFedorov65d06532023-05-17 19:01:36 +01001/*
2 * SPDX-License-Identifier: BSD-3-Clause
3 * SPDX-FileCopyrightText: Copyright TF-RMM Contributors.
4 */
5
6#include <CppUTest/CommandLineTestRunner.h>
7#include <CppUTest/TestHarness.h>
8
9extern "C" {
10#include <arch_helpers.h>
11#include <debug.h>
12#include <host_utils.h>
13#include <psci.h>
14#include <rsi-logger.h>
15#include <smc-rsi.h>
16#include <stdlib.h>
17#include <string.h>
18#include <test_helpers.h>
19#include <utils_def.h>
20}
21
22#define LOG_SUCCESS 0U
23#define LOG_ERROR 1U
24#define LOG_RANDOM 2U
25
26TEST_GROUP(rsi_logger_tests) {
27 TEST_SETUP()
28 {
29 test_helpers_init();
30
31 /* Enable the platform with support for multiple PEs */
32 test_helpers_rmm_start(true);
33
34 /* Make sure current CPU Id is 0 (primary processor) */
35 host_util_set_cpuid(0U);
36 test_helpers_expect_assert_fail(false);
37 }
38 TEST_TEARDOWN()
39 {}
40};
41
AlexeiFedorov77a8f572023-07-20 16:16:03 +010042#if (RSI_LOG_LEVEL > LOG_LEVEL_NONE) && (RSI_LOG_LEVEL <= LOG_LEVEL)
AlexeiFedorov65d06532023-05-17 19:01:36 +010043static void rsi_log_test(unsigned int id, unsigned int status)
44{
45 unsigned long args[10];
46 unsigned long regs[5];
47 unsigned int i;
48
49 /* Fill input arguments */
50 for (i = 0U; i < ARRAY_SIZE(args); i++) {
51 args[i] = rand();
52 }
53
54 /* Fill output values */
55 switch (status) {
56 case LOG_SUCCESS:
AlexeiFedorov1d9e9972023-09-15 14:59:57 +010057 regs[0] = RSI_SUCCESS;
AlexeiFedorov65d06532023-05-17 19:01:36 +010058 break;
59 case LOG_ERROR:
AlexeiFedorov1d9e9972023-09-15 14:59:57 +010060 regs[0] = test_helpers_get_rand_in_range(RSI_ERROR_INPUT, RSI_INCOMPLETE);
AlexeiFedorov65d06532023-05-17 19:01:36 +010061 break;
62 default:
63 regs[0] = rand();
64 }
65
66 for (i = 1U; i < ARRAY_SIZE(regs); i++) {
67 regs[i] = rand();
68 }
69
AlexeiFedorov29ad2bd2023-09-13 09:43:49 +010070 rsi_log_on_exit(id, args, regs);
AlexeiFedorov65d06532023-05-17 19:01:36 +010071}
72
73TEST(rsi_logger_tests, RSI_LOGGER_TC1)
74{
75 unsigned int status, id;
76
77 for (status = LOG_SUCCESS; status <= LOG_RANDOM; status++) {
78 for (id = SMC_RSI_ABI_VERSION; id <= SMC_RSI_HOST_CALL; id++) {
Javier Almansa Sobrino654ebf32023-06-13 10:51:39 +010079 rsi_log_test(id, status);
AlexeiFedorov65d06532023-05-17 19:01:36 +010080 }
81 }
82
83 rsi_log_test(SMC32_PSCI_FID_MIN, LOG_RANDOM);
84 rsi_log_test(SMC64_PSCI_FID_MAX, LOG_RANDOM);
85 rsi_log_test(SMC64_PSCI_FID_MAX + rand(), LOG_RANDOM);
86
87 TEST_EXIT;
88}
AlexeiFedorov77a8f572023-07-20 16:16:03 +010089#else
90IGNORE_TEST(rsi_logger_tests, RSI_LOGGER_TC1)
91{
92}
93#endif