Subversion Repositories DevTools

Rev

Rev 5883 | Rev 5885 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5883 Rev 5884
Line 1043... Line 1043...
1043
}
1043
}
1044
 
1044
 
1045
###############################################################################
1045
###############################################################################
1046
# Function        : ToolsetPreprocessTests
1046
# Function        : ToolsetPreprocessTests
1047
#
1047
#
1048
# Description     : 
1048
# Description     : Generate $(OBJDIR)/lcov-baseline.info 
-
 
1049
#                   Generate full coverage info
1049
#
1050
#
1050
# Inputs          : None
1051
# Inputs          : None
1051
#
1052
#
1052
# Returns         : Nothing
1053
# Returns         : Nothing
1053
#
1054
#
Line 1056... Line 1057...
1056
sub ToolsetPreprocessTests
1057
sub ToolsetPreprocessTests
1057
{
1058
{
1058
    my ($io) = ToolsetPrinter::New();
1059
    my ($io) = ToolsetPrinter::New();
1059
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1060
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1060
    {
1061
    {
-
 
1062
        #
-
 
1063
        #   Setup Env so that the files created by GCOV are within the package
-
 
1064
        #   being created. Elsewise they will be created all over the file 
-
 
1065
        #   system in the original location where the external objects were created.
-
 
1066
        #
-
 
1067
        $io->PrtLn('GCOV_PREFIX := $(abspath $(INTERFACEDIR)/gcov)' );
-
 
1068
        $io->PrtLn('GCOV_PREFIX_STRIP := 0' );
-
 
1069
        $io->PrtLn('export GCOV_PREFIX GCOV_PREFIX_STRIP' );
-
 
1070
        $io->Newline();
-
 
1071
 
-
 
1072
        #
-
 
1073
        #   GCOV_PKGBASE - used to 'extract' coverage artifacts
-
 
1074
        #   Used to limit the coverage report to files that are within this package
-
 
1075
        #   Ideally it should be the root of the package, but this is not always known
-
 
1076
        #   Use the first two path elements of the current package
-
 
1077
        #       Really just want to filter out compiler bits
-
 
1078
        #     
-
 
1079
 
-
 
1080
        $io->PrtLn('GCOV_PKGBASE :=  $(subst $(space),/,$(space)$(wordlist 1,2,$(subst /,$(space),$(CURDIR))))' );
-
 
1081
        $io->PrtLn('GCOV_VERBOSE :=  $(if $(VERBOSE_OPT),,--quiet)' );
-
 
1082
        $io->Newline();
-
 
1083
 
1061
        my $ruleName = 'preprocess_gcov_data';
1084
        my $ruleName = 'preprocess_gcov_data';
1062
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1085
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1063
        my $final=$finaldir . '/lcov-final.info';
1086
        my $final=$finaldir . '/lcov-final.info';
1064
        
1087
        
1065
        PlatformDefine( "GCOV_PREFIX:= $(abspath $(INTERFACEDIR)/gcov)" );
-
 
1066
        ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
-
 
1067
        ToolsetAddUnitTestPreProcess($ruleName);
1088
        ToolsetAddUnitTestPreProcess($ruleName);
1068
        $io->PrtLn('.PHONY: ' . $ruleName );
1089
        $io->PrtLn('.PHONY: ' . $ruleName );
1069
        $io->PrtLn($ruleName . ':' );
1090
        $io->PrtLn($ruleName . ':' );
1070
 
-
 
1071
        my $key;
-
 
1072
        my $value;
-
 
1073
        while(($key, $value) = each(%::OBJSOURCE))
1091
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ${GCOV_PREFIX}/$(CURDIR)/$(OBJDIR)/*.gcda' );
1074
        {
-
 
1075
            $io->PrtLn("\t" . '$(XX_PRE)rm -f $(OBJDIR)/' . $key . ".gcda");
1092
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f $(OBJDIR)/*.gcda' );
1076
        }
-
 
1077
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ' . $final);
1093
        $io->PrtLn("\t" . '${XX_PRE}$(rm) -f ' . $final);
1078
        $io->PrtLn("\t" . 'echo PREPROCESSING: $$PWD');
-
 
1079
        $io->PrtLn("\t" . '${XX_PRE}lcov'
1094
        $io->PrtLn("\t" . '${XX_PRE}lcov'
1080
                        . $LcovExplicitBranch
1095
                        . ' $(GCOV_VERBOSE)'
1081
                        . ' --capture'
1096
                        . ' --capture'
1082
                        . ' --initial'
1097
                        . ' --initial'
1083
                        . ' --base-directory ' . $::Cwd
1098
                        . ' --base-directory $(CURDIR)'
1084
                        . ' --directory $(OBJDIR)'
1099
                        . ' --directory $(OBJDIR)'
1085
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
1100
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
1086
                        . ' --output-file $(OBJDIR)/lcov-baseline-raw.info' );
-
 
1087
        $io->PrtLn("\t" . '${XX_PRE}lcov'
-
 
1088
                        . $LcovExplicitBranch
-
 
1089
                        . ' --extract $(OBJDIR)/lcov-baseline-raw.info "$(GBE_ROOT_ABS)/*"'
-
 
1090
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1091
                        . ' --output-file $(OBJDIR)/lcov-baseline-raw1.info' );
-
 
1092
        $io->PrtLn("\t" . '${XX_PRE}lcov'
-
 
1093
                        . $LcovExplicitBranch
-
 
1094
                        . ' --remove $(OBJDIR)/lcov-baseline-raw1.info "$(abspath $(INTERFACEDIR))/*"'
-
 
1095
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1096
                        . ' --output-file $(OBJDIR)/lcov-baseline.info' );
1101
                       . ' --output-file $(OBJDIR)/lcov-baseline.info' );
1097
 
-
 
1098
        $io->PrtLn("\t" . 'echo PREPROCESSING DONE');
-
 
1099
        $io->Newline();
1102
        $io->Newline();
1100
        ToolsetGenerate ('$(OBJDIR)/lcov-baseline-raw.info');
-
 
1101
        ToolsetGenerate ('$(OBJDIR)/lcov-baseline-raw1.info' );
1103
        ToolsetGenerate( '$(OBJDIR)/lcov-baseline.info' );
1102
    }
1104
    }
1103
}
1105
}
1104
 
1106
 
1105
 
1107
 
1106
###############################################################################
1108
###############################################################################
1107
# Function        : ToolsetPostprocessTests
1109
# Function        : ToolsetPostprocessTests
1108
#
1110
#
-
 
1111
# Description     : Merge this sub-components bits into the the final coverage
-
 
1112
#                   file in lcov-baseline.info
1109
# Description     : 
1113
#                   
-
 
1114
#                   Need to locate the .gcda files and place them in the same directory
-
 
1115
#                   as the .gcno files that were created during preprocssing
-
 
1116
#                   
-
 
1117
#                   Then we can add our trace bits into the file coverage file
1110
#
1118
#
1111
# Inputs          : None
1119
# Inputs          : None
1112
#
1120
#
1113
# Returns         : Nothing
1121
# Returns         : Nothing
1114
#
1122
#
Line 1121... Line 1129...
1121
    {
1129
    {
1122
        my $ruleName = 'postprocess_gcov_data';
1130
        my $ruleName = 'postprocess_gcov_data';
1123
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1131
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1124
        my $final=$finaldir . '/lcov-final.info';
1132
        my $final=$finaldir . '/lcov-final.info';
1125
        
1133
        
1126
        ToolsetGenerate( '$(OBJDIR)/lcov-capture.info' );
-
 
1127
        ToolsetGenerate( $final );
-
 
1128
        ToolsetAddUnitTestPostProcess($ruleName);
1134
        ToolsetAddUnitTestPostProcess($ruleName);
1129
 
1135
 
1130
        $io->PrtLn('.PHONY: ' . $ruleName );
1136
        $io->PrtLn('.PHONY: ' . $ruleName );
1131
        $io->PrtLn($ruleName . ':' );
1137
        $io->PrtLn($ruleName . ':' );
1132
        $io->PrtLn("\t" . '$(eval GCDA_COUNT := $(shell find $(OBJDIR) -name "*.gcda"))');
1138
        $io->PrtPart("\t" . '$(XX_PRE)if [ -d "${GCOV_PREFIX}/$(CURDIR)/$(OBJDIR)" ]; then' ); 
-
 
1139
        $io->PrtPart("\t\t" . 'cd ${GCOV_PREFIX}/$(CURDIR);');
-
 
1140
        $io->PrtPart("\t\t" . 'find $(OBJDIR) -name \'*.gcda\' -exec cp --parent {} $(CURDIR) \\; ;');
-
 
1141
#        $io->PrtPart("\t" . 'else');
-
 
1142
#        $io->PrtPart("\t\t" . 'echo NO .gcda DATA for $(CURDIR);');
1133
        
1143
        $io->PrtLn  ("\t" . 'fi' );
1134
        $io->PrtLn  ("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir);
1144
        $io->PrtLn  ("\t" . '$(XX_PRE)$(mkdir) -p ' . $finaldir);
-
 
1145
        $io->PrtPart("\t" . '$(XX_PRE)GCDA_COUNT=$$(find $(OBJDIR) -name "*.gcda" | wc -l);' ); 
1135
        $io->PrtPart("\t" . '$(XX_PRE)if [ "$(GCDA_COUNT)" = "" ]; then');
1146
        $io->PrtPart("\t" . 'if [ "$${GCDA_COUNT}" -eq "0" ]; then ');
1136
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1147
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1137
        $io->PrtPart("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . ';');
1148
        $io->PrtPart("\t\t\t" . '$(cp) $(OBJDIR)/lcov-baseline.info ' . $final . ';');
1138
        $io->PrtPart("\t\t" . 'else');
1149
        $io->PrtPart("\t\t" . 'else');
1139
        $io->PrtPart("\t\t\t" . 'lcov'
1150
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1151
                          . ' $(GCOV_VERBOSE)'
1140
                          . $LcovExplicitBranch
1152
                          . $LcovExplicitBranch
1141
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1153
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1142
                          . ' --add-tracefile ' . $final
1154
                          . ' --add-tracefile ' . $final
1143
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1155
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1144
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1156
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
Line 1146... Line 1158...
1146
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1158
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1147
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1159
        $io->PrtPart("\t\t\t" . '$(mv) $(OBJDIR)/lcov-merge.info ' . $final . ';');
1148
        $io->PrtPart("\t\t" . 'fi' . ';');
1160
        $io->PrtPart("\t\t" . 'fi' . ';');
1149
        $io->PrtPart("\t" . 'else');
1161
        $io->PrtPart("\t" . 'else');
1150
        $io->PrtPart("\t\t" . 'lcov'
1162
        $io->PrtPart("\t\t" . 'lcov'
-
 
1163
                        . ' $(GCOV_VERBOSE)'
1151
                          . $LcovExplicitBranch
1164
                        . $LcovExplicitBranch
1152
                        . ' --capture'
1165
                        . ' --capture'
1153
                        . ' --base-directory ' . $::Cwd
1166
                        . ' --base-directory $(CURDIR)'
1154
                        . ' --directory $(OBJDIR)'
1167
                        . ' --directory $(OBJDIR)'
1155
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
1168
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
1156
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
1169
                        . ' --output-file $(OBJDIR)/lcov-capture.info' 
1157
                        . ';'); 
1170
                        . ';'); 
1158
        $io->PrtPart("\t\t" . 'lcov'
-
 
1159
                          . $LcovExplicitBranch
-
 
1160
                        . ' --extract $(OBJDIR)/lcov-capture.info "$(GBE_ROOT_ABS)/*"'
-
 
1161
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1162
                        . ' --output-file $(OBJDIR)/lcov-capture-filtered0.info' 
-
 
1163
                        . ';'); 
-
 
1164
        $io->PrtPart("\t\t" . 'lcov'
-
 
1165
                          . $LcovExplicitBranch
-
 
1166
                        . ' --remove $(OBJDIR)/lcov-capture-filtered0.info "$(abspath $(INTERFACEDIR))/*"'
-
 
1167
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1168
                        . ' --output-file $(OBJDIR)/lcov-capture-filtered.info' 
-
 
1169
                        . ';'); 
-
 
1170
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1171
        $io->PrtPart("\t\t" . 'if [ ! -e ' . $final . " ]; then");
1171
        $io->PrtPart("\t\t\t" . 'lcov'
1172
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1173
                          . ' $(GCOV_VERBOSE)'
1172
                          . $LcovExplicitBranch
1174
                          . $LcovExplicitBranch
1173
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1175
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1174
                          . ' --add-tracefile $(OBJDIR)/lcov-capture-filtered.info'
1176
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1175
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1177
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1176
                          . ' --output-file ' .  $final
1178
                          . ' --output-file ' .  $final
1177
                          . ';'); 
1179
                          . ';'); 
1178
        $io->PrtPart("\t\t" . 'else');
1180
        $io->PrtPart("\t\t" . 'else');
1179
        $io->PrtPart("\t\t\t" . 'lcov'
1181
        $io->PrtPart("\t\t\t" . 'lcov'
-
 
1182
                          . ' $(GCOV_VERBOSE)'
1180
                          . $LcovExplicitBranch
1183
                          . $LcovExplicitBranch
1181
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1184
                          . ' --add-tracefile $(OBJDIR)/lcov-baseline.info'
1182
                          . ' --add-tracefile $(OBJDIR)/lcov-capture-filtered.info'
1185
                          . ' --add-tracefile $(OBJDIR)/lcov-capture.info'
1183
                          . ' --add-tracefile ' . $final
1186
                          . ' --add-tracefile ' . $final
1184
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1187
                          . ' --gcov-tool $(GCC_GCOVTOOL)' 
1185
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1188
                          . ' --output-file $(OBJDIR)/lcov-merge.info'
1186
                          . ';'); 
1189
                          . ';'); 
1187
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
1190
        $io->PrtPart("\t\t\t" . '$(rm) -f ' . $final . ';');
Line 1189... Line 1192...
1189
        $io->PrtPart("\t\t" . 'fi' . ';');
1192
        $io->PrtPart("\t\t" . 'fi' . ';');
1190
        $io->PrtLn  ("\t" . 'fi');
1193
        $io->PrtLn  ("\t" . 'fi');
1191
        $io->Newline();
1194
        $io->Newline();
1192
 
1195
 
1193
        ToolsetGenerate ('$(OBJDIR)/lcov-capture.info' );
1196
        ToolsetGenerate ('$(OBJDIR)/lcov-capture.info' );
1194
        ToolsetGenerate ('$(OBJDIR)/lcov-capture-filtered0.info' );
-
 
1195
        ToolsetGenerate ('$(OBJDIR)/lcov-capture-filtered.info' );
-
 
1196
        ToolsetGenerate ($final);
1197
        ToolsetGenerate ($final);
1197
 
1198
 
1198
    }
1199
    }
1199
}
1200
}
1200
 
1201
 
1201
 
1202
 
1202
###############################################################################
1203
###############################################################################
1203
# Function        : ToolsetCollateTestResults
1204
# Function        : ToolsetCollateTestResults
1204
#
1205
#
1205
# Description     : 
1206
# Description     : Process the lcov-final.info by
-
 
1207
#                       Extract parts generated by files in this package
-
 
1208
#                       Remove parts generated by files in the interface directory
-
 
1209
#                           They are the results of a 'BuildPkgArchive'
1206
#
1210
#
1207
# Inputs          : None
1211
# Inputs          : None
1208
#
1212
#
1209
# Returns         : Nothing
1213
# Returns         : Nothing
1210
#
1214
#
Line 1215... Line 1219...
1215
{
1219
{
1216
    my ($io) = ToolsetPrinter::New();
1220
    my ($io) = ToolsetPrinter::New();
1217
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1221
    if ( $UseGcov && scalar(keys %::OBJSOURCE) > 0 )
1218
    {
1222
    {
1219
        my $ruleName = 'collate_gcov_results';
1223
        my $ruleName = 'collate_gcov_results';
1220
        my $finaldir='$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1224
        my $finaldir = '$(LOCALDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1221
        my $final=$finaldir . '/lcov-final.info';
1225
        my $final     = $finaldir . '/lcov-final.info';
-
 
1226
        my $finalTmp  = $finaldir . '/lcov-final.tmp.info';
-
 
1227
        my $finalTmp1 = $finaldir . '/lcov-$(GBE_PBASE)_$(BUILDVER).info';
-
 
1228
 
-
 
1229
        ToolsetGenerate ( $final );
-
 
1230
        ToolsetGenerate ( $finalTmp );
-
 
1231
        ToolsetGenerate ( $finalTmp1 );
1222
 
1232
 
1223
        ToolsetAddUnitTestCollateProcess($ruleName);
1233
        ToolsetAddUnitTestCollateProcess($ruleName);
1224
        
1234
        
1225
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1235
        my $reportdir='$(PKGDIR)/lcov/$(GBE_PLATFORM)$(GBE_TYPE)';
1226
        my $reportindex=$reportdir . '/index.html';
1236
        my $reportindex=$reportdir . '/index.html';
1227
        
-
 
1228
        $io->PrtLn('.PHONY: ' . $ruleName );
1237
        $io->PrtLn('.PHONY: ' . $ruleName );
1229
        $io->PrtLn($ruleName . ': ' . $reportindex);
1238
        $io->PrtLn($ruleName . ': ' . $reportindex);
-
 
1239
 
1230
        $io->Newline();
1240
        $io->Newline();
1231
        $io->PrtLn($reportindex . ': ' . $final);
1241
        $io->PrtLn($reportindex . ': ' . $final);
-
 
1242
        $io->PrtPart("\t" . 'lcov'
-
 
1243
                        . ' $(GCOV_VERBOSE)'
-
 
1244
                        . $LcovExplicitBranch
-
 
1245
                        . ' --extract '. $final .' "$(GCOV_PKGBASE)/*"'
-
 
1246
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1247
                        . ' --output-file ' . $finalTmp
-
 
1248
                        . ';'); 
-
 
1249
        $io->PrtPart("\t" . 'lcov'
-
 
1250
                        . ' $(GCOV_VERBOSE)'
-
 
1251
                        . $LcovExplicitBranch
-
 
1252
                        . ' --remove '. $finalTmp .' "$(abspath $(INTERFACEDIR))/*"'
-
 
1253
                        . ' --gcov-tool $(GCC_GCOVTOOL)' 
-
 
1254
                        . ' --output-file ' .$finalTmp1
-
 
1255
                        . ';'); 
1232
        $io->PrtLn("\t" . 'genhtml'
1256
        $io->PrtLn("\t" . 'genhtml'
-
 
1257
                      . ' $(GCOV_VERBOSE)'
1233
                      . ' --frames'
1258
                      . ' --frames'
1234
                      . ' --show-details'
1259
                      . ' --show-details'
1235
                      . ' --function-coverage'
1260
                      . ' --function-coverage'
1236
                      . ' --branch-coverage'
1261
                      . ' --branch-coverage'
1237
                      . ' --output-directory ' . $reportdir
1262
                      . ' --output-directory ' . $reportdir
1238
                      . ' --legend'
1263
                      . ' --legend'
1239
                      . ' --demangle-cpp'
1264
                      . ' --demangle-cpp'
1240
                      . ' ' . $final);
1265
                      . ' ' . $finalTmp1);
1241
        $io->Newline();
1266
        $io->Newline();
1242
    }
1267
    }
1243
}
1268
}
1244
 
1269
 
1245
 
1270