TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
t_cose_ns_testsuite.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Arm Limited. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #include "t_cose_ns_tests.h"
9 #include <stdio.h>
10 #include "run_tests.h"
11 
12 /*
13  * The t_cose test cases are defined in: lib/ext/t_cose/test/run_test.c
14  *
15  * There are two types of configuration to execute test cases:
16  * - All tests: Just pass an array containing a NULL pointer to RunTest():
17  * t_cose_test_cases_all[]. This is the default configuration.
18  *
19  * - Selected tests: Edit the s_tests[] array in
20  * lib/ext/t_cose/test/run_tests.c.
21  */
22 
23 /* Define test suite for t_cose library */
24 static void tfm_t_cose_test_8001(struct test_result_t *ret);
25 
26 static struct test_t t_cose_regression_test[] = {
27  {&tfm_t_cose_test_8001, "TFM_T_COSE_TEST_8001",
28  "Regression test of t_cose library", {TEST_PASSED} },
29 };
30 
31 /* To execute all test cases, then pass this array to RunTestsTCose()
32  * Test cases are defined in: lib/ext/t_cose/test/run_tests.c
33  */
34 const static char *t_cose_test_cases_all[] = {
35  0, /* Indicates to run all enabled test case */
36 };
37 
45 static void fputs_wrapper(const char *string, void *out_ctx, int new_line)
46 {
47  (void)out_ctx;
48  (void)new_line;
49  /*
50  * To get test result per test case, change
51  * the preprocessor '#if 0' to '#if 1'.
52  */
53 # if 0
54  TEST_LOG("%s\r\n", string);
55 #else
56  (void)string;
57 #endif
58 }
59 
60 static void tfm_t_cose_test_8001(struct test_result_t *ret)
61 {
62  int32_t test_failed_cnt = 0;
63 
64  test_failed_cnt = RunTestsTCose(t_cose_test_cases_all, fputs_wrapper,
65  NULL, NULL);
66  if (test_failed_cnt != 0) {
67  TEST_FAIL("t_cose test failed");
68  return;
69  }
70 
71  ret->val = TEST_PASSED;
72 }
73 
74 void
76 {
77  uint32_t list_size;
78 
79  list_size = (sizeof(t_cose_regression_test) /
80  sizeof(t_cose_regression_test[0]));
81 
82  set_testsuite("T_COSE regression test"
83  "(TFM_T_COSE_TEST_8XXX)",
84  t_cose_regression_test, list_size, p_test_suite);
85 }
#define TEST_FAIL(info_msg)
enum test_suite_err_t set_testsuite(const char *name, struct test_t *test_list, uint32_t size, struct test_suite_t *p_ts)
Sets test suite parameters.
struct test_result_t ret
#define TEST_LOG(...)
enum test_status_t val
void register_testsuite_ns_t_cose(struct test_suite_t *p_test_suite)
Register test suite for the t_cose library.