From 4ab232da4441162e512f85a122b26364496f4801 Mon Sep 17 00:00:00 2001 From: Ray Speth Date: Wed, 18 Jan 2012 23:44:57 +0000 Subject: [PATCH] Allow optional collection of code coverage information with gcc --- .gitignore | 2 ++ SConstruct | 15 +++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/.gitignore b/.gitignore index 4710e6173..0dc5fd950 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,5 @@ config.log .pydevproject .settings Cantera/matlab/build_cantera.m +*.gcda +*.gcno diff --git a/SConstruct b/SConstruct index 3ddf8d4c4..df5e9b022 100644 --- a/SConstruct +++ b/SConstruct @@ -222,6 +222,11 @@ opts.AddVariables( 'debug', """Enable extra printing code to aid in debugging.""", False), + BoolVariable( + 'coverage', + """Enable collection of code coverage information with gcov. + Available only when compiling with gcc.""", + False), BoolVariable( 'with_lattice_solid', """Include thermodynamic model for lattice solids in the @@ -709,6 +714,16 @@ else: env['CCFLAGS'] = listify(env['cc_flags']) + listify(env['debug_flags']) env['LINKFLAGS'] += listify(defaults.debugLinkFlags) +if env['coverage']: + if env['CC'] == 'gcc': + env.Append(CCFLAGS=['-fprofile-arcs', '-ftest-coverage']) + env.Append(LINKFLAGS=['-fprofile-arcs', '-ftest-coverage']) +# ipdb() + + else: + print 'Error: coverage testing is only available with GCC' + exit(0) + # ************************************** # *** Set options needed in config.h *** # **************************************