#!/bin/bash # Local example $./run.unittest.sh :0 5.12.5 /media/sf_VMSHARE echo " ------------------------------ Definisions " DISPLAY_NO=:10.0 QT_VER="" SERVER_DIR="/media/BambooProjects" DENALI_SQUISH=denaliSquish DENALI_QTTEST=denaliTest if [ ! -z "$RUN_FOR_LOCAL" ];then #is local DISPLAY_NO=:0 QT_VER="5.12.5" SERVER_DIR="/media/sf_VMSHARE" #Setting up Display number if [ ! -z "$1" ]; then DISPLAY_NO=$1 fi #setup Qt dir version if [ ! -z "$2" ]; then QT_VER=$2 fi #Setting up server folder if [ ! -z "$1" ]; then SERVER_DIR=$3 fi fi SQUISH_SERVER_PORT=4322 BUID_DIR=build QT_DIR="/opt/Qt$QT_VER/5.12.5/gcc_64" SQUISH_DIR="/opt/squishqt" COCO_DIR="/opt/SquishCoco" REMOTE_DIR="$SERVER_DIR/DEN_UI" REPORT_DIR="$timeStamp-BuildNo-$buildNumber-$buildPlan" REPORT=Report LOG=Logs UNITTEST_RESULT=0 export PATH=$PATH:$QT_DIR/bin/:$QT_DIR/lib export PATH=$COCO_DIR/wrapper/bin/:$COCO_DIR/bin/:$PATH export LD_LIBRARY_PATH=$QT_DIR/lib export DISPLAY=$DISPLAY_NO export SQUISH_GUI_COVERAGE=1 echo " ------------------------------ Create the Report output/log folder" mkdir -p $REPORT/$LOG echo " ------------------------------ Clone Denali " if [ -z "$RUN_FOR_LOCAL" ]; then git clone ssh://git@dvm-linux02:7999/ui/application.git else cp -r ../../Project/application application fi echo " ------------------------------ Clone the Test Suites" if [ -z "$RUN_FOR_LOCAL" ]; then git clone ssh://git@dvm-linux02:7999/ui/testsuites.git else cp -r ../../Project/testsuites testsuites fi echo " ------------------------------ Build Application " mkdir $BUID_DIR cd $BUID_DIR if [ -z "$RUN_QTTEST" ]; then echo " ------------------------------ QtTest : Configure The Project for Coverage" # Coco Build - Instrumentation $QT_DIR/bin/qmake ../application/denali.pro -spec linux-g++ CONFIG+=qtquickcompiler CONFIG+=tst_canbus CONFIG+=CodeCoverage TARGET=tst_canbus_$DENALI_QTTEST /usr/bin/make LINK=csg++ AR=csar CXX=csg++ CC=csgcc -j4 1>>../$REPORT/$LOG/build_for_QtTest.log 2>>../$REPORT/$LOG/build_for_QtTest.err /usr/bin/make clean ./tst_canbus_$DENALI_QTTEST -o -,txt 1>>../$REPORT/$LOG/QtTest.log 2>>../$REPORT/$LOG/QtTest.err UNITTEST_RESULT=$((UNITTEST_RESULT+$?)) $QT_DIR/bin/qmake ../application/denali.pro -spec linux-g++ CONFIG+=qtquickcompiler CONFIG+=tst_logging CONFIG+=CodeCoverage TARGET=tst_logging_$DENALI_QTTEST /usr/bin/make LINK=csg++ AR=csar CXX=csg++ CC=csgcc -j4 1>>../$REPORT/$LOG/build_for_QtTest.log 2>>../$REPORT/$LOG/build_for_QtTest.err /usr/bin/make clean ./tst_logging_$DENALI_QTTEST -o -,txt 1>>../$REPORT/$LOG/QtTest.log 2>>../$REPORT/$LOG/QtTest.err UNITTEST_RESULT=$((UNITTEST_RESULT+$?)) $QT_DIR/bin/qmake ../application/denali.pro -spec linux-g++ CONFIG+=qtquickcompiler CONFIG+=tst_utilities CONFIG+=CodeCoverage TARGET=tst_utilities_$DENALI_QTTEST /usr/bin/make LINK=csg++ AR=csar CXX=csg++ CC=csgcc -j4 1>>../$REPORT/$LOG/build_for_QtTest.log 2>>../$REPORT/$LOG/build_for_QtTest.err /usr/bin/make clean ./tst_utilities_$DENALI_QTTEST -o -,txt 1>>../$REPORT/$LOG/QtTest.log 2>>../$REPORT/$LOG/QtTest.err UNITTEST_RESULT=$((UNITTEST_RESULT+$?)) fi echo " ------------------------------ Squish : Configure The Project for Coverage" # Coco Build - Instrumentation $QT_DIR/bin/qmake ../application/denali.pro -spec linux-g++ CONFIG+=qtquickcompiler CONFIG+=CodeCoverage TARGET=$DENALI_SQUISH /usr/bin/make LINK=csg++ AR=csar CXX=csg++ CC=csgcc -j4 1>../$REPORT/$LOG/build_for_SquishQt.log 2>../$REPORT/$LOG/build_for_SquishQt.err /usr/bin/make clean cd .. echo " ------------------------------ Starting the Squish Server" $SQUISH_DIR/bin/squishserver --config addAUT $DENALI_SQUISH $(pwd)/$BUID_DIR/ 1>$REPORT/$LOG/squishqtserver.log 2>$REPORT/$LOG/squishqtserver.err $SQUISH_DIR/bin/squishserver 1>>$REPORT/$LOG/squishqtserver.log 2>>$REPORT/$LOG/squishqtserver.err & echo " ------------------------------ Starting tests" $SQUISH_DIR/bin/squishrunner --testsuite testsuites --exitCodeOnFail 10000 --reportgen html,$REPORT/UnitTest 1>$REPORT/$LOG/squishqtrunner.log 2>$REPORT/$LOG/squishqtrunner.err cp $REPORT/$LOG/QtTest.log $REPORT/UnitTest/QtTest.txt UNITTEST_RESULT=$((UNITTEST_RESULT+$?)) echo " ------------------------------ Merging the excecution report databases" cmmerge -o $BUID_DIR/denali.csmes \ $BUID_DIR/$DENALI_SQUISH.csmes \ $BUID_DIR/tst_canbus_$DENALI_QTTEST.csmes \ $BUID_DIR/tst_logging_$DENALI_QTTEST.csmes \ $BUID_DIR/tst_utilities_$DENALI_QTTEST.csmes \ 1>$REPORT/$LOG/cmmerge.log 2>$REPORT/$LOG/cmmerge.err echo " ------------------------------ Importing the excecution report into the coverage database" cmcsexeimport -m $BUID_DIR/denali.csmes -t QtTest -e $BUID_DIR/tst_canbus_$DENALI_QTTEST.csexe 1>$REPORT/$LOG/cmcsexeimport_qttest.log 2>$REPORT/$LOG/cmcsexeimport_qttest.err cmcsexeimport -m $BUID_DIR/denali.csmes -t QtTest -e $BUID_DIR/tst_logging_$DENALI_QTTEST.csexe 1>$REPORT/$LOG/cmcsexeimport_qttest.log 2>$REPORT/$LOG/cmcsexeimport_qttest.err cmcsexeimport -m $BUID_DIR/denali.csmes -t QtTest -e $BUID_DIR/tst_utilities_$DENALI_QTTEST.csexe 1>$REPORT/$LOG/cmcsexeimport_qttest.log 2>$REPORT/$LOG/cmcsexeimport_qttest.err cmcsexeimport -m $BUID_DIR/denali.csmes -t Squish -e $BUID_DIR/$DENALI_SQUISH.csexe 1>$REPORT/$LOG/cmcsexeimport_squish.log 2>$REPORT/$LOG/cmcsexeimport_squish.err echo " ------------------------------ Generating the coverage report" cmreport --csmes=$BUID_DIR/denali.csmes --html=$REPORT/Coverage/index 1>$REPORT/$LOG/cmreport.log 2>$REPORT/$LOG/cmreport.err echo " ------------------------------ Copy the reports to server" mkdir -p $REMOTE_DIR/$REPORT_DIR cp -rd Report/* $REMOTE_DIR/$REPORT_DIR sync;sync;sync; echo " ------------------------------ Stoping the Squish Server" $SQUISH_DIR/bin/squishserver --stop if [ -z "$StopOnUnitTestError" ]; then exit $UNITTEST_RESULT else exit 0 fi