|
| 1 | +#!/bin/bash |
| 2 | +# Copyright (C) 2024 Intel Corporation |
| 3 | +# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT. |
| 4 | +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 5 | + |
| 6 | +# This script calculates coverage for a single build |
| 7 | + |
| 8 | +set -e |
| 9 | + |
| 10 | +[ "$1" != "" ] && OUTPUT_NAME="$1" || OUTPUT_NAME="output_coverage" |
| 11 | + |
| 12 | +set -x |
| 13 | + |
| 14 | +lcov --capture --directory . \ |
| 15 | +--exclude "/usr/*" \ |
| 16 | +--exclude "*/build/*" \ |
| 17 | +--exclude "*/benchmark/*" \ |
| 18 | +--exclude "*/examples/*" \ |
| 19 | +--exclude "*/test/*" \ |
| 20 | +--exclude "*/src/critnib/*" \ |
| 21 | +--exclude "*/src/ravl/*" \ |
| 22 | +--exclude "*proxy_lib_new_delete.h" \ |
| 23 | +--output-file $OUTPUT_NAME || \ |
| 24 | + ( echo "RETRY after ERROR !!!:" && \ |
| 25 | + lcov --capture --directory . \ |
| 26 | + --exclude "/usr/*" \ |
| 27 | + --exclude "*/build/*" \ |
| 28 | + --exclude "*/benchmark/*" \ |
| 29 | + --exclude "*/examples/*" \ |
| 30 | + --exclude "*/test/*" \ |
| 31 | + --exclude "*/src/critnib/*" \ |
| 32 | + --exclude "*/src/ravl/*" \ |
| 33 | + --exclude "*proxy_lib_new_delete.h" \ |
| 34 | + --ignore-errors mismatch,unused,negative,corrupt \ |
| 35 | + --output-file $OUTPUT_NAME ) |
| 36 | + |
| 37 | +# Most common UMF source code directory on most GH CI runners |
| 38 | +COMMON_UMF_DIR=/home/runner/work/unified-memory-framework/unified-memory-framework |
| 39 | + |
| 40 | +# Get the current UMF source code directory |
| 41 | +# This is ${CURRENT_UMF_DIR}/scripts/coverage/coverage_capture.sh file, so |
| 42 | +CURRENT_UMF_DIR=$(realpath $(dirname $0)/../..) |
| 43 | + |
| 44 | +# Coverage (lcov) has to be run in the same directory on all runners: |
| 45 | +# /home/runner/work/unified-memory-framework/unified-memory-framework/build |
| 46 | +# to be able to merge all results, so we have to replace the paths if they are different: |
| 47 | +if [ "$CURRENT_UMF_DIR" != "$COMMON_UMF_DIR" ]; then |
| 48 | + sed -i "s|$CURRENT_UMF_DIR|$COMMON_UMF_DIR|g" $OUTPUT_NAME |
| 49 | +fi |
0 commit comments