CPack/Deb test changes due to breaking changes

New CPack/Deb tests and changes to old tests
as package file names and inter component dependency
detection was changed.
This commit is contained in:
Domen Vrankar 2016-05-10 15:40:48 +02:00 committed by Brad King
parent 3b64889436
commit 7e940bf74a
27 changed files with 211 additions and 29 deletions

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
@ -60,9 +60,9 @@ if(DPKGDEB_EXECUTABLE)
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-application'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
set(dpkgdeb_output_errors_all ${dpkgdeb_output_errors_all}
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
if(NOT "${dpkg_depends}" STREQUAL "depend-default")

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
set(config_verbose -V)
@ -73,9 +73,9 @@ if(DPKGDEB_EXECUTABLE)
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' does contains 'depend-default'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-headers")
if(NOT "${dpkg_depends}" STREQUAL "depend-headers")
if(NOT "${dpkg_depends}" STREQUAL "mylib-libraries (= 1.0.2), depend-headers")
set(dpkgdeb_output_errors_all "${dpkgdeb_output_errors_all}"
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'depend-headers'\n")
"dpkg-deb: ${_f}: Incorrect dependencies for package ${dpkg_package_name}: '${dpkg_depends}' != 'mylib-libraries (= 1.0.2), depend-headers'\n")
endif()
elseif("${dpkg_package_name}" STREQUAL "mylib-libraries")
if(NOT "${dpkg_depends}" STREQUAL "depend-default")

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -7,7 +7,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -5,7 +5,7 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# TODO: currently debian doens't produce lower cased names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -9,7 +9,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# requirements
# debian now produces lower case names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)

View File

@ -6,7 +6,7 @@ include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# expected results
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib-*_1.0.2-1_*.deb")
set(expected_count 3)
set(config_verbose -V)

View File

@ -5,7 +5,7 @@ endif()
include(${CPackComponentsDEB_SOURCE_DIR}/RunCPackVerifyResult.cmake)
# TODO: currently debian doens't produce lower cased names
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsDEB_BINARY_DIR}/mylib_1.0.2-1_*.deb")
set(expected_count 1)
set(actual_output)

View File

@ -60,7 +60,7 @@ elseif (CPackGen MATCHES "RPM")
set(expected_count 1)
endif ()
elseif (CPackGen MATCHES "DEB")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/MyLib-*.deb")
set(expected_file_mask "${CPackComponentsForAll_BINARY_DIR}/mylib*_1.0.2-1_*.deb")
if (${CPackComponentWay} STREQUAL "default")
set(expected_count 1)
elseif (${CPackComponentWay} STREQUAL "OnePackPerGroup")

View File

@ -9,6 +9,20 @@ function(run_cpack_test TEST_NAME types build)
file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
if(EXISTS "${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
include("${RunCMake_SOURCE_DIR}/${TEST_TYPE}/${TEST_NAME}-Prerequirements.cmake")
set(FOUND_PREREQUIREMENTS false)
get_test_prerequirements("FOUND_PREREQUIREMENTS"
"${TEST_CONFIG_DIR}/${type}_config.cmake")
# skip the test if prerequirements are not met
if(NOT FOUND_PREREQUIREMENTS)
message(STATUS "${TEST_NAME} - SKIPPED")
return()
endif()
endif()
# execute cmake
set(RunCMake_TEST_OPTIONS "-DGENERATOR_TYPE=${TEST_TYPE}")
run_cmake(${TEST_NAME})

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "components_empty_dir*.deb")
set(EXPECTED_FILE_1 "components_empty_dir-test_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -1,9 +1,9 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "deb_extra-*-foo.deb")
set(EXPECTED_FILE_1 "deb_extra-foo_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "deb_extra-*-bar.deb")
set(EXPECTED_FILE_2 "deb_extra-bar_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/${whitespaces_}.*/usr/bar/${whitespaces_}.*/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_3 "deb_extra-*-bas.deb")
set(EXPECTED_FILE_3 "deb_extra-bas_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/${whitespaces_}.*/usr/bas/${whitespaces_}.*/usr/bas/CMakeLists.txt$")

View File

@ -0,0 +1,6 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "generate_shlibs_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/libtest_lib\\..*$")

View File

@ -0,0 +1,7 @@
function(get_test_prerequirements found_var)
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,3 @@
set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs \\(\\= 0\\.1\\.1\\)\n$")
set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*")
verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs")

View File

@ -0,0 +1,6 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "generate_shlibs_ldconfig_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/lib${whitespaces_}.*/usr/lib/libtest_lib\\..*$")

View File

@ -0,0 +1,7 @@
function(get_test_prerequirements found_var)
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(${found_var} true PARENT_SCOPE)
endif()
endfunction()

View File

@ -0,0 +1,7 @@
set(shlibs_shlibs "^libtest_lib 0\\.8 generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$")
set(shlibs_shlibs_permissions_regex "-rw-r--r-- .*")
set(shlibs_postinst ".*ldconfig.*")
set(shlibs_postinst_permissions_regex "-rwxr-xr-x .*")
set(shlibs_postrm ".*ldconfig.*")
set(shlibs_postrm_permissions_regex "-rwxr-xr-x .*")
verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs;postinst;postrm")

View File

@ -1,14 +1,14 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "5")
set(EXPECTED_FILE_1 "dependencies*-applications.deb")
set(EXPECTED_FILE_1 "dependencies-applications_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/test_prog$")
set(EXPECTED_FILE_2 "dependencies*-applications_auto.deb")
set(EXPECTED_FILE_2 "dependencies-applications_auto_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo_auto${whitespaces_}.*/usr/foo_auto/test_prog$")
set(EXPECTED_FILE_3 "dependencies*-headers.deb")
set(EXPECTED_FILE_3 "dependencies-headers_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/bar${whitespaces_}.*/usr/bar/CMakeLists.txt$")
set(EXPECTED_FILE_4 "dependencies*-libs.deb")
set(EXPECTED_FILE_4 "dependencies-libs_0.1.1-1_*.deb")
# dynamic lib extension is .so on Linux and .dylib on Mac so we will use a wildcard .* for it
set(EXPECTED_FILE_CONTENT_4 "^.*/usr/bas${whitespaces_}.*/usr/bas/libtest_lib\\..*$")
set(EXPECTED_FILE_5 "dependencies*-libs_auto.deb")
set(EXPECTED_FILE_5 "dependencies-libs_auto_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_5 "^.*/usr/bas_auto${whitespaces_}.*/usr/bas_auto/libtest_lib\\..*$")

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "empty_dir*.deb")
set(EXPECTED_FILE_1 "empty_dir_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/empty/$")

View File

@ -1,7 +1,7 @@
set(ALL_FILES_GLOB "*.deb")
function(getPackageContent FILE RESULT_VAR)
execute_process(COMMAND ${DPKG_EXECUTABLE} -c ${FILE}
execute_process(COMMAND ${DPKG_EXECUTABLE} -c "${FILE}"
OUTPUT_VARIABLE package_content_
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE)
@ -9,8 +9,73 @@ function(getPackageContent FILE RESULT_VAR)
set(${RESULT_VAR} "${package_content_}" PARENT_SCOPE)
endfunction()
function(getMissingShlibsErrorExtra FILE RESULT_VAR)
execute_process(COMMAND ${DPKG_EXECUTABLE} -x "${FILE}" data_${PREFIX}
ERROR_VARIABLE err_)
if(err_)
set(error_extra " Extra: Could not unpack package content: '${err}'")
else()
cmake_policy(PUSH)
# Tell file(GLOB_RECURSE) not to follow directory symlinks
# even if the project does not set this policy to NEW.
cmake_policy(SET CMP0009 NEW)
file(GLOB_RECURSE FILE_PATHS_ LIST_DIRECTORIES false "${CMAKE_CURRENT_BINARY_DIR}/data_${PREFIX}/*")
cmake_policy(POP)
# get file info so that we can determine if file is executable or not
foreach(FILE_ IN LISTS FILE_PATHS_)
execute_process(COMMAND file "${FILE_}"
WORKING_DIRECTORY "${WDIR}"
OUTPUT_VARIABLE INSTALL_FILE_
ERROR_VARIABLE err_)
if(NOT err_)
list(APPEND deb_install_files "${INSTALL_FILE_}")
else()
list(APPEND deb_install_files_errors "'${FILE_}': '${err_}'\n")
endif()
endforeach()
set(error_extra " Extra: install files '${deb_install_files}'")
if(deb_install_files_errors)
set(error_extra "${error_extra}; errors \"${deb_install_files_errors}\"")
endif()
find_program(READELF_EXECUTABLE NAMES readelf)
if(READELF_EXECUTABLE)
set(error_extra "${error_extra}; readelf \"\n")
# Only dynamically linked ELF files are included
# Extract only file name infront of ":"
foreach(_FILE IN LISTS deb_install_files)
if(_FILE MATCHES "ELF.*shared object")
string(REGEX MATCH "(^.*):" _FILE_NAME "${_FILE}")
execute_process(COMMAND ${READELF_EXECUTABLE} -d "${CMAKE_MATCH_1}"
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
RESULT_VARIABLE result
OUTPUT_VARIABLE output
ERROR_VARIABLE err_
OUTPUT_STRIP_TRAILING_WHITESPACE)
set(error_extra "${error_extra} name '${CMAKE_MATCH_1}'\n result '${result}'\n output '${output}'\n error '${err_}'\n")
endif()
endforeach()
set(error_extra "${error_extra}\"")
else()
set(error_extra "${error_extra}; error readelf missing")
endif()
endif()
set(${RESULT_VAR} "${error_extra}" PARENT_SCOPE)
endfunction()
function(verifyDebControl FILE PREFIX VERIFY_FILES)
execute_process(COMMAND ${DPKG_EXECUTABLE} --control ${FILE} control_${PREFIX}
execute_process(COMMAND ${DPKG_EXECUTABLE} --control "${FILE}" control_${PREFIX}
ERROR_VARIABLE err_)
if(err_)
@ -19,6 +84,14 @@ function(verifyDebControl FILE PREFIX VERIFY_FILES)
endif()
foreach(FILE_ IN LISTS VERIFY_FILES)
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}")
if(FILE_ STREQUAL "shlibs")
getMissingShlibsErrorExtra("${FILE}" error_extra)
endif()
message(FATAL_ERROR "Expected Debian control file does not exist: '${FILE_}'${error_extra}")
endif()
file(READ "${CMAKE_CURRENT_BINARY_DIR}/control_${PREFIX}/${FILE_}" content_)
if(NOT content_ MATCHES "${${PREFIX}_${FILE_}}")
message(FATAL_ERROR "Unexpected content in for '${PREFIX}_${FILE_}'!"

View File

@ -1,5 +1,5 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "1")
set(EXPECTED_FILE_1 "minimal*.deb")
set(EXPECTED_FILE_1 "minimal_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/${whitespaces_}.*/usr/foo/${whitespaces_}.*/usr/foo/CMakeLists.txt$")

View File

@ -1,9 +1,9 @@
set(whitespaces_ "[\t\n\r ]*")
set(EXPECTED_FILES_COUNT "3")
set(EXPECTED_FILE_1 "per_component*-pkg_1.deb")
set(EXPECTED_FILE_1 "per_component-pkg_1_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_1 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_2 "per_component*-pkg_2.deb")
set(EXPECTED_FILE_2 "second_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_2 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")
set(EXPECTED_FILE_3 "per_component*-pkg_3.deb")
set(EXPECTED_FILE_3 "per_component-pkg_3_0.1.1-1_*.deb")
set(EXPECTED_FILE_CONTENT_3 "^.*/usr/foo${whitespaces_}.*/usr/foo/CMakeLists.txt$")

View File

@ -0,0 +1,17 @@
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
"#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
install(TARGETS test_lib DESTINATION foo COMPONENT libs)
set(CPACK_PACKAGE_NAME "generate_shlibs")

View File

@ -0,0 +1,18 @@
set(CPACK_PACKAGE_CONTACT "someone")
set(CPACK_DEB_COMPONENT_INSTALL "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS "ON")
set(CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS_POLICY ">=")
set(CMAKE_BUILD_WITH_INSTALL_RPATH 1)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.hpp"
"int test_lib();\n")
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp"
"#include \"test_lib.hpp\"\nint test_lib() {return 0;}\n")
add_library(test_lib SHARED "${CMAKE_CURRENT_BINARY_DIR}/test_lib.cpp")
set_target_properties(test_lib PROPERTIES SOVERSION "0.8")
install(TARGETS test_lib LIBRARY DESTINATION lib COMPONENT libs NAMELINK_SKIP)
set(CPACK_PACKAGE_NAME "generate_shlibs_ldconfig")

View File

@ -1,6 +1,9 @@
RunCMake.CPack is a test module that is intended for testing of package
generators that can be validated from command line.
TODO: all tests should cover all packaging types (single package, grouped and
component packaging)
-------------
Adding a test
-------------
@ -19,10 +22,29 @@ run_cpack_test(<test_name> "<generator_name>")
will be run for all listed generators.
Test consists of
- test prerequirements phase (optional)
- CMake execution phase
- CPack execution phase
- verification of generated files
test prerequirements phase (optional):
--------------------------------------
In some cases individual tests for certain generator need additional
prerequirements met.
In such cases '<generator_name>/<test_name>-Prerequirements.cmake' file
containing 'function(get_test_prerequirements found_var)' should be created.
Function should return true if all prerequirements are met.
If prerequirements are not met test will be skipped outputting
'<test_name> - SKIPPED' string. Note that this doesn't fail the entire test
group.
TODO: skipped tests should provide expected error string so test should fail
if error string is not found in the output of run test (this would add
'EXPECTED FAIL' string on success and 'ERROR' on failure).
CMake execution phase:
----------------------

View File

@ -12,3 +12,5 @@ run_cpack_test(EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(COMPONENTS_EMPTY_DIR "RPM;DEB;TGZ" true)
run_cpack_test(PER_COMPONENT_FIELDS "RPM;DEB" false)
run_cpack_test(INSTALL_SCRIPTS "RPM" false)
run_cpack_test(DEB_GENERATE_SHLIBS "DEB" true)
run_cpack_test(DEB_GENERATE_SHLIBS_LDCONFIG "DEB" true)