mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-28 22:25:32 -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
|
|
@ -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