mbed TLS Build
Dependents: Encrypt_Decrypt1 mbed_blink_tls encrypt encrypt
tests/suites/test_suite_version.function@0:cdf462088d13, 2017-01-05 (annotated)
- Committer:
- markrad
- Date:
- Thu Jan 05 00:18:44 2017 +0000
- Revision:
- 0:cdf462088d13
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
markrad | 0:cdf462088d13 | 1 | /* BEGIN_HEADER */ |
markrad | 0:cdf462088d13 | 2 | #include "mbedtls/version.h" |
markrad | 0:cdf462088d13 | 3 | /* END_HEADER */ |
markrad | 0:cdf462088d13 | 4 | |
markrad | 0:cdf462088d13 | 5 | /* BEGIN_DEPENDENCIES |
markrad | 0:cdf462088d13 | 6 | * depends_on:MBEDTLS_VERSION_C |
markrad | 0:cdf462088d13 | 7 | * END_DEPENDENCIES |
markrad | 0:cdf462088d13 | 8 | */ |
markrad | 0:cdf462088d13 | 9 | |
markrad | 0:cdf462088d13 | 10 | /* BEGIN_CASE */ |
markrad | 0:cdf462088d13 | 11 | void check_compiletime_version( char *version_str ) |
markrad | 0:cdf462088d13 | 12 | { |
markrad | 0:cdf462088d13 | 13 | char build_str[100]; |
markrad | 0:cdf462088d13 | 14 | char build_str_full[100]; |
markrad | 0:cdf462088d13 | 15 | unsigned int build_int; |
markrad | 0:cdf462088d13 | 16 | |
markrad | 0:cdf462088d13 | 17 | memset( build_str, 0, 100 ); |
markrad | 0:cdf462088d13 | 18 | memset( build_str_full, 0, 100 ); |
markrad | 0:cdf462088d13 | 19 | |
markrad | 0:cdf462088d13 | 20 | mbedtls_snprintf( build_str, 100, "%d.%d.%d", MBEDTLS_VERSION_MAJOR, |
markrad | 0:cdf462088d13 | 21 | MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH ); |
markrad | 0:cdf462088d13 | 22 | |
markrad | 0:cdf462088d13 | 23 | mbedtls_snprintf( build_str_full, 100, "mbed TLS %d.%d.%d", MBEDTLS_VERSION_MAJOR, |
markrad | 0:cdf462088d13 | 24 | MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH ); |
markrad | 0:cdf462088d13 | 25 | |
markrad | 0:cdf462088d13 | 26 | build_int = MBEDTLS_VERSION_MAJOR << 24 | |
markrad | 0:cdf462088d13 | 27 | MBEDTLS_VERSION_MINOR << 16 | |
markrad | 0:cdf462088d13 | 28 | MBEDTLS_VERSION_PATCH << 8; |
markrad | 0:cdf462088d13 | 29 | |
markrad | 0:cdf462088d13 | 30 | TEST_ASSERT( build_int == MBEDTLS_VERSION_NUMBER ); |
markrad | 0:cdf462088d13 | 31 | TEST_ASSERT( strcmp( build_str, MBEDTLS_VERSION_STRING ) == 0 ); |
markrad | 0:cdf462088d13 | 32 | TEST_ASSERT( strcmp( build_str_full, MBEDTLS_VERSION_STRING_FULL ) == 0 ); |
markrad | 0:cdf462088d13 | 33 | TEST_ASSERT( strcmp( version_str, MBEDTLS_VERSION_STRING ) == 0 ); |
markrad | 0:cdf462088d13 | 34 | } |
markrad | 0:cdf462088d13 | 35 | /* END_CASE */ |
markrad | 0:cdf462088d13 | 36 | |
markrad | 0:cdf462088d13 | 37 | /* BEGIN_CASE */ |
markrad | 0:cdf462088d13 | 38 | void check_runtime_version( char *version_str ) |
markrad | 0:cdf462088d13 | 39 | { |
markrad | 0:cdf462088d13 | 40 | char build_str[100]; |
markrad | 0:cdf462088d13 | 41 | char get_str[100]; |
markrad | 0:cdf462088d13 | 42 | char build_str_full[100]; |
markrad | 0:cdf462088d13 | 43 | char get_str_full[100]; |
markrad | 0:cdf462088d13 | 44 | unsigned int get_int; |
markrad | 0:cdf462088d13 | 45 | |
markrad | 0:cdf462088d13 | 46 | memset( build_str, 0, 100 ); |
markrad | 0:cdf462088d13 | 47 | memset( get_str, 0, 100 ); |
markrad | 0:cdf462088d13 | 48 | memset( build_str_full, 0, 100 ); |
markrad | 0:cdf462088d13 | 49 | memset( get_str_full, 0, 100 ); |
markrad | 0:cdf462088d13 | 50 | |
markrad | 0:cdf462088d13 | 51 | get_int = mbedtls_version_get_number(); |
markrad | 0:cdf462088d13 | 52 | mbedtls_version_get_string( get_str ); |
markrad | 0:cdf462088d13 | 53 | mbedtls_version_get_string_full( get_str_full ); |
markrad | 0:cdf462088d13 | 54 | |
markrad | 0:cdf462088d13 | 55 | mbedtls_snprintf( build_str, 100, "%d.%d.%d", |
markrad | 0:cdf462088d13 | 56 | (get_int >> 24) & 0xFF, |
markrad | 0:cdf462088d13 | 57 | (get_int >> 16) & 0xFF, |
markrad | 0:cdf462088d13 | 58 | (get_int >> 8) & 0xFF ); |
markrad | 0:cdf462088d13 | 59 | mbedtls_snprintf( build_str_full, 100, "mbed TLS %s", version_str ); |
markrad | 0:cdf462088d13 | 60 | |
markrad | 0:cdf462088d13 | 61 | TEST_ASSERT( strcmp( build_str, version_str ) == 0 ); |
markrad | 0:cdf462088d13 | 62 | TEST_ASSERT( strcmp( build_str_full, get_str_full ) == 0 ); |
markrad | 0:cdf462088d13 | 63 | TEST_ASSERT( strcmp( version_str, get_str ) == 0 ); |
markrad | 0:cdf462088d13 | 64 | } |
markrad | 0:cdf462088d13 | 65 | /* END_CASE */ |
markrad | 0:cdf462088d13 | 66 | |
markrad | 0:cdf462088d13 | 67 | /* BEGIN_CASE */ |
markrad | 0:cdf462088d13 | 68 | void check_feature( char *feature, int result ) |
markrad | 0:cdf462088d13 | 69 | { |
markrad | 0:cdf462088d13 | 70 | int check = mbedtls_version_check_feature( feature ); |
markrad | 0:cdf462088d13 | 71 | TEST_ASSERT( check == result ); |
markrad | 0:cdf462088d13 | 72 | } |
markrad | 0:cdf462088d13 | 73 | /* END_CASE */ |