Debian Codegraph @

others/mbedtls/tests/suites/test_suite_version.function

raw
1 /* BEGIN_HEADER */
2 #include "mbedtls/version.h"
3 /* END_HEADER */
4
5 /* BEGIN_DEPENDENCIES
6 * depends_on:MBEDTLS_VERSION_C
7 * END_DEPENDENCIES
8 */
9
10 /* BEGIN_CASE */
11 void check_compiletime_version(char *version_str)
12 {
13 char build_str[100];
14 char build_str_full[100];
15 unsigned int build_int;
16
17 memset(build_str, 0, 100);
18 memset(build_str_full, 0, 100);
19
20 mbedtls_snprintf(build_str, 100, "%d.%d.%d", MBEDTLS_VERSION_MAJOR,
21 MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH);
22
23 mbedtls_snprintf(build_str_full, 100, "Mbed TLS %d.%d.%d", MBEDTLS_VERSION_MAJOR,
24 MBEDTLS_VERSION_MINOR, MBEDTLS_VERSION_PATCH);
25
26 build_int = MBEDTLS_VERSION_MAJOR << 24 |
27 MBEDTLS_VERSION_MINOR << 16 |
28 MBEDTLS_VERSION_PATCH << 8;
29
30 TEST_ASSERT(build_int == MBEDTLS_VERSION_NUMBER);
31 TEST_ASSERT(strcmp(build_str, MBEDTLS_VERSION_STRING) == 0);
32 TEST_ASSERT(strcmp(build_str_full, MBEDTLS_VERSION_STRING_FULL) == 0);
33 TEST_ASSERT(strcmp(version_str, MBEDTLS_VERSION_STRING) == 0);
34 }
35 /* END_CASE */
36
37 /* BEGIN_CASE */
38 void check_runtime_version(char *version_str)
39 {
40 char build_str[100];
41 const char *get_str;
42 char build_str_full[100];
43 const char *get_str_full;
44 unsigned int get_int;
45
46 memset(build_str, 0, 100);
47 memset(build_str_full, 0, 100);
48
49 get_int = mbedtls_version_get_number();
50 get_str = mbedtls_version_get_string();
51 get_str_full = mbedtls_version_get_string_full();
52
53 mbedtls_snprintf(build_str, 100, "%u.%u.%u",
54 (get_int >> 24) & 0xFF,
55 (get_int >> 16) & 0xFF,
56 (get_int >> 8) & 0xFF);
57 mbedtls_snprintf(build_str_full, 100, "Mbed TLS %s", version_str);
58
59 TEST_ASSERT(strcmp(build_str, version_str) == 0);
60 TEST_ASSERT(strcmp(build_str_full, get_str_full) == 0);
61 TEST_ASSERT(strcmp(version_str, get_str) == 0);
62 }
63 /* END_CASE */
64
65 /* BEGIN_CASE depends_on:MBEDTLS_VERSION_FEATURES */
66 void check_feature(char *feature, int result)
67 {
68 int check = mbedtls_version_check_feature(feature);
69 TEST_ASSERT(check == result);
70 }
71 /* END_CASE */