Skip to content

Commit

Permalink
HBCI-177: Enable Code Coverage in CI
Browse files Browse the repository at this point in the history
To enable code coverage set in the environment
    export HOSTBOOT_PROFILE=1
Report is generated under obj/gcov_report

Change-Id: I9548c742f5d3bb83aab6d6e4ffd857cccb48b5f1
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/78736
Reviewed-by: Camvan T. Nguyen <ctnguyen@us.ibm.com>
Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com>
Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com>
Reviewed-by: Zachary Clark <zach@ibm.com>
Reviewed-by: Daniel M. Crowell <dcrowell@us.ibm.com>
  • Loading branch information
danlarson-ibm authored and dcrowell77 committed Jun 27, 2019
1 parent d978f97 commit a4c72a5
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 21 deletions.
51 changes: 37 additions & 14 deletions src/build/citest/autocitest
Expand Up @@ -333,20 +333,23 @@ while [ $(($modsstarted)) -lt 1 -o $(($modsstarted)) -ne $(($modscompleted)) ];
sleep 20
((loopcount++)) # increment loopcount
echo "loopcount = $loopcount"

date +'%H:%M:%S'
echo "modscompleted log command"
echo "autosim $NOWIN --simcmd \"print ((system_cmp0.phys_mem).read 0x$mods_completed_addr 0x08)\" 1> $SBXHOME/modscompleted.log 2> /dev/null"
autosim $NOWIN --simcmd "print ((system_cmp0.phys_mem).read 0x$mods_completed_addr 0x08)" 1> $SBXHOME/modscompleted.log 2> /dev/null
echo "autosim $NOWIN --simcmd \"print ((system_cmp0.phys_mem).read 0x$mods_completed_addr 0x08)\" 1> $SBXHOME/modscompleted.log 2> /dev/null"
autosim $NOWIN --simcmd "print ((system_cmp0.phys_mem).read 0x$mods_completed_addr 0x08)" 1> $SBXHOME/modscompleted.log 2> /dev/null
date +'%H:%M:%S'
echo

echo "modscompleted command"
echo "cat $SBXHOME/modscompleted.log | awk '/0x/ {print strtonum($1)}'"
modscompleted=`cat $SBXHOME/modscompleted.log | awk '/0x/ {print strtonum($1)}'`
echo

date +'%H:%M:%S'
echo "modsstarted log command"
echo "autosim $NOWIN --simcmd \"print ((system_cmp0.phys_mem).read 0x$mods_started_addr 0x08)\" 1> $SBXHOME/modsstarted.log 2> /dev/null"
autosim $NOWIN --simcmd "print ((system_cmp0.phys_mem).read 0x$mods_started_addr 0x08)" 1> $SBXHOME/modsstarted.log 2> /dev/null
echo "autosim $NOWIN --simcmd \"print ((system_cmp0.phys_mem).read 0x$mods_started_addr 0x08)\" 1> $SBXHOME/modsstarted.log 2> /dev/null"
autosim $NOWIN --simcmd "print ((system_cmp0.phys_mem).read 0x$mods_started_addr 0x08)" 1> $SBXHOME/modsstarted.log 2> /dev/null
date +'%H:%M:%S'
echo

echo "modsstarted command"
Expand All @@ -356,18 +359,29 @@ while [ $(($modsstarted)) -lt 1 -o $(($modsstarted)) -ne $(($modscompleted)) ];

echo "ModulesStarted:ModulesCompleted => $modsstarted:$modscompleted"

# @TODO RTC:149210 temporary fix for autosim hangs on real code errors. For some reason
# when we hit an actual bug and simics halts, the autosim commands hang
# causing this loop to take >8 hours.
if [ -z $modsstarted ] && [ -z $modscompleted ]; then
echo "ERROR: autosim hanging on real code errors, temporarily catching early"
echo "See archived hbTracMerg for more info"
exit 1
# For code coverage, sometimes simics takes a while to respond as it dumps data.
# Allow it to continue if this condition is seen.
if [[ -z "${HOSTBOOT_PROFILE}" ]]; then
# @TODO RTC:149210 temporary fix for autosim hangs on real code errors. For some reason
# when we hit an actual bug and simics halts, the autosim commands hang
# causing this loop to take >8 hours.
if [ -z $modsstarted ] && [ -z $modscompleted ]; then
echo "ERROR: autosim hanging on real code errors, temporarily catching early"
echo "See archived hbTracMerg for more info"
exit 1
fi
fi

if [ "$loopcount" -ge 150 ]; then
if [[ -z "${HOSTBOOT_PROFILE}" ]]; then
loop_timeout=150
else
# Increase timeout for code coverage
loop_timeout=500
fi

if [ "$loopcount" -ge "$loop_timeout" ]; then
timestamp=`date +'%H:%M:%S'`
echo "$timestamp ERROR: timed out after 50 minutes waiting for until test completion"
echo "$timestamp ERROR: timed out waiting for until test completion"
autosim $NOWIN --simcmd "hb-Ps with-backtrace"
timeout=$(($modsstarted - $modscompleted))
break
Expand Down Expand Up @@ -467,6 +481,15 @@ if [ $? -ne 0 ] ; then
echo "ERROR: Unable to run $?"
fi

if [[ ! -z "${HOSTBOOT_PROFILE}" ]]; then
# After simics test are complete, dump data.
echo "====> hb-Gcov..."
autosim $NOWIN --simcmd "hb-Gcov" --timeout 300
if [ $? -ne 0 ] ; then
echo "ERROR: Unable to run $?"
fi
fi

########################################################
## done. Stop the simulation
########################################################
Expand Down
37 changes: 30 additions & 7 deletions src/build/citest/build-script
Expand Up @@ -59,13 +59,24 @@ CREATESANDBOX_PID=$!

my_date=$(date)
# Build Hostboot.
echo "#--------------------------------"
printf "\n\n$(date): STARTED running \"make -j32\"\n\n"
echo "#--------------------------------"
make -j32 || exit -1
echo "#--------------------------------"
printf "\n\nrc=$?: $(date): FINISHED running (\"make -j32\" was started at $my_date)\n\n"
echo "#--------------------------------"
if [[ -z "${HOSTBOOT_PROFILE}" ]]; then
echo "#--------------------------------"
printf "\n\n$(date): STARTED running \"make -j32\"\n\n"
echo "#--------------------------------"
make -j32 || exit -1
echo "#--------------------------------"
printf "\n\nrc=$?: $(date): FINISHED running (\"make -j32\" was started at $my_date)\n\n"
echo "#--------------------------------"
else
# Build with code coverage when HOSTBOOT_PROFILE=1
echo "#--------------------------------"
printf "\n\n$(date): STARTED running \"make -j32 gcov\"\n\n"
echo "#--------------------------------"
make -j32 gcov || exit -1
echo "#--------------------------------"
printf "\n\nrc=$?: $(date): FINISHED running (\"make -j32 gcov\" was started at $my_date)\n\n"
echo "#--------------------------------"
fi

# Check sandbox create completion.
wait $CREATESANDBOX_PID
Expand Down Expand Up @@ -124,3 +135,15 @@ else

fi

if [[ ! -z "${HOSTBOOT_PROFILE}" ]]; then
# Generate the code coverage report. Located obj/gcov_report
# Jenkins will artifact and can display html report
my_date=$(date)
echo "#--------------------------------"
printf "\n\n$(date): STARTED running \"make lcov\"\n\n"
echo "#--------------------------------"
make lcov || exit -1
echo "#--------------------------------"
printf "\n\nrc=$?: $(date): FINISHED running (\"make lcov\" was started at $my_date)\n\n"
echo "#--------------------------------"
fi

0 comments on commit a4c72a5

Please sign in to comment.