Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Simple program to test that Mbed TLS builds correctly as a CMake package. |
| 3 | * |
| 4 | * Copyright The Mbed TLS Contributors |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | * |
| 7 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 8 | * not use this file except in compliance with the License. |
| 9 | * You may obtain a copy of the License at |
| 10 | * |
| 11 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | * |
| 13 | * Unless required by applicable law or agreed to in writing, software |
| 14 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 15 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | * See the License for the specific language governing permissions and |
| 17 | * limitations under the License. |
| 18 | */ |
| 19 | |
Bence Szépkúti | c662b36 | 2021-05-27 11:25:03 +0200 | [diff] [blame] | 20 | #include "mbedtls/build_info.h" |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 21 | |
| 22 | #if defined(MBEDTLS_PLATFORM_C) |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 23 | # include "mbedtls/platform.h" |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 24 | #else |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 25 | # include <stdio.h> |
| 26 | # include <stdlib.h> |
| 27 | # define mbedtls_fprintf fprintf |
| 28 | # define mbedtls_printf printf |
| 29 | # define mbedtls_exit exit |
| 30 | # define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS |
| 31 | # define MBEDTLS_EXIT_FAILURE EXIT_FAILURE |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 32 | #endif /* MBEDTLS_PLATFORM_C */ |
| 33 | |
| 34 | #include "mbedtls/version.h" |
| 35 | |
| 36 | /* The main reason to build this is for testing the CMake build, so the program |
| 37 | * doesn't need to do very much. It calls a single library function to ensure |
| 38 | * linkage works, but that is all. */ |
| 39 | int main() |
| 40 | { |
| 41 | /* This version string is 18 bytes long, as advised by version.h. */ |
| 42 | char version[18]; |
| 43 | |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 44 | mbedtls_version_get_string_full(version); |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 45 | |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 46 | mbedtls_printf("Built against %s\n", version); |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 47 | |
Mateusz Starzyk | c0eabdc | 2021-08-03 14:09:02 +0200 | [diff] [blame^] | 48 | return 0; |
Chris Kay | d259e34 | 2021-03-25 16:03:25 +0000 | [diff] [blame] | 49 | } |