From 8575affa4c72e1c0d07f964d2f28eb6ddbadb291 Mon Sep 17 00:00:00 2001 From: Domen Vrankar Date: Sat, 26 Nov 2016 20:37:07 +0100 Subject: Tests: CPack test move and merge VerifyResult Merge VerifyResult of different generators pertest and move the file to its test dir. --- .../CPack/DEB/DEB_EXTRA-VerifyResult.cmake | 18 ----- .../DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake | 4 -- ...DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake | 8 --- .../CPack/DEB/DEPENDENCIES-VerifyResult.cmake | 34 --------- .../CPack/DEB/LONG_FILENAMES-VerifyResult.cmake | 26 ------- .../DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake | 18 ----- .../CPack/RPM/DEPENDENCIES-VerifyResult.cmake | 45 ------------ .../CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake | 29 -------- .../RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake | 18 ----- .../RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake | 11 --- .../CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake | 31 -------- .../CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake | 63 ----------------- .../CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake | 12 ---- Tests/RunCMake/CPack/VerifyResult.cmake | 4 +- .../CPack/tests/DEB_EXTRA/VerifyResult.cmake | 18 +++++ .../tests/DEB_GENERATE_SHLIBS/VerifyResult.cmake | 4 ++ .../VerifyResult.cmake | 8 +++ .../CPack/tests/DEPENDENCIES/VerifyResult.cmake | 82 ++++++++++++++++++++++ .../CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake | 29 ++++++++ .../CPack/tests/LONG_FILENAMES/VerifyResult.cmake | 26 +++++++ .../tests/PACKAGE_CHECKSUM/VerifyResult.cmake | 12 ++++ .../tests/PER_COMPONENT_FIELDS/VerifyResult.cmake | 26 +++++++ .../CPack/tests/RPM_DIST/VerifyResult.cmake | 11 +++ .../CPack/tests/RPM_SUGGESTS/VerifyResult.cmake | 31 ++++++++ .../CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake | 63 +++++++++++++++++ 25 files changed, 312 insertions(+), 319 deletions(-) delete mode 100644 Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake delete mode 100644 Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEB_EXTRA/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/RPM_DIST/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/RPM_SUGGESTS/VerifyResult.cmake create mode 100644 Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake diff --git a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake deleted file mode 100644 index 85e137f..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_EXTRA-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -set(foo_preinst "^echo default_preinst$") -# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems -set(foo_preinst_permissions_regex "-rwxr-xr-x\.? .*") -set(foo_prerm "^echo default_prerm$") -set(foo_prerm_permissions_regex "-rwxr-xr-x\.? .*") -verifyDebControl("${FOUND_FILE_1}" "foo" "preinst;prerm") - -set(bar_preinst "^echo bar_preinst$") -set(bar_preinst_permissions_regex "-rwx------\.? .*") -set(bar_prerm "^echo bar_prerm$") -set(bar_prerm_permissions_regex "-rwx------\.? .*") -verifyDebControl("${FOUND_FILE_2}" "bar" "preinst;prerm") - -set(bas_preinst "^echo default_preinst$") -set(bas_preinst_permissions_regex "-rwxr-xr-x\.? .*") -set(bas_prerm "^echo default_prerm$") -set(bas_prerm_permissions_regex "-rwxr-xr-x\.? .*") -verifyDebControl("${FOUND_FILE_3}" "bas" "preinst;prerm") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake deleted file mode 100644 index f5d97db..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS-VerifyResult.cmake +++ /dev/null @@ -1,4 +0,0 @@ -set(shlibs_shlibs "^libtest_lib 0\\.8 deb_generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") -# optional dot at the end of permissions regex is for SELinux enabled systems -set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*") -verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs") diff --git a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake deleted file mode 100644 index 320732b..0000000 --- a/Tests/RunCMake/CPack/DEB/DEB_GENERATE_SHLIBS_LDCONFIG-VerifyResult.cmake +++ /dev/null @@ -1,8 +0,0 @@ -set(shlibs_shlibs "^libtest_lib 0\\.8 deb_generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$") -# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems -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") diff --git a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index ba39f2e..0000000 --- a/Tests/RunCMake/CPack/DEB/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,34 +0,0 @@ -function(checkDependencies_ FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) - string(TOLOWER "${dependency_type_}" lower_dependency_type_) - string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) - string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) - set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") - - checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") - checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") - checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") - checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") -endforeach() - -checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") -checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") -checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") - -# PREDEPENDS -checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") -checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") -checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") -checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") diff --git a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake deleted file mode 100644 index 0452343..0000000 --- a/Tests/RunCMake/CPack/DEB/LONG_FILENAMES-VerifyResult.cmake +++ /dev/null @@ -1,26 +0,0 @@ -# create structure required by non root dpkg install -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/updates") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/info") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/available" "") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/status" "") - -# some programs used by fakeroot require sbin in path so we should not -# leave this to chance (programs: ldconfig and start-stop-daemon) -set(ENV{PATH} "$ENV{PATH}:/usr/local/sbin:/usr/sbin:/sbin") - -execute_process(COMMAND ${FAKEROOT_EXECUTABLE} ${DPKG_EXECUTABLE} - -i --force-not-root --root=${CMAKE_CURRENT_BINARY_DIR}/root_dir - --admindir=${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir - --log=${CMAKE_CURRENT_BINARY_DIR}/root_dir/dpkg.log - ${FOUND_FILE_1} - RESULT_VARIABLE install_result_ - ERROR_VARIABLE install_error_ - OUTPUT_QUIET - ) - -if(install_result_) - message(FATAL_ERROR "LONG_FILENAMES package error - result:" - " '${install_result_}'; text: '${install_error_}'") -endif() diff --git a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index 0f69925..0000000 --- a/Tests/RunCMake/CPack/DEB/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Package${whitespaces_}:${whitespaces_}per_component_fields-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Package${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Package${whitespaces_}:${whitespaces_}per_component_fields-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Section${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Section${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Section${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake deleted file mode 100644 index fec8889..0000000 --- a/Tests/RunCMake/CPack/RPM/DEPENDENCIES-VerifyResult.cmake +++ /dev/null @@ -1,45 +0,0 @@ -function(checkDependencies_ FILE TYPE COMPARE_LIST) - set(whitespaces_ "[\t\n\r ]*") - - execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE FILE_DEPENDENCIES_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") - - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) - - foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() - endif() - endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() -endfunction() - -# TODO add tests for what should not be present in lists -checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") -checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") -checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") -checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") -checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") - -checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") -checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") -checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") -checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") - -checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") -checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") -checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") diff --git a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake deleted file mode 100644 index d7d82f2..0000000 --- a/Tests/RunCMake/CPack/RPM/INSTALL_SCRIPTS-VerifyResult.cmake +++ /dev/null @@ -1,29 +0,0 @@ -function(checkScripts_ FILE COMPARE_LIST) - set(whitespaces_ "[\t\n\r ]*") - - execute_process(COMMAND ${RPM_EXECUTABLE} -qp --scripts ${FILE} - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - OUTPUT_VARIABLE FILE_SCRIPTS_ - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - - string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}") - - foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) - unset(FOUND_) - - foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_) - if(COMPARE_ MATCHES "${COMPARE_REGEX_}") - set(FOUND_ true) - break() - endif() - endforeach() - - if(NOT FOUND_) - message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'") - endif() - endforeach() -endfunction() - -checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\"") -checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\"") diff --git a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake deleted file mode 100644 index 1ff9a22..0000000 --- a/Tests/RunCMake/CPack/RPM/PER_COMPONENT_FIELDS-VerifyResult.cmake +++ /dev/null @@ -1,18 +0,0 @@ -function(checkPackageInfo_ TYPE FILE REGEX) - set(whitespaces_ "[\t\n\r ]*") - - getPackageInfo("${FILE}" "FILE_INFO_") - if(NOT FILE_INFO_ MATCHES "${REGEX}") - message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") - endif() -endfunction() - -# check package name -checkPackageInfo_("name" "${FOUND_FILE_1}" ".*Name${whitespaces_}:${whitespaces_}per_component_fields-pkg_1") -checkPackageInfo_("name" "${FOUND_FILE_2}" ".*Name${whitespaces_}:${whitespaces_}second") -checkPackageInfo_("name" "${FOUND_FILE_3}" ".*Name${whitespaces_}:${whitespaces_}per_component_fields-pkg_3") - -# check package group -checkPackageInfo_("group" "${FOUND_FILE_1}" ".*Group${whitespaces_}:${whitespaces_}default") -checkPackageInfo_("group" "${FOUND_FILE_2}" ".*Group${whitespaces_}:${whitespaces_}second_group") -checkPackageInfo_("group" "${FOUND_FILE_3}" ".*Group${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake deleted file mode 100644 index 7375ecc..0000000 --- a/Tests/RunCMake/CPack/RPM/RPM_DIST-VerifyResult.cmake +++ /dev/null @@ -1,11 +0,0 @@ -execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist} - OUTPUT_VARIABLE DIST_TAG - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - -set(whitespaces_ "[\t\n\r ]*") - -getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_") -if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}") - message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'") -endif() diff --git a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake deleted file mode 100644 index 32cc6d1..0000000 --- a/Tests/RunCMake/CPack/RPM/RPM_SUGGESTS-VerifyResult.cmake +++ /dev/null @@ -1,31 +0,0 @@ -execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags - OUTPUT_VARIABLE RPMBUILD_CAPS - RESULT_VARIABLE RPMBUILD_CAPS_RESULT) - -if(NOT RPMBUILD_CAPS_RESULT) - string(REPLACE "\n" ";" RPMBUILD_CAPS "${RPMBUILD_CAPS}") - cmake_policy(PUSH) - cmake_policy(SET CMP0057 NEW) - if(SUGGESTS IN_LIST RPMBUILD_CAPS) - set(should_contain_suggests_tag_ true) - endif() - cmake_policy(POP) -endif() - -# Only verify that suggests tag is present only if that tag is supported. -# If it is not supported the rpm package was corretly generated by ignoring -# that tag and that was already checked by expected files test. -if(should_contain_suggests_tag_) - execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}" - WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" - RESULT_VARIABLE rpm_result_ - OUTPUT_VARIABLE rpm_output_ - ERROR_VARIABLE error_variable_ - OUTPUT_STRIP_TRAILING_WHITESPACE) - - if(rpm_result_ OR NOT rpm_output_ STREQUAL "libsuggested") - message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages" - " (result: '${rpm_result_}'; output: '${rpm_output_}';" - " error: '${error_variable_}')") - endif() -endif() diff --git a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake b/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake deleted file mode 100644 index a84e296..0000000 --- a/Tests/RunCMake/CPack/RPM/SOURCE_PACKAGE-VerifyResult.cmake +++ /dev/null @@ -1,63 +0,0 @@ -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SOURCES") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SPECS") -file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SRPMS") - -# make sure that we are using the version of cmake and cpack that we are testing -get_filename_component(cpack_path_ "${CMAKE_CPACK_COMMAND}" DIRECTORY) -set(ENV{PATH} "${cpack_path_}:$ENV{PATH}") - -execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/test_rpm" --rebuild ${FOUND_FILE_1} - RESULT_VARIABLE result_ - ERROR_VARIABLE error_ - OUTPUT_QUIET - ) - -set(output_error_message_ - "\n${RPMBUILD_EXECUTABLE} error: '${error_}';\nresult: '${result_}';\n${output_error_message}") - -set(EXPECTED_FILE_CONTENT_ "^/foo${whitespaces_}/foo/test_prog$") - -file(GLOB_RECURSE FOUND_FILE_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/*.rpm") -list(APPEND foundFiles_ "${FOUND_FILE_}") -list(LENGTH FOUND_FILE_ foundFilesCount_) - -if(foundFilesCount_ EQUAL 1) - unset(PACKAGE_CONTENT) - getPackageContent("${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/${FOUND_FILE_}" "PACKAGE_CONTENT") - - string(REGEX MATCH "${EXPECTED_FILE_CONTENT_}" - expected_content_list "${PACKAGE_CONTENT}") - - if(NOT expected_content_list) - message(FATAL_ERROR - "Unexpected file content!\n" - " Content: '${PACKAGE_CONTENT}'\n\n" - " Expected: '${EXPECTED_FILE_CONTENT_}'" - "${output_error_message_}") - endif() -else() - message(FATAL_ERROR - "Found more than one file!" - " Found files count '${foundFilesCount_}'." - " Files: '${FOUND_FILE_}'" - "${output_error_message_}") -endif() - -# check that there were no extra files generated -foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB) - file(GLOB foundAll_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${all_files_glob_}") - list(APPEND allFoundFiles_ "${foundAll_}") -endforeach() - -list(LENGTH foundFiles_ foundFilesCount_) -list(LENGTH allFoundFiles_ allFoundFilesCount_) - -if(NOT foundFilesCount_ EQUAL allFoundFilesCount_) - message(FATAL_ERROR - "Found more files than expected! Found files: '${allFoundFiles_}'" - "${output_error_message_}") -endif() diff --git a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake b/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake deleted file mode 100644 index e4f9618..0000000 --- a/Tests/RunCMake/CPack/TGZ/PACKAGE_CHECKSUM-VerifyResult.cmake +++ /dev/null @@ -1,12 +0,0 @@ -if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") - string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) - file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") - file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") - file(STRINGS ${CSUMFILE} CHSUM_VALUE) - file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) - set(expected_value "${expected_value} ${PACKAGE}") - - if(NOT expected_value STREQUAL CHSUM_VALUE) - message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]") - endif() -endif() diff --git a/Tests/RunCMake/CPack/VerifyResult.cmake b/Tests/RunCMake/CPack/VerifyResult.cmake index 803b4bc..9ab6f11 100644 --- a/Tests/RunCMake/CPack/VerifyResult.cmake +++ b/Tests/RunCMake/CPack/VerifyResult.cmake @@ -84,8 +84,8 @@ else() endif() # handle additional result verifications -if(EXISTS "${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") - include("${src_dir}/${GENERATOR_TYPE}/${RunCMake_TEST_FILE_PREFIX}-VerifyResult.cmake") +if(EXISTS "${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") + include("${src_dir}/tests/${RunCMake_TEST_FILE_PREFIX}/VerifyResult.cmake") endif() message(STATUS "${output}") diff --git a/Tests/RunCMake/CPack/tests/DEB_EXTRA/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_EXTRA/VerifyResult.cmake new file mode 100644 index 0000000..85e137f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_EXTRA/VerifyResult.cmake @@ -0,0 +1,18 @@ +set(foo_preinst "^echo default_preinst$") +# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems +set(foo_preinst_permissions_regex "-rwxr-xr-x\.? .*") +set(foo_prerm "^echo default_prerm$") +set(foo_prerm_permissions_regex "-rwxr-xr-x\.? .*") +verifyDebControl("${FOUND_FILE_1}" "foo" "preinst;prerm") + +set(bar_preinst "^echo bar_preinst$") +set(bar_preinst_permissions_regex "-rwx------\.? .*") +set(bar_prerm "^echo bar_prerm$") +set(bar_prerm_permissions_regex "-rwx------\.? .*") +verifyDebControl("${FOUND_FILE_2}" "bar" "preinst;prerm") + +set(bas_preinst "^echo default_preinst$") +set(bas_preinst_permissions_regex "-rwxr-xr-x\.? .*") +set(bas_prerm "^echo default_prerm$") +set(bas_prerm_permissions_regex "-rwxr-xr-x\.? .*") +verifyDebControl("${FOUND_FILE_3}" "bas" "preinst;prerm") diff --git a/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS/VerifyResult.cmake new file mode 100644 index 0000000..f5d97db --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS/VerifyResult.cmake @@ -0,0 +1,4 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 deb_generate_shlibs \\(\\= 0\\.1\\.1\\)\n$") +# optional dot at the end of permissions regex is for SELinux enabled systems +set(shlibs_shlibs_permissions_regex "-rw-r--r--\.? .*") +verifyDebControl("${FOUND_FILE_1}" "shlibs" "shlibs") diff --git a/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake new file mode 100644 index 0000000..320732b --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEB_GENERATE_SHLIBS_LDCONFIG/VerifyResult.cmake @@ -0,0 +1,8 @@ +set(shlibs_shlibs "^libtest_lib 0\\.8 deb_generate_shlibs_ldconfig \\(>\\= 0\\.1\\.1\\)\n$") +# NOTE: optional dot at the end of permissions regex is for SELinux enabled systems +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") diff --git a/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake new file mode 100644 index 0000000..1c7ff5e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DEPENDENCIES/VerifyResult.cmake @@ -0,0 +1,82 @@ +if(GENERATOR_TYPE STREQUAL "DEB") + function(checkDependencies_ FILE REGEX) + set(whitespaces_ "[\t\n\r ]*") + + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected dependencies in '${FILE}'; file info: '${FILE_INFO_}'") + endif() + endfunction() + + foreach(dependency_type_ DEPENDS CONFLICTS ENHANCES BREAKS REPLACES RECOMMENDS SUGGESTS) + string(TOLOWER "${dependency_type_}" lower_dependency_type_) + string(SUBSTRING ${lower_dependency_type_} 1 -1 lower_dependency_type_tail_) + string(SUBSTRING ${dependency_type_} 0 1 dependency_type_head_) + set(dependency_type_name_ "${dependency_type_head_}${lower_dependency_type_tail_}") + + checkDependencies_("${FOUND_FILE_1}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}.*${lower_dependency_type_}-application, ${lower_dependency_type_}-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*${dependency_type_name_}${whitespaces_}:${whitespaces_}${lower_dependency_type_}-default, ${lower_dependency_type_}-default-b.*") + endforeach() + + checkDependencies_("${FOUND_FILE_1}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_2}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_3}" ".*Provides${whitespaces_}:${whitespaces_}provided-default, provided-default-b") + checkDependencies_("${FOUND_FILE_4}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib.*") + checkDependencies_("${FOUND_FILE_5}" ".*Provides${whitespaces_}:${whitespaces_}provided-lib_auto.*, provided-lib_auto-b.*") + + # PREDEPENDS + checkDependencies_("${FOUND_FILE_1}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_2}" ".*Pre-Depends${whitespaces_}:${whitespaces_}.*predepends-application, predepends-application-b.*") + checkDependencies_("${FOUND_FILE_3}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-headers.*") + checkDependencies_("${FOUND_FILE_4}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") + checkDependencies_("${FOUND_FILE_5}" ".*Pre-Depends${whitespaces_}:${whitespaces_}predepends-default, predepends-default-b.*") +elseif(GENERATOR_TYPE STREQUAL "RPM") + function(checkDependencies_ FILE TYPE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --${TYPE} ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_DEPENDENCIES_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_DEPENDENCIES_LIST_ "${FILE_DEPENDENCIES_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_DEPENDENCIES_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing dependencies in '${FILE}'; check type: '${TYPE}'; file info: '${FILE_DEPENDENCIES_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() + endfunction() + + # TODO add tests for what should not be present in lists + checkDependencies_("${FOUND_FILE_1}" "requires" "depend-application;depend-application-b") + checkDependencies_("${FOUND_FILE_2}" "requires" "depend-application;depend-application-b;libtest_lib\\.so.*") + checkDependencies_("${FOUND_FILE_3}" "requires" "depend-headers") + checkDependencies_("${FOUND_FILE_4}" "requires" "depend-default;depend-default-b") + checkDependencies_("${FOUND_FILE_5}" "requires" "depend-default;depend-default-b") + + checkDependencies_("${FOUND_FILE_1}" "conflicts" "conflict-application;conflict-application-b") + checkDependencies_("${FOUND_FILE_2}" "conflicts" "conflict-application;conflict-application-b") + checkDependencies_("${FOUND_FILE_3}" "conflicts" "conflict-headers") + checkDependencies_("${FOUND_FILE_4}" "conflicts" "conflict-default;conflict-default-b") + checkDependencies_("${FOUND_FILE_5}" "conflicts" "conflict-default;conflict-default-b") + + checkDependencies_("${FOUND_FILE_1}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_2}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_3}" "provides" "provided-default;provided-default-b") + checkDependencies_("${FOUND_FILE_4}" "provides" "provided-lib") + checkDependencies_("${FOUND_FILE_5}" "provides" "provided-lib_auto;provided-lib_auto-b") +endif() diff --git a/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake new file mode 100644 index 0000000..d7d82f2 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/INSTALL_SCRIPTS/VerifyResult.cmake @@ -0,0 +1,29 @@ +function(checkScripts_ FILE COMPARE_LIST) + set(whitespaces_ "[\t\n\r ]*") + + execute_process(COMMAND ${RPM_EXECUTABLE} -qp --scripts ${FILE} + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + OUTPUT_VARIABLE FILE_SCRIPTS_ + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + + string(REPLACE "\n" ";" FILE_SCRIPTS_LIST_ "${FILE_SCRIPTS_}") + + foreach(COMPARE_REGEX_ IN LISTS COMPARE_LIST) + unset(FOUND_) + + foreach(COMPARE_ IN LISTS FILE_SCRIPTS_LIST_) + if(COMPARE_ MATCHES "${COMPARE_REGEX_}") + set(FOUND_ true) + break() + endif() + endforeach() + + if(NOT FOUND_) + message(FATAL_ERROR "Missing scripts in '${FILE}'; file info: '${FILE_SCRIPTS_}'; missing: '${COMPARE_REGEX_}'") + endif() + endforeach() +endfunction() + +checkScripts_("${FOUND_FILE_1}" "echo \"pre install foo\";echo \"post install foo\";echo \"pre uninstall foo\";echo \"post uninstall foo\"") +checkScripts_("${FOUND_FILE_2}" "echo \"pre install\";echo \"post install\";echo \"pre uninstall\";echo \"post uninstall\"") diff --git a/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake new file mode 100644 index 0000000..0452343 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/LONG_FILENAMES/VerifyResult.cmake @@ -0,0 +1,26 @@ +# create structure required by non root dpkg install +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/updates") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/info") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/available" "") +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir/status" "") + +# some programs used by fakeroot require sbin in path so we should not +# leave this to chance (programs: ldconfig and start-stop-daemon) +set(ENV{PATH} "$ENV{PATH}:/usr/local/sbin:/usr/sbin:/sbin") + +execute_process(COMMAND ${FAKEROOT_EXECUTABLE} ${DPKG_EXECUTABLE} + -i --force-not-root --root=${CMAKE_CURRENT_BINARY_DIR}/root_dir + --admindir=${CMAKE_CURRENT_BINARY_DIR}/root_dir/admindir + --log=${CMAKE_CURRENT_BINARY_DIR}/root_dir/dpkg.log + ${FOUND_FILE_1} + RESULT_VARIABLE install_result_ + ERROR_VARIABLE install_error_ + OUTPUT_QUIET + ) + +if(install_result_) + message(FATAL_ERROR "LONG_FILENAMES package error - result:" + " '${install_result_}'; text: '${install_error_}'") +endif() diff --git a/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake new file mode 100644 index 0000000..e4f9618 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PACKAGE_CHECKSUM/VerifyResult.cmake @@ -0,0 +1,12 @@ +if(NOT ${RunCMake_SUBTEST_SUFFIX} MATCHES "invalid") + string(TOLOWER ${RunCMake_SUBTEST_SUFFIX} EXTENSION) + file(GLOB PACKAGE RELATIVE ${bin_dir} "*.tar.gz") + file(GLOB CSUMFILE RELATIVE ${bin_dir} "*.${EXTENSION}") + file(STRINGS ${CSUMFILE} CHSUM_VALUE) + file(${RunCMake_SUBTEST_SUFFIX} ${PACKAGE} expected_value ) + set(expected_value "${expected_value} ${PACKAGE}") + + if(NOT expected_value STREQUAL CHSUM_VALUE) + message(FATAL_ERROR "Generated checksum is not valid! Expected [${expected_value}] Got [${CHSUM_VALUE}]") + endif() +endif() diff --git a/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake new file mode 100644 index 0000000..18ef63c --- /dev/null +++ b/Tests/RunCMake/CPack/tests/PER_COMPONENT_FIELDS/VerifyResult.cmake @@ -0,0 +1,26 @@ +function(checkPackageInfo_ TYPE FILE REGEX) + getPackageInfo("${FILE}" "FILE_INFO_") + if(NOT FILE_INFO_ MATCHES "${REGEX}") + message(FATAL_ERROR "Unexpected ${TYPE} in '${FILE}'; file info: '${FILE_INFO_}'") + endif() +endfunction() + +if(GENERATOR_TYPE STREQUAL "DEB") + set(name_ "Package") + set(group_ "Section") +elseif(GENERATOR_TYPE STREQUAL "RPM") + set(name_ "Name") + set(group_ "Group") +endif() + +set(whitespaces_ "[\t\n\r ]*") + +# check package name +checkPackageInfo_("name" "${FOUND_FILE_1}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_1") +checkPackageInfo_("name" "${FOUND_FILE_2}" ".*${name_}${whitespaces_}:${whitespaces_}second") +checkPackageInfo_("name" "${FOUND_FILE_3}" ".*${name_}${whitespaces_}:${whitespaces_}per_component_fields-pkg_3") + +# check package group +checkPackageInfo_("group" "${FOUND_FILE_1}" ".*${group_}${whitespaces_}:${whitespaces_}default") +checkPackageInfo_("group" "${FOUND_FILE_2}" ".*${group_}${whitespaces_}:${whitespaces_}second_group") +checkPackageInfo_("group" "${FOUND_FILE_3}" ".*${group_}${whitespaces_}:${whitespaces_}default") diff --git a/Tests/RunCMake/CPack/tests/RPM_DIST/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/RPM_DIST/VerifyResult.cmake new file mode 100644 index 0000000..7375ecc --- /dev/null +++ b/Tests/RunCMake/CPack/tests/RPM_DIST/VerifyResult.cmake @@ -0,0 +1,11 @@ +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} -E %{?dist} + OUTPUT_VARIABLE DIST_TAG + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set(whitespaces_ "[\t\n\r ]*") + +getPackageInfo("${FOUND_FILE_1}" "FILE_INFO_") +if(NOT FILE_INFO_ MATCHES ".*Release${whitespaces_}:${whitespaces_}1${DIST_TAG}") + message(FATAL_ERROR "Unexpected Release in '${FOUND_FILE_1}'; file info: '${FILE_INFO_}'") +endif() diff --git a/Tests/RunCMake/CPack/tests/RPM_SUGGESTS/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/RPM_SUGGESTS/VerifyResult.cmake new file mode 100644 index 0000000..32cc6d1 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/RPM_SUGGESTS/VerifyResult.cmake @@ -0,0 +1,31 @@ +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --querytags + OUTPUT_VARIABLE RPMBUILD_CAPS + RESULT_VARIABLE RPMBUILD_CAPS_RESULT) + +if(NOT RPMBUILD_CAPS_RESULT) + string(REPLACE "\n" ";" RPMBUILD_CAPS "${RPMBUILD_CAPS}") + cmake_policy(PUSH) + cmake_policy(SET CMP0057 NEW) + if(SUGGESTS IN_LIST RPMBUILD_CAPS) + set(should_contain_suggests_tag_ true) + endif() + cmake_policy(POP) +endif() + +# Only verify that suggests tag is present only if that tag is supported. +# If it is not supported the rpm package was corretly generated by ignoring +# that tag and that was already checked by expected files test. +if(should_contain_suggests_tag_) + execute_process(COMMAND ${RPM_EXECUTABLE} -q --suggests -p "${FOUND_FILE_1}" + WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}" + RESULT_VARIABLE rpm_result_ + OUTPUT_VARIABLE rpm_output_ + ERROR_VARIABLE error_variable_ + OUTPUT_STRIP_TRAILING_WHITESPACE) + + if(rpm_result_ OR NOT rpm_output_ STREQUAL "libsuggested") + message(FATAL_ERROR "RPM_SUGGESTED package error: no suggested packages" + " (result: '${rpm_result_}'; output: '${rpm_output_}';" + " error: '${error_variable_}')") + endif() +endif() diff --git a/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake new file mode 100644 index 0000000..a84e296 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/SOURCE_PACKAGE/VerifyResult.cmake @@ -0,0 +1,63 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILD") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/BUILDROOT") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SOURCES") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SPECS") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/SRPMS") + +# make sure that we are using the version of cmake and cpack that we are testing +get_filename_component(cpack_path_ "${CMAKE_CPACK_COMMAND}" DIRECTORY) +set(ENV{PATH} "${cpack_path_}:$ENV{PATH}") + +execute_process(COMMAND ${RPMBUILD_EXECUTABLE} --define "_topdir ${CMAKE_CURRENT_BINARY_DIR}/test_rpm" --rebuild ${FOUND_FILE_1} + RESULT_VARIABLE result_ + ERROR_VARIABLE error_ + OUTPUT_QUIET + ) + +set(output_error_message_ + "\n${RPMBUILD_EXECUTABLE} error: '${error_}';\nresult: '${result_}';\n${output_error_message}") + +set(EXPECTED_FILE_CONTENT_ "^/foo${whitespaces_}/foo/test_prog$") + +file(GLOB_RECURSE FOUND_FILE_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/*.rpm") +list(APPEND foundFiles_ "${FOUND_FILE_}") +list(LENGTH FOUND_FILE_ foundFilesCount_) + +if(foundFilesCount_ EQUAL 1) + unset(PACKAGE_CONTENT) + getPackageContent("${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS/${FOUND_FILE_}" "PACKAGE_CONTENT") + + string(REGEX MATCH "${EXPECTED_FILE_CONTENT_}" + expected_content_list "${PACKAGE_CONTENT}") + + if(NOT expected_content_list) + message(FATAL_ERROR + "Unexpected file content!\n" + " Content: '${PACKAGE_CONTENT}'\n\n" + " Expected: '${EXPECTED_FILE_CONTENT_}'" + "${output_error_message_}") + endif() +else() + message(FATAL_ERROR + "Found more than one file!" + " Found files count '${foundFilesCount_}'." + " Files: '${FOUND_FILE_}'" + "${output_error_message_}") +endif() + +# check that there were no extra files generated +foreach(all_files_glob_ IN LISTS ALL_FILES_GLOB) + file(GLOB foundAll_ RELATIVE "${CMAKE_CURRENT_BINARY_DIR}/test_rpm/RPMS" "${all_files_glob_}") + list(APPEND allFoundFiles_ "${foundAll_}") +endforeach() + +list(LENGTH foundFiles_ foundFilesCount_) +list(LENGTH allFoundFiles_ allFoundFilesCount_) + +if(NOT foundFilesCount_ EQUAL allFoundFilesCount_) + message(FATAL_ERROR + "Found more files than expected! Found files: '${allFoundFiles_}'" + "${output_error_message_}") +endif() -- cgit v0.12