blob: b9e093c1db0672c0ab48a83d7004e78e0b2ad06d [file] [log] [blame]
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01001/*
2 * Simple program to test that CMake builds with Mbed TLS as a subdirectory
3 * work correctly.
4 *
Bence Szépkúti1e148272020-08-07 13:07:28 +02005 * Copyright The Mbed TLS Contributors
Jaeden Ameroab83fdf2019-06-20 17:38:22 +01006 * SPDX-License-Identifier: Apache-2.0
7 *
8 * Licensed under the Apache License, Version 2.0 (the "License"); you may
9 * not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010019 */
20
Bence Szépkútic662b362021-05-27 11:25:03 +020021#include "mbedtls/build_info.h"
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010022
23#if defined(MBEDTLS_PLATFORM_C)
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020024# include "mbedtls/platform.h"
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010025#else
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020026# include <stdio.h>
27# include <stdlib.h>
28# define mbedtls_fprintf fprintf
29# define mbedtls_printf printf
30# define mbedtls_exit exit
31# define MBEDTLS_EXIT_SUCCESS EXIT_SUCCESS
32# define MBEDTLS_EXIT_FAILURE EXIT_FAILURE
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010033#endif /* MBEDTLS_PLATFORM_C */
34
35#include "mbedtls/version.h"
36
37/* The main reason to build this is for testing the CMake build, so the program
38 * doesn't need to do very much. It calls a single library function to ensure
39 * linkage works, but that is all. */
40int main()
41{
42 /* This version string is 18 bytes long, as advised by version.h. */
43 char version[18];
44
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020045 mbedtls_version_get_string_full(version);
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010046
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020047 mbedtls_printf("Built against %s\n", version);
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010048
Mateusz Starzykc0eabdc2021-08-03 14:09:02 +020049 return 0;
Jaeden Ameroab83fdf2019-06-20 17:38:22 +010050}