From 930be8d77a8d0a60464ec4f2256020d7c25432d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sun, 19 Aug 2018 20:49:40 +0300 Subject: [PATCH] Fix CMake problems in system test The paths were wrong in the scripts used to run tests. The same problem was in the CMake files that used CMAKE_SOURCE_DIR instead of CMAKE_CURRENT_SOURCE_DIR. Added missing check for BUILD_SYSTEM_TESTS in avrorouter for the workaround to building without all dependencies present. --- CMakeLists.txt | 4 +--- cmake/FindLibUUID.cmake | 4 ++-- maxscale-system-test/mdbci/run_test.sh | 2 +- maxscale-system-test/mdbci/run_test_snapshot.sh | 4 ++-- maxscale-system-test/templates.h.in | 2 +- maxscale-system-test/utilities.cmake | 6 +++--- server/modules/routing/avrorouter/CMakeLists.txt | 2 +- 7 files changed, 11 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 45d728799..093c8d64e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,9 +28,7 @@ project(MaxScale) include(${CMAKE_SOURCE_DIR}/cmake/install_layout.cmake) # Do the platform check -if (NOT BUILD_SYSTEM_TESTS) - include(cmake/CheckPlatform.cmake) -endif() +include(cmake/CheckPlatform.cmake) check_dirs() find_package(OpenSSL) diff --git a/cmake/FindLibUUID.cmake b/cmake/FindLibUUID.cmake index f72b34ac8..228bf3298 100644 --- a/cmake/FindLibUUID.cmake +++ b/cmake/FindLibUUID.cmake @@ -5,13 +5,13 @@ find_library(LIBUUID_LIBRARIES NAMES uuid) if (NOT LIBUUID_LIBRARIES) - message(FATAL_ERROR "Could not find libuuid library") + message(STATUS "Could not find libuuid library") else() message(STATUS "Found libuuid ${LIBUUID_LIBRARIES}") endif() find_path(LIBUUID_HEADERS uuid.h PATH_SUFFIXES uuid/) if (NOT LIBUUID_HEADERS) - message(FATAL_ERROR "Could not find libuuid headers") + message(STATUS "Could not find libuuid headers") else() message(STATUS "Found libuuid headers ${LIBUUID_HEADERS}") endif() diff --git a/maxscale-system-test/mdbci/run_test.sh b/maxscale-system-test/mdbci/run_test.sh index 8cf13563d..97e2a739d 100755 --- a/maxscale-system-test/mdbci/run_test.sh +++ b/maxscale-system-test/mdbci/run_test.sh @@ -67,7 +67,7 @@ if [ $res == 0 ] ; then cd ${script_dir}/../../ mkdir build && cd build - cmake ../../ -DBUILD_SYSTEM_TESTS=Y -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug + cmake .. -DBUILD_SYSTEM_TESTS=Y -DBUILDNAME=$name -DCMAKE_BUILD_TYPE=Debug cd maxscale-system-test make diff --git a/maxscale-system-test/mdbci/run_test_snapshot.sh b/maxscale-system-test/mdbci/run_test_snapshot.sh index 5f6cd9cf3..33432f2a1 100755 --- a/maxscale-system-test/mdbci/run_test_snapshot.sh +++ b/maxscale-system-test/mdbci/run_test_snapshot.sh @@ -66,12 +66,12 @@ ${mdbci_dir}/mdbci install_product --product maxscale_ci $name/maxscale checkExitStatus $? "Error installing Maxscale" $snapshot_lock_file -cd ${script_dir}/.. +cd ${script_dir}/../../ rm -rf build mkdir build && cd build -cmake ../../ -DBUILDNAME=$JOB_NAME-$BUILD_NUMBER-$target -DBUILD_SYSTEM_TESTS=Y +cmake .. -DBUILDNAME=$JOB_NAME-$BUILD_NUMBER-$target -DBUILD_SYSTEM_TESTS=Y cd maxscale-system-test make diff --git a/maxscale-system-test/templates.h.in b/maxscale-system-test/templates.h.in index aa64d2036..e4321fd51 100644 --- a/maxscale-system-test/templates.h.in +++ b/maxscale-system-test/templates.h.in @@ -12,6 +12,6 @@ static struct static const char * default_template __attribute__((unused)) = "replication"; /** This is the working directory for all tests */ -static const char *test_dir __attribute__((unused)) = "@CMAKE_SOURCE_DIR@"; +static const char *test_dir __attribute__((unused)) = "@CMAKE_CURRENT_SOURCE_DIR@"; #endif diff --git a/maxscale-system-test/utilities.cmake b/maxscale-system-test/utilities.cmake index 6ec3f0589..aa5a07d3f 100644 --- a/maxscale-system-test/utilities.cmake +++ b/maxscale-system-test/utilities.cmake @@ -21,7 +21,7 @@ function(add_test_executable source name template) add_template(${name} ${template}) add_executable(${name} ${source}) target_link_libraries(${name} testcore) - add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) list(REMOVE_AT ARGV 0 1 2 3) @@ -42,7 +42,7 @@ endfunction() # Add a test which uses another test as the executable function(add_test_derived name executable template) add_template(${name} ${template}) - add_test(NAME ${name} COMMAND ${CMAKE_BINARY_DIR}/${executable} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${executable} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) set_property(TEST ${name} PROPERTY TIMEOUT ${TIMEOUT}) list(REMOVE_AT ARGV 0 1 2) @@ -58,7 +58,7 @@ endfunction() # also suitable for symlinks function(add_test_script name script template labels) add_template(${name} ${template}) - add_test(NAME ${name} COMMAND ${CMAKE_SOURCE_DIR}/${script} ${name} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) + add_test(NAME ${name} COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/${script} ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) list(REMOVE_AT ARGV 0 1 2) diff --git a/server/modules/routing/avrorouter/CMakeLists.txt b/server/modules/routing/avrorouter/CMakeLists.txt index 8e8ece7e7..9d640104d 100644 --- a/server/modules/routing/avrorouter/CMakeLists.txt +++ b/server/modules/routing/avrorouter/CMakeLists.txt @@ -18,7 +18,7 @@ if(AVRO_FOUND AND JANSSON_FOUND) if (BUILD_TESTS) add_subdirectory(test) endif() -else() +elseif(NOT BUILD_SYSTEM_TESTS) message(FATAL_ERROR "No Avro C or Jansson libraries found, cannot build avrorouter. " "Use the -DBUILD_CDC=N option to `cmake` to disable building of the avrorouter.") endif()