mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 06:05:29 -04:00
Docker: Migrate coverage test to CMake
This commit is contained in:
parent
e82c618570
commit
a99a1edcfd
10 changed files with 97 additions and 159 deletions
|
|
@ -1,6 +1,7 @@
|
|||
exe
|
||||
lib
|
||||
obj
|
||||
build
|
||||
regtesting
|
||||
tools/toolchain/install
|
||||
tools/toolchain/build
|
||||
|
|
|
|||
|
|
@ -122,6 +122,18 @@ elif [[ "${PROFILE}" == "toolchain_generic" ]] && [[ "${VERSION}" == "psmp" ]];
|
|||
.. |& tee ./cmake.log
|
||||
CMAKE_EXIT_CODE=$?
|
||||
|
||||
elif [[ "${PROFILE}" == "toolchain_coverage" ]] && [[ "${VERSION}" == "psmp" ]]; then
|
||||
cmake \
|
||||
-GNinja \
|
||||
-DCMAKE_BUILD_TYPE="Coverage" \
|
||||
-DCMAKE_INSTALL_PREFIX="${INSTALL_PREFIX}" \
|
||||
-DCP2K_USE_EVERYTHING=ON \
|
||||
-DCP2K_USE_DLAF=OFF \
|
||||
-DCP2K_USE_PEXSI=OFF \
|
||||
-Werror=dev \
|
||||
.. |& tee ./cmake.log
|
||||
CMAKE_EXIT_CODE=$?
|
||||
|
||||
elif [[ "${PROFILE}" == "toolchain_asan" ]] && [[ "${VERSION}" == "psmp" ]]; then
|
||||
# TODO Re-enable GREENX. It currently leads to a heap-buffer-overflow
|
||||
# in `greenx_refine_pade()` at greenx_interface.F:80.
|
||||
|
|
|
|||
|
|
@ -113,17 +113,17 @@ report_url: https://storage.googleapis.com/cp2k-ci/dashboard_gcc8_report.txt
|
|||
|
||||
# ==============================================================================
|
||||
|
||||
[minimal-sdbg]
|
||||
[minimal]
|
||||
sortkey: 581
|
||||
name: Minimal arch-file (sdbg)
|
||||
name: Minimal arch-file
|
||||
host: GCP
|
||||
report_url: https://storage.googleapis.com/cp2k-ci/dashboard_minimal_report.txt
|
||||
|
||||
[coverage-pdbg]
|
||||
[coverage]
|
||||
sortkey: 583
|
||||
name: Coverage (pdbg)
|
||||
name: Coverage
|
||||
host: GCP
|
||||
report_url: https://storage.googleapis.com/cp2k-ci/dashboard_coverage-pdbg_report.txt
|
||||
report_url: https://storage.googleapis.com/cp2k-ci/dashboard_coverage_report.txt
|
||||
info_url: https://www.cp2k.org/static/coverage/
|
||||
|
||||
# ==============================================================================
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#
|
||||
# This file was created by generate_dockerfiles.py.
|
||||
# Usage: podman build --shm-size=1g -f ./Dockerfile.test_coverage-pdbg ../../
|
||||
# Usage: podman build --shm-size=1g -f ./Dockerfile.test_coverage ../../
|
||||
#
|
||||
|
||||
FROM ubuntu:24.04
|
||||
|
|
@ -23,7 +23,7 @@ COPY ./tools/toolchain/install_cp2k_toolchain.sh .
|
|||
RUN ./install_cp2k_toolchain.sh \
|
||||
--install-all \
|
||||
--mpi-mode=mpich \
|
||||
--with-dbcsr=no \
|
||||
--with-dbcsr \
|
||||
--with-gcc=system \
|
||||
--dry-run
|
||||
|
||||
|
|
@ -64,24 +64,25 @@ COPY ./tools/toolchain/scripts/arch_base.tmpl \
|
|||
./scripts/
|
||||
RUN ./scripts/generate_arch_files.sh && rm -rf ./build
|
||||
|
||||
# Install CP2K using local_coverage.pdbg.
|
||||
WORKDIR /opt/cp2k
|
||||
ARG GIT_COMMIT_SHA
|
||||
COPY ./Makefile .
|
||||
ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}
|
||||
|
||||
# Install CP2K sources.
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./src ./src
|
||||
COPY ./exts ./exts
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
RUN /bin/bash -c " \
|
||||
if [ -n "${GIT_COMMIT_SHA}" ] ; then echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi && \
|
||||
mkdir -p arch && \
|
||||
ln -vs /opt/cp2k-toolchain/install/arch/local_coverage.pdbg ./arch/"
|
||||
COPY ./data ./data
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/regtesting ./tools/regtesting
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./CMakeLists.txt .
|
||||
|
||||
# Run coverage test for pdbg.
|
||||
# Compile CP2K.
|
||||
COPY ./tools/docker/scripts/build_cp2k_cmake.sh .
|
||||
RUN ./build_cp2k_cmake.sh toolchain_coverage psmp
|
||||
|
||||
# Run coverage test.
|
||||
COPY ./tools/docker/scripts/test_coverage.sh .
|
||||
RUN ./test_coverage.sh "pdbg" 2>&1 | tee report.log
|
||||
RUN ./test_coverage.sh 2>&1 | tee report.log
|
||||
|
||||
# Output the report if the image is old and was therefore pulled from the build cache.
|
||||
CMD cat $(find ./report.log -mmin +10) | sed '/^Summary:/ s/$/ (cached)/'
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
#
|
||||
# This file was created by generate_dockerfiles.py.
|
||||
# Usage: podman build --shm-size=1g -f ./Dockerfile.test_coverage-sdbg ../../
|
||||
#
|
||||
|
||||
FROM ubuntu:24.04
|
||||
|
||||
# Install requirements for the toolchain.
|
||||
WORKDIR /opt/cp2k-toolchain
|
||||
COPY ./tools/toolchain/install_requirements*.sh ./
|
||||
RUN ./install_requirements.sh ubuntu:24.04
|
||||
|
||||
# Install the toolchain.
|
||||
RUN mkdir scripts
|
||||
COPY ./tools/toolchain/scripts/VERSION \
|
||||
./tools/toolchain/scripts/parse_if.py \
|
||||
./tools/toolchain/scripts/tool_kit.sh \
|
||||
./tools/toolchain/scripts/common_vars.sh \
|
||||
./tools/toolchain/scripts/signal_trap.sh \
|
||||
./tools/toolchain/scripts/get_openblas_arch.sh \
|
||||
./scripts/
|
||||
COPY ./tools/toolchain/install_cp2k_toolchain.sh .
|
||||
RUN ./install_cp2k_toolchain.sh \
|
||||
--install-all \
|
||||
--mpi-mode=mpich \
|
||||
--with-dbcsr=no \
|
||||
--with-gcc=system \
|
||||
--dry-run
|
||||
|
||||
# Dry-run leaves behind config files for the followup install scripts.
|
||||
# This breaks up the lengthy installation into smaller build steps.
|
||||
COPY ./tools/toolchain/scripts/stage0/ ./scripts/stage0/
|
||||
RUN ./scripts/stage0/install_stage0.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage1/ ./scripts/stage1/
|
||||
RUN ./scripts/stage1/install_stage1.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage2/ ./scripts/stage2/
|
||||
RUN ./scripts/stage2/install_stage2.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage3/ ./scripts/stage3/
|
||||
RUN ./scripts/stage3/install_stage3.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage4/ ./scripts/stage4/
|
||||
RUN ./scripts/stage4/install_stage4.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage5/ ./scripts/stage5/
|
||||
RUN ./scripts/stage5/install_stage5.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage6/ ./scripts/stage6/
|
||||
RUN ./scripts/stage6/install_stage6.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage7/ ./scripts/stage7/
|
||||
RUN ./scripts/stage7/install_stage7.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage8/ ./scripts/stage8/
|
||||
RUN ./scripts/stage8/install_stage8.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/stage9/ ./scripts/stage9/
|
||||
RUN ./scripts/stage9/install_stage9.sh && rm -rf ./build
|
||||
|
||||
COPY ./tools/toolchain/scripts/arch_base.tmpl \
|
||||
./tools/toolchain/scripts/generate_arch_files.sh \
|
||||
./scripts/
|
||||
RUN ./scripts/generate_arch_files.sh && rm -rf ./build
|
||||
|
||||
# Install CP2K using local_coverage.sdbg.
|
||||
WORKDIR /opt/cp2k
|
||||
ARG GIT_COMMIT_SHA
|
||||
COPY ./Makefile .
|
||||
COPY ./src ./src
|
||||
COPY ./exts ./exts
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
RUN /bin/bash -c " \
|
||||
if [ -n "${GIT_COMMIT_SHA}" ] ; then echo "git:\${GIT_COMMIT_SHA::7}" > REVISION; fi && \
|
||||
mkdir -p arch && \
|
||||
ln -vs /opt/cp2k-toolchain/install/arch/local_coverage.sdbg ./arch/"
|
||||
COPY ./data ./data
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/regtesting ./tools/regtesting
|
||||
|
||||
# Run coverage test for sdbg.
|
||||
COPY ./tools/docker/scripts/test_coverage.sh .
|
||||
RUN ./test_coverage.sh "sdbg" 2>&1 | tee report.log
|
||||
|
||||
# Output the report if the image is old and was therefore pulled from the build cache.
|
||||
CMD cat $(find ./report.log -mmin +10) | sed '/^Summary:/ s/$/ (cached)/'
|
||||
ENTRYPOINT []
|
||||
|
||||
#EOF
|
||||
|
|
@ -155,13 +155,13 @@ cache_from: sdbg
|
|||
build_path: /
|
||||
dockerfile: /tools/docker/Dockerfile.test_minimal
|
||||
|
||||
[coverage-pdbg]
|
||||
[coverage]
|
||||
display_name: Coverage
|
||||
tags: daily
|
||||
cpu: 32
|
||||
nodepools: pool-main
|
||||
build_path: /
|
||||
dockerfile: /tools/docker/Dockerfile.test_coverage-pdbg
|
||||
dockerfile: /tools/docker/Dockerfile.test_coverage
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -58,10 +58,9 @@ def main() -> None:
|
|||
f.write(install_deps_toolchain(with_dbcsr=""))
|
||||
f.write(regtest_cmake("toolchain_asan", "psmp"))
|
||||
|
||||
for version in "sdbg", "pdbg":
|
||||
with OutputFile(f"Dockerfile.test_coverage-{version}", args.check) as f:
|
||||
f.write(install_deps_toolchain())
|
||||
f.write(coverage(version))
|
||||
with OutputFile(f"Dockerfile.test_coverage", args.check) as f:
|
||||
f.write(install_deps_toolchain(with_dbcsr=""))
|
||||
f.write(coverage())
|
||||
|
||||
for gcc_version in 8, 9, 10, 11, 12, 13, 14:
|
||||
with OutputFile(f"Dockerfile.test_gcc{gcc_version}", args.check) as f:
|
||||
|
|
@ -219,13 +218,13 @@ RUN ./test_performance.sh "{arch}" 2>&1 | tee report.log
|
|||
|
||||
|
||||
# ======================================================================================
|
||||
def coverage(version: str) -> str:
|
||||
def coverage() -> str:
|
||||
return (
|
||||
install_cp2k(version=version, arch="local_coverage", revision=True)
|
||||
install_cp2k_cmake(profile="toolchain_coverage", version="psmp", revision=True)
|
||||
+ rf"""
|
||||
# Run coverage test for {version}.
|
||||
# Run coverage test.
|
||||
COPY ./tools/docker/scripts/test_coverage.sh .
|
||||
RUN ./test_coverage.sh "{version}" 2>&1 | tee report.log
|
||||
RUN ./test_coverage.sh 2>&1 | tee report.log
|
||||
"""
|
||||
+ print_cached_report()
|
||||
)
|
||||
|
|
@ -402,6 +401,31 @@ COPY ./tools/regtesting ./tools/regtesting
|
|||
"""
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def install_cp2k_cmake(profile: str, version: str, revision: bool = False) -> str:
|
||||
output = ""
|
||||
if revision:
|
||||
output += "\n"
|
||||
output += "ARG GIT_COMMIT_SHA\n"
|
||||
output += "ENV GIT_COMMIT_SHA=${GIT_COMMIT_SHA}\n"
|
||||
|
||||
output += rf"""
|
||||
# Install CP2K sources.
|
||||
WORKDIR /opt/cp2k
|
||||
COPY ./src ./src
|
||||
COPY ./data ./data
|
||||
COPY ./tests ./tests
|
||||
COPY ./tools/build_utils ./tools/build_utils
|
||||
COPY ./cmake ./cmake
|
||||
COPY ./CMakeLists.txt .
|
||||
|
||||
# Compile CP2K.
|
||||
COPY ./tools/docker/scripts/build_cp2k_cmake.sh .
|
||||
RUN ./build_cp2k_cmake.sh {profile} {version}
|
||||
"""
|
||||
return output
|
||||
|
||||
|
||||
# ======================================================================================
|
||||
def install_dbcsr(profile: str, version: str) -> str:
|
||||
return rf"""
|
||||
|
|
|
|||
|
|
@ -3,16 +3,19 @@
|
|||
# authors: Ole Schuett, Matthias Krack
|
||||
|
||||
if (($# != 2)); then
|
||||
echo "ERROR: Script ${BASH_SOURCE##*/} expects exactly two arguments"
|
||||
echo "Usage: ${BASH_SOURCE##*/} <PROFILE> <VERSION>"
|
||||
echo "ERROR: Script build_cp2k_cmake.sh expects exactly two arguments"
|
||||
echo "Usage: build_cp2k_cmake.sh <PROFILE> <VERSION>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
PROFILE=$1
|
||||
VERSION=$2
|
||||
|
||||
echo "==================== Building CP2K ===================="
|
||||
if [ -n "${GIT_COMMIT_SHA}" ]; then
|
||||
echo "git:${GIT_COMMIT_SHA::7}" > REVISION
|
||||
fi
|
||||
|
||||
echo "==================== Building CP2K ===================="
|
||||
# shellcheck disable=SC1091
|
||||
source ./cmake/cmake_cp2k.sh "${PROFILE}" "${VERSION}"
|
||||
|
||||
|
|
@ -30,4 +33,9 @@ else
|
|||
exit 1
|
||||
fi
|
||||
|
||||
# Fake installation of data files.
|
||||
cd ..
|
||||
mkdir -p ./share/cp2k
|
||||
ln -s ../../data ./share/cp2k/data
|
||||
|
||||
#EOF
|
||||
|
|
|
|||
|
|
@ -2,45 +2,25 @@
|
|||
|
||||
# author: Ole Schuett
|
||||
|
||||
if (($# != 1)); then
|
||||
echo "Usage: test_coverage.sh <VERSION>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ARCH=local_coverage
|
||||
VERSION=$1
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
source /opt/cp2k-toolchain/install/setup
|
||||
|
||||
echo -e "\n========== Compiling CP2K =========="
|
||||
# Get CP2K revision.
|
||||
cd /opt/cp2k || exit 1
|
||||
CP2K_REVISION=$(./tools/build_utils/get_revision_number ./src)
|
||||
rm -rf "obj/${ARCH}/${VERSION}"/*.gcda # remove old gcov statistics
|
||||
|
||||
# Compile cp2k.
|
||||
echo -en "\nCompiling cp2k... "
|
||||
if make -j ARCH="${ARCH}" VERSION="${VERSION}" &> make.out; then
|
||||
echo "done."
|
||||
else
|
||||
echo -e "failed.\n\n"
|
||||
tail -n 100 make.out
|
||||
mkdir -p /workspace/artifacts/
|
||||
cp make.out /workspace/artifacts/
|
||||
echo -e "\nSummary: Compilation failed."
|
||||
echo -e "Status: FAILED\n"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo -e "\n========== Installing Dependencies =========="
|
||||
lcov_version="1.15"
|
||||
lcov_sha256="c1cda2fa33bec9aa2c2c73c87226cfe97de0831887176b45ee523c5e30f8053a"
|
||||
lcov_version="2.3.1"
|
||||
lcov_sha256="b3017679472d5fcca727254493d0eb44253c564c2c8384f86965ba9c90116704"
|
||||
|
||||
# LCOV dependencies
|
||||
apt-get update -qq
|
||||
apt-get install -qq --no-install-recommends \
|
||||
libperlio-gzip-perl \
|
||||
libjson-perl
|
||||
libcapture-tiny-perl \
|
||||
libdatetime-perl \
|
||||
libtimedate-perl \
|
||||
libjson-xs-perl
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
cd /tmp || exit 1
|
||||
|
|
@ -54,32 +34,38 @@ rm -rf "lcov-${lcov_version}.tar.gz" "lcov-${lcov_version}"
|
|||
|
||||
echo -e "\n========== Running Regtests =========="
|
||||
cd /opt/cp2k || exit 1
|
||||
make ARCH="${ARCH}" VERSION="${VERSION}" TESTOPTS="${TESTOPTS}" test
|
||||
./tests/do_regtest.py ./build/bin/ psmp
|
||||
|
||||
# gcov gets stuck on some files...
|
||||
# Maybe related: https://bugs.launchpad.net/gcc-arm-embedded/+bug/1694644
|
||||
# As a workaround we'll simply remove the offending files for now.
|
||||
rm -f "/opt/cp2k/obj/${ARCH}/${VERSION}"/exts/*/*.gcda
|
||||
cd /tmp || exit 1
|
||||
GCOV_TIMEOUT="10s"
|
||||
for fn in "/opt/cp2k/obj/${ARCH}/${VERSION}"/*.gcda; do
|
||||
find /opt/cp2k/build/src/ -name "*.gcda" -print0 | while read -r -d $'\0' fn; do
|
||||
if ! timeout "${GCOV_TIMEOUT}" gcov "$fn" &> /dev/null; then
|
||||
echo "Skipping ${fn} because gcov took longer than ${GCOV_TIMEOUT}."
|
||||
rm "${fn}"
|
||||
fi
|
||||
done
|
||||
|
||||
# collect coverage stats
|
||||
mkdir -p /workspace/artifacts/coverage
|
||||
cd /workspace/artifacts/coverage || exit 1
|
||||
lcov --directory "/opt/cp2k/obj/${ARCH}/${VERSION}" \
|
||||
|
||||
# collect coverage stats
|
||||
lcov --directory "/opt/cp2k/build/src" \
|
||||
--exclude "/opt/cp2k-toolchain/*" \
|
||||
--ignore-errors inconsistent \
|
||||
--capture \
|
||||
--output-file coverage.info > lcov.log
|
||||
|
||||
# print summary
|
||||
lcov --summary coverage.info
|
||||
|
||||
# generate html report
|
||||
genhtml --title "CP2K Regtests (${CP2K_REVISION})" coverage.info > genhtml.log
|
||||
genhtml \
|
||||
--ignore-errors range \
|
||||
--title "CP2K Regtests (${CP2K_REVISION})" \
|
||||
coverage.info > genhtml.log
|
||||
|
||||
# plot
|
||||
LINE_COV=$(lcov --summary coverage.info | grep lines | awk '{print substr($2, 1, length($2)-1)}')
|
||||
|
|
|
|||
|
|
@ -22,10 +22,6 @@ fi
|
|||
# Compile CP2K.
|
||||
./build_cp2k_cmake.sh "${PROFILE}" "${VERSION}" || exit 0
|
||||
|
||||
# Fake installation of data files.
|
||||
mkdir -p ./share/cp2k
|
||||
ln -s ../../data ./share/cp2k/data
|
||||
|
||||
# Extend stack size only for Intel compilers.
|
||||
if "./build/bin/cp2k.${VERSION}" --version | grep -q "compiler: Intel"; then
|
||||
ulimit -s unlimited # breaks address sanitizer
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue