diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 8cbebca0996edcf61264a38fa8c0ee8c372ab97c..97ff5ee261ee09fdf96e838b47c8d7a3bf7f0e5b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -226,3 +226,52 @@ lizard: artifacts: paths: - lizard.txt + +# code coverage +gcov: + stage: test + + only: ["schedules"] + + before_script: + - export DEBIAN_FRONTEND=noninteractive + - apt-get update + - pip3 install gcovr + - gcovr --version + + script: + - mkdir $CI_PROJECT_DIR/build + - cd $CI_PROJECT_DIR/build + - cmake .. -DBUILD_VF_CPU=ON -DBUILD_VF_COVERAGE=ON -DBUILD_VF_UNIT_TESTS=ON + - make -j4 + - ./bin/basicsTests + - cd .. + - mkdir coverage + - gcovr -r $CI_PROJECT_DIR -k build -f "src" --print-summary --html coverage/coverage.html --html-details --xml coverage/coverage.xml + + artifacts: + paths: + - coverage/ + reports: + cobertura: coverage/coverage.xml + + +deploy_gcov_to_elladan: + stage: deploy + + only: ["schedules"] + + needs: ["gcov"] + + before_script: + - 'command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )' + - apt-get install -y rsync + - mkdir -p ~/.ssh + - chmod 700 ~/.ssh + - eval $(ssh-agent -s) + - echo "$SSH_PRIVATE_KEY_ELLADAN" | tr -d '\r' | ssh-add - + - ssh-keyscan -t rsa elladan.irmb.bau.tu-bs.de >> ~/.ssh/known_hosts + - pip3 install ansible + + script: + - ansible-playbook -i ansible/hosts.cfg -u public_pages ansible/playbook_gcov.yml \ No newline at end of file diff --git a/CMake/VirtualFluidsMacros.cmake b/CMake/VirtualFluidsMacros.cmake index 6b7964dfda94853bbae5dad298895cfcbb58b50f..69e56fa63d4f25adb84e539678055e7f46b62d3d 100644 --- a/CMake/VirtualFluidsMacros.cmake +++ b/CMake/VirtualFluidsMacros.cmake @@ -267,6 +267,9 @@ function(vf_add_tests) target_include_directories(${library_test_name} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) target_include_directories(${library_test_name} PRIVATE ${VF_SRC_DIR}) + # flags + addAdditionalFlags(${library_test_name}) + # link googlemock linkGMOCK() diff --git a/CMake/compilerflags/GNU.cmake b/CMake/compilerflags/GNU.cmake index bd69600c60b89ddac120663de4716bf99528e87d..211f2a040b9c6c71d632fbee8621377d1df63350 100644 --- a/CMake/compilerflags/GNU.cmake +++ b/CMake/compilerflags/GNU.cmake @@ -16,6 +16,12 @@ if(NOT BUILD_VF_INCLUDE_WHAT_YOU_USE) # optimization flag '-funroll-all-loops' i LIST(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "-funroll-all-loops") endif() +# gcov +if (BUILD_VF_COVERAGE) + list(APPEND CAB_COMPILER_ADDTIONAL_CXX_COMPILER_FLAGS "--coverage") + set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} " --coverage") +endif() + ############################################################################################################# # warnings ############################################################################################################# diff --git a/CMakeLists.txt b/CMakeLists.txt index e1540fd0a319739662cc2f50013da4f8975257c5..8b8807eb870743def85cf3342e04e8c56e20e9a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,11 +41,14 @@ option(BUILD_VF_UNIT_TESTS "Build VirtualFluids unit tests" OFF) option(BUILD_VF_CLANG_TIDY "Add the clang tidy checks to the targets" OFF) option(BUILD_VF_INCLUDE_WHAT_YOU_USE "Add IWYU to the targets" OFF) option(BUILD_VF_CPPCHECK "Add cppcheck to the targets" OFF) +option(BUILD_VF_COVERAGE "Add the -coverage compiler flag." OFF) option(BUILD_SHARED_LIBS "" ON) option(USE_OPENMP "Include OpenMP support" ON) +option(BUILD_VF_PYTHON_BINDINGS "" OFF) + ################################################################################# # CMAKE POLICIES ################################################################################# diff --git a/ansible/hosts.cfg b/ansible/hosts.cfg index 791cf36df2f9597d84ecef9d512b6855dfeb1873..259f123d255fdf1979baf0df55eae986ef76749a 100644 --- a/ansible/hosts.cfg +++ b/ansible/hosts.cfg @@ -4,3 +4,5 @@ host_key_checking=False phoenix.hlr.rz.tu-bs.de ansible_ssh_private_key_file=./private_key [gitlab_ci_deploy_cppcheck] elladan.irmb.bau.tu-bs.de +[gitlab_ci_deploy_gcov] +elladan.irmb.bau.tu-bs.de \ No newline at end of file diff --git a/ansible/playbook_cppcheck.yml b/ansible/playbook_cppcheck.yml index b33d71ba8821c1a0af38c1bf265d9f7393f4c462..942f842450c91d27f3eea08c21060e152c7c2fed 100644 --- a/ansible/playbook_cppcheck.yml +++ b/ansible/playbook_cppcheck.yml @@ -7,4 +7,4 @@ - name: Synchronize cppcheck with remote synchronize: src: "../html_report" - dest: "~/cppcheck/html_report" + dest: "~/cppcheck" diff --git a/ansible/playbook_gcov.yml b/ansible/playbook_gcov.yml new file mode 100644 index 0000000000000000000000000000000000000000..45e53b9cd08090750a3e10e7e1e2c9ffa71e0766 --- /dev/null +++ b/ansible/playbook_gcov.yml @@ -0,0 +1,10 @@ +- hosts: gitlab_ci_deploy_gcov + tasks: + - name: Create remote gcov dir + command: mkdir ~/gcov + ignore_errors: yes + + - name: Synchronize gcov with remote + synchronize: + src: "../coverage" + dest: "~/gcov" diff --git a/cpu.cmake b/cpu.cmake index 5c7fdda0e845cf5f702de27f5fde2bff7d89b79a..7e90d1b54732407e9716bada7b9460544ff0a74c 100644 --- a/cpu.cmake +++ b/cpu.cmake @@ -85,8 +85,11 @@ add_subdirectory(${VF_THIRD_DIR}/MuParser) add_subdirectory(${VF_THIRD_DIR}/pybind11/pybind11-2.5.0) add_subdirectory(src/cpu/VirtualFluidsCore) -add_subdirectory(src/cpu/simulationconfig) -add_subdirectory(src/cpu/pythonbindings) + +if(BUILD_VF_PYTHON_BINDINGS) + add_subdirectory(src/cpu/simulationconfig) + add_subdirectory(src/cpu/pythonbindings) +endif() set (APPS_ROOT_CPU "${VF_ROOT_DIR}/apps/cpu/") include(${APPS_ROOT_CPU}/Applications.cmake) \ No newline at end of file diff --git a/setup.py b/setup.py index fc52cc39f8d6a1e59b772260ba332e2221e438ee..10cf9863ed265ae6f732dc2fe20e31a96d40ff85 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ from skbuild import setup -cmake_args = ["-DBUILD_VF_CPU:BOOL=ON", "-DUSE_METIS=ON", "-DUSE_MPI=ON", "-DBUILD_SHARED_LIBS=OFF", +cmake_args = ["-DBUILD_VF_CPU:BOOL=ON", "-DUSE_METIS=ON", "-DUSE_MPI=ON", "-DBUILD_SHARED_LIBS=OFF", "-DBUILD_VF_PYTHON_BINDINGS=ON", "-DBUILD_VF_UNIT_TESTS:BOOL=ON"] setup(