Marco Zecchini
/
Example_RTOS
Rtos API example
mbed-os/TESTS/mbedtls/selftest/main.cpp@0:9fca2b23d0ba, 2019-02-23 (annotated)
- Committer:
- marcozecchini
- Date:
- Sat Feb 23 12:13:36 2019 +0000
- Revision:
- 0:9fca2b23d0ba
final commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
marcozecchini | 0:9fca2b23d0ba | 1 | /* mbed Microcontroller Library |
marcozecchini | 0:9fca2b23d0ba | 2 | * Copyright (c) 2016 ARM Limited |
marcozecchini | 0:9fca2b23d0ba | 3 | * |
marcozecchini | 0:9fca2b23d0ba | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
marcozecchini | 0:9fca2b23d0ba | 5 | * you may not use this file except in compliance with the License. |
marcozecchini | 0:9fca2b23d0ba | 6 | * You may obtain a copy of the License at |
marcozecchini | 0:9fca2b23d0ba | 7 | * |
marcozecchini | 0:9fca2b23d0ba | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
marcozecchini | 0:9fca2b23d0ba | 9 | * |
marcozecchini | 0:9fca2b23d0ba | 10 | * Unless required by applicable law or agreed to in writing, software |
marcozecchini | 0:9fca2b23d0ba | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
marcozecchini | 0:9fca2b23d0ba | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
marcozecchini | 0:9fca2b23d0ba | 13 | * See the License for the specific language governing permissions and |
marcozecchini | 0:9fca2b23d0ba | 14 | * limitations under the License. |
marcozecchini | 0:9fca2b23d0ba | 15 | */ |
marcozecchini | 0:9fca2b23d0ba | 16 | |
marcozecchini | 0:9fca2b23d0ba | 17 | #include "mbed.h" |
marcozecchini | 0:9fca2b23d0ba | 18 | #include "greentea-client/test_env.h" |
marcozecchini | 0:9fca2b23d0ba | 19 | #include "unity.h" |
marcozecchini | 0:9fca2b23d0ba | 20 | #include "utest.h" |
marcozecchini | 0:9fca2b23d0ba | 21 | #include "rtos.h" |
marcozecchini | 0:9fca2b23d0ba | 22 | |
marcozecchini | 0:9fca2b23d0ba | 23 | using namespace utest::v1; |
marcozecchini | 0:9fca2b23d0ba | 24 | |
marcozecchini | 0:9fca2b23d0ba | 25 | #if !defined(MBEDTLS_CONFIG_FILE) |
marcozecchini | 0:9fca2b23d0ba | 26 | #include "mbedtls/config.h" |
marcozecchini | 0:9fca2b23d0ba | 27 | #else |
marcozecchini | 0:9fca2b23d0ba | 28 | #include MBEDTLS_CONFIG_FILE |
marcozecchini | 0:9fca2b23d0ba | 29 | #endif |
marcozecchini | 0:9fca2b23d0ba | 30 | |
marcozecchini | 0:9fca2b23d0ba | 31 | #include "mbedtls/sha256.h" |
marcozecchini | 0:9fca2b23d0ba | 32 | #include "mbedtls/sha512.h" |
marcozecchini | 0:9fca2b23d0ba | 33 | #include "mbedtls/entropy.h" |
marcozecchini | 0:9fca2b23d0ba | 34 | #include "mbedtls/entropy_poll.h" |
marcozecchini | 0:9fca2b23d0ba | 35 | |
marcozecchini | 0:9fca2b23d0ba | 36 | #include <string.h> |
marcozecchini | 0:9fca2b23d0ba | 37 | |
marcozecchini | 0:9fca2b23d0ba | 38 | #if defined(MBEDTLS_PLATFORM_C) |
marcozecchini | 0:9fca2b23d0ba | 39 | #include "mbedtls/platform.h" |
marcozecchini | 0:9fca2b23d0ba | 40 | #else |
marcozecchini | 0:9fca2b23d0ba | 41 | #include <stdio.h> |
marcozecchini | 0:9fca2b23d0ba | 42 | #include <stdlib.h> |
marcozecchini | 0:9fca2b23d0ba | 43 | #define mbedtls_printf printf |
marcozecchini | 0:9fca2b23d0ba | 44 | #define mbedtls_snprintf snprintf |
marcozecchini | 0:9fca2b23d0ba | 45 | #define mbedtls_exit exit |
marcozecchini | 0:9fca2b23d0ba | 46 | #define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS |
marcozecchini | 0:9fca2b23d0ba | 47 | #define MBEDTLS_EXIT_FAILURE EXIT_FAILURE |
marcozecchini | 0:9fca2b23d0ba | 48 | #endif |
marcozecchini | 0:9fca2b23d0ba | 49 | |
marcozecchini | 0:9fca2b23d0ba | 50 | #define MBEDTLS_SELF_TEST_TEST_CASE(self_test_function) \ |
marcozecchini | 0:9fca2b23d0ba | 51 | void self_test_function ## _test_case() { \ |
marcozecchini | 0:9fca2b23d0ba | 52 | int ret = self_test_function(0); \ |
marcozecchini | 0:9fca2b23d0ba | 53 | TEST_ASSERT_EQUAL(ret, 0); \ |
marcozecchini | 0:9fca2b23d0ba | 54 | } |
marcozecchini | 0:9fca2b23d0ba | 55 | |
marcozecchini | 0:9fca2b23d0ba | 56 | #if defined(MBEDTLS_SELF_TEST) |
marcozecchini | 0:9fca2b23d0ba | 57 | |
marcozecchini | 0:9fca2b23d0ba | 58 | #if defined(MBEDTLS_SHA256_C) |
marcozecchini | 0:9fca2b23d0ba | 59 | MBEDTLS_SELF_TEST_TEST_CASE(mbedtls_sha256_self_test) |
marcozecchini | 0:9fca2b23d0ba | 60 | #endif |
marcozecchini | 0:9fca2b23d0ba | 61 | |
marcozecchini | 0:9fca2b23d0ba | 62 | #if defined(MBEDTLS_SHA512_C) |
marcozecchini | 0:9fca2b23d0ba | 63 | MBEDTLS_SELF_TEST_TEST_CASE(mbedtls_sha512_self_test) |
marcozecchini | 0:9fca2b23d0ba | 64 | #endif |
marcozecchini | 0:9fca2b23d0ba | 65 | |
marcozecchini | 0:9fca2b23d0ba | 66 | #if defined(MBEDTLS_ENTROPY_C) |
marcozecchini | 0:9fca2b23d0ba | 67 | MBEDTLS_SELF_TEST_TEST_CASE(mbedtls_entropy_self_test) |
marcozecchini | 0:9fca2b23d0ba | 68 | #endif |
marcozecchini | 0:9fca2b23d0ba | 69 | |
marcozecchini | 0:9fca2b23d0ba | 70 | #else |
marcozecchini | 0:9fca2b23d0ba | 71 | #warning "MBEDTLS_SELF_TEST not enabled" |
marcozecchini | 0:9fca2b23d0ba | 72 | #endif /* MBEDTLS_SELF_TEST */ |
marcozecchini | 0:9fca2b23d0ba | 73 | |
marcozecchini | 0:9fca2b23d0ba | 74 | Case cases[] = { |
marcozecchini | 0:9fca2b23d0ba | 75 | #if defined(MBEDTLS_SELF_TEST) |
marcozecchini | 0:9fca2b23d0ba | 76 | |
marcozecchini | 0:9fca2b23d0ba | 77 | #if defined(MBEDTLS_SHA256_C) |
marcozecchini | 0:9fca2b23d0ba | 78 | Case("mbedtls_sha256_self_test", mbedtls_sha256_self_test_test_case), |
marcozecchini | 0:9fca2b23d0ba | 79 | #endif |
marcozecchini | 0:9fca2b23d0ba | 80 | |
marcozecchini | 0:9fca2b23d0ba | 81 | #if defined(MBEDTLS_SHA512_C) |
marcozecchini | 0:9fca2b23d0ba | 82 | Case("mbedtls_sha512_self_test", mbedtls_sha512_self_test_test_case), |
marcozecchini | 0:9fca2b23d0ba | 83 | #endif |
marcozecchini | 0:9fca2b23d0ba | 84 | |
marcozecchini | 0:9fca2b23d0ba | 85 | #if defined(MBEDTLS_ENTROPY_C) |
marcozecchini | 0:9fca2b23d0ba | 86 | Case("mbedtls_entropy_self_test", mbedtls_entropy_self_test_test_case), |
marcozecchini | 0:9fca2b23d0ba | 87 | #endif |
marcozecchini | 0:9fca2b23d0ba | 88 | |
marcozecchini | 0:9fca2b23d0ba | 89 | #endif /* MBEDTLS_SELF_TEST */ |
marcozecchini | 0:9fca2b23d0ba | 90 | }; |
marcozecchini | 0:9fca2b23d0ba | 91 | |
marcozecchini | 0:9fca2b23d0ba | 92 | utest::v1::status_t test_setup(const size_t num_cases) { |
marcozecchini | 0:9fca2b23d0ba | 93 | GREENTEA_SETUP(120, "default_auto"); |
marcozecchini | 0:9fca2b23d0ba | 94 | return verbose_test_setup_handler(num_cases); |
marcozecchini | 0:9fca2b23d0ba | 95 | } |
marcozecchini | 0:9fca2b23d0ba | 96 | |
marcozecchini | 0:9fca2b23d0ba | 97 | Specification specification(test_setup, cases); |
marcozecchini | 0:9fca2b23d0ba | 98 | |
marcozecchini | 0:9fca2b23d0ba | 99 | int main() { |
marcozecchini | 0:9fca2b23d0ba | 100 | return !Harness::run(specification); |
marcozecchini | 0:9fca2b23d0ba | 101 | } |
marcozecchini | 0:9fca2b23d0ba | 102 |