blob: b62043ecedc017f830c069fee7d78ac6246f1b5f [file] [log] [blame]
Mate Toth-Pal14ba4af2022-10-21 14:24:49 +02001/*
2 * Copyright (c) 2022, Arm Ltd. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <assert.h>
8#include <stdio.h>
9
10#include <mbedtls_common.h>
11#include <plat/common/platform.h>
12#include <psa/crypto.h>
13#include <rss_comms.h>
14
15#include "rss_ap_testsuites.h"
16
17static struct test_suite_t test_suites[] = {
18 {.freg = register_testsuite_delegated_attest},
19 {.freg = register_testsuite_measured_boot},
20};
21
22static void run_tests(void)
23{
24 enum test_suite_err_t ret;
25 psa_status_t status;
26 size_t i;
27
28 rss_comms_init(PLAT_RSS_AP_SND_MHU_BASE, PLAT_RSS_AP_RCV_MHU_BASE);
29 mbedtls_init();
30 status = psa_crypto_init();
31 if (status != PSA_SUCCESS) {
32 printf("\n\npsa_crypto_init failed (status = %d)\n", status);
33 assert(false);
34 plat_error_handler(-1);
35 }
36
37 for (i = 0; i < ARRAY_SIZE(test_suites); ++i) {
38 struct test_suite_t *suite = &(test_suites[i]);
39
40 suite->freg(suite);
41 ret = run_testsuite(suite);
42 if (ret != TEST_SUITE_ERR_NO_ERROR) {
43 printf("\n\nError during executing testsuite '%s'.\n", suite->name);
44 assert(false);
45 plat_error_handler(-1);
46 }
47 }
48 printf("\nAll tests are run.\n");
49}
50
51void run_platform_tests(void)
52{
53 size_t i;
54
55 run_tests();
56
57 printf("\n\n");
58
59 /* Print a summary of all the tests that had been run. */
60 printf("SUMMARY:\n");
61 for (i = 0; i < ARRAY_SIZE(test_suites); ++i) {
62
63 struct test_suite_t *suite = &(test_suites[i]);
64
65 switch (suite->val) {
66 case TEST_PASSED:
67 printf(" %s PASSED.\n", suite->name);
68 break;
69 case TEST_FAILED:
70 printf(" %s FAILED.\n", suite->name);
71 break;
72 case TEST_SKIPPED:
73 printf(" %s SKIPPED.\n", suite->name);
74 break;
75 default:
76 assert(false);
77 break;
78 }
79 }
80
81 printf("\n\n");
82}