diff options
author | Fred Baksik <frodak17@gmail.com> | 2019-01-05 16:01:20 (GMT) |
---|---|---|
committer | Fred Baksik <frodak17@gmail.com> | 2019-01-16 15:41:03 (GMT) |
commit | 5cef3c61fc815393248762c14ba1878aae68394d (patch) | |
tree | f50de502f49e9c7dc43ec2195d3951a955cf4399 /Tests/GhsMulti/GhsMultiLinkTest | |
parent | a42e40e78dc3d9c4289a3c9640cae94ecd034373 (diff) | |
download | CMake-5cef3c61fc815393248762c14ba1878aae68394d.zip CMake-5cef3c61fc815393248762c14ba1878aae68394d.tar.gz CMake-5cef3c61fc815393248762c14ba1878aae68394d.tar.bz2 |
GHS: Update test suite
-- Update test suite so that CMake can use multiple toolsets
CMake_TEST_GreenHillsMULTI_config
ghs_config_name
ghs_target_arch
ghs_tools
ghs_toolset_name
ghs_os_root
ghs_os_dir
ghs_target_platform
ghs_bsp_name
-- Change ARM Integrity test to generic Integrity test
Add Monolithic build test
-- Add other GHS generator tests
Diffstat (limited to 'Tests/GhsMulti/GhsMultiLinkTest')
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt | 96 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in | 35 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/exe1.c | 6 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/exe1.h | 6 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func2.c | 4 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func3.c | 4 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func4.c | 4 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func5.c | 4 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func6.c | 4 | ||||
-rw-r--r-- | Tests/GhsMulti/GhsMultiLinkTest/func7.c | 4 |
10 files changed, 167 insertions, 0 deletions
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt new file mode 100644 index 0000000..9b23493 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt @@ -0,0 +1,96 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +message("Copy project") +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt.in + ${CMAKE_CURRENT_BINARY_DIR}/link_src/CMakeLists.txt COPYONLY) + +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/exe1.c + ${CMAKE_CURRENT_SOURCE_DIR}/exe1.h + ${CMAKE_CURRENT_SOURCE_DIR}/func2.c + ${CMAKE_CURRENT_SOURCE_DIR}/func3.c + ${CMAKE_CURRENT_SOURCE_DIR}/func4.c + ${CMAKE_CURRENT_SOURCE_DIR}/func5.c + ${CMAKE_CURRENT_SOURCE_DIR}/func6.c + ${CMAKE_CURRENT_SOURCE_DIR}/func7.c + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/link_src +) + +message("Building project") +try_compile(RESULT + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_src + test + CMAKE_FLAGS -DGHS_BSP_NAME=${GHS_BSP_NAME} + -DGHS_OS_ROOT=${GHS_OS_ROOT} + -DGHS_OS_DIR=${GHS_OS_DIR} + -DGHS_TOOLSET_ROOT=${GHS_TOOLSET_ROOT} + -DGHS_TARGET_PLATFORM=${GHS_TARGET_PLATFORM} + -DRUN_TEST=${RUN_TEST} + -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS} + OUTPUT_VARIABLE OUTPUT) + +message("Output from build:\n${OUTPUT}") +if (RUN_TEST STREQUAL "NO_FLAGS") + if(NOT RESULT) + message(SEND_ERROR "Could not build test project (1)!") + endif() +else() + unset(fileName CACHE) + find_file (fileName exe1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -add-link-options1 -add-link-options2 + link_directories_used1 link_directories_used2 "c:/absolute" + link_libraries_used1 link_libraries_used2 + -lcsl1 csl2 + -clinkexe1 -clinkexe2 + -special-lib2-public-link) + foreach( opt IN LISTS expected_flags ) + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach(opt) + + unset(fileName CACHE) + find_file (fileName lib1.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -clinkexeA1 -clinkexeA2 + -static-lib-flags1 -static-lib-flags2) + foreach( opt IN LISTS expected_flags ) + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach(opt) + + unset(fileName CACHE) + find_file (fileName lib2.gpj + ${CMAKE_CURRENT_BINARY_DIR}/link_build + ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2 + ) + message("Parsing project file: ${fileName}") + file(STRINGS ${fileName} fileText) + set(expected_flags + -clinkexeA1 -clinkexeA2) + foreach( opt IN LISTS expected_flags ) + string(FIND "${fileText}" "${opt}" opt_found) + if ( opt_found EQUAL -1 ) + message(SEND_ERROR "Could not find: ${opt}") + endif() + endforeach(opt) +endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in new file mode 100644 index 0000000..4cf86a2 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt.in @@ -0,0 +1,35 @@ +# Distributed under the OSI-approved BSD 3-Clause License. See accompanying +# file Copyright.txt or https://cmake.org/licensing for details. + +cmake_minimum_required(VERSION 3.12 FATAL_ERROR) + +project(test C) + +if( RUN_TEST STREQUAL "CHECK_FLAGS" ) +add_link_options(-add-link-options1 -add-link-options2) +link_directories(link_directories_used1 link_directories_used2 "c:/absolute") +link_libraries(link_libraries_used1 link_libraries_used2 ) +set( CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} -lcsl1 csl2" ) +set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -clinkexe1 -clinkexe2") +endif() + +add_executable(exe1 exe1.c) +target_link_libraries(exe1 lib1) +if( RUN_TEST STREQUAL "CHECK_FLAGS" ) +set_property( TARGET exe1 APPEND_STRING PROPERTY LINK_FLAGS "--link-flag-prop1 --link-flag-prop2") +set_property( TARGET exe1 APPEND PROPERTY LINK_OPTIONS --link-opt-prop1 --link-opt-prop2) +endif() + +if( RUN_TEST STREQUAL "CHECK_FLAGS" ) +set( CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS} "-clinkexeA1 -clinkexeA2") +endif() +add_library(lib1 STATIC func2.c func3.c func4.c) +target_link_libraries(lib1 lib2) +if( RUN_TEST STREQUAL "CHECK_FLAGS" ) +set_property( TARGET lib1 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS "-static-lib-flags1 -static-lib-flags2") +endif() + +add_library(lib2 STATIC func5.c func6.c func7.c) +if( RUN_TEST STREQUAL "CHECK_FLAGS" ) +target_link_options(lib2 PUBLIC -special-lib2-public-link) +endif() diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.c b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c new file mode 100644 index 0000000..f21c126 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.c @@ -0,0 +1,6 @@ +#include "exe1.h" + +int main(void) +{ + return func2a() + func3a() + func4a() + func5a() + func6a() + func7a(); +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/exe1.h b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h new file mode 100644 index 0000000..e2b1725 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/exe1.h @@ -0,0 +1,6 @@ +extern int func2a(void); +extern int func3a(void); +extern int func4a(void); +extern int func5a(void); +extern int func6a(void); +extern int func7a(void); diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func2.c b/Tests/GhsMulti/GhsMultiLinkTest/func2.c new file mode 100644 index 0000000..8f66fba --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func2.c @@ -0,0 +1,4 @@ +int func2a(void) +{ + return 2; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func3.c b/Tests/GhsMulti/GhsMultiLinkTest/func3.c new file mode 100644 index 0000000..57c7a6f --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func3.c @@ -0,0 +1,4 @@ +int func3a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func4.c b/Tests/GhsMulti/GhsMultiLinkTest/func4.c new file mode 100644 index 0000000..109fd7b --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func4.c @@ -0,0 +1,4 @@ +int func4a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func5.c b/Tests/GhsMulti/GhsMultiLinkTest/func5.c new file mode 100644 index 0000000..f28a705 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func5.c @@ -0,0 +1,4 @@ +int func5a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func6.c b/Tests/GhsMulti/GhsMultiLinkTest/func6.c new file mode 100644 index 0000000..bf77406 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func6.c @@ -0,0 +1,4 @@ +int func6a(void) +{ + return 1; +} diff --git a/Tests/GhsMulti/GhsMultiLinkTest/func7.c b/Tests/GhsMulti/GhsMultiLinkTest/func7.c new file mode 100644 index 0000000..6a4a9a1 --- /dev/null +++ b/Tests/GhsMulti/GhsMultiLinkTest/func7.c @@ -0,0 +1,4 @@ +int func7a(void) +{ + return 1; +} |