--- /dev/null
+#!/usr/bin/env bash
+
+#==================================================================================
+# Copyright (c) 2018-2020 AT&T Intellectual Property.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#==================================================================================
+
+
+#
+# Mnemonic: pub_cov.ksh
+# Abstract: This script will push any coverage files (.gcov) in the current
+# directory to the indicated target directory (/tmp/gcov_rpts by
+# default. Because sonar needs to match the source listed in the
+# .gcov file with what it perceives was analysed by it's code, we
+# must fiddle the name in the .gcov file to be a path relative to
+# the project root. For example, if the .gcov file has the line:
+#
+# 0:Source:mc_listener.c
+#
+# we must change that to be the path of sidecars/listener/src
+#
+# Date: 3 September 2020
+# Author: E. Scott Daniels
+# -------------------------------------------------------------------------
+
+sdir=sidecars/listener/src # default source directory
+pdir=/tmp/gcov_rpts # publish directory
+
+while [[ $1 == -* ]]
+do
+ case $1 in
+ -p) pdir=$2; shift;;
+ -s) sdir=$2; shift;;
+ esac
+
+ shift
+done
+
+
+echo "publishing gcov files to: $pdir"
+
+for f in *.gcov
+do
+ echo "publishing: $f to ${pdir}/$f"
+
+ # rel replace will replace things like ../src based on the source directory
+ awk -v sdir="$sdir" \
+ -v rel_rep="../${sdir##*/}/" '
+ /0:Source:/ {
+ gsub( rel_rep, "", $0 ) # relative replace must be first
+ n = split( $0, a, ":" ) # file name into a[n]
+ gsub( a[n], sdir "/" a[n], $0 )
+ }
+
+ { print }
+ ' $f >${pdir}/$f
+done
force_rmr_load=0
no_rmr_load=0
+test_dir=$PWD
# defined in the CI configuration where jenkins jobs are looking for gcov files
gcov_dir=/tmp/gcov_rpts
ensure_pkgs # some CI enviroments may not have RMR; get it
-script_dir=${PWD%/*}/src
cd ../src
# build the binaries with coverage options set
export TEST_COV_OPTS="-ftest-coverage -fprofile-arcs" # picked up by make so we get coverage on tools for sonar
make clean # ensure coverage files removed
-make -B # ensure coverage data is nuked
+make -B # force build under the eyes of sonar build wrapper
+
+rm -fr *.gcov *.gcda # ditch any previously generated coverage info
# drive with full complement to test good branches, then with bad (missing value) to drive exceptions
-mc_listener -p 4567 -q -r 10 -e -d foo -x >/dev/null 2>&1 # -x (invalid) prevents execution loop
+./mc_listener -p 4567 -q -r 10 -e -d foo -x >/dev/null 2>&1 # -x (invalid) prevents execution loop
for x in d p r \? h # drive with missing values for d, p, r and singletons -h and -?
do
- gcov mc_listener.c # debugging because jenkins gcov doesn't seem to be accumulating data
- mc_listener -$x >/dev/null 2>&1
+ ./mc_listener -$x >/dev/null 2>&1
done
-gcov mc_listener.c # debugging because jenkins gcov doesn't seem to be accumulating data
+gcov mc_listener.c # debugging because jenkins gcov doesn't seem to be accumulating data
-pipe_reader -d foo -e -f -m 0 -s -x >/dev/null 2>&1 # drive for all "good" conditions
+./pipe_reader -d foo -e -f -m 0 -s -x >/dev/null 2>&1 # drive for all "good" conditions
for x in d m \? h
do
- pipe_reader -$x >/dev/null 2>&1 # drive each exception (missing value) or 'help'
+ ./pipe_reader -$x >/dev/null 2>&1 # drive each exception (missing value) or 'help'
done
-rdc_replay -d foo -f bar -t 0 -x >/dev/null 2>&1 # drive for all "good" conditions
+./rdc_replay -d foo -f bar -t 0 -x >/dev/null 2>&1 # drive for all "good" conditions
for x in d f t \? h
do
- rdc_replay -$x >/dev/null 2>&1 # drive each exception (missing value) or 'help'
+ ./rdc_replay -$x >/dev/null 2>&1 # drive each exception (missing value) or 'help'
done
-$script_dir/verify.sh # verify MUST be first (replay relies on its output)
-$script_dir/verify_replay.sh
+./verify.sh # verify MUST be first (replay relies on its output)
+./verify_replay.sh
# generate and copy coverage files to parent which is where the CI jobs are looking for them
# we do NOT gen stats for the library functions; the unit test script(s) do that
#
for x in mc_listener sender rdc_replay pipe_reader
do
- gcov $x.c
- cp $x.c.gcov $gcov_dir/
+ gcov $x.c
+ #cp $x.c.gcov $gcov_dir/
done
+$test_dir/publish_cov.ksh # publish coverage files and fixup source names
+
+echo "[INFO] ----- published coverage information ----------------------------------"
+ls -al $gcov_dir
+grep -i "0:Source:" $gcov_dir/*.gcov
+
+echo "------------------------------------------------------------------------------"
+echo "run_app_tests finished"
exit
ensure_pkgs # ensure that we have RMR; some CI environments are lacking
-echo "[INFO] ----------------------------------------------"
-gcov --version # gcov files don't seem to aggregate on the LF guest
-echo "[INFO] ----------------------------------------------"
-
if (( ci_mode )) # in CI mode we must force a build in the src so build wrapper captures trigger data
then
echo "building in src for sonar build wrapper capture"
exit
fi
+rm -fr *.gcov *.gcda # ditch any previously generated coverage info
+
./unit_test >/tmp/PID$$.utlog 2>&1 &
pid=$!
abort_after 60 $pid &
echo "[FAIL] overall test fails"
else
echo "[PASS] overall test passes"
- rm -f *test*.gcov
+ rm -f *test*.gcov # ditch test specific coverage files first
+ #cp *.gcov $gcov_dir/ # make avilable to jenkins job(s)
+ ./publish_cov.ksh # push to reports dir and fix internal source filenames
fi
-cp *.gcov $gcov_dir/ # make avilable to jenkins job(s)
rm -f /tmp/PID$$.*
exit $rc
show_all=0
cfail="DCHK"
-gcov -f $1 | sed "s/'//g" | awk \
+gcov -f $1 | sed "s/'//g" | awk \
-v cfail=$cfail \
-v show_all=$show_all \
-v ignore_list="$iflist" \