bump product version to 5.0.4.1
[LibreOffice.git] / sal / qa / helper / gcov / gcov_resultcompare.pl
blob38855d2586a65fa2ec3fa5411ac52cebbf37a95d
1 #!/usr/bin/perl -w
4 # This file is part of the LibreOffice project.
6 # This Source Code Form is subject to the terms of the Mozilla Public
7 # License, v. 2.0. If a copy of the MPL was not distributed with this
8 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 # This file incorporates work covered by the following license notice:
12 # Licensed to the Apache Software Foundation (ASF) under one or more
13 # contributor license agreements. See the NOTICE file distributed
14 # with this work for additional information regarding copyright
15 # ownership. The ASF licenses this file to you under the Apache
16 # License, Version 2.0 (the "License"); you may not use this file
17 # except in compliance with the License. You may obtain a copy of
18 # the License at http://www.apache.org/licenses/LICENSE-2.0 .
21 # GCOV_RESULTCOMPARE
23 # Helper, to compare two different results
25 # Q: Why perl?
26 # A: regexp ;-)
29 use strict;
30 use File::Basename;
31 use Getopt::Long;
33 our $version_info = 'gcov_resultcompare: 1.2 ';
35 our $help; # Help option flag
36 our $version; # Version option flag
37 # our $infile;
39 our $orig;
40 our $compare;
42 # Prototypes
43 sub print_usage(*);
44 sub read_gcov_function_file($);
46 # Parse command line options
47 if (!GetOptions(
48 "o=s" => \$orig,
49 "c=s" => \$compare,
50 "help" => \$help,
51 "version" => \$version
54 print_usage(*STDERR);
55 exit(1);
58 # Check for help option
59 if ($help)
61 print_usage(*STDOUT);
62 exit(0);
65 # Check for version option
66 if ($version)
68 print("$version_info\n");
69 exit(0);
72 # check if enough parameters
73 # if ($#ARGV < 1)
74 # {
75 # print("No input filenames specified\n");
76 # print_usage(*STDERR);
77 # exit(1);
78 # }
80 if (! $orig)
82 print_usage(*STDOUT);
83 exit(0);
85 if (! $compare)
87 print_usage(*STDOUT);
88 exit(0);
91 # ------------------------------------------------------------------------------
93 my %origlist = read_gcov_function_file($orig);
94 my %cmplist = read_gcov_function_file($compare);
96 my $key;
97 my $value;
99 while (($key, $value) = each %origlist)
101 my $cmpvalue = $cmplist{$key};
103 if ($cmpvalue != 0.00)
105 if ($value < 100.00)
107 if ($cmpvalue > $value && $value < 90.0)
109 print "$key, $value, CMP:$cmpvalue\n";
115 # --------------------------------------------------------------------------------
116 # Read the gcov function (gcov -f) file
117 # and compare line by line with the export function list
118 # so we get a list of functions, which are only exported, and not all stuff.
120 sub read_gcov_function_file($)
122 local *INPUT_HANDLE;
123 my $file = shift;
124 my %list;
125 my $line = "";
127 open(INPUT_HANDLE, $file)
128 or die("ERROR: cannot open $file!\n");
130 while ($line = <INPUT_HANDLE>)
132 chomp($line);
133 # sample line (for reg exp:)
134 # 100.00 rtl_ustr_toDouble
135 if ($line =~ /^(.{6}) (\w+)$/ )
137 my $percent = $1;
138 my $value = $2;
140 $list{$value} = $percent;
143 close(INPUT_HANDLE);
144 return %list;
147 # ----------------------------------------------------------------------------
148 sub print_usage(*)
150 local *HANDLE = $_[0];
151 my $tool_name = basename($0);
153 print(HANDLE <<END_OF_USAGE);
155 Usage: $tool_name [OPTIONS] INPUTFILE
157 -o Original File, which gives the main values
158 if here a value is smaller than in compare, the found value is a candidate for better check.
159 -c Compare file.
161 -h, --help Print this help, then exit
162 -v, --version Print version number, then exit
164 END_OF_USAGE