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