Skip to content

Commit 4bb2863

Browse files
committed
Merge branch 'master' into vehre/async-alloc-comp-support
2 parents 82c7e98 + bb700f2 commit 4bb2863

File tree

9 files changed

+367
-18
lines changed

9 files changed

+367
-18
lines changed

AddInstallationScriptTest.cmake

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
macro(add_installation_script_test name path)
2+
3+
# Copy the source to the binary tree
4+
configure_file(
5+
${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}
6+
${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}
7+
COPYONLY
8+
)
9+
configure_file(
10+
${CMAKE_CURRENT_SOURCE_DIR}/${path}/${name}-usage
11+
${CMAKE_CURRENT_BINARY_DIR}/${path}/${name}-usage
12+
COPYONLY
13+
)
14+
add_test(NAME test-${name} COMMAND "${CMAKE_BINARY_DIR}/${path}/${name}")
15+
set_property(TEST test-${name} PROPERTY WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/${path}")
16+
set_property(TEST test-${name} PROPERTY ENVIRONMENT "OPENCOARRAYS_SRC_DIR=${CMAKE_SOURCE_DIR}")
17+
endmacro(add_installation_script_test)

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,3 +418,6 @@ else()
418418
add_test(co_reduce_extension ${tests_root}/unit/extensions/test-co_reduce-extension.sh)
419419
set_property(TEST co_reduce_extension PROPERTY PASS_REGULAR_EXPRESSION "Test passed.")
420420
endif()
421+
422+
include(AddInstallationScriptTest.cmake )
423+
add_installation_script_test(installation-scripts.sh src/tests/installation/)
Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#shellcheck shell=bash
12
# shellcheck disable=SC2154
23
build_opencoarrays()
34
{
@@ -9,18 +10,27 @@ build_opencoarrays()
910
build_path="${build_path}"/opencoarrays/$("${opencoarrays_src_dir}"/install.sh -V opencoarrays)
1011
mkdir -p "$build_path"
1112
pushd "$build_path"
12-
if [[ -z "${MPICC:-}" || -z "${MPIFC:-}" || -z "${CMAKE:-}" ]]; then
13-
emergency "Empty MPICC=$MPICC or MPIFC=$MPIFC or CMAKE=$CMAKE [exit 90]"
14-
else
15-
info "Configuring OpenCoarrays in ${PWD} with the command:"
16-
info "CC=\"${MPICC}\" FC=\"${MPIFC}\" $CMAKE \"${opencoarrays_src_dir}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\""
17-
CC="${MPICC}" FC="${MPIFC}" $CMAKE "${opencoarrays_src_dir}" -DCMAKE_INSTALL_PREFIX="${install_path}"
18-
info "Building OpenCoarrays in ${PWD} with the command make -j${num_threads}"
19-
make "-j${num_threads}"
20-
if [[ ! -z ${SUDO:-} ]]; then
21-
printf "\nThe chosen installation path requires sudo privileges. Please enter password if prompted.\n"
22-
fi
23-
info "Installing OpenCoarrays in ${install_path} with the command ${SUDO:-} make install"
24-
${SUDO:-} make install
13+
if [[ -z ${MPIFC:-} || -z ${MPICC:-} ]]; then
14+
emergency "build_opencoarrays.sh: empty \${MPIFC}=${MPIFC:-} or \${MPICC}=${MPICC:-}"
2515
fi
16+
MPIFC_show=`$MPIFC -show`
17+
MPICC_show=`$MPICC -show`
18+
if [[ ${MPIFC_show} != *gfortran* || ${MPICC_show} != *gcc* ]]; then
19+
emergency "build_opencoarrays.sh: MPI doesn't wrap gfortran/gcc: \${MPIFC_show}=${MPIFC_show}, \${MPICC_show}=${MPICC_show}"
20+
fi
21+
# Set FC to the MPI implementation's gfortran command with any preceding path but without any subsequent arguments:
22+
FC="${MPIFC_show%%gfortran*}"gfortran
23+
# Set CC to the MPI implementation's gcc command...
24+
CC="${MPICC_show%%gcc*}"gcc
25+
info "Configuring OpenCoarrays in ${PWD} with the command:"
26+
info "CC=\"${CC}\" FC=\"${FC}\" $CMAKE \"${opencoarrays_src_dir}\" -DCMAKE_INSTALL_PREFIX=\"${install_path}\" -DMPI_C_COMPILER=\"${MPICC}\" -DMPI_Fortran_COMPILER=\"${MPIFC}\""
27+
CC="${CC}" FC="${FC}" $CMAKE "${opencoarrays_src_dir}" -DCMAKE_INSTALL_PREFIX="${install_path}" -DMPI_C_COMPILER="${MPICC}" -DMPI_Fortran_COMPILER="${MPIFC}"
28+
info "Building OpenCoarrays in ${PWD} with the command make -j${num_threads}"
29+
make "-j${num_threads}"
30+
if [[ ! -z ${SUDO:-} ]]; then
31+
printf "\nThe chosen installation path requires sudo privileges. Please enter password if prompted.\n"
32+
fi
33+
info "Installing OpenCoarrays in ${install_path} with the command ${SUDO:-} make install"
34+
${SUDO:-} make install
2635
}
36+

prerequisites/stack.sh

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@
4141
function stack_destroy
4242
{
4343
: "${1?'Missing stack name'}"
44+
45+
if no_such_stack "$1"
46+
then
47+
echo "No such stack -- $1" >&2
48+
return 1
49+
fi
50+
4451
eval "unset _stack_$1 _stack_$1_i"
4552
return 0
4653
}
@@ -51,7 +58,7 @@ function stack_destroy
5158
function stack_push
5259
{
5360
: "${1?'Missing stack name'}"
54-
: "${2?'Missing item(s) to push'}"
61+
: "${2?'Missing variable name in stack_push'}"
5562

5663
if no_such_stack "$1"
5764
then
@@ -91,6 +98,11 @@ function stack_size
9198
echo "No such stack -- $1" >&2
9299
return 1
93100
fi
101+
# TODO: revise the eval below to eliminate the need for this pop/push
102+
# sequene, which is a workaround to prevent an error that occurs with
103+
# if the stack is new and has not been the target of a stack_push.
104+
stack_push $1 __push_junk
105+
stack_pop $1 __pop_trash
94106
eval "$2"='$'"{#_stack_$1[*]}"
95107
}
96108

@@ -125,16 +137,16 @@ function no_such_stack
125137
function stack_pop
126138
{
127139
: "${1?'Missing stack name'}"
128-
: "${2?'Missing name of variable for popped result'}"
129-
130-
eval 'let _i=$'"_stack_$1_i"
140+
: "${2?'Missing variable name in stack_pop'}"
131141

132142
if no_such_stack "$1"
133143
then
134144
echo "No such stack -- $1" >&2
135145
return 1
136146
fi
137147

148+
eval 'let _i=$'"_stack_$1_i"
149+
138150
if [[ "$_i" -eq 0 ]]
139151
then
140152
echo "Empty stack -- $1" >&2
@@ -247,6 +259,15 @@ function stack_exists
247259
# echo "Got $top"
248260
function stack_peek
249261
{
262+
: "${1?'Missing stack name'}"
263+
: "${2?'Missing variable name in stack_peek'}"
264+
265+
if no_such_stack "$1"
266+
then
267+
echo "No such stack -- $1" >&2
268+
return 1
269+
fi
270+
250271
stack_pop "$1" "$2"
251272
eval argument_name="\$$2"
252273
# shellcheck disable=SC2154

src/tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ endif()
1717

1818
add_subdirectory(integration)
1919
add_subdirectory(unit)
20-
#add_subdirectory(performance)
20+
add_subdirectory(installation)

src/tests/installation/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/installation-scripts.sh ${CMAKE_CURRENT_BINARY_DIR}/installation-scripts.sh COPYONLY)
Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
#!/usr/bin/env bash
2+
#
3+
# installation-scripts.sh
4+
#
5+
# -- This script tests the bash scripts that install OpenCoarrays and its prerequisites.
6+
#
7+
# OpenCoarrays is distributed under the OSI-approved BSD 3-clause License:
8+
# Copyright (c) 2015-2016, Sourcery, Inc.
9+
# Copyright (c) 2015-2016, Sourcery Institute
10+
# All rights reserved.
11+
#
12+
# Redistribution and use in source and binary forms, with or without modification,
13+
# are permitted provided that the following conditions are met:
14+
#
15+
# 1. Redistributions of source code must retain the above copyright notice, this
16+
# list of conditions and the following disclaimer.
17+
# 2. Redistributions in binary form must reproduce the above copyright notice, this
18+
# list of conditions and the following disclaimer in the documentation and/or
19+
# other materials provided with the distribution.
20+
# 3. Neither the names of the copyright holders nor the names of their contributors
21+
# may be used to endorse or promote products derived from this software without
22+
# specific prior written permission.
23+
#
24+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
25+
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26+
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27+
# IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
28+
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29+
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
30+
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
31+
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33+
# POSSIBILITY OF SUCH DAMAGE.
34+
#
35+
# Portions of this script derive from BASH3 Boilerplate and are distributed under
36+
# the following license:
37+
#
38+
# The MIT License (MIT)
39+
#
40+
# Copyright (c) 2014 Kevin van Zonneveld
41+
#
42+
# Permission is hereby granted, free of charge, to any person obtaining a copy
43+
# of this software and associated documentation files (the "Software"), to deal
44+
# in the Software without restriction, including without limitation the rights
45+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
46+
# copies of the Software, and to permit persons to whom the Software is
47+
# furnished to do so, subject to the following conditions:
48+
#
49+
# The above copyright notice and this permission notice shall be included in all
50+
# copies or substantial portions of the Software.
51+
#
52+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
53+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
54+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
55+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
56+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
57+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
58+
# SOFTWARE.
59+
#
60+
#
61+
# - https://github.com/kvz/bash3boilerplate
62+
# - http://kvz.io/blog/2013/02/26/introducing-bash3boilerplate/
63+
#
64+
# Version: 2.0.0
65+
#
66+
# Authors:
67+
#
68+
# - Kevin van Zonneveld (http://kvz.io)
69+
# - Izaak Beekman (https://izaakbeekman.com/)
70+
# - Alexander Rathai ([email protected])
71+
# - Dr. Damian Rouson (http://www.sourceryinstitute.org/) (documentation)
72+
#
73+
# Licensed under MIT
74+
# Copyright (c) 2013 Kevin van Zonneveld (http://kvz.io)
75+
76+
# The invocation of bootstrap.sh below performs the following tasks:
77+
# (1) Import several bash3boilerplate helper functions & default settings.
78+
# (2) Set several variables describing the current file and its usage page.
79+
# (3) Parse the usage information (default usage file name: current file's name with -usage appended).
80+
# (4) Parse the command line using the usage information.
81+
82+
### Start of boilerplate -- do not edit this block #######################
83+
export OPENCOARRAYS_SRC_DIR="${OPENCOARRAYS_SRC_DIR:-${PWD%/}/../../..}"
84+
if [[ ! -f "${OPENCOARRAYS_SRC_DIR}/src/libcaf.h" ]]; then
85+
echo "Please run this script inside the OpenCoarrays source sudirectory src/tests/instsallation"
86+
echo "or set OPENCOARRAYS_SRC_DIR to the OpenCoarrays source directory path."
87+
exit 1
88+
fi
89+
export B3B_USE_CASE="${B3B_USE_CASE:-${OPENCOARRAYS_SRC_DIR}/prerequisites/use-case}"
90+
if [[ ! -f "${B3B_USE_CASE:-}/bootstrap.sh" ]]; then
91+
echo "Please set B3B_USE_CASE to the bash3boilerplate use-case directory path."
92+
exit 2
93+
else
94+
# shellcheck source=../../../prerequisites/use-case/bootstrap.sh
95+
source "${B3B_USE_CASE}/bootstrap.sh" "$@"
96+
fi
97+
### End of boilerplate -- start user edits below #########################
98+
99+
# Set expected value of present flags that take no arguments
100+
export __flag_present=1
101+
102+
# Set up a function to call when receiving an EXIT signal to do some cleanup. Remove if
103+
# not needed. Other signals can be trapped too, like SIGINT and SIGTERM.
104+
function cleanup_before_exit () {
105+
info "Cleaning up. Done"
106+
}
107+
trap cleanup_before_exit EXIT # The signal is specified here. Could be SIGINT, SIGTERM etc.
108+
109+
110+
pushd "${OPENCOARRAYS_SRC_DIR}"/src/tests/installation
111+
112+
# shellcheck source=../../../prerequisites/stack.sh
113+
source "${OPENCOARRAYS_SRC_DIR}"/prerequisites/stack.sh
114+
source test-stack.sh
115+
test_stack
116+
117+
popd
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-b --install-branch [arg] Install the specified repository development branch.
2+
-B --list-branches [arg] List the available branches in the specified package's repository.
3+
-c --with-c [arg] Use specified C compiler.
4+
-C --with-cxx [arg] Use specified C++ compiler.
5+
-d --debug Enable debug mode.
6+
-D --print-downloader [arg] Print download program for package specified in argument.
7+
-e --verbose Enable verbose mode, print script as it is executed.
8+
-f --with-fortran [arg] Use specified Fortran compiler.
9+
-h --help Print this page.
10+
-i --install-prefix [arg] Install package in specified path. Default="${OPENCOARRAYS_SRC_DIR}/prerequisites/installations/${package_name:-}/${version_to_build:-}"
11+
-I --install-version [arg] Install package version.
12+
-j --num-threads [arg] Number of threads to use when invoking make. Default="1"
13+
-l --list-packages Print packages this script can install.
14+
-m --with-cmake [arg] Use specified CMake installation. Default="cmake"
15+
-M --with-mpi [arg] Use specified MPI installation.
16+
-n --no-color Disable color output.
17+
-p --package [arg] Install specified package. Default="opencoarrays"
18+
-P --print-path [arg] Print installation directory for specified package.
19+
-U --print-url [arg] Print download location for specified package.
20+
-v --version Print OpenCoarrays version number.
21+
-V --print-version [arg] Print version number for specified package.
22+
-y --yes-to-all Build non-interactively by assuming affirmative user responses.

0 commit comments

Comments
 (0)