@@ -575,7 +575,10 @@ if (0 == $exit_code) {
575575 $exit_code = 1;
576576 }
577577}
578+ # $trace_data may be undef if no non-empty GCDA files found and the
579+ # 'empty' warning is ignored
578580if (0 == $exit_code &&
581+ defined ($trace_data ) &&
579582 $single_file ) {
580583
581584 $trace_data -> checkCoverageCriteria();
@@ -595,7 +598,8 @@ lcovutil::save_profile(
595598# exit with non-zero status if --keep-going and some errors detected
596599$exit_code = 1
597600 if (0 == $exit_code &&
598- lcovutil::saw_error());
601+ (!(defined ($trace_data ) && $single_file ) ||
602+ lcovutil::saw_error()));
599603exit ($exit_code );
600604
601605#
@@ -2783,6 +2787,7 @@ sub process_intermediate($$$$)
27832787 my ($fdir , $fbase , $fext );
27842788 my $data_file ;
27852789 my $errmsg ;
2790+ my $errorType = $lcovutil::ERROR_GCOV ;
27862791 my %data ;
27872792 my $fd ;
27882793 my $base ;
@@ -2802,34 +2807,38 @@ sub process_intermediate($$$$)
28022807 $data_file =
28032808 File::Spec-> catfile($tempdir , " $fbase$graph_file_extension " );
28042809 if (!copy($file , $data_file )) {
2805- $errmsg = " ERROR: Could not copy file $file : $! " ;
2810+ $errmsg = " ERROR: Could not copy file $file : $! " ;
2811+ $errorType = $lcovutil::ERROR_PATH ;
28062812 goto err;
28072813 }
28082814 } else {
2815+ $gcno_file = solve_relative_path($cwd , $gcno_file );
2816+ foreach my $f ($file , $gcno_file ) {
2817+ my $p = -l $f ? Cwd::abs_path($f ) : $f ;
2818+ if (!-r $p ) {
2819+ $errmsg = " $f does not exist/is not readable" ;
2820+ $errorType = $lcovutil::ERROR_PATH ;
2821+ goto err;
2822+ }
2823+ }
28092824 # if .gcda and .gcno files are in the same directory, then simply
28102825 # process in place - otherwise, link the .gcda and .gcno files
28112826 # into tempdir and run from here
2812- if (dirname($filename ) eq dirname($gcno_file )) {
2827+ if (dirname($file ) eq dirname($gcno_file )) {
28132828 # Process data file in place
28142829 $data_file = $file ;
28152830 } else {
28162831 $data_file = basename($file );
2817- my $gcda = File::Spec-> catfile($tempdir , $data_file );
2818- debug(" create links to process $filename in $tempdir \n " );
2819- symlink ($file , $gcda );
2820- # unclear why symlink returns an error code when it actually
2821- # created the link
2822- if ($? && !-l $gcda ) {
2823- $errmsg = " unable to create link $data_file : $! " ;
2824- goto err;
2825- }
2826- # and the gcno file
2827- my $g = solve_relative_path($cwd , $gcno_file );
2828- my $gcno = File::Spec-> catfile($tempdir , basename($gcno_file ));
2829- symlink ($g , $gcno );
2830- if ($? && !-l $gcda ) {
2831- $errmsg = " unable to create link $gcno : $! " ;
2832- goto err;
2832+ foreach my $f ($file , $gcno_file ) {
2833+ my $l = File::Spec-> catfile($tempdir , basename($f ));
2834+ debug(" create links to process $f in $tempdir \n " );
2835+ symlink ($f , $l );
2836+ # unclear why symlink returns an error code when it actually
2837+ # created the link
2838+ if ($? && !-l $l ) {
2839+ $errmsg = " unable to create link for $f : $! " ;
2840+ goto err;
2841+ }
28332842 }
28342843 }
28352844 }
@@ -2863,8 +2872,6 @@ sub process_intermediate($$$$)
28632872 if (check_gcov_fail($err , $file )) {
28642873 return ;
28652874 }
2866- }
2867- if ($rc ) {
28682875 $errmsg = " GCOV failed for $file " ;
28692876 goto err;
28702877 }
@@ -2940,7 +2947,7 @@ sub process_intermediate($$$$)
29402947 return $trace ;
29412948
29422949 err:
2943- ignorable_error($ERROR_GCOV , " $errmsg !" );
2950+ ignorable_error($errorType , " $errmsg !" );
29442951 return undef ;
29452952}
29462953
0 commit comments