merge the formfield patch from ooo-build
[ooovba.git] / sal / qa / helper / gcov / gcov_result.pl
blob1731a965e6eee616490ab6ad08f47bef46a4f98d
1 #!/usr/bin/perl -w
2 #
3 # $Id: gcov_result.pl,v 1.2 2003-06-11 16:36:30 vg Exp $
6 # GCOV_RESULT
7 #
8 # Helper, to interpret the result and put the result via html in a database.
9 # Put into DB works via php.
11 # Q: Why perl?
12 # A: regexp ;-)
15 use strict;
16 use File::Basename;
17 use Getopt::Long;
18 use Time::localtime;
20 our $version_info = 'gcov helper $Revision: 1.2 $ ';
22 our $help; # Help option flag
23 our $version; # Version option flag
24 # our $infile;
26 our $usedFunctions; # name of all functions filename, which have a value > 0
27 our $nonusedFunctions; # name of all functions filename, which have a value == 0
28 our $complete; # name of all functions filename, which have a value == 100
29 our $incomplete; # name of all functions filename, which have a value > 0 && < 100
31 our $environment;
32 our $major;
33 our $minor;
34 our $cwsname;
35 our $outputDir;
37 # Prototypes
38 sub print_usage(*);
39 sub read_gcov_function_file($);
40 sub create2DigitNumber($);
42 # Parse command line options
43 if (!GetOptions(
44 "help" => \$help,
45 "version" => \$version,
47 "usedfunctions=s" => \$usedFunctions,
48 "nonusedfunctions=s" => \$nonusedFunctions,
49 "complete=s" => \$complete,
50 "incomplete=s" => \$incomplete,
51 "cwsname=s" => \$cwsname,
52 "major=s" => \$major,
53 "minor=s" => \$minor,
54 "environment=s" => \$environment,
55 "outputdir=s" => \$outputDir
58 print_usage(*STDERR);
59 exit(1);
62 # Check for help option
63 if ($help)
65 print_usage(*STDOUT);
66 exit(0);
69 # Check for version option
70 if ($version)
72 print("$version_info\n");
73 exit(0);
76 # check if enough parameters
77 # if ($#ARGV < 0)
78 # {
79 # print("No input filename specified\n");
80 # print_usage(*STDERR);
81 # exit(1);
82 # }
84 # ------------------------------------------------------------------------------
86 my $sURL = "http://mahler.germany.sun.com/qadev/baselib/gcov_result_in_db_putter.php";
88 my $next = "?";
90 if ($complete)
92 my $result = `cat $complete | wc -l`;
93 chomp($result);
94 $result =~ / *(\d+)/;
95 $sURL = $sURL . "$next" . "complete=$1";
96 $next = "&";
99 if ($nonusedFunctions)
101 my $result = `cat $nonusedFunctions | wc -l`;
102 chomp($result);
103 $result =~ / *(\d+)/;
104 $sURL = $sURL . "$next" . "notused=$1";
105 $next = "&";
107 if ($usedFunctions)
109 my $result = `cat $usedFunctions | wc -l`;
110 chomp($result);
111 $result =~ / *(\d+)/;
112 $sURL = $sURL . "$next" . "used=$1";
113 $next = "&";
115 if ($incomplete)
117 my $result = `cat $incomplete | wc -l`;
118 chomp($result);
119 $result =~ / *(\d+)/;
120 $sURL = $sURL . "$next" . "incomplete=$1";
121 $next = "&";
124 if ($cwsname)
126 # qadev8
127 $sURL = $sURL . "$next" . "cwsname=$cwsname";
128 $next = "&";
130 if ($major)
132 # srx645
133 $sURL = $sURL . "$next" . "major=$major";
134 $next = "&";
136 if ($minor)
138 # m3s1
139 $sURL = $sURL . "$next" . "minor=$minor";
140 $next = "&";
143 if ($environment)
145 # unxlngi5
146 $sURL = $sURL . "$next" . "environment=$environment";
147 $next = "&";
150 my $year = localtime->year() + 1900;
151 my $month = create2DigitNumber(localtime->mon() + 1);
152 my $day = create2DigitNumber(localtime->mday());
153 $sURL = $sURL . "$next" . "date=$year-$month-$day";
154 $next = "&";
156 my $output;
157 if ($outputDir)
159 chomp($outputDir);
160 $output = $outputDir;
163 # check if output ends with "/"
164 if ( $output =~ /\/$/ )
166 print "Output name ends with '/'\n";
168 else
170 print "Output name does not end with '/'\n";
171 $output = $output . "/";
173 $output = $output . "php_result.txt";
175 my $result = `wget -O $output "$sURL"`;
176 print "$sURL\n";
178 print `cat $output`;
181 # ----------------------------------------------------------------------------
182 sub print_usage(*)
184 local *HANDLE = $_[0];
185 my $tool_name = basename($0);
187 print(HANDLE <<END_OF_USAGE);
189 Usage: $tool_name [OPTIONS]
191 -u, --usedfunctions count of all functions, which have a value > 0
192 -n, --nonusedfunctions count of all functions, which have a value == 0
193 -co, --complete count of all functions, which have a value == 100
194 -i, --incomplete count of all functions, which have a value > 0 && < 100
196 -cw, --cwsname set cwsname
197 -ma, --major set major number
198 -mi, --minor set minor number
199 -e, --environment set environment
201 -o, --outputdir set the directory, where to store the wget result
203 -h, --help Print this help, then exit
204 -v, --version Print version number, then exit
206 END_OF_USAGE
209 # ------------------------------------------------------------------------------
210 sub create2DigitNumber($)
212 my $digit = $_[0];
213 my $str;
214 my $nDigitLen = length $digit;
216 if ($nDigitLen == 1)
218 $str = "0" . $digit;
220 else
222 if ($nDigitLen > 2)
224 $str = substr $digit, $nDigitLen - 2, 2;
226 else
228 $str = $digit;
231 return $str;