Skip to content

Commit

Permalink
WIP: Move stuff/ to with_subpackages/b/, strengthen install_package_b…
Browse files Browse the repository at this point in the history
…y_package test (TriBITSPub#314)

Now I know that if a package fails to build and install that the other
packages that did build will install and have the correct permissions.
  • Loading branch information
bartlettroscoe committed Apr 25, 2020
1 parent bfa4f45 commit 553b926
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 42 deletions.
83 changes: 57 additions & 26 deletions test/core/ExamplesUnitTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,7 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
XHOSTTYPE Windows

TEST_0
MESSAGE "Copy TribitsExampleProject so we can change the source permissions"
CMND cp
Expand All @@ -1342,10 +1343,10 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms
-DTribitsExProj_ENABLE_SECONDARY_TESTED_CODE=ON
-DTribitsExProj_ENABLE_WithSubpackages=ON
-DCMAKE_INSTALL_PREFIX=install_base/install
-DTribitsExProj_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=install_base
-DTribitsExProj_MAKE_INSTALL_WORLD_READABLE=TRUE
-DTribitsExProj_MAKE_INSTALL_GROUP_WRITABLE=TRUE
-DTribitsExProj_MAKE_INSTALL_GROUP=${TribitsExProj_INSTALL_OWNING_GROUP}
-DTribitsExProj_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR=install_base
TribitsExampleProject
PASS_REGULAR_EXPRESSION_ALL
"Configuring done"
Expand Down Expand Up @@ -1374,14 +1375,14 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms
install_base/install/bin
install_base/install/include
install_base/install/lib
install_base/install/share/WithSubpackagesC/stuff
install_base/install/share/WithSubpackagesB/stuff
PASS_REGULAR_EXPRESSION_ALL
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesC/stuff"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_6
Expand All @@ -1392,7 +1393,7 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms
install_base/install/include/wsp_c
install_base/install/lib
install_base/install/bin
install_base/install/share/WithSubpackagesC/stuff
install_base/install/share/WithSubpackagesB/stuff
PASS_REGULAR_EXPRESSION_ALL
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* MixedLang.hpp"
"[d]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c"
Expand All @@ -1409,28 +1410,50 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_perms

TEST_7
MESSAGE "Make sure that exec_script.sh is exectuable"
CMND ./install_base/install/share/WithSubpackagesC/stuff/exec_script.sh
CMND ./install_base/install/share/WithSubpackagesB/stuff/exec_script.sh
PASS_REGULAR_EXPRESSION
"exec_script.sh executed and returned this string"

)
# NOTE: The above test checks a few important things:
#
# * The CMake install machinery will actually create multiple base dirs
# under ${CMAKE_INSTALL_PREFIX} in case they don't already exist.
#
# * The group ownership actaully will be set correctly starting with
# ${<Project>_SET_GROUP_AND_PERMISSIONS_ON_INSTALL_BASE_DIR} which is
# above ${CMAKE_INSTALL_PREFIX}. This is needed to address systems where
# the group sticky bit is disabled (like we see on some SNL systems, see
# ATDV-241).
#
# * Even with the source directory permissions being 'rwx------' (i.e. 700),
# the files isntalled under share/WithSubpackagesB/stuff using
# install(DIRECTORY ... USE_SOURCE_PERMISSIONS) will actually have the
# correct group and other permissions set.


TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_package_by_package_perms
OVERALL_WORKING_DIRECTORY TEST_NAME
OVERALL_NUM_MPI_PROCS 1
XHOSTTYPE Windows

TEST_0
MESSAGE "Copy TribitsExampleProject so we can change the source permissions"
CMND cp
ARGS -r ${${PROJECT_NAME}_TRIBITS_DIR}/examples/TribitsExampleProject .

TEST_1
MESSAGE "Break the WithSubpackagesB so that it will not install"
CMND ${CMAKE_CURRENT_SOURCE_DIR}/append_file_with_line.sh
ARGS TribitsExampleProject/packages/with_subpackages/c/C.cpp
"C.cpp is broken!"

TEST_2
MESSAGE "Make TribitsExampleProject source dir user rwX only!"
CMND chmod
ARGS g-rwx,o-rwx -R TribitsExampleProject

TEST_2
TEST_3
MESSAGE "Do initial configure with just libs not tests with default install settings"
CMND ${CMAKE_COMMAND}
ARGS
Expand All @@ -1448,66 +1471,74 @@ TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_install_package_by_package_perm
"Configuring done"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_3
MESSAGE "Do make to build everything"
TEST_4
MESSAGE "Do make -k to build everything that will build"
CMND make ARGS ${CTEST_BUILD_FLAGS}
ALWAYS_FAIL_ON_NONZERO_RETURN
PASS_REGULAR_EXPRESSION_ALL
"C.cpp is broken"
"packages/with_subpackages/c/CMakeFiles/pws_c.dir/C.cpp.o.*Error"
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_4
TEST_5
MESSAGE "Make install_pakage_by_package with fixup of permissions"
CMND make ARGS ${CTEST_BUILD_FLAGS} install_package_by_package
PASS_REGULAR_EXPRESSION_ALL
".*/install_base/install/include/wsp_c/C.hpp"
".*/install_base/install/lib/libpws_c.a"
"The global install failed so resorting to package-by-package installs"
".*/install_base/install/include/B.hpp"
".*/install_base/install/lib/libpws_b.a"
"Running: chgrp ${TribitsExProj_INSTALL_OWNING_GROUP} -R .*/TriBITS_TribitsExampleProject_install_package_by_package_perms/install_base"
"Running: chmod g[+]rwX,o[+]rX -R .*/TriBITS_TribitsExampleProject_install_package_by_package_perms/install_base"
ALWAYS_FAIL_ON_NONZERO_RETURN
ALWAYS_FAIL_ON_ZERO_RETURN

TEST_5
TEST_6
MESSAGE "Check some installed directory permissions and the owning group"
CMND ls ARGS -ld
install_base
install_base/install
install_base/install/bin
install_base/install/include
install_base/install/lib
install_base/install/share/WithSubpackagesC/stuff
install_base/install/share/WithSubpackagesB/stuff
PASS_REGULAR_EXPRESSION_ALL
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/bin"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/include"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/lib"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesC/stuff"
"drwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* install_base/install/share/WithSubpackagesB/stuff"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_6
TEST_7
MESSAGE "Check some installed file permissions"
CMND ls ARGS -l
install_base/install
install_base/install/include
install_base/install/include/wsp_c
install_base/install/lib
install_base/install/bin
install_base/install/share/WithSubpackagesC/stuff
install_base/install/share/WithSubpackagesB/stuff
PASS_REGULAR_EXPRESSION_ALL
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* MixedLang.hpp"
"[d]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* wsp_c"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* C.hpp"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* Makefile.export.WithSubpackagesC"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_c.a"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* B.hpp"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* Makefile.export.WithSubpackagesB"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* libpws_b.a"
"[-]rwxrwxr-x.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* exec_script.sh"
"[-]rw-rw-r--.* .* ${TribitsExProj_INSTALL_OWNING_USER} ${TribitsExProj_INSTALL_OWNING_GROUP} .* regular_file.txt"
ALWAYS_FAIL_ON_NONZERO_RETURN

TEST_7
TEST_8
MESSAGE "Make sure that exec_script.sh is exectuable"
CMND ./install_base/install/share/WithSubpackagesC/stuff/exec_script.sh
CMND ./install_base/install/share/WithSubpackagesB/stuff/exec_script.sh
PASS_REGULAR_EXPRESSION
"exec_script.sh executed and returned this string"

)

# NOTE: In addition to the same checks performed by the test
# TribitsExampleProject_install_perms described above, this above test also
# ensures that owning group and directory permissions get set even if there
# is a package install failure. The other packages that did build correctly
# will get installed and all of the files and directories that did install
# will have the correct group and permissions.


TRIBITS_ADD_ADVANCED_TEST( TribitsExampleProject_ALL_ST_NoFortran_enable_installation_testing
OVERALL_WORKING_DIRECTORY TEST_NAME
Expand Down
6 changes: 6 additions & 0 deletions test/core/ExamplesUnitTests/append_file_with_line.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

FILE_TO_EDIT=$1
LINE_TO_ADD=$2

echo "$LINE_TO_ADD" >> $FILE_TO_EDIT
21 changes: 12 additions & 9 deletions tribits/core/installation/cmake_pbp_install.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,31 @@ execute_process(
RESULT_VARIABLE global_install_rtn)

if (NOT global_install_rtn EQUAL 0)

message(
"\n"
"***\n"
"*** The global install failed so resorting to package-by-package installs\n"
"***\n"
"\n"
)

foreach (pkg_binary_dir ${TRIBITS_ENABLED_PACKAGES_BINARY_DIRS})
execute_process(COMMAND @CMAKE_COMMAND@ -P cmake_install.cmake
WORKING_DIRECTORY ${pkg_binary_dir}
RESULT_VARIABLE global_install_rtn)
endforeach()
message(SEND_ERROR "Error, full install failed!")
endif()

set(set_installed_group_and_permissions_file
"${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake")
if (EXISTS "${set_installed_group_and_permissions_file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -P "${set_installed_group_and_permissions_file}"
RESULT_VARIABLE set_installed_rtn)
if (NOT global_install_rtn EQUAL 0)
message(SEND_ERROR "ERROR: Fixup of group and permissions filed!")
set(set_installed_group_and_permissions_file
"${PROJECT_BINARY_DIR}/set_installed_group_and_permissions.cmake")
if (EXISTS "${set_installed_group_and_permissions_file}")
execute_process(
COMMAND @CMAKE_COMMAND@ -P "${set_installed_group_and_permissions_file}"
RESULT_VARIABLE set_installed_rtn)
if (NOT global_install_rtn EQUAL 0)
message(SEND_ERROR "ERROR: Fixup of group and permissions filed!")
endif()
endif()

endif()
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,11 @@ ADD_SUBDIRECTORY(src)

TRIBITS_ADD_TEST_DIRECTORIES(tests)

INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}"
USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE )
# Above, we must use 'USE_SOURCE_PERMISSIONS' to preserve the executable
# permission on the scripts in that directory. (TriBITS will add commands to
# fix the permissions after the install.)

TRIBITS_SUBPACKAGE_POSTPROCESS()
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,4 @@ TRIBITS_ADD_LIBRARY(pws_c

TRIBITS_ADD_TEST_DIRECTORIES(tests)

INSTALL( DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/stuff"
DESTINATION "${CMAKE_INSTALL_PREFIX}/share/${PACKAGE_NAME}"
USE_SOURCE_PERMISSIONS PATTERN "*~" EXCLUDE )
# Above, we must use 'USE_SOURCE_PERMISSIONS' to preserve the executable
# permission on the scripts in that directory. (TriBITS will add commands to
# fix the permissions after the install.)

TRIBITS_SUBPACKAGE_POSTPROCESS()

0 comments on commit 553b926

Please sign in to comment.