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