From a3ed34fed6ca6a0a21147c6204180148bc7df649 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Tue, 5 Jan 2021 21:11:16 +0100 Subject: [PATCH] ssl_test_lib.[hc]: new source file for common SSL test code Create a new source file for code that is shared between ssl_client2.c and ssl_server2.c. This commit only creates the file; subsequent commits will populate it. Add it to the official build systems (make, cmake, VS). Signed-off-by: Gilles Peskine --- programs/Makefile | 8 ++++++-- programs/ssl/CMakeLists.txt | 6 ++++-- programs/ssl/ssl_test_lib.c | 21 +++++++++++++++++++++ programs/ssl/ssl_test_lib.h | 23 +++++++++++++++++++++++ scripts/generate_visualc_files.pl | 3 +++ visualc/VS2010/ssl_client2.vcxproj | 1 + visualc/VS2010/ssl_server2.vcxproj | 1 + 7 files changed, 59 insertions(+), 4 deletions(-) create mode 100644 programs/ssl/ssl_test_lib.c create mode 100644 programs/ssl/ssl_test_lib.h diff --git a/programs/Makefile b/programs/Makefile index f53724ea9..8bb7f2bff 100644 --- a/programs/Makefile +++ b/programs/Makefile @@ -267,9 +267,13 @@ ssl/ssl_client1$(EXEXT): ssl/ssl_client1.c $(DEP) echo " CC ssl/ssl_client1.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client1.c $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ -SSL_TEST_OBJECTS = test/query_config.o +SSL_TEST_OBJECTS = test/query_config.o ssl/ssl_test_lib.o -ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(SSL_TEST_OBJECTS) $(DEP) +ssl/ssl_test_lib.o: ssl/ssl_test_lib.c ssl/ssl_test_lib.h $(DEP) + echo " CC ssl/ssl_test_lib.c" + $(CC) $(LOCAL_CFLAGS) $(CFLAGS) -c ssl/ssl_test_lib.c -o $@ + +ssl/ssl_client2$(EXEXT): ssl/ssl_client2.c $(SSL_TEST_OBJECTS) ssl/ssl_test_lib.h $(DEP) echo " CC ssl/ssl_client2.c" $(CC) $(LOCAL_CFLAGS) $(CFLAGS) ssl/ssl_client2.c $(SSL_TEST_OBJECTS) $(LOCAL_LDFLAGS) $(LDFLAGS) -o $@ diff --git a/programs/ssl/CMakeLists.txt b/programs/ssl/CMakeLists.txt index 149aa303b..e4038f7b3 100644 --- a/programs/ssl/CMakeLists.txt +++ b/programs/ssl/CMakeLists.txt @@ -32,8 +32,10 @@ foreach(exe IN LISTS executables) target_include_directories(${exe} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/include) endforeach() -set_property(TARGET ssl_client2 APPEND PROPERTY SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) -set_property(TARGET ssl_server2 APPEND PROPERTY SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) +set_property(TARGET ssl_client2 APPEND PROPERTY SOURCES + ssl_test_lib.c ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) +set_property(TARGET ssl_server2 APPEND PROPERTY SOURCES + ssl_test_lib.c ${CMAKE_CURRENT_SOURCE_DIR}/../test/query_config.c) if(THREADS_FOUND) add_executable(ssl_pthread_server ssl_pthread_server.c $) diff --git a/programs/ssl/ssl_test_lib.c b/programs/ssl/ssl_test_lib.c new file mode 100644 index 000000000..e3645f354 --- /dev/null +++ b/programs/ssl/ssl_test_lib.c @@ -0,0 +1,21 @@ +/* + * Common code for SSL test programs + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "ssl_test_lib.h" + diff --git a/programs/ssl/ssl_test_lib.h b/programs/ssl/ssl_test_lib.h new file mode 100644 index 000000000..07c784c2f --- /dev/null +++ b/programs/ssl/ssl_test_lib.h @@ -0,0 +1,23 @@ +/* + * Common code for SSL test programs + * + * Copyright The Mbed TLS Contributors + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H +#define MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H + +#endif /* MBEDTLS_PROGRAMS_SSL_SSL_TEST_LIB_H */ diff --git a/scripts/generate_visualc_files.pl b/scripts/generate_visualc_files.pl index 6c2b5e4ab..df5d66e81 100755 --- a/scripts/generate_visualc_files.pl +++ b/scripts/generate_visualc_files.pl @@ -161,6 +161,9 @@ sub gen_app { $appname eq "query_compile_time_config" ) { $srcs .= "\r\n "; } + if( $appname eq "ssl_client2" or $appname eq "ssl_server2" ) { + $srcs .= "\r\n "; + } my $content = $template; $content =~ s//$srcs/g; diff --git a/visualc/VS2010/ssl_client2.vcxproj b/visualc/VS2010/ssl_client2.vcxproj index 9021602b6..9884f2370 100644 --- a/visualc/VS2010/ssl_client2.vcxproj +++ b/visualc/VS2010/ssl_client2.vcxproj @@ -21,6 +21,7 @@ + diff --git a/visualc/VS2010/ssl_server2.vcxproj b/visualc/VS2010/ssl_server2.vcxproj index 61eedaaa0..d8f3e592d 100644 --- a/visualc/VS2010/ssl_server2.vcxproj +++ b/visualc/VS2010/ssl_server2.vcxproj @@ -21,6 +21,7 @@ +