From 771f1b00dc1e9422e543534ca2ea823c98b3e2be Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 22 May 2015 15:24:18 -0400 Subject: Tests: Rename Visibility{InlinesHidden =>} We will soon generalize it to cover other visibility properties. --- Tests/CMakeLists.txt | 10 +++++----- Tests/Visibility/CMakeLists.txt | 13 +++++++++++++ Tests/Visibility/bar.c | 1 + Tests/Visibility/foo.cpp | 11 +++++++++++ Tests/Visibility/verify.cmake | 14 ++++++++++++++ Tests/VisibilityInlinesHidden/CMakeLists.txt | 14 -------------- Tests/VisibilityInlinesHidden/bar.c | 1 - Tests/VisibilityInlinesHidden/foo.cpp | 11 ----------- Tests/VisibilityInlinesHidden/verify.cmake | 14 -------------- 9 files changed, 44 insertions(+), 45 deletions(-) create mode 100644 Tests/Visibility/CMakeLists.txt create mode 100644 Tests/Visibility/bar.c create mode 100644 Tests/Visibility/foo.cpp create mode 100644 Tests/Visibility/verify.cmake delete mode 100644 Tests/VisibilityInlinesHidden/CMakeLists.txt delete mode 100644 Tests/VisibilityInlinesHidden/bar.c delete mode 100644 Tests/VisibilityInlinesHidden/foo.cpp delete mode 100644 Tests/VisibilityInlinesHidden/verify.cmake diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 1f93675..8865063 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -484,16 +484,16 @@ if(BUILD_TESTING) endif() if(run_inlines_hidden_test) - add_test(VisibilityInlinesHidden ${CMAKE_CTEST_COMMAND} + add_test(Visibility ${CMAKE_CTEST_COMMAND} --build-and-test - "${CMake_SOURCE_DIR}/Tests/VisibilityInlinesHidden" - "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden" + "${CMake_SOURCE_DIR}/Tests/Visibility" + "${CMake_BINARY_DIR}/Tests/Visibility" ${build_generator_args} - --build-project VisibilityInlinesHidden + --build-project Visibility --build-options ${build_options} ) list(APPEND TEST_BUILD_DIRS - "${CMake_BINARY_DIR}/Tests/VisibilityInlinesHidden" + "${CMake_BINARY_DIR}/Tests/Visibility" ) endif() diff --git a/Tests/Visibility/CMakeLists.txt b/Tests/Visibility/CMakeLists.txt new file mode 100644 index 0000000..df75630 --- /dev/null +++ b/Tests/Visibility/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.2) +project(Visibility) + +add_library(inlines_hidden SHARED foo.cpp bar.c) +set_property(TARGET inlines_hidden PROPERTY VISIBILITY_INLINES_HIDDEN ON) +target_compile_options(inlines_hidden PRIVATE -Werror) + +add_custom_command(TARGET inlines_hidden POST_BUILD + COMMAND ${CMAKE_COMMAND} + -DCMAKE_NM=${CMAKE_NM} + -DTEST_LIBRARY_PATH=$ + -P ${CMAKE_CURRENT_SOURCE_DIR}/verify.cmake +) diff --git a/Tests/Visibility/bar.c b/Tests/Visibility/bar.c new file mode 100644 index 0000000..e425999 --- /dev/null +++ b/Tests/Visibility/bar.c @@ -0,0 +1 @@ +void bar() {} diff --git a/Tests/Visibility/foo.cpp b/Tests/Visibility/foo.cpp new file mode 100644 index 0000000..2b66b69 --- /dev/null +++ b/Tests/Visibility/foo.cpp @@ -0,0 +1,11 @@ +class Foo +{ +public: + void bar() {} +}; + +void baz() +{ + Foo foo; + foo.bar(); +} diff --git a/Tests/Visibility/verify.cmake b/Tests/Visibility/verify.cmake new file mode 100644 index 0000000..80dd13c --- /dev/null +++ b/Tests/Visibility/verify.cmake @@ -0,0 +1,14 @@ +execute_process(COMMAND ${CMAKE_NM} -D ${TEST_LIBRARY_PATH} + RESULT_VARIABLE RESULT + OUTPUT_VARIABLE OUTPUT + ERROR_VARIABLE ERROR +) + +if(NOT "${RESULT}" STREQUAL "0") + message(FATAL_ERROR "nm failed [${RESULT}] [${OUTPUT}] [${ERROR}]") +endif() + +if(${OUTPUT} MATCHES "Foo[^\\n]*bar") + message(FATAL_ERROR + "Found Foo::bar() which should have been hidden [${OUTPUT}]") +endif() diff --git a/Tests/VisibilityInlinesHidden/CMakeLists.txt b/Tests/VisibilityInlinesHidden/CMakeLists.txt deleted file mode 100644 index 8ebc39c..0000000 --- a/Tests/VisibilityInlinesHidden/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -cmake_minimum_required(VERSION 2.8) - -project(VisibilityInlinesHidden) - -add_library(inlines_hidden SHARED foo.cpp bar.c) -set_property(TARGET inlines_hidden PROPERTY VISIBILITY_INLINES_HIDDEN ON) -target_compile_options(inlines_hidden PRIVATE -Werror) - -add_custom_command(TARGET inlines_hidden POST_BUILD - COMMAND ${CMAKE_COMMAND} - -DCMAKE_NM=${CMAKE_NM} - -DTEST_LIBRARY_PATH=$ - -P ${CMAKE_CURRENT_SOURCE_DIR}/verify.cmake -) diff --git a/Tests/VisibilityInlinesHidden/bar.c b/Tests/VisibilityInlinesHidden/bar.c deleted file mode 100644 index e425999..0000000 --- a/Tests/VisibilityInlinesHidden/bar.c +++ /dev/null @@ -1 +0,0 @@ -void bar() {} diff --git a/Tests/VisibilityInlinesHidden/foo.cpp b/Tests/VisibilityInlinesHidden/foo.cpp deleted file mode 100644 index 2b66b69..0000000 --- a/Tests/VisibilityInlinesHidden/foo.cpp +++ /dev/null @@ -1,11 +0,0 @@ -class Foo -{ -public: - void bar() {} -}; - -void baz() -{ - Foo foo; - foo.bar(); -} diff --git a/Tests/VisibilityInlinesHidden/verify.cmake b/Tests/VisibilityInlinesHidden/verify.cmake deleted file mode 100644 index 80dd13c..0000000 --- a/Tests/VisibilityInlinesHidden/verify.cmake +++ /dev/null @@ -1,14 +0,0 @@ -execute_process(COMMAND ${CMAKE_NM} -D ${TEST_LIBRARY_PATH} - RESULT_VARIABLE RESULT - OUTPUT_VARIABLE OUTPUT - ERROR_VARIABLE ERROR -) - -if(NOT "${RESULT}" STREQUAL "0") - message(FATAL_ERROR "nm failed [${RESULT}] [${OUTPUT}] [${ERROR}]") -endif() - -if(${OUTPUT} MATCHES "Foo[^\\n]*bar") - message(FATAL_ERROR - "Found Foo::bar() which should have been hidden [${OUTPUT}]") -endif() -- cgit v0.12