[Libreoffice-commits] buildbot.git: lcov-report/lcov-report.sh lcov-report/README

Maarten Hoes hoes.maarten at gmail.com
Mon Dec 1 08:46:22 PST 2014


 lcov-report/README         |   13 ++++++--
 lcov-report/lcov-report.sh |   72 +++++++++++++++++++++++++++++++++------------
 2 files changed, 63 insertions(+), 22 deletions(-)

New commits:
commit c4b8cd8833b41bd870ce8e2544824f82198fca15
Author: Maarten Hoes <hoes.maarten at gmail.com>
Date:   Mon Dec 1 16:57:43 2014 +0100

    Describe test that was run using lcov's 'description file'.
    
    Change-Id: I5ac843e80e38f9eb31c20a69dc2421a9c329706d
    Reviewed-on: https://gerrit.libreoffice.org/13246
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/lcov-report/README b/lcov-report/README
index 200ff9e..0300238 100644
--- a/lcov-report/README
+++ b/lcov-report/README
@@ -46,6 +46,12 @@ SYNOPSIS
         Specifies the directory in which to contain the generated HTML
         report files. This flag is mandatory when you run '-b'.
 
+-d
+        Specify a descriptive name for the test(s) you wish to create
+        a report for. For example, if your test consists of the make
+        target 'make check', you could specify '-d "make check"'.
+
+
 
 EXAMPLE
 
@@ -88,7 +94,8 @@ EXAMPLE
                 run this command ('-b') before you run your tests.
 
                 lcov-report.sh -b -C /home/user/build -t \
-                /home/user/traces
+                /home/user/traces -s /home/user/src/libreoffice \
+		-d "make check"
 
 
         3.) Run tests.
@@ -107,10 +114,10 @@ EXAMPLE
 
                 lcov-report.sh -a -C /home/user/build \
                 -s /home/user/src/libreoffice -t \
-                /home/user/traces -w /home/user/html
+                /home/user/traces -w /home/user/html -d "make check"
 
                 Make sure that you specify the same directory for the
                 tracefiles ('-t') as you did when running the command
-                '-b' befpre your tests, as lcov needs access to the
+                '-b' before your tests, as lcov needs access to the
                 baseline file that was created in that step.
 
diff --git a/lcov-report/lcov-report.sh b/lcov-report/lcov-report.sh
index c5298c8..d4d17fd 100755
--- a/lcov-report/lcov-report.sh
+++ b/lcov-report/lcov-report.sh
@@ -53,6 +53,11 @@ init()
         if [ -z "${SRC_DIR?}" ] ; then
             die "When specifying '-a', you also need to specify '-s'."
         fi
+
+        if [ ! -d "${TRACEFILE_DIR?}" ] ; then
+            die "Failed to locate tracefile directory ${TRACEFILE_DIR?}."
+        fi
+
         if [ ! -d "${HTML_DIR?}" ] ; then
             mkdir "${HTML_DIR?}" || die "Failed to create html directory ${HTML_DIR?}."
         else
@@ -65,6 +70,14 @@ init()
         if [ -z "${TRACEFILE_DIR?}" ] ; then
             die "When specifying '-a' or '-b', you also need to specify '-t'."
         fi
+
+        if [ -z "${TEST_NAME?}" ] ; then
+            die "When specifying '-a' or '-b', you also need to specify '-d'."
+        fi
+
+        if [ -z "${SRC_DIR?}" ] ; then
+            die "When specifying '-a', you also need to specify '-s'."
+        fi
     fi
 
     if [ "${BEFORE?}" = "TRUE" ] ; then
@@ -76,12 +89,6 @@ init()
         fi
     fi
 
-    if [ "${AFTER?}" = "TRUE" ] ; then
-        if [ ! -d "${TRACEFILE_DIR?}" ] ; then
-            die "Failed to locate tracefile directory ${TRACEFILE_DIR?}."
-        fi
-    fi
-
     if [ "${SOURCE_COMPILE?}" = "TRUE" ] ; then
         if [ -z "${BUILD_DIR?}" ] ; then
             die "When specifying '-c', you also need to specify '-C'."
@@ -101,7 +108,7 @@ init()
 
 lcov_cleanup()
 {
-    lcov --zerocounters --directory "${SRC_DIR?}"
+    lcov --zerocounters --directory "${BUILD_DIR?}"
 }
 
 source_build()
@@ -113,24 +120,26 @@ source_build()
     || die "autogen.sh failed."
 
     make build-nocheck || die "make build-nocheck failed."
+
+    cd -
 }
 
 lcov_tracefile_baseline()
 {
-    lcov --rc geninfo_auto_base=1 --capture --initial --directory "${BUILD_DIR?}" --output-file "${TRACEFILE_DIR?}/lcov_base.info" \
+    lcov --rc geninfo_auto_base=1 --capture --initial --directory "${BUILD_DIR?}" --output-file "${TRACEFILE_DIR?}/lcov_base.info" --test-name "${TEST_NAME?}" \
     || die "Tracefile ${TRACEFILE_DIR?}/lcov_base.info generation failed."
 }
 
 lcov_tracefile_tests()
 {
-    lcov --rc geninfo_auto_base=1 --capture --directory "${BUILD_DIR?}" --output-file "${TRACEFILE_DIR?}/lcov_test.info" \
+    lcov --rc geninfo_auto_base=1 --capture --directory "${BUILD_DIR?}" --output-file "${TRACEFILE_DIR?}/lcov_test.info" --test-name "${TEST_NAME?}" \
     || die "Tracefile ${TRACEFILE_DIR?}/lcov_test.info generation failed."
 }
 
 lcov_tracefile_join()
 {
     lcov --rc geninfo_auto_base=1 --add-tracefile "${TRACEFILE_DIR?}/lcov_base.info" \
-    --add-tracefile "${TRACEFILE_DIR?}/lcov_test.info" --output-file "${TRACEFILE_DIR?}/lcov_total.info" \
+    --add-tracefile "${TRACEFILE_DIR?}/lcov_test.info" --output-file "${TRACEFILE_DIR?}/lcov_total.info" --test-name "${TEST_NAME?}" \
     || die "Tracefile generation $TRACEFILE_DIR/lcov_total.info failed."
 }
 
@@ -139,36 +148,50 @@ lcov_tracefile_cleanup()
     lcov --rc geninfo_auto_base=1 --remove "${TRACEFILE_DIR?}/lcov_total.info" \
     "/usr/include/*" "/usr/lib/*" "${SRC_DIR?}/*/UnpackedTarball/*" "${SRC_DIR?}/workdir/*" \
     "${BUILD_DIR?}/workdir/*" "${SRC_DIR?}/instdir/*" "${SRC_DIR?}/external/*" \
-    -o "${TRACEFILE_DIR?}/lcov_filtered.info" \
+    -o "${TRACEFILE_DIR?}/lcov_filtered.info" --test-name "${TEST_NAME?}" \
     || die "tracefile generation ${TRACEFILE_DIR?}/lcov_filtered.info failed."
 }
 
 lcov_mkhtml()
 {
+    mkdir "${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}" || die "Failed to create subdirectory in ${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}"
+
+    genhtml --rc geninfo_auto_base=1 --prefix "${SRC_DIR?}" --ignore-errors source "${TRACEFILE_DIR?}/lcov_filtered.info" \
+    --legend --title "${TEST_NAME?}" --rc genhtml_desc_html=1 \
+    --output-directory="${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}" --description-file "${TRACEFILE_DIR?}/${DESC_FILE?}" \
+    || die "ERROR: Generation of html files in ${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?} failed."
+}
+
+lcov_get_commit()
+{
     cd "${SRC_DIR?}"
 
     COMMIT_SHA1=$(git log --date=iso | head -3 | awk '/^commit/ {print $2}')
     COMMIT_DATE=$(git log --date=iso | head -3 | awk '/^Date/ {print $2}')
     COMMIT_TIME=$(git log --date=iso | head -3 | awk '/^Date/ {print $3}')
 
-    mkdir "${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}" || die "Failed to create subdirectory in ${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}"
+    cd -
+}
 
-    genhtml --rc geninfo_auto_base=1 --prefix "${SRC_DIR?}" --ignore-errors source "${TRACEFILE_DIR?}/lcov_filtered.info" \
-    --legend --title "commit ${COMMIT_SHA1?}" \
-    --output-directory="${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?}" \
-    || die "ERROR: Generation of html files in ${HTML_DIR?}/master~${COMMIT_DATE?}_${COMMIT_TIME?} failed."
+lcov_mk_desc()
+{
+    echo "TN: ${TEST_NAME?}" > "${TRACEFILE_DIR?}/${DESC_FILE?}"
+    echo "TD: Commit SHA1: ${COMMIT_SHA1?} <br>" >> "${TRACEFILE_DIR?}/${DESC_FILE?}"
+    echo "TD: Commit DATE: ${COMMIT_DATE?} ${COMMIT_TIME?} <br>" >> "${TRACEFILE_DIR?}/${DESC_FILE?}"
+    echo "TD: Source Code Directory: ${SRC_DIR?} <br>" >> "${TRACEFILE_DIR?}/${DESC_FILE?}"
 }
 
 usage()
 {
-    echo >&2 "Usage: lcov-report.sh [-a|-b|-c] -s [DIRECTORY] -C [DIRECTORY] -t [DIRECTORY] -w [DIRECTORY]
+    echo >&2 "Usage: lcov-report.sh [-a|-b|-c] -s [DIRECTORY] -C [DIRECTORY] -t [DIRECTORY] -w [DIRECTORY] -d "test description"
         -b    run lcov commands before your tests
         -a    run lcov commands after your tests
         -c    compile libreoffice sources
         -C    build directory to compile libreoffice sources in
         -s    source code directory
         -t    tracefile directory
-        -w    html (www) directory"
+        -w    html (www) directory
+        -d    description of test that was ran"
     exit 1
 }
 
@@ -183,12 +206,17 @@ SRC_DIR=
 TRACEFILE_DIR=
 HTML_DIR=
 BUILD_DIR=
+COMMIT_SHA1=
+COMMIT_DATE=
+COMMIT_TIME=
+TEST_NAME=
+DESC_FILE=descfile.desc
 
 if [ "$#" = "0" ] ; then
     usage
 fi
 
-while getopts ":s:t:w:C:abc" opt ; do
+while getopts ":s:t:w:C:d:abc" opt ; do
     case "$opt" in
     s)
         SRC_DIR="$OPTARG"
@@ -211,6 +239,9 @@ while getopts ":s:t:w:C:abc" opt ; do
     a)
         AFTER=TRUE
         ;;
+    d)
+        TEST_NAME="${OPTARG?}"
+        ;;
     *)
         usage
         ;;
@@ -221,7 +252,9 @@ init
 
 if [ "${BEFORE?}" = "TRUE" ] ; then
     lcov_cleanup
+    lcov_get_commit
     lcov_tracefile_baseline
+    lcov_mk_desc
 fi
 
 if [ "${SOURCE_COMPILE?}" = "TRUE" ] ; then
@@ -229,6 +262,7 @@ if [ "${SOURCE_COMPILE?}" = "TRUE" ] ; then
 fi
 
 if [ "${AFTER?}" = "TRUE" ] ; then
+    lcov_get_commit
     lcov_tracefile_tests
     lcov_tracefile_join
     lcov_tracefile_cleanup


More information about the Libreoffice-commits mailing list