mbed-os

Fork of mbed-os by erkin yucel

Committer:
xuaner
Date:
Thu Jul 20 14:26:57 2017 +0000
Revision:
1:3deb71413561
Parent:
0:f269e3021894
mbed_os

Who changed what in which revision?

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