Force build of listener in unit test 57/4657/1
authorE. Scott Daniels <daniels@research.att.com>
Tue, 1 Sep 2020 12:45:45 +0000 (08:45 -0400)
committerE. Scott Daniels <daniels@research.att.com>
Tue, 1 Sep 2020 12:45:45 +0000 (08:45 -0400)
The jenkins wrapper script that drives unit test for sonar needs
to "see" a build in the source directory in order to actually
trigger the scan.  This change ensures this happens in the unit
test script which is driven by the jenkins jobs (via CMake
created build).

Issue-ID: RIC-632

Signed-off-by: E. Scott Daniels <daniels@research.att.com>
Change-Id: I1d4641d724498ba27f900b3146db909c61779223

sidecars/listener/test/run_unit_test.ksh

index 2ccd47e..6ee435e 100755 (executable)
 #                              the ability to pre-install before running this test, so
 #                              we will force one to be there if we don't find it in /usr.
 #
+#                              CI Mode
+#                              For the Jenkins jobs to capture trigger data allowing sonar
+#                              analysis, we must force a build in the ../src directory.
+#                              CI mode is on by default, to force this build, but can be
+#                              turned off with the -c option for local builds/testing.
+#
 #      Date:           10 December 2019
 #      Author:         E. Scott Daniels
 # -------------------------------------------------------------------------
@@ -127,10 +133,12 @@ export LIBRARY_PATH=/usr/local/lib:$LIBRARY_PATH
 
 running=/tmp/PID$$.running
 force_rmr_load=0
+ci_mode=1                                                              # -c turns off; see the flower box above
 
 while [[ $1 == -* ]]
 do
        case $1 in
+               -c) ci_mode=0;;
                -f)     force_rmr_load=1;;
                -N) no_rmr_load=1;;                                     # for local testing
 
@@ -150,6 +158,16 @@ fi
 
 ensure_pkgs                                            # ensure that we have RMR; some CI environments are lacking
 
+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"
+       (
+               cd ../src
+               make
+       )
+fi
+
+echo "building unit test(s)"
 if ! make -B unit_test                 # ensure that it's fresh
 then
        echo "[FAIL] cannot make unit_test"
@@ -224,5 +242,7 @@ else
        rm -f *test*.gcov
 fi
 
+cp *.gcov ../                          # jjb description points to top listener dir for sonar to find gcov files
+
 rm -f /tmp/PID$$.*
 exit $rc