3 #==================================================================================
4 # Copyright (c) 2018-2020 AT&T Intellectual Property.
6 # Licensed under the Apache License, Version 2.0 (the "License");
7 # you may not use this file except in compliance with the License.
8 # You may obtain a copy of the License at
10 # http://www.apache.org/licenses/LICENSE-2.0
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS,
14 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 # See the License for the specific language governing permissions and
16 # limitations under the License.
17 #==================================================================================
21 # Mnemonic: pub_cov.ksh
22 # Abstract: This script will push any coverage files (.gcov) in the current
23 # directory to the indicated target directory (/tmp/gcov_rpts by
24 # default. Because sonar needs to match the source listed in the
25 # .gcov file with what it perceives was analysed by it's code, we
26 # must fiddle the name in the .gcov file to be a path relative to
27 # the project root. For example, if the .gcov file has the line:
29 # 0:Source:mc_listener.c
31 # we must change that to be the path of sidecars/listener/src
33 # Date: 3 September 2020
34 # Author: E. Scott Daniels
35 # -------------------------------------------------------------------------
37 sdir=sidecars/listener/src # default source directory
38 pdir=/tmp/gcov_rpts # publish directory
51 echo "publishing gcov files to: $pdir"
55 echo "publishing: $f to ${pdir}/$f"
57 # rel replace will replace things like ../src based on the source directory
59 -v rel_rep="../${sdir##*/}/" '
61 gsub( rel_rep, "", $0 ) # relative replace must be first
62 n = split( $0, a, ":" ) # file name into a[n]
63 gsub( a[n], sdir "/" a[n], $0 )