TF-M Reference Manual  1.2.0
TrustedFirmware-M
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
test_framework.h File Reference
#include <stdarg.h>
#include <stdint.h>
#include <stdio.h>
#include "tfm_log_raw.h"
#include "test_framework_helpers.h"
Include dependency graph for test_framework.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  test_result_t
 
struct  test_t
 
struct  test_suite_t
 

Macros

#define TEST_FAIL(info_msg)   set_test_failed(info_msg, __FILE__, __LINE__, ret)
 
#define TEST_LOG(...)   tfm_log_printf(__VA_ARGS__)
 

Typedefs

typedef void TEST_FUN (struct test_result_t *ret)
 Runs the test. More...
 
typedef void TESTSUITE_REG (struct test_suite_t *p_test_suite)
 Registers test in the testsuite structure and sets the name. More...
 

Enumerations

enum  test_status_t { TEST_PASSED = 0, TEST_FAILED = 1 }
 
enum  test_suite_err_t { TEST_SUITE_ERR_NO_ERROR = 0, TEST_SUITE_ERR_INVALID_DATA = 1, TEST_SUITE_ERR_INVALID_TEST_DATA = 2, TEST_SUITE_ERR_TEST_FAILED = 3 }
 

Functions

const char * test_err_to_str (enum test_suite_err_t err)
 Translates the test suite error into a string. More...
 
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. More...
 
enum test_suite_err_t run_testsuite (struct test_suite_t *test_suite)
 Runs the given test suite. More...
 
void show_tests (const struct test_suite_t *ts)
 Prints all test in the the given test suite. More...
 
void set_test_failed (const char *info_msg, const char *filename, uint32_t line, struct test_result_t *ret)
 Sets test failure state and information in the test_result_t structure. More...
 

Macro Definition Documentation

#define TEST_FAIL (   info_msg)    set_test_failed(info_msg, __FILE__, __LINE__, ret)

Definition at line 137 of file test_framework.h.

#define TEST_LOG (   ...)    tfm_log_printf(__VA_ARGS__)

Definition at line 139 of file test_framework.h.

Typedef Documentation

typedef void TEST_FUN(struct test_result_t *ret)

Runs the test.

Parameters
[out]retTest result value

Definition at line 41 of file test_framework.h.

typedef void TESTSUITE_REG(struct test_suite_t *p_test_suite)

Registers test in the testsuite structure and sets the name.

Parameters
[in]p_test_suitePointer to the p_test_suite_location.

Definition at line 57 of file test_framework.h.

Enumeration Type Documentation

Enumerator
TEST_PASSED 

Test has passed

TEST_FAILED 

Test has failed

Definition at line 22 of file test_framework.h.

Enumerator
TEST_SUITE_ERR_NO_ERROR 

No error

TEST_SUITE_ERR_INVALID_DATA 

Invalid test suite if any of the pointers is NULL

TEST_SUITE_ERR_INVALID_TEST_DATA 

Invalid test if any of the pointers is NULL

TEST_SUITE_ERR_TEST_FAILED 

Last executed test has failed

Definition at line 69 of file test_framework.h.

Function Documentation

enum test_suite_err_t run_testsuite ( struct test_suite_t test_suite)

Runs the given test suite.

Parameters
[in,out]test_suiteTest suite to run the list of tests and store test results.
Returns
Returns error code as specified in test_suite_err_t

Definition at line 86 of file test_framework.c.

Here is the call graph for this function:

Here is the caller graph for this function:

void set_test_failed ( const char *  info_msg,
const char *  filename,
uint32_t  line,
struct test_result_t ret 
)

Sets test failure state and information in the test_result_t structure.

Parameters
[in]info_msgInformation message to show
[in]filenameFilename where the error has ocurred
[in]lineLine in the file where the error has ocurred
[out]retPointer to test_result_t structure to set the values
Note
: If info_msg is "" or , info message is not shown. If filename is "", filename and line are not shown.

Definition at line 72 of file test_framework.c.

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.

Parameters
[in]nameTest suite name
[in]test_listPointer to the test list
[in]sizeTest list size
[in,out]p_tsPointer to test suite object to fill in the parameters
Returns
Returns error code as specified in test_suite_err_t

Definition at line 56 of file test_framework.c.

Here is the caller graph for this function:

void show_tests ( const struct test_suite_t ts)

Prints all test in the the given test suite.

Parameters
[in]tsTest suite to print the list of tests
const char* test_err_to_str ( enum test_suite_err_t  err)

Translates the test suite error into a string.

Parameters
[in]errError value test_suite_err_t
Returns
error as string.

Definition at line 38 of file test_framework.c.