HowTo: Using gcov (the GNU coverage tool) with LMDZ : Différence entre versions

De LMDZPedia
Aller à : navigation, rechercher
Ligne 26 : Ligne 26 :
 
  gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/
 
  gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/
 
                                           ^
 
                                           ^
                                           this is where the gcda and gcno files are saved by the compiler. They're created where the source files were actually compiled             
+
                                           this is where the gcda and gcno files are saved by the compiler. They're created where the source files were actually compiled.
 +
              
 
to create html files with the prefix <code>gcm_details</code>  and the name of the routine included in the file. Each file in your code will have a corresponding html file giving the usage for each line of the routine included in that file.
 
to create html files with the prefix <code>gcm_details</code>  and the name of the routine included in the file. Each file in your code will have a corresponding html file giving the usage for each line of the routine included in that file.
  
 
+
You'll find [[https://web.lmd.jussieu.fr/~fairhead/Labo/LMDZ_Coverage/sequential/example-html-details.html here]] an example of the output for the actual LMDZ code.
  
  
 
[[Category:HowTo]]
 
[[Category:HowTo]]

Version du 29 avril 2022 à 13:56


If you want a summary of the lines (and branches) in your code that are actually executed, you can use the GNU [coverage tool]. This entails the following three steps:

  1. compiling your code with the right options
  2. running the code to output the statistics that gcov will analyze
  3. running gcov on the data files created in the previous step to analyze the code coverage

Running gcov on LMDZ

We will be using [gcovr] a utility using gcov and providing different types of outputs

Compiling LMDZ

You will need to add the following flags to your compilation flags in the arch.fcm.file:

 %BASE_FFLAGS          -cpp -ffree-line-length-0 -fdefault-real-8 -DNC_DOUBLE -pg --coverage -fprofile-arcs -ftest-coverage -fprofile-abs-path

Running LMDZ

You just run gcm.e as you usually do. This will create a bunch of gcda and gcno files that are used by gcov in the following step

Running gcovr

You then launch the gcovr command as

gcovr -r . -v --html-details gcm_details libo/local_32x32x39_phylmd_seq.e/.config/tmp/
                                         ^
                                         this is where the gcda and gcno files are saved by the compiler. They're created where the source files were actually compiled.
           

to create html files with the prefix gcm_details and the name of the routine included in the file. Each file in your code will have a corresponding html file giving the usage for each line of the routine included in that file.

You'll find [here] an example of the output for the actual LMDZ code.