SlideShare a Scribd company logo
1 of 17
Autotools adaptation for:
- Automatic unitary tests (Google test/mock)
- Generation of KPI report using lcov
Thierry GAYET (EUROGICIEL)
Revolution-S Rennes - 2011
The main goal of the following slides is to describe how to:
1. Automate the launch of the unit tests
2. Generate KPI from the unit test coverage
2
Objective
06/17/10
3
Hudson workflow
06/17/10
Hudson
Server
Code covering for KPI project needs using lcov by
analyzing the gcov data and generate an html report
Latest doxygen documentation of the
public API in html format
Launch the unit tests with Google{test/gmock}
(generate junit xml files as a report)
Set the environment
Autotools targets
available on Hudson 
mkdir tmp_srcdir
./autogen.sh
./configure --prefix=/usr --srcdir=`pwd`/tmp_srcdir …
make coverity
make check
Make the latest stable archive, extract it in a specific
directory, then launch the configure script before
building the component
make dist
tar zxvf composant-version.tar.gz -C <BUILD_PATH>
cd <BUILD_PATH>/composant-version/
./autogen.sh
./configure --prefix=/usr –enable-covering –enable-test
make –j7
make DESTDIR=<STAGINGDIR> install
make html
Deliver to default CI stream
+ Baseline
+ Recommended baseline
Overview of the autotool process
Makefile.am
configure.ac aclocal.m4
configure
xxx.pc.in
config.h.in
For each package:
• provided by the developers
• stored in repository
Makefile.in
config.cache
config.log
config.h
Makefile
xxx.pc
autogen.sh

automake
autoheader
aclocal
autoconf
USER VIEW
DEV. VIEW
Overview
./autogen.sh
./configure 
--prefix=/usr 
--enable-test 
--enable-covering make covering
--enable-test :
- Enable the unitary tests
- If the Google tests are used the libgtest is checked
- Same for the libgmock
--enable-covering :
- Add the gcov flags to gcc
Step #1 Step #2 Step #3
t
make check
Will compile and launch the unit test
[ with gcov data at the runtime ]
make
It will generate:
- Makefile.in
- configure script
- config.h.in if used
It will generate:
- Makefile
- config.h header
- .pc file
It will generate the
expected ELF objects
(binaries, libraries, … )
including gcov support. Analyze the
data
generated
by gcov and
make html
output
It will generate an html
report that includes a
synthesis of the gcov data
generated at the runtime.
Thus, there is a
correlation between the
unit tests and the lcov
results !!
Step #4
/
Root of the
component
/src/ : implementation’s source code
/inc/ : private headers
Example of component pattern
<name>/ : public headers
autogen.sh : mandatory file for the autotools
configure.ac : main configure template
Makefile.am : main Makefile template
<name>.pc.in : pkgconfig’s metadata used by
libraries.
/test/
src/ : implementation of the Google test/mock
inc/ : headers used by the Google test/mock
 This template is used by individuals components (binary or library). In case of a binary, no
unit tests are provided.
Makefile dependencies
make covering
make DESTDIR=<PATH> install
./autogen.sh
./configure –prefix …
make dist
make or make –j7
make check
make html
 This target generates html output from the lcov
analysis and provides human readable data about the
source code covering by the unitary tests.
--enable-covering should be set to the configure script
 This target launches the unitary tests using the Google
test/mock and provides junit.xml report per unit test.
If gcov has been set, it will generate some information
that will be analysed by lcov.
--enable-test should be set to the configure script
make fullhtml
 This target generates a documentation
of the implementation.
 This target generates a
documentation from the latest
public API (headers).
This target generates the
(cross)compilation
and the link of the component.
This target generates a tarball..
This target intalls the files generated during
the build process.
Generates the final files (Makefile, config.h, … )
Adaptations needed
 configure.ac :
 Add the --enable-test support that exports HAVE_TEST to
the Makefiles.
Add the --enable-covering support for adding the gcov flags
to the build process.
 Makefile.am :
Add the make check support to make the unit tests automatic
Add the make covering support to make the lcov analysis
automatic.
Unit tests 1/5
 Name : --enable-test
 Mandatory : no
 If this flags is not set, the unit test binaries are not built. Thus, the “make check” command
doesn’t do anything at all.
Unit tests 2/5
dnl --------------------------------------------
dnl Brief : enable or disable the unitary test
dnl Mandatory : no
dnl Values : none (just enable the tests if set)
dnl Default's value : disable
dnl --------------------------------------------
AC_ARG_ENABLE(test,
AS_HELP_STRING([--enable-test], [Enable the test unitary support [default=no]]),
[case "${enableval}" in
yes) have_test=true ;;
no) have_test=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-test) ;;
esac],
[have_test=false])
dnl --------------------------------------------
dnl Export the conditional HAVE_TEST variable to the Makefiles
dnl --------------------------------------------
AM_CONDITIONAL(HAVE_TEST, $have_test)
dnl --------------------------------------------
dnl Test the have_test variable and if equal to true
dnl --------------------------------------------
AC_MSG_CHECKING(Checking the test support)
if test "$have_test" != "false" ; then
dnl --------------------------------------------
dnl Display the result of the test ... yes
dnl --------------------------------------------
AC_MSG_RESULT([yes])
LIBGTEST_REQUIRED_VERSION=1.5.0
PKG_CHECK_MODULES([GTEST],[gtest >= $LIBGTEST_REQUIRED_VERSION],[have_libgtest=yes],[have_libgtest=no])
if test "$have_libgtest" = no ; then
AC_MSG_ERROR([Missing libgtest library (http://code.google.com/p/googletest/) !!])
fi
LIBGMOCK_REQUIRED_VERSION=1.5.0
PKG_CHECK_MODULES([GMOCK],[gmock >= $LIBGMOCK_REQUIRED_VERSION],[have_libgmock=yes],[have_libgmock=no])
if test "$have_libgmock" = no ; then
AC_MSG_ERROR([Missing libgmock library !!])
fi
else
dnl --------------------------------------------
dnl Display the result of the test ... no
dnl --------------------------------------------
AC_MSG_RESULT([no])
fi
If you are not using the Google test/mock you can avoid this step. If you need to check both the gtest and gmock
dependencies.
configure.ac
dnl --------------------------------------------
dnl Test if the libgtest is well available in the stagingdir
dnl If so get the cflags and ldflag from the .pc file
dnl --------------------------------------------
LIBGTEST_REQUIRED_VERSION=1.5.0
PKG_CHECK_MODULES([GTEST],[gtest >= $LIBGTEST_REQUIRED_VERSION],[have_libgtest=yes],[have_libgtest=no])
if test "$have_libgtest" = no ; then
AC_MSG_ERROR([Missing libgtest library (http://code.google.com/p/googletest/) !!])
fi
Unit tests 3/5
dnl --------------------------------------------
dnl Test if the libgmock is well available in the stagingdir
dnl If so get the cflags and ldflag from the .pc file
dnl --------------------------------------------
LIBGMOCK_REQUIRED_VERSION=1.5.0
PKG_CHECK_MODULES([GMOCK],[gmock >= $LIBGMOCK_REQUIRED_VERSION],[have_libgmock=yes],[have_libgmock=no])
if test "$have_libgmock" = no ; then
AC_MSG_ERROR([Missing libgmock (http://code.google.com/p/googlemock/) library !!])
fi
 Check the Google test library :
 Check the Google mock library :
configure.ac
configure.ac
Unit tests : direct call 4/5
# ----------------------------------------------------------------
# Unit Tests
# ----------------------------------------------------------------
# Listing of the program to launch
# Those programs should not be installed
# ----------------------------------------------------------------
if HAVE_TEST
TESTS = toe_gtest_assert
noinst_PROGRAMS = $(TESTS)
toe_gtest_assert_SOURCES = $(top_srcdir)/test/src/toe_gtest_assert.cpp
toe_gtest_assert_CPPFLAGS = -I$(HEADER_DIR) 
$(GTEST_CFLAGS) 
$(LIBCONFIG_CFLAGS) 
$(LIBLOG_CFLAGS) 
-DLOG_NAME=TOE_ASSERT 
-DLOG_MASK_PRIO=255
toe_gtest_assert_LDFLAGS = $(top_builddir)/.libs/libtoe.a 
-lpthread 
-lrt
toe_gtest_assert_LDADD = $(GTEST_LIBS) 
$(LIBCONFIG_LIBS) 
$(LIBLOG_LIBS) 
$(EFENCE_LIBS)
else
TESTS =
endif
Makefile.am
 The Makefile will call the toe_gtest_assert binary directly.
make check
Unit tests : call over a script 5/5
# ----------------------------------------------------------------
# Unit Tests for par_si
# ----------------------------------------------------------------
# - Listing of the program to launch
# - Those programs should not be installed
# ----------------------------------------------------------------
if HAVE_TEST
check_SCRIPTS = unitary_test.sh
TESTS = $(check_SCRIPTS)
unitary_test.sh:
@rm -f test/pasi_gtest
@cp ./pasi_gtest test/pasi_gtest
@echo "cd test" >> ./unitary_test.sh
@echo "./pasi_gtest " >> ./unitary_test.sh
@chmod +x ./unitary_test.sh
noinst_PROGRAMS = pasi_gtest
pasi_gtest_SOURCES = test/pasi_test.cpp 
test/pasi_handle.cpp 
test/pasi_atsc_handle.cpp 
test/pasi_mpeg_parsing.cpp 
test/pasi_dvb_parsing.cpp 
test/pasi_atsc_parsing.cpp 
test/pasi_string_converter.cpp
pasi_gtest_CPPFLAGS = -I$(HEADER_DIR) 
-g 
-Wall 
-Wextra
pasi_gtest_LDFLAGS = -lrt 
-lstdc++
pasi_gtest_LDADD = $(GTEST_LIBS) 
$(EFENCE_LIBS)
else
TESTS =
endif
 This Makefile first generates a shell script called unitary_test.sh, then the binary, then launch it.
Makefile.am
make check
14
Code covering 1/2
06/17/10
 Name : --enable-covering
 Mandatory flag : no
 If this flag is set, the ELF objects will be compiled and linked with the following options:
CFLAGS/CXXFLAGS : --fprofile-arcs -ftest-coverage.
LDFLAGS : --fprofile-arcs
 If this flag is not set, it won't add all the covering flags needed.
 This creates an instrumented executable which contains additional instructions that record the
number of times each line of the program is executed. The option -ftest-coverage adds instructions
for counting the number of times individual lines are executed, while -fprofile-arcs incorporates
instrumentation code for each branch of the program. Branch instrumentation records how
frequently different paths are taken through ‘if’ statements and other conditionals. The executable
must then be run to create the coverage data.
 Integration in Hudson through the Cobertura plugin :
http://meekrosoft.wordpress.com/2010/06/02/continuous-code-coverage-with-gcc-googletest-and-
hudson/
Code covering 2/2
dnl --------------------------------------------
dnl Brief : enable or disable the buildin covering mode
dnl Mandatory : no
dnl Values : none (just enable the covering mode if set)
dnl --------------------------------------------
AC_ARG_ENABLE(covering,
AS_HELP_STRING([--enable-covering], [Enable the building covering (gnu/gcov) support [default=no]]),
[case "${enableval}" in
yes) have_covering=true ;;
no) have_covering=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-covering) ;;
esac],
[have_covering=false])
dnl --------------------------------------------
dnl Test the have_covering variable and if equal to true
dnl --------------------------------------------
AC_MSG_CHECKING([Checking the covering support])
if test "$have_covering" = "true" ; then
dnl --------------------------------------------
dnl Display the result of the test ... yes
dnl --------------------------------------------
AC_MSG_RESULT([yes])
dnl --------------------------------------------
dnl Update the CFLAGS and CPPFLAGS with gcov options for gcc
dnl --------------------------------------------
COVERING_CFLAGS=" -fprofile-arcs -ftest-coverage "
COVERING_CPPFLAGS=" -fprofile-arcs -ftest-coverage "
COVERING_LDFLAGS=" -fprofile-arcs "
else
dnl --------------------------------------------
dnl Display the result of the test ... no
dnl --------------------------------------------
AC_MSG_RESULT([no])
fi
configure.ac
make covering : launch the kpi
 Analyse the data generated by the unit tests compiled with the gcov support. It makes an html
report in the output directory.
 The lcov host tool (lcov and genhtml) must be available in the server.
 Example of result available in the output directory:
# ----------------------------------------------------------------
# Automatic LCOV analyzing
# ----------------------------------------------------------------
covering: all check
@echo -n "Removing the previous html generation : "
@rm -fR ./output
@echo "OK"
@echo -n "Analyzing the covering : "
@lcov -c -d . -b . -o toe.log
@echo "OK"
@echo -n "Generating the html report : "
@genhtml -o output toe.log
@echo "OK"
@echo "--> You can now browse the html generated covering using the output/index.html file."
@echo " firefox output/index.html & "
@rm -f *.gcno *.gcda
Makefile.am
TIPS
 The more the unitary tests (based on Google test/mock) will test
functions, the more the KPI will give good data.
 The main goal is to target 100% but because some tests can
be difficult to check (exception, interraction with the system, … )
 The tests should be runable on Hudson.
 Actually each component provides the following data:
o Number of lines (wc –l)
o % of lines tested
o % of functions tested
o % of branches tested

More Related Content

Similar to Autotools adaptation for integrating autotmatic unit tests and covering for KPI-1

Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoMark Wong
 
Integration Testing with Behat drupal
Integration Testing with Behat drupalIntegration Testing with Behat drupal
Integration Testing with Behat drupalOscar Merida
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017Ortus Solutions, Corp
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django ApplicationsGareth Rushgrove
 
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docx
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docxPRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docx
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docxharrisonhoward80223
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suiteericholscher
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to javaciklum_ods
 
Linux Kernel Selftest Framework - Quality Control for New Releases
Linux Kernel Selftest Framework - Quality Control for New ReleasesLinux Kernel Selftest Framework - Quality Control for New Releases
Linux Kernel Selftest Framework - Quality Control for New ReleasesSamsung Open Source Group
 
Node.js basics
Node.js basicsNode.js basics
Node.js basicsBen Lin
 
Project3build.xml Builds, tests, and runs the project .docx
Project3build.xml      Builds, tests, and runs the project .docxProject3build.xml      Builds, tests, and runs the project .docx
Project3build.xml Builds, tests, and runs the project .docxwoodruffeloisa
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox testsKevin Beeman
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous deliveryEatDog
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernelJohnson Chou
 
OpenWRT guide and memo
OpenWRT guide and memoOpenWRT guide and memo
OpenWRT guide and memo家榮 吳
 

Similar to Autotools adaptation for integrating autotmatic unit tests and covering for KPI-1 (20)

Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
Dusan Lukic Magento 2 Integration Tests Meet Magento Serbia 2016
 
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 HowtoPostgreSQL Portland Performance Practice Project - Database Test 2 Howto
PostgreSQL Portland Performance Practice Project - Database Test 2 Howto
 
Integration Testing with Behat drupal
Integration Testing with Behat drupalIntegration Testing with Behat drupal
Integration Testing with Behat drupal
 
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
North Virginia Coldfusion User Group Meetup - Testbox - July 19th 2017
 
Kranthi kumar implement_ci_cd_my_notes
Kranthi kumar implement_ci_cd_my_notesKranthi kumar implement_ci_cd_my_notes
Kranthi kumar implement_ci_cd_my_notes
 
Testing Django Applications
Testing Django ApplicationsTesting Django Applications
Testing Django Applications
 
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docx
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docxPRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docx
PRG 420 Week 3 Individual Assignment Netbeans Project (annual co.docx
 
Making the most of your Test Suite
Making the most of your Test SuiteMaking the most of your Test Suite
Making the most of your Test Suite
 
Bring the fun back to java
Bring the fun back to javaBring the fun back to java
Bring the fun back to java
 
Linux Kernel Selftest Framework - Quality Control for New Releases
Linux Kernel Selftest Framework - Quality Control for New ReleasesLinux Kernel Selftest Framework - Quality Control for New Releases
Linux Kernel Selftest Framework - Quality Control for New Releases
 
Native Hadoop with prebuilt spark
Native Hadoop with prebuilt sparkNative Hadoop with prebuilt spark
Native Hadoop with prebuilt spark
 
Java 9
Java 9Java 9
Java 9
 
Node.js basics
Node.js basicsNode.js basics
Node.js basics
 
N Unit Presentation
N Unit PresentationN Unit Presentation
N Unit Presentation
 
Project3build.xml Builds, tests, and runs the project .docx
Project3build.xml      Builds, tests, and runs the project .docxProject3build.xml      Builds, tests, and runs the project .docx
Project3build.xml Builds, tests, and runs the project .docx
 
Testing in go
Testing in goTesting in go
Testing in go
 
Containerize your Blackbox tests
Containerize your Blackbox testsContainerize your Blackbox tests
Containerize your Blackbox tests
 
Continuous integration / continuous delivery
Continuous integration / continuous deliveryContinuous integration / continuous delivery
Continuous integration / continuous delivery
 
Introduction of unit test on android kernel
Introduction of unit test on android kernelIntroduction of unit test on android kernel
Introduction of unit test on android kernel
 
OpenWRT guide and memo
OpenWRT guide and memoOpenWRT guide and memo
OpenWRT guide and memo
 

Recently uploaded

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Andreas Granig
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxnada99848
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based projectAnoyGreter
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfAlina Yurenko
 

Recently uploaded (20)

Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024Automate your Kamailio Test Calls - Kamailio World 2024
Automate your Kamailio Test Calls - Kamailio World 2024
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
software engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptxsoftware engineering Chapter 5 System modeling.pptx
software engineering Chapter 5 System modeling.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
MYjobs Presentation Django-based project
MYjobs Presentation Django-based projectMYjobs Presentation Django-based project
MYjobs Presentation Django-based project
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdfGOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
GOING AOT WITH GRAALVM – DEVOXX GREECE.pdf
 

Autotools adaptation for integrating autotmatic unit tests and covering for KPI-1

  • 1. Autotools adaptation for: - Automatic unitary tests (Google test/mock) - Generation of KPI report using lcov Thierry GAYET (EUROGICIEL) Revolution-S Rennes - 2011
  • 2. The main goal of the following slides is to describe how to: 1. Automate the launch of the unit tests 2. Generate KPI from the unit test coverage 2 Objective 06/17/10
  • 3. 3 Hudson workflow 06/17/10 Hudson Server Code covering for KPI project needs using lcov by analyzing the gcov data and generate an html report Latest doxygen documentation of the public API in html format Launch the unit tests with Google{test/gmock} (generate junit xml files as a report) Set the environment Autotools targets available on Hudson  mkdir tmp_srcdir ./autogen.sh ./configure --prefix=/usr --srcdir=`pwd`/tmp_srcdir … make coverity make check Make the latest stable archive, extract it in a specific directory, then launch the configure script before building the component make dist tar zxvf composant-version.tar.gz -C <BUILD_PATH> cd <BUILD_PATH>/composant-version/ ./autogen.sh ./configure --prefix=/usr –enable-covering –enable-test make –j7 make DESTDIR=<STAGINGDIR> install make html Deliver to default CI stream + Baseline + Recommended baseline
  • 4. Overview of the autotool process Makefile.am configure.ac aclocal.m4 configure xxx.pc.in config.h.in For each package: • provided by the developers • stored in repository Makefile.in config.cache config.log config.h Makefile xxx.pc autogen.sh  automake autoheader aclocal autoconf USER VIEW DEV. VIEW
  • 5. Overview ./autogen.sh ./configure --prefix=/usr --enable-test --enable-covering make covering --enable-test : - Enable the unitary tests - If the Google tests are used the libgtest is checked - Same for the libgmock --enable-covering : - Add the gcov flags to gcc Step #1 Step #2 Step #3 t make check Will compile and launch the unit test [ with gcov data at the runtime ] make It will generate: - Makefile.in - configure script - config.h.in if used It will generate: - Makefile - config.h header - .pc file It will generate the expected ELF objects (binaries, libraries, … ) including gcov support. Analyze the data generated by gcov and make html output It will generate an html report that includes a synthesis of the gcov data generated at the runtime. Thus, there is a correlation between the unit tests and the lcov results !! Step #4
  • 6. / Root of the component /src/ : implementation’s source code /inc/ : private headers Example of component pattern <name>/ : public headers autogen.sh : mandatory file for the autotools configure.ac : main configure template Makefile.am : main Makefile template <name>.pc.in : pkgconfig’s metadata used by libraries. /test/ src/ : implementation of the Google test/mock inc/ : headers used by the Google test/mock  This template is used by individuals components (binary or library). In case of a binary, no unit tests are provided.
  • 7. Makefile dependencies make covering make DESTDIR=<PATH> install ./autogen.sh ./configure –prefix … make dist make or make –j7 make check make html  This target generates html output from the lcov analysis and provides human readable data about the source code covering by the unitary tests. --enable-covering should be set to the configure script  This target launches the unitary tests using the Google test/mock and provides junit.xml report per unit test. If gcov has been set, it will generate some information that will be analysed by lcov. --enable-test should be set to the configure script make fullhtml  This target generates a documentation of the implementation.  This target generates a documentation from the latest public API (headers). This target generates the (cross)compilation and the link of the component. This target generates a tarball.. This target intalls the files generated during the build process. Generates the final files (Makefile, config.h, … )
  • 8. Adaptations needed  configure.ac :  Add the --enable-test support that exports HAVE_TEST to the Makefiles. Add the --enable-covering support for adding the gcov flags to the build process.  Makefile.am : Add the make check support to make the unit tests automatic Add the make covering support to make the lcov analysis automatic.
  • 9. Unit tests 1/5  Name : --enable-test  Mandatory : no  If this flags is not set, the unit test binaries are not built. Thus, the “make check” command doesn’t do anything at all.
  • 10. Unit tests 2/5 dnl -------------------------------------------- dnl Brief : enable or disable the unitary test dnl Mandatory : no dnl Values : none (just enable the tests if set) dnl Default's value : disable dnl -------------------------------------------- AC_ARG_ENABLE(test, AS_HELP_STRING([--enable-test], [Enable the test unitary support [default=no]]), [case "${enableval}" in yes) have_test=true ;; no) have_test=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-test) ;; esac], [have_test=false]) dnl -------------------------------------------- dnl Export the conditional HAVE_TEST variable to the Makefiles dnl -------------------------------------------- AM_CONDITIONAL(HAVE_TEST, $have_test) dnl -------------------------------------------- dnl Test the have_test variable and if equal to true dnl -------------------------------------------- AC_MSG_CHECKING(Checking the test support) if test "$have_test" != "false" ; then dnl -------------------------------------------- dnl Display the result of the test ... yes dnl -------------------------------------------- AC_MSG_RESULT([yes]) LIBGTEST_REQUIRED_VERSION=1.5.0 PKG_CHECK_MODULES([GTEST],[gtest >= $LIBGTEST_REQUIRED_VERSION],[have_libgtest=yes],[have_libgtest=no]) if test "$have_libgtest" = no ; then AC_MSG_ERROR([Missing libgtest library (http://code.google.com/p/googletest/) !!]) fi LIBGMOCK_REQUIRED_VERSION=1.5.0 PKG_CHECK_MODULES([GMOCK],[gmock >= $LIBGMOCK_REQUIRED_VERSION],[have_libgmock=yes],[have_libgmock=no]) if test "$have_libgmock" = no ; then AC_MSG_ERROR([Missing libgmock library !!]) fi else dnl -------------------------------------------- dnl Display the result of the test ... no dnl -------------------------------------------- AC_MSG_RESULT([no]) fi If you are not using the Google test/mock you can avoid this step. If you need to check both the gtest and gmock dependencies. configure.ac
  • 11. dnl -------------------------------------------- dnl Test if the libgtest is well available in the stagingdir dnl If so get the cflags and ldflag from the .pc file dnl -------------------------------------------- LIBGTEST_REQUIRED_VERSION=1.5.0 PKG_CHECK_MODULES([GTEST],[gtest >= $LIBGTEST_REQUIRED_VERSION],[have_libgtest=yes],[have_libgtest=no]) if test "$have_libgtest" = no ; then AC_MSG_ERROR([Missing libgtest library (http://code.google.com/p/googletest/) !!]) fi Unit tests 3/5 dnl -------------------------------------------- dnl Test if the libgmock is well available in the stagingdir dnl If so get the cflags and ldflag from the .pc file dnl -------------------------------------------- LIBGMOCK_REQUIRED_VERSION=1.5.0 PKG_CHECK_MODULES([GMOCK],[gmock >= $LIBGMOCK_REQUIRED_VERSION],[have_libgmock=yes],[have_libgmock=no]) if test "$have_libgmock" = no ; then AC_MSG_ERROR([Missing libgmock (http://code.google.com/p/googlemock/) library !!]) fi  Check the Google test library :  Check the Google mock library : configure.ac configure.ac
  • 12. Unit tests : direct call 4/5 # ---------------------------------------------------------------- # Unit Tests # ---------------------------------------------------------------- # Listing of the program to launch # Those programs should not be installed # ---------------------------------------------------------------- if HAVE_TEST TESTS = toe_gtest_assert noinst_PROGRAMS = $(TESTS) toe_gtest_assert_SOURCES = $(top_srcdir)/test/src/toe_gtest_assert.cpp toe_gtest_assert_CPPFLAGS = -I$(HEADER_DIR) $(GTEST_CFLAGS) $(LIBCONFIG_CFLAGS) $(LIBLOG_CFLAGS) -DLOG_NAME=TOE_ASSERT -DLOG_MASK_PRIO=255 toe_gtest_assert_LDFLAGS = $(top_builddir)/.libs/libtoe.a -lpthread -lrt toe_gtest_assert_LDADD = $(GTEST_LIBS) $(LIBCONFIG_LIBS) $(LIBLOG_LIBS) $(EFENCE_LIBS) else TESTS = endif Makefile.am  The Makefile will call the toe_gtest_assert binary directly. make check
  • 13. Unit tests : call over a script 5/5 # ---------------------------------------------------------------- # Unit Tests for par_si # ---------------------------------------------------------------- # - Listing of the program to launch # - Those programs should not be installed # ---------------------------------------------------------------- if HAVE_TEST check_SCRIPTS = unitary_test.sh TESTS = $(check_SCRIPTS) unitary_test.sh: @rm -f test/pasi_gtest @cp ./pasi_gtest test/pasi_gtest @echo "cd test" >> ./unitary_test.sh @echo "./pasi_gtest " >> ./unitary_test.sh @chmod +x ./unitary_test.sh noinst_PROGRAMS = pasi_gtest pasi_gtest_SOURCES = test/pasi_test.cpp test/pasi_handle.cpp test/pasi_atsc_handle.cpp test/pasi_mpeg_parsing.cpp test/pasi_dvb_parsing.cpp test/pasi_atsc_parsing.cpp test/pasi_string_converter.cpp pasi_gtest_CPPFLAGS = -I$(HEADER_DIR) -g -Wall -Wextra pasi_gtest_LDFLAGS = -lrt -lstdc++ pasi_gtest_LDADD = $(GTEST_LIBS) $(EFENCE_LIBS) else TESTS = endif  This Makefile first generates a shell script called unitary_test.sh, then the binary, then launch it. Makefile.am make check
  • 14. 14 Code covering 1/2 06/17/10  Name : --enable-covering  Mandatory flag : no  If this flag is set, the ELF objects will be compiled and linked with the following options: CFLAGS/CXXFLAGS : --fprofile-arcs -ftest-coverage. LDFLAGS : --fprofile-arcs  If this flag is not set, it won't add all the covering flags needed.  This creates an instrumented executable which contains additional instructions that record the number of times each line of the program is executed. The option -ftest-coverage adds instructions for counting the number of times individual lines are executed, while -fprofile-arcs incorporates instrumentation code for each branch of the program. Branch instrumentation records how frequently different paths are taken through ‘if’ statements and other conditionals. The executable must then be run to create the coverage data.  Integration in Hudson through the Cobertura plugin : http://meekrosoft.wordpress.com/2010/06/02/continuous-code-coverage-with-gcc-googletest-and- hudson/
  • 15. Code covering 2/2 dnl -------------------------------------------- dnl Brief : enable or disable the buildin covering mode dnl Mandatory : no dnl Values : none (just enable the covering mode if set) dnl -------------------------------------------- AC_ARG_ENABLE(covering, AS_HELP_STRING([--enable-covering], [Enable the building covering (gnu/gcov) support [default=no]]), [case "${enableval}" in yes) have_covering=true ;; no) have_covering=false ;; *) AC_MSG_ERROR(bad value ${enableval} for --enable-covering) ;; esac], [have_covering=false]) dnl -------------------------------------------- dnl Test the have_covering variable and if equal to true dnl -------------------------------------------- AC_MSG_CHECKING([Checking the covering support]) if test "$have_covering" = "true" ; then dnl -------------------------------------------- dnl Display the result of the test ... yes dnl -------------------------------------------- AC_MSG_RESULT([yes]) dnl -------------------------------------------- dnl Update the CFLAGS and CPPFLAGS with gcov options for gcc dnl -------------------------------------------- COVERING_CFLAGS=" -fprofile-arcs -ftest-coverage " COVERING_CPPFLAGS=" -fprofile-arcs -ftest-coverage " COVERING_LDFLAGS=" -fprofile-arcs " else dnl -------------------------------------------- dnl Display the result of the test ... no dnl -------------------------------------------- AC_MSG_RESULT([no]) fi configure.ac
  • 16. make covering : launch the kpi  Analyse the data generated by the unit tests compiled with the gcov support. It makes an html report in the output directory.  The lcov host tool (lcov and genhtml) must be available in the server.  Example of result available in the output directory: # ---------------------------------------------------------------- # Automatic LCOV analyzing # ---------------------------------------------------------------- covering: all check @echo -n "Removing the previous html generation : " @rm -fR ./output @echo "OK" @echo -n "Analyzing the covering : " @lcov -c -d . -b . -o toe.log @echo "OK" @echo -n "Generating the html report : " @genhtml -o output toe.log @echo "OK" @echo "--> You can now browse the html generated covering using the output/index.html file." @echo " firefox output/index.html & " @rm -f *.gcno *.gcda Makefile.am
  • 17. TIPS  The more the unitary tests (based on Google test/mock) will test functions, the more the KPI will give good data.  The main goal is to target 100% but because some tests can be difficult to check (exception, interraction with the system, … )  The tests should be runable on Hudson.  Actually each component provides the following data: o Number of lines (wc –l) o % of lines tested o % of functions tested o % of branches tested

Editor's Notes

  1. 1
  2. 2
  3. 3
  4. 4
  5. 14