mirror of
https://github.com/Z3Prover/z3
synced 2025-08-04 18:30:24 +00:00
[TravisCI] Implement TravisCI build and testing infrastructure for Linux
The Linux builds rely on Docker (using Ubuntu 16.04LTS and Ubuntu 14.04LTS) to build and test Z3 so that builds are easily reproducible. A build status button has been added to `README.md` so that it is easy to see the current build status. More documentation can be found in `contrib/ci/README.md`. This implementation currently tests 13 different configurations. If build times become too long we can remove some of them. Although it would be nice to test macOS builds that requires significantly more work so I have left this as future work.
This commit is contained in:
parent
be4b0ffe69
commit
8310fed528
21 changed files with 1107 additions and 3 deletions
128
contrib/ci/scripts/build_z3_cmake.sh
Executable file
128
contrib/ci/scripts/build_z3_cmake.sh
Executable file
|
@ -0,0 +1,128 @@
|
|||
#!/bin/bash
|
||||
# This script builds Z3
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${Z3_SRC_DIR?"Z3_SRC_DIR must be specified"}
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
: ${Z3_BUILD_TYPE?"Z3_BUILD_TYPE must be specified"}
|
||||
: ${Z3_CMAKE_GENERATOR?"Z3_CMAKE_GENERATOR must be specified"}
|
||||
: ${Z3_STATIC_BUILD?"Z3_STATIC_BUILD must be specified"}
|
||||
: ${USE_OPENMP?"USE_OPENMP must be specified"}
|
||||
: ${USE_LIBGMP?"USE_LIBGMP must be specified"}
|
||||
: ${BUILD_DOCS?"BUILD_DOCS must be specified"}
|
||||
: ${PYTHON_EXECUTABLE?"PYTHON_EXECUTABLE must be specified"}
|
||||
: ${PYTHON_BINDINGS?"PYTHON_BINDINGS must be specified"}
|
||||
: ${DOTNET_BINDINGS?"DOTNET_BINDINGS must be specified"}
|
||||
: ${JAVA_BINDINGS?"JAVA_BINDINGS must be specified"}
|
||||
: ${USE_LTO?"USE_LTO must be specified"}
|
||||
: ${Z3_INSTALL_PREFIX?"Z3_INSTALL_PREFIX"}
|
||||
|
||||
ADDITIONAL_Z3_OPTS=()
|
||||
|
||||
# Static or dynamic libz3
|
||||
if [ "X${Z3_STATIC_BUILD}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=('-DBUILD_LIBZ3_SHARED=OFF')
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=('-DBUILD_LIBZ3_SHARED=ON')
|
||||
fi
|
||||
|
||||
# Use OpenMP?
|
||||
if [ "X${USE_OPENMP}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=('-DUSE_OPENMP=ON')
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=('-DUSE_OPENMP=OFF')
|
||||
fi
|
||||
|
||||
# Use LibGMP?
|
||||
if [ "X${USE_LIBGMP}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=('-DUSE_LIB_GMP=ON')
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=('-DUSE_LIB_GMP=OFF')
|
||||
fi
|
||||
|
||||
# Use link time optimziation?
|
||||
if [ "X${USE_LTO}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=('-DLINK_TIME_OPTIMIZATION=ON')
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=('-DLINK_TIME_OPTIMIZATION=OFF')
|
||||
fi
|
||||
|
||||
# Build API docs?
|
||||
if [ "X${BUILD_DOCS}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_DOCUMENTATION=ON' \
|
||||
'-DALWAYS_BUILD_DOCS=OFF' \
|
||||
)
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=('-DBUILD_DOCUMENTATION=OFF')
|
||||
fi
|
||||
|
||||
# Python bindings?
|
||||
if [ "X${PYTHON_BINDINGS}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_PYTHON_BINDINGS=ON' \
|
||||
'-DINSTALL_PYTHON_BINDINGS=ON' \
|
||||
)
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_PYTHON_BINDINGS=OFF' \
|
||||
'-DINSTALL_PYTHON_BINDINGS=OFF' \
|
||||
)
|
||||
fi
|
||||
|
||||
# .NET bindings?
|
||||
if [ "X${DOTNET_BINDINGS}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_DOTNET_BINDINGS=ON' \
|
||||
'-DINSTALL_DOTNET_BINDINGS=ON' \
|
||||
)
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_DOTNET_BINDINGS=OFF' \
|
||||
'-DINSTALL_DOTNET_BINDINGS=OFF' \
|
||||
)
|
||||
fi
|
||||
|
||||
# Java bindings?
|
||||
if [ "X${JAVA_BINDINGS}" = "X1" ]; then
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_JAVA_BINDINGS=ON' \
|
||||
'-DINSTALL_JAVA_BINDINGS=ON' \
|
||||
)
|
||||
else
|
||||
ADDITIONAL_Z3_OPTS+=( \
|
||||
'-DBUILD_JAVA_BINDINGS=OFF' \
|
||||
'-DINSTALL_JAVA_BINDINGS=OFF' \
|
||||
)
|
||||
fi
|
||||
|
||||
# Set compiler flags
|
||||
source ${SCRIPT_DIR}/set_compiler_flags.sh
|
||||
|
||||
# Sanity check
|
||||
if [ ! -e "${Z3_SRC_DIR}/CMakeLists.txt" ]; then
|
||||
echo "Z3_SRC_DIR is invalid"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Make build tree
|
||||
mkdir -p "${Z3_BUILD_DIR}"
|
||||
cd "${Z3_BUILD_DIR}"
|
||||
|
||||
# Configure
|
||||
cmake \
|
||||
-G "${Z3_CMAKE_GENERATOR}" \
|
||||
-DCMAKE_BUILD_TYPE=${Z3_BUILD_TYPE} \
|
||||
-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE} \
|
||||
-DCMAKE_INSTALL_PREFIX=${Z3_INSTALL_PREFIX} \
|
||||
"${ADDITIONAL_Z3_OPTS[@]}" \
|
||||
"${Z3_SRC_DIR}"
|
||||
|
||||
# Build
|
||||
source ${SCRIPT_DIR}/set_generator_args.sh
|
||||
cmake --build $(pwd) "${GENERATOR_ARGS[@]}"
|
41
contrib/ci/scripts/run_quiet.sh
Normal file
41
contrib/ci/scripts/run_quiet.sh
Normal file
|
@ -0,0 +1,41 @@
|
|||
# Simple wrapper function that runs a command suppressing
|
||||
# it's output. However it's output will be shown in the
|
||||
# case that `NO_SUPPRESS_OUTPUT` is set to `1` or the command
|
||||
# fails.
|
||||
#
|
||||
# The use case for this trying to avoid large logs on TravisCI
|
||||
function run_quiet() {
|
||||
if [ "X${NO_SUPPRESS_OUTPUT}" = "X1" ]; then
|
||||
"${@}"
|
||||
else
|
||||
OLD_SETTINGS="$-"
|
||||
set +x
|
||||
set +e
|
||||
TMP_DIR="${TMP_DIR:-/tmp/}"
|
||||
STDOUT="${TMP_DIR}/$$.stdout"
|
||||
STDERR="${TMP_DIR}/$$.stderr"
|
||||
"${@}" > "${STDOUT}" 2> "${STDERR}"
|
||||
EXIT_STATUS="$?"
|
||||
if [ "${EXIT_STATUS}" -ne 0 ]; then
|
||||
echo "Command \"$@\" failed"
|
||||
echo "EXIT CODE: ${EXIT_STATUS}"
|
||||
echo "STDOUT"
|
||||
echo ""
|
||||
echo "\`\`\`"
|
||||
cat ${STDOUT}
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
echo "STDERR"
|
||||
echo ""
|
||||
echo "\`\`\`"
|
||||
cat ${STDERR}
|
||||
echo "\`\`\`"
|
||||
echo ""
|
||||
fi
|
||||
# Clean up
|
||||
rm "${STDOUT}" "${STDERR}"
|
||||
[ $( echo "${OLD_SETTINGS}" | grep -c 'e') -ne 0 ] && set -e
|
||||
[ $( echo "${OLD_SETTINGS}" | grep -c 'x') -ne 0 ] && set -x
|
||||
return ${EXIT_STATUS}
|
||||
fi
|
||||
}
|
46
contrib/ci/scripts/set_compiler_flags.sh
Normal file
46
contrib/ci/scripts/set_compiler_flags.sh
Normal file
|
@ -0,0 +1,46 @@
|
|||
# This script should is intended to be included by other
|
||||
# scripts and should not be executed directly
|
||||
|
||||
: ${TARGET_ARCH?"TARGET_ARCH must be specified"}
|
||||
: ${ASAN_BUILD?"ASAN_BUILD must be specified"}
|
||||
: ${UBSAN_BUILD?"UBSAN_BUILD must be specified"}
|
||||
: ${CC?"CC must be specified"}
|
||||
: ${CXX?"CXX must be specified"}
|
||||
|
||||
case ${TARGET_ARCH} in
|
||||
x86_64)
|
||||
CXXFLAGS="${CXXFLAGS} -m64"
|
||||
CFLAGS="${CFLAGS} -m64"
|
||||
;;
|
||||
i686)
|
||||
CXXFLAGS="${CXXFLAGS} -m32"
|
||||
CFLAGS="${CFLAGS} -m32"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown arch \"${TARGET_ARCH}\""
|
||||
exit 1
|
||||
esac
|
||||
|
||||
if [ "X${ASAN_BUILD}" = "X1" ]; then
|
||||
CXXFLAGS="${CXXFLAGS} -fsanitize=address -fno-omit-frame-pointer"
|
||||
CFLAGS="${CFLAGS} -fsanitize=address -fno-omit-frame-pointer"
|
||||
fi
|
||||
|
||||
if [ "X${UBSAN_BUILD}" = "X1" ]; then
|
||||
CXXFLAGS="${CXXFLAGS} -fsanitize=undefined"
|
||||
CFLAGS="${CFLAGS} -fsanitize=undefined"
|
||||
fi
|
||||
|
||||
# Report flags
|
||||
echo "CXXFLAGS: ${CXXFLAGS}"
|
||||
echo "CFLAGS: ${CFLAGS}"
|
||||
|
||||
# Report compiler
|
||||
echo "CC: ${CC}"
|
||||
${CC} --version
|
||||
echo "CXX: ${CXX}"
|
||||
${CXX} --version
|
||||
|
||||
# Export the values
|
||||
export CFLAGS
|
||||
export CXXFLAGS
|
20
contrib/ci/scripts/set_generator_args.sh
Normal file
20
contrib/ci/scripts/set_generator_args.sh
Normal file
|
@ -0,0 +1,20 @@
|
|||
# This script should is intended to be included by other
|
||||
# scripts and should not be executed directly
|
||||
|
||||
: ${Z3_CMAKE_GENERATOR?"Z3_CMAKE_GENERATOR must be specified"}
|
||||
: ${Z3_VERBOSE_BUILD_OUTPUT?"Z3_VERBOSE_BUILD_OUTPUT must be specified"}
|
||||
|
||||
GENERATOR_ARGS=('--')
|
||||
if [ "${Z3_CMAKE_GENERATOR}" = "Unix Makefiles" ]; then
|
||||
GENERATOR_ARGS+=("-j$(nproc)")
|
||||
if [ "X${Z3_VERBOSE_BUILD_OUTPUT}" = "X1" ]; then
|
||||
GENERATOR_ARGS+=("VERBOSE=1")
|
||||
fi
|
||||
elif [ "${Z3_CMAKE_GENERATOR}" = "Ninja" ]; then
|
||||
if [ "X${Z3_VERBOSE_BUILD_OUTPUT}" = "X1" ]; then
|
||||
GENERATOR_ARGS+=("-v")
|
||||
fi
|
||||
else
|
||||
echo "Unknown CMake generator \"${Z3_CMAKE_GENERATOR}\""
|
||||
exit 1
|
||||
fi
|
24
contrib/ci/scripts/test_z3_docs.sh
Executable file
24
contrib/ci/scripts/test_z3_docs.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
. ${SCRIPT_DIR}/run_quiet.sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
: ${BUILD_DOCS?"BUILD_DOCS must be specified"}
|
||||
|
||||
# Set CMake generator args
|
||||
source ${SCRIPT_DIR}/set_generator_args.sh
|
||||
|
||||
cd "${Z3_BUILD_DIR}"
|
||||
|
||||
# Generate documentation
|
||||
if [ "X${BUILD_DOCS}" = "X1" ]; then
|
||||
# TODO: Make quiet once we've fixed the build
|
||||
run_quiet cmake --build $(pwd) --target api_docs "${GENERATOR_ARGS[@]}"
|
||||
fi
|
||||
|
||||
# TODO: Test or perhaps deploy the built docs?
|
87
contrib/ci/scripts/test_z3_examples_cmake.sh
Executable file
87
contrib/ci/scripts/test_z3_examples_cmake.sh
Executable file
|
@ -0,0 +1,87 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This script tests Z3
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
. ${SCRIPT_DIR}/run_quiet.sh
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
: ${Z3_SRC_DIR?"Z3_SRC_DIR must be specified"}
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
: ${PYTHON_BINDINGS?"PYTHON_BINDINGS must be specified"}
|
||||
: ${PYTHON_EXECUTABLE?"PYTHON_EXECUTABLE must be specified"}
|
||||
: ${DOTNET_BINDINGS?"DOTNET_BINDINGS must be specified"}
|
||||
: ${JAVA_BINDINGS?"JAVA_BINDINGS must be specified"}
|
||||
|
||||
# Set compiler flags
|
||||
source ${SCRIPT_DIR}/set_compiler_flags.sh
|
||||
|
||||
# Set CMake generator args
|
||||
source ${SCRIPT_DIR}/set_generator_args.sh
|
||||
|
||||
cd "${Z3_BUILD_DIR}"
|
||||
|
||||
# Build and run C example
|
||||
cmake --build $(pwd) --target c_example "${GENERATOR_ARGS[@]}"
|
||||
run_quiet examples/c_example_build_dir/c_example
|
||||
|
||||
# Build and run C++ example
|
||||
cmake --build $(pwd) --target cpp_example "${GENERATOR_ARGS[@]}"
|
||||
run_quiet examples/cpp_example_build_dir/cpp_example
|
||||
|
||||
# Build and run tptp5 example
|
||||
cmake --build $(pwd) --target z3_tptp5 "${GENERATOR_ARGS[@]}"
|
||||
# FIXME: Do something more useful with example
|
||||
run_quiet examples/tptp_build_dir/z3_tptp5 -help
|
||||
|
||||
# Build an run c_maxsat_example
|
||||
cmake --build $(pwd) --target c_maxsat_example "${GENERATOR_ARGS[@]}"
|
||||
run_quiet \
|
||||
examples/c_maxsat_example_build_dir/c_maxsat_example \
|
||||
${Z3_SRC_DIR}/examples/maxsat/ex.smt
|
||||
|
||||
|
||||
if [ "X${PYTHON_BINDINGS}" = "X1" ]; then
|
||||
# Run python examples
|
||||
# `all_interval_series.py` produces a lot of output so just throw
|
||||
# away output.
|
||||
# TODO: This example is slow should we remove it from testing?
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/all_interval_series.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/complex.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/example.py
|
||||
# FIXME: `hamiltonian.py` example is disabled because its too slow.
|
||||
#${PYTHON_EXECUTABLE} python/hamiltonian.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/marco.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/mss.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/socrates.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/visitor.py
|
||||
run_quiet ${PYTHON_EXECUTABLE} python/z3test.py
|
||||
fi
|
||||
|
||||
if [ "X${DOTNET_BINDINGS}" = "X1" ]; then
|
||||
# Build .NET example
|
||||
# FIXME: Move compliation step into CMake target
|
||||
mcs ${Z3_SRC_DIR}/examples/dotnet/Program.cs /target:exe /out:dotnet_test.exe /reference:Microsoft.Z3.dll /r:System.Numerics.dll
|
||||
# Run .NET example
|
||||
run_quiet mono ./dotnet_test.exe
|
||||
fi
|
||||
|
||||
if [ "X${JAVA_BINDINGS}" = "X1" ]; then
|
||||
# Build Java example
|
||||
# FIXME: Move compilation step into CMake target
|
||||
mkdir -p examples/java
|
||||
cp ${Z3_SRC_DIR}/examples/java/JavaExample.java examples/java/
|
||||
javac examples/java/JavaExample.java -classpath com.microsoft.z3.jar
|
||||
# Run Java example
|
||||
if [ "$(uname)" = "Darwin" ]; then
|
||||
# macOS
|
||||
export DYLD_LIBRARY_PATH=$(pwd):${DYLD_LIBRARY_PATH}
|
||||
else
|
||||
# Assume Linux for now
|
||||
export LD_LIBRARY_PATH=$(pwd):${LD_LIBRARY_PATH}
|
||||
fi
|
||||
run_quiet java -cp .:examples/java:com.microsoft.z3.jar JavaExample
|
||||
fi
|
||||
|
24
contrib/ci/scripts/test_z3_install_cmake.sh
Executable file
24
contrib/ci/scripts/test_z3_install_cmake.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${TEST_INSTALL?"TEST_INSTALL must be specified"}
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
|
||||
if [ "X${TEST_INSTALL}" != "X1" ]; then
|
||||
echo "Skipping install"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set CMake generator args
|
||||
source ${SCRIPT_DIR}/set_generator_args.sh
|
||||
|
||||
cd "${Z3_BUILD_DIR}"
|
||||
|
||||
sudo cmake --build $(pwd) --target install "${GENERATOR_ARGS[@]}"
|
||||
|
||||
# TODO: Test the installed version in some way
|
54
contrib/ci/scripts/test_z3_system_tests.sh
Executable file
54
contrib/ci/scripts/test_z3_system_tests.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
: ${Z3_BUILD_TYPE?"Z3_BUILD_TYPE must be specified"}
|
||||
: ${RUN_SYSTEM_TESTS?"RUN_SYSTEM_TESTS must be speicifed"}
|
||||
: ${PYTHON_BINDINGS?"PYTHON_BINDINGS must be specified"}
|
||||
: ${PYTHON_EXECUTABLE?"PYTHON_EXECUTABLE must be specified"}
|
||||
: ${Z3_SYSTEM_TEST_DIR?"Z3_SYSTEM_TEST_DIR must be specified"}
|
||||
|
||||
if [ "X${RUN_SYSTEM_TESTS}" != "X1" ]; then
|
||||
echo "Skipping system tests"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Z3_EXE="${Z3_BUILD_DIR}/z3"
|
||||
Z3_LIB_DIR="${Z3_BUILD_DIR}"
|
||||
|
||||
# Set value if not already defined externally
|
||||
Z3_SYSTEM_TEST_GIT_URL="${Z3_GIT_URL:-https://github.com/Z3Prover/z3test.git}"
|
||||
|
||||
# Clone repo to destination
|
||||
mkdir -p "${Z3_SYSTEM_TEST_GIT_URL}"
|
||||
git clone "${Z3_SYSTEM_TEST_GIT_URL}" "${Z3_SYSTEM_TEST_DIR}"
|
||||
cd "${Z3_SYSTEM_TEST_DIR}"
|
||||
|
||||
if [ -n "${Z3_SYSTEM_TEST_GIT_REVISION}" ]; then
|
||||
# If a particular revision is requested then check it out.
|
||||
# This is useful for reproducible builds
|
||||
git checkout "${Z3_SYSTEM_TEST_GIT_REVISION}"
|
||||
fi
|
||||
|
||||
###############################################################################
|
||||
# Run system tests
|
||||
###############################################################################
|
||||
|
||||
# SMTLIBv2 tests
|
||||
${PYTHON_EXECUTABLE} scripts/test_benchmarks.py "${Z3_EXE}" regressions/smt2
|
||||
|
||||
${PYTHON_EXECUTABLE} scripts/test_benchmarks.py "${Z3_EXE}" regressions/smt2-extra
|
||||
|
||||
if [ "X${Z3_BUILD_TYPE}" = "XDebug" ]; then
|
||||
${PYTHON_EXECUTABLE} scripts/test_benchmarks.py "${Z3_EXE}" regressions/smt2-debug
|
||||
fi
|
||||
|
||||
if [ "X${PYTHON_BINDINGS}" = "X1" ]; then
|
||||
# Run python binding tests
|
||||
${PYTHON_EXECUTABLE} scripts/test_pyscripts.py "${Z3_LIB_DIR}" regressions/python/
|
||||
fi
|
||||
|
||||
# FIXME: Run `scripts/test_cs.py` once it has been modified to support mono
|
24
contrib/ci/scripts/test_z3_unit_tests_cmake.sh
Executable file
24
contrib/ci/scripts/test_z3_unit_tests_cmake.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${Z3_BUILD_DIR?"Z3_BUILD_DIR must be specified"}
|
||||
: ${RUN_UNIT_TESTS?"RUN_UNIT_TESTS must be specified"}
|
||||
|
||||
if [ "X${RUN_UNIT_TESTS}" != "X1" ]; then
|
||||
echo "Skipping unit tests"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Set CMake generator args
|
||||
source ${SCRIPT_DIR}/set_generator_args.sh
|
||||
|
||||
cd "${Z3_BUILD_DIR}"
|
||||
|
||||
# Build and run internal tests
|
||||
cmake --build $(pwd) --target test-z3 "${GENERATOR_ARGS[@]}"
|
||||
./test-z3
|
18
contrib/ci/scripts/travis_ci_entry_point.sh
Executable file
18
contrib/ci/scripts/travis_ci_entry_point.sh
Executable file
|
@ -0,0 +1,18 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
: ${TRAVIS_OS_NAME?"TRAVIS_OS_NAME should be set"}
|
||||
|
||||
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
|
||||
${SCRIPT_DIR}/travis_ci_osx_entry_point.sh
|
||||
elif [ "${TRAVIS_OS_NAME}" = "linux" ]; then
|
||||
${SCRIPT_DIR}/travis_ci_linux_entry_point.sh
|
||||
else
|
||||
echo "Unsupported OS \"${TRAVIS_OS_NAME}\""
|
||||
exit 1
|
||||
fi
|
208
contrib/ci/scripts/travis_ci_linux_entry_point.sh
Executable file
208
contrib/ci/scripts/travis_ci_linux_entry_point.sh
Executable file
|
@ -0,0 +1,208 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
DOCKER_FILE_DIR="$(cd ${SCRIPT_DIR}/../Dockerfiles; echo $PWD)"
|
||||
|
||||
: ${LINUX_BASE?"LINUX_BASE must be specified"}
|
||||
|
||||
|
||||
|
||||
# Sanity check. Current working directory should be repo root
|
||||
if [ ! -f "./README.md" ]; then
|
||||
echo "Current working directory should be repo root"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BUILD_OPTS=()
|
||||
# Override options if they have been provided.
|
||||
# Otherwise the defaults in the Docker file will be used
|
||||
if [ -n "${Z3_CMAKE_GENERATOR}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "Z3_CMAKE_GENERATOR=${Z3_CMAKE_GENERATOR}")
|
||||
fi
|
||||
|
||||
if [ -n "${USE_OPENMP}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "USE_OPENMP=${USE_OPENMP}")
|
||||
fi
|
||||
|
||||
if [ -n "${USE_LIBGMP}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "USE_LIBGMP=${USE_LIBGMP}")
|
||||
fi
|
||||
|
||||
if [ -n "${BUILD_DOCS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "BUILD_DOCS=${BUILD_DOCS}")
|
||||
fi
|
||||
|
||||
if [ -n "${PYTHON_EXECUTABLE}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}")
|
||||
fi
|
||||
|
||||
if [ -n "${PYTHON_BINDINGS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "PYTHON_BINDINGS=${PYTHON_BINDINGS}")
|
||||
fi
|
||||
|
||||
if [ -n "${DOTNET_BINDINGS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "DOTNET_BINDINGS=${DOTNET_BINDINGS}")
|
||||
fi
|
||||
|
||||
if [ -n "${JAVA_BINDINGS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "JAVA_BINDINGS=${JAVA_BINDINGS}")
|
||||
fi
|
||||
|
||||
if [ -n "${USE_LTO}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "USE_LTO=${USE_LTO}")
|
||||
fi
|
||||
|
||||
if [ -n "${Z3_INSTALL_PREFIX}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "Z3_INSTALL_PREFIX=${Z3_INSTALL_PREFIX}")
|
||||
fi
|
||||
|
||||
# TravisCI reserves CC for itself so use a different name
|
||||
if [ -n "${C_COMPILER}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "CC=${C_COMPILER}")
|
||||
fi
|
||||
|
||||
# TravisCI reserves CXX for itself so use a different name
|
||||
if [ -n "${CXX_COMPILER}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "CXX=${CXX_COMPILER}")
|
||||
fi
|
||||
|
||||
if [ -n "${TARGET_ARCH}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "TARGET_ARCH=${TARGET_ARCH}")
|
||||
fi
|
||||
|
||||
if [ -n "${ASAN_BUILD}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "ASAN_BUILD=${ASAN_BUILD}")
|
||||
fi
|
||||
|
||||
if [ -n "${UBSAN_BUILD}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "UBSAN_BUILD=${UBSAN_BUILD}")
|
||||
fi
|
||||
|
||||
if [ -n "${TEST_INSTALL}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "TEST_INSTALL=${TEST_INSTALL}")
|
||||
fi
|
||||
|
||||
if [ -n "${RUN_SYSTEM_TESTS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "RUN_SYSTEM_TESTS=${RUN_SYSTEM_TESTS}")
|
||||
fi
|
||||
|
||||
if [ -n "${Z3_SYSTEM_TEST_GIT_REVISION}" ]; then
|
||||
BUILD_OPTS+=( \
|
||||
"--build-arg" \
|
||||
"Z3_SYSTEM_TEST_GIT_REVISION=${Z3_SYSTEM_TEST_GIT_REVISION}" \
|
||||
)
|
||||
fi
|
||||
|
||||
if [ -n "${RUN_UNIT_TESTS}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "RUN_UNIT_TESTS=${RUN_UNIT_TESTS}")
|
||||
fi
|
||||
|
||||
if [ -n "${Z3_VERBOSE_BUILD_OUTPUT}" ]; then
|
||||
BUILD_OPTS+=( \
|
||||
"--build-arg" \
|
||||
"Z3_VERBOSE_BUILD_OUTPUT=${Z3_VERBOSE_BUILD_OUTPUT}" \
|
||||
)
|
||||
fi
|
||||
|
||||
if [ -n "${Z3_STATIC_BUILD}" ]; then
|
||||
BUILD_OPTS+=("--build-arg" "Z3_STATIC_BUILD=${Z3_STATIC_BUILD}")
|
||||
fi
|
||||
|
||||
if [ -n "${NO_SUPPRESS_OUTPUT}" ]; then
|
||||
BUILD_OPTS+=( \
|
||||
"--build-arg" \
|
||||
"NO_SUPPRESS_OUTPUT=${NO_SUPPRESS_OUTPUT}" \
|
||||
)
|
||||
fi
|
||||
|
||||
case ${LINUX_BASE} in
|
||||
ubuntu_14.04)
|
||||
BASE_DOCKER_FILE="${DOCKER_FILE_DIR}/z3_base_ubuntu_14.04.Dockerfile"
|
||||
BASE_DOCKER_IMAGE_NAME="z3_base_ubuntu:14.04"
|
||||
;;
|
||||
ubuntu_16.04)
|
||||
BASE_DOCKER_FILE="${DOCKER_FILE_DIR}/z3_base_ubuntu_16.04.Dockerfile"
|
||||
BASE_DOCKER_IMAGE_NAME="z3_base_ubuntu:16.04"
|
||||
;;
|
||||
ubuntu32_16.04)
|
||||
BASE_DOCKER_FILE="${DOCKER_FILE_DIR}/z3_base_ubuntu32_16.04.Dockerfile"
|
||||
BASE_DOCKER_IMAGE_NAME="z3_base_ubuntu32:16.04"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown Linux base ${LINUX_BASE}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
# Initially assume that we need to build the base Docker image
|
||||
MUST_BUILD=1
|
||||
|
||||
# Travis CI persistent cache.
|
||||
#
|
||||
# This inspired by http://rundef.com/fast-travis-ci-docker-build .
|
||||
# The idea is to cache the built image for subsequent builds to
|
||||
# reduce build time.
|
||||
if [ -n "${DOCKER_TRAVIS_CI_CACHE_DIR}" ]; then
|
||||
CHECKSUM_FILE="${DOCKER_TRAVIS_CI_CACHE_DIR}/${BASE_DOCKER_IMAGE_NAME}.chksum"
|
||||
CACHED_DOCKER_IMAGE="${DOCKER_TRAVIS_CI_CACHE_DIR}/${BASE_DOCKER_IMAGE_NAME}.gz"
|
||||
if [ -f "${CACHED_DOCKER_IMAGE}" ]; then
|
||||
# There's a cached image to use. Check the checksums of the Dockerfile
|
||||
# match. If they don't that implies we need to build a fresh image.
|
||||
if [ -f "${CHECKSUM_FILE}" ]; then
|
||||
CURRENT_DOCKERFILE_CHECKSUM=$(sha256sum "${BASE_DOCKER_FILE}" | awk '{ print $1 }')
|
||||
CACHED_DOCKERFILE_CHECKSUM=$(cat "${CHECKSUM_FILE}")
|
||||
if [ "X${CURRENT_DOCKERFILE_CHECKSUM}" = "X${CACHED_DOCKERFILE_CHECKSUM}" ]; then
|
||||
# Load the cached image
|
||||
MUST_BUILD=0
|
||||
gunzip --stdout "${CACHED_DOCKER_IMAGE}" | docker load
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "${MUST_BUILD}" -eq 1 ]; then
|
||||
# The base image contains all the dependencies we want to build
|
||||
# Z3.
|
||||
docker build -t "${BASE_DOCKER_IMAGE_NAME}" - < "${BASE_DOCKER_FILE}"
|
||||
|
||||
if [ -n "${DOCKER_TRAVIS_CI_CACHE_DIR}" ]; then
|
||||
# Write image and checksum to cache
|
||||
docker save "${BASE_DOCKER_IMAGE_NAME}" | \
|
||||
gzip > "${CACHED_DOCKER_IMAGE}"
|
||||
sha256sum "${BASE_DOCKER_FILE}" | awk '{ print $1 }' > \
|
||||
"${CHECKSUM_FILE}"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
DOCKER_MAJOR_VERSION=$(docker info --format '{{.ServerVersion}}' | sed 's/^\([0-9]\+\)\.\([0-9]\+\).*$/\1/')
|
||||
DOCKER_MINOR_VERSION=$(docker info --format '{{.ServerVersion}}' | sed 's/^\([0-9]\+\)\.\([0-9]\+\).*$/\2/')
|
||||
DOCKER_BUILD_FILE="${DOCKER_FILE_DIR}/z3_build.Dockerfile"
|
||||
|
||||
if [ "${DOCKER_MAJOR_VERSION}${DOCKER_MINOR_VERSION}" -lt 1705 ]; then
|
||||
# Workaround limitation in older Docker versions where the FROM
|
||||
# command cannot be parameterized with an ARG.
|
||||
sed \
|
||||
-e '/^ARG DOCKER_IMAGE_BASE/d' \
|
||||
-e 's/${DOCKER_IMAGE_BASE}/'"${BASE_DOCKER_IMAGE_NAME}/" \
|
||||
"${DOCKER_BUILD_FILE}" > "${DOCKER_BUILD_FILE}.patched"
|
||||
DOCKER_BUILD_FILE="${DOCKER_BUILD_FILE}.patched"
|
||||
else
|
||||
# This feature landed in Docker 17.05
|
||||
# See https://github.com/moby/moby/pull/31352
|
||||
BUILD_OPTS+=( \
|
||||
"--build-arg" \
|
||||
"DOCKER_IMAGE_BASE=${BASE_DOCKER_IMAGE_NAME}" \
|
||||
)
|
||||
fi
|
||||
|
||||
# Now build Z3 and test it using the created base image
|
||||
docker build \
|
||||
-f "${DOCKER_BUILD_FILE}" \
|
||||
"${BUILD_OPTS[@]}" \
|
||||
.
|
10
contrib/ci/scripts/travis_ci_osx_entry_point.sh
Executable file
10
contrib/ci/scripts/travis_ci_osx_entry_point.sh
Executable file
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
|
||||
SCRIPT_DIR="$( cd ${BASH_SOURCE[0]%/*} ; echo $PWD )"
|
||||
|
||||
set -x
|
||||
set -e
|
||||
set -o pipefail
|
||||
|
||||
echo "Not implemented"
|
||||
exit 1
|
Loading…
Add table
Add a link
Reference in a new issue