Etienne Carriere | 7514117 | 2020-05-16 11:58:23 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: BSD-2-Clause */ |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2014, STMicroelectronics International N.V. |
| 4 | * All rights reserved. |
Pascal Brand | c639ac8 | 2015-07-02 08:53:34 +0200 | [diff] [blame] | 5 | */ |
| 6 | #ifndef TB_MACROS_H |
| 7 | #define TB_MACROS_H |
| 8 | |
| 9 | #include <tee_internal_api_extensions.h> |
| 10 | |
| 11 | #define TB_HEADER(str) \ |
| 12 | printf("\n*********** TESTBENCH ***********" \ |
| 13 | "\n*** RUNNING: <<< %s >>>" \ |
| 14 | "\n*********************************\n\n", str) |
| 15 | |
| 16 | #define TB_FOOTER(str) \ |
| 17 | printf("\n*********** TESTBENCH ***********" \ |
| 18 | "\n*** PASSED: <<< %s >>>" \ |
| 19 | "\n*********************************\n\n", str) |
| 20 | |
| 21 | #define TB_INFO(str) printf("*** INFO : %s \n", (str)) |
| 22 | |
| 23 | #define HALT \ |
| 24 | { \ |
| 25 | printf("\n*** FAILED ***" \ |
| 26 | "\nTestbench halted at line %d in function %s\n", \ |
| 27 | __LINE__, __func__); \ |
| 28 | printf("\nWaiting for keypress to enable debugging.\n"); \ |
| 29 | TEE_Panic(0); \ |
| 30 | } |
| 31 | |
| 32 | #define STARTING \ |
| 33 | printf("\n*********** TESTBENCH ***********" \ |
| 34 | "\n*** For the GlobalPlatform Math API" \ |
| 35 | "\n*********************************\n\n") |
| 36 | |
| 37 | #define ALL_PASSED \ |
| 38 | printf("\n*********** TESTBENCH ***********" \ |
| 39 | "\n*** ALL TESTS PASSED ***" \ |
| 40 | "\n*********************************\n\n") |
| 41 | |
| 42 | /* |
| 43 | * DEF_BIGINT defines and initialize a BigInt with name and size. |
| 44 | */ |
| 45 | #define DEF_BIGINT(name, size) \ |
| 46 | TEE_BigInt *name; \ |
| 47 | size_t name##_size; \ |
| 48 | name##_size = TEE_BigIntSizeInU32(size); \ |
| 49 | name = (TEE_BigInt *)TEE_Malloc(name##_size * sizeof(TEE_BigInt), 0); \ |
| 50 | TEE_BigIntInit(name, name##_size) |
| 51 | |
| 52 | /* |
| 53 | * DEL_BIGINT frees the BigInt. |
| 54 | */ |
| 55 | #define DEL_BIGINT(name) TEE_Free(name) |
| 56 | |
| 57 | /* |
| 58 | * TB_PRINT_BIGINT prints the mpanum in base 16. |
| 59 | */ |
| 60 | #define TB_PRINT_BIGINT(n) \ |
| 61 | do { \ |
| 62 | char *str; \ |
| 63 | str = TEE_BigIntConvertToString(NULL, TEE_STRING_MODE_HEX_UC, 0, (n)); \ |
| 64 | printf("%s\n", str); \ |
| 65 | TEE_Free(str); \ |
| 66 | } while (0) |
| 67 | |
| 68 | #endif |