From a4c72a5f2da81540b4d8309bac3413548aadd6e0 Mon Sep 17 00:00:00 2001 From: Dan Larson Date: Tue, 11 Jun 2019 08:49:29 -0500 Subject: [PATCH] HBCI-177: Enable Code Coverage in CI 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 Tested-by: Jenkins Server Tested-by: FSP CI Jenkins Tested-by: Jenkins OP Build CI Tested-by: Jenkins OP HW Reviewed-by: Zachary Clark Reviewed-by: Daniel M. Crowell --- src/build/citest/autocitest | 51 +++++++++++++++++++++++++---------- src/build/citest/build-script | 37 ++++++++++++++++++++----- 2 files changed, 67 insertions(+), 21 deletions(-) diff --git a/src/build/citest/autocitest b/src/build/citest/autocitest index 0cb8d078ffd..e2b8126d60b 100755 --- a/src/build/citest/autocitest +++ b/src/build/citest/autocitest @@ -333,10 +333,11 @@ 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" @@ -344,9 +345,11 @@ while [ $(($modsstarted)) -lt 1 -o $(($modsstarted)) -ne $(($modscompleted)) ]; 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" @@ -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 @@ -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 ######################################################## diff --git a/src/build/citest/build-script b/src/build/citest/build-script index 7510d76c917..0327293c8c0 100755 --- a/src/build/citest/build-script +++ b/src/build/citest/build-script @@ -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 @@ -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 \ No newline at end of file