merge the formfield patch from ooo-build
[ooovba.git] / sal / qa / helper / gcov / gcov_resultcompare.pl
blobbb0f86c0a03246023eab01ff673ebd25ef98ea29
1 #!/usr/bin/perl -w
2 #
3 # $Id: gcov_resultcompare.pl,v 1.2 2004-03-19 14:46:51 obo Exp $
6 # GCOV_RESULTCOMPARE
7 #
8 # Helper, to compare two different results
10 # Q: Why perl?
11 # A: regexp ;-)
14 use strict;
15 use File::Basename;
16 use Getopt::Long;
18 our $version_info = 'gcov_resultcompare $Revision: 1.2 $ ';
20 our $help; # Help option flag
21 our $version; # Version option flag
22 # our $infile;
24 our $orig;
25 our $compare;
27 # Prototypes
28 sub print_usage(*);
29 sub read_gcov_function_file($);
31 # Parse command line options
32 if (!GetOptions(
33 "o=s" => \$orig,
34 "c=s" => \$compare,
35 "help" => \$help,
36 "version" => \$version
39 print_usage(*STDERR);
40 exit(1);
43 # Check for help option
44 if ($help)
46 print_usage(*STDOUT);
47 exit(0);
50 # Check for version option
51 if ($version)
53 print("$version_info\n");
54 exit(0);
57 # check if enough parameters
58 # if ($#ARGV < 1)
59 # {
60 # print("No input filenames specified\n");
61 # print_usage(*STDERR);
62 # exit(1);
63 # }
65 if (! $orig)
67 print_usage(*STDOUT);
68 exit(0);
70 if (! $compare)
72 print_usage(*STDOUT);
73 exit(0);
76 # ------------------------------------------------------------------------------
78 my %origlist = read_gcov_function_file($orig);
79 my %cmplist = read_gcov_function_file($compare);
81 my $key;
82 my $value;
84 while (($key, $value) = each %origlist)
86 my $cmpvalue = $cmplist{$key};
88 if ($cmpvalue != 0.00)
90 if ($value < 100.00)
92 if ($cmpvalue > $value && $value < 90.0)
94 print "$key, $value, CMP:$cmpvalue\n";
100 # --------------------------------------------------------------------------------
101 # Read the gcov function (gcov -f) file
102 # and compare line by line with the export function list
103 # so we get a list of functions, which are only exported, and not all stuff.
105 sub read_gcov_function_file($)
107 local *INPUT_HANDLE;
108 my $file = shift;
109 my %list;
110 my $line = "";
112 open(INPUT_HANDLE, $file)
113 or die("ERROR: cannot open $file!\n");
115 while ($line = <INPUT_HANDLE>)
117 chomp($line);
118 # sample line (for reg exp:)
119 # 100.00 rtl_ustr_toDouble
120 if ($line =~ /^(.{6}) (\w+)$/ )
122 my $percent = $1;
123 my $value = $2;
125 $list{$value} = $percent;
128 close(INPUT_HANDLE);
129 return %list;
132 # ----------------------------------------------------------------------------
133 sub print_usage(*)
135 local *HANDLE = $_[0];
136 my $tool_name = basename($0);
138 print(HANDLE <<END_OF_USAGE);
140 Usage: $tool_name [OPTIONS] INPUTFILE
142 -o Original File, which gives the main values
143 if here a value is smaller than in compare, the found value is a candidate for better check.
144 -c Compare file.
146 -h, --help Print this help, then exit
147 -v, --version Print version number, then exit
149 END_OF_USAGE