diff options
Diffstat (limited to 'sal/qa/helper/gcov')
-rwxr-xr-x | sal/qa/helper/gcov/build_coverage | 23 | ||||
-rw-r--r-- | sal/qa/helper/gcov/deprecated.txt | 213 | ||||
-rwxr-xr-x | sal/qa/helper/gcov/gcov_all | 15 | ||||
-rwxr-xr-x | sal/qa/helper/gcov/gcov_filter.pl | 427 | ||||
-rw-r--r-- | sal/qa/helper/gcov/gcov_result.pl | 232 | ||||
-rw-r--r-- | sal/qa/helper/gcov/gcov_resultcompare.pl | 151 | ||||
-rw-r--r-- | sal/qa/helper/gcov/gcov_resultinterpreter.pl | 172 | ||||
-rwxr-xr-x | sal/qa/helper/gcov/gcov_run.sh | 64 | ||||
-rw-r--r-- | sal/qa/helper/gcov/readme.txt | 13 | ||||
-rwxr-xr-x | sal/qa/helper/gcov/statistics | 20 |
10 files changed, 1330 insertions, 0 deletions
diff --git a/sal/qa/helper/gcov/build_coverage b/sal/qa/helper/gcov/build_coverage new file mode 100755 index 000000000000..8948789a87e7 --- /dev/null +++ b/sal/qa/helper/gcov/build_coverage @@ -0,0 +1,23 @@ + +# this is a helper, to build sal with the right compiler parameters +# IMPORTANT, this works only within Linux + +if ( `uname` == "Linux" ) then + echo "running on Linux Intel, ok." + + build killobj + + # setenv OLDCFLAGS $ENVCFLAGS + + setenv ENVCFLAGS "-fprofile-arcs -ftest-coverage" + + build + + # setenv ENVCFLAGS $OLDCFLAGS + +else + + echo "Sorry, gcov works only within Linux environment." + +endif + diff --git a/sal/qa/helper/gcov/deprecated.txt b/sal/qa/helper/gcov/deprecated.txt new file mode 100644 index 000000000000..a46a94acca65 --- /dev/null +++ b/sal/qa/helper/gcov/deprecated.txt @@ -0,0 +1,213 @@ +# contain all functions, which are mark as deprecated +# this function will removed from the allexportlist +# Format of a line MUST be / (.*);/ + + rtl_ustr_trim; + rtl_str_trim; + +# since 16.9.2003 +# Function List: +# A. deprecated functions: +# 1) Profile class and all its sub C API: + osl_openProfile; + osl_closeProfile; + osl_flushProfile; + osl_readProfileString; + + osl_readProfileBool; + osl_readProfileIdent; + osl_writeProfileString; + + osl_writeProfileBool; + osl_writeProfileIdent; + osl_removeProfileEntry; + + osl_getProfileSectionEntries; + osl_getProfileSections; + +# 2) VolumeDevice class and all this sub C API: + osl_unmountVolumeDevice; + osl_automountVolumeDevice; + osl_releaseVolumeDeviceHandle; + + osl_acquireVolumeDeviceHandle; + osl_getVolumeDeviceMountPath; + +# 3) in FileBase class: + osl_getCanonicalName; + +# B. untested functions: +# functions need Client/Server model and blocking mode of transmission. some of the functions +# can not run through on testshl2 env while the same code can run successfully in normal seperate +# files. +# 1) in DatagramSocket class: +# osl_receiveFromSocket; +# osl_sendToSocket; + +# 2) in StreamSocket class: +# osl_readSocket; +# osl_writeSocket; +# osl_receiveSocket; +# osl_sendSocket; + +# 3) in Socket class: + osl_isExceptionPending; +# osl_shutdownSocket; + +# 4) in Pipe class: +# osl_acceptPipe; + +# 5) in StreamPipe class: +# osl_readPipe; +# osl_writePipe; +# osl_receivePipe; +# osl_sendPipe; + +#C. unreachable functions +# (*)in .map file but does not appear in.hxx header file thus unreachable, +# mostly for internal use, can not be reached by accessing class, so need +# not be tested. +# 1) in file module*: + osl_abbreviateSystemPath; + +# 2) in socket module*: + osl_addToSocketSet; + osl_clearSocketSet; + osl_createSocketSet; + osl_destroySocketSet; + osl_isInSocketSet; + osl_removeFromSocketSet + + osl_createHostAddrByName; + osl_createHostAddrByAddr; + + osl_createHostAddr; + osl_copyHostAddr; + osl_destroyHostAddr; + osl_getHostnameOfHostAddr; + osl_getSocketAddrOfHostAddr; + osl_createInetBroadcastAddr; + + osl_demultiplexSocketEvents; + osl_getDottedInetAddrOfSocketAddr; + osl_getFamilyOfSocketAddr; + +# 3) in thread module*: + osl_createThread; + osl_setThreadTextEncoding; + +# or (#)does not wrapper into a class, only in C API. does not in our Class +# check list. +# 1) all diagnose module#: + osl_breakDebug; + osl_assertFailedLine; + osl_trace; + osl_reportError; + + osl_setDebugMessageFunc; + +# 2) all signal module#: + osl_addSignalHandler; + osl_removeSignalHandler; + osl_raiseSignal; + +# 3) all time module#: + osl_getSystemTime; + osl_getDateTimeFromTimeValue; + + osl_getTimeValueFromDateTime; + osl_getLocalTimeFromSystemTime; + + osl_getSystemTimeFromLocalTime; + osl_getGlobalTimer; + +# 4) all process module#: + osl_executeProcess; + osl_executeProcess_WithRedirectedIO; + + osl_terminateProcess; + osl_getProcess; + + osl_freeProcessHandle; + osl_joinProcess; + osl_joinProcessWithTimeout; + + osl_getProcessInfo; + osl_getExecutableFile; + osl_getCommandArgCount; + + osl_getCommandArg; + osl_getEnvironment; + osl_getProcessWorkingDir; + + osl_getProcessLocale; + osl_setProcessLocale; + osl_sendResourcePipe; + + osl_receiveResourcePipe; + +# 5) all util module#: + osl_getEthernetAddress; + + + +### +# LLA: +# this functions are not deprecated, they only marked as deprecated, to say that +# there is no test need. +### + rtl_zeroMemory; + rtl_fillMemory; + rtl_copyMemory; + rtl_moveMemory; + rtl_compareMemory; + rtl_findInMemory; + +# LLA: +# Marked as deprecated by Stephan Bergmann + + rtl_byte_sequence_reference2One; + rtl_byte_sequence_realloc; + rtl_byte_sequence_acquire; + rtl_byte_sequence_release; + rtl_byte_sequence_construct; + rtl_byte_sequence_constructNoDefault; + rtl_byte_sequence_constructFromArray; + rtl_byte_sequence_assign; + rtl_byte_sequence_equals; + rtl_byte_sequence_getConstArray; + rtl_byte_sequence_getLength; + +# LLA: +# old test environment need no extra test + rtl_tres_create; + rtl_tres_destroy; + +# LLA: +# found in source code, marked as deprecated +# rtl_locale_getDefault; +# rtl_locale_setDefault; + +# LLA: +# marked as deprecated, due to the fact there is no access from outside +# so this functions are not really accessable +# They are used in rtl/source/locale.c + rtl_hashentry_destroy; + rtl_hashfunc; + rtl_hashtable_add; + rtl_hashtable_destroy; + rtl_hashtable_find; + rtl_hashtable_grow; + rtl_hashtable_init; + +# LLA: +# marked as deprecated by Joachim Lingner 20040414 + rtl_moduleCount_acquire; + rtl_moduleCount_release; + rtl_moduleCount_canUnload; + rtl_registerModuleForUnloading; + rtl_unregisterModuleForUnloading; + rtl_unloadUnusedModules; + rtl_addUnloadingListener; + rtl_removeUnloadingListener; + diff --git a/sal/qa/helper/gcov/gcov_all b/sal/qa/helper/gcov/gcov_all new file mode 100755 index 000000000000..dad1f736c688 --- /dev/null +++ b/sal/qa/helper/gcov/gcov_all @@ -0,0 +1,15 @@ +#!/bin/bash +# $Id: gcov_all,v 1.4 2005-11-02 17:23:43 kz Exp $ +# This helper run lists all c and cxx files from selected directories. + +# PRJ points to the flat project directory +PRJ='../../..' + +# selected directories +FILES=`/bin/ls $PRJ/osl/unx/*.c $PRJ/osl/unx/*.cxx $PRJ/rtl/source/*.c $PRJ/rtl/source/*.cxx $PRJ/osl/all/*.c $PRJ/osl/all/*.cxx $PRJ/textenc/*.c` + +# Use gcov_filter on every c/cxx file. +for file in $FILES; do + # echo $file + perl gcov_filter.pl -o $PRJ/unxlngi6/slo -i $PRJ/util/sal.map $file $* +done diff --git a/sal/qa/helper/gcov/gcov_filter.pl b/sal/qa/helper/gcov/gcov_filter.pl new file mode 100755 index 000000000000..5074c0251ce5 --- /dev/null +++ b/sal/qa/helper/gcov/gcov_filter.pl @@ -0,0 +1,427 @@ +#!/usr/bin/perl -w +# +# $Id: gcov_filter.pl,v 1.4 2005-11-02 17:23:57 kz Exp $ +# + +# GCOV_FILTER +# +# Helper to filter the gcov output. +# Handle a compare between the hole gcov output and a given select list of exported functions. +# +# Q: Why perl? +# A: regexp ;-) +# + + +use strict; +use File::Basename; +use Getopt::Long; + +# Global constants +our $version_info = 'gcov helper $Revision: 1.4 $ '; +our $help; # Help option flag +our $version; # Version option flag +our $cwd = `pwd`; # current working directory +chomp($cwd); +# our $tool_dir = dirname($0); +# our $tool_file = basename($0); + +# our $output_filename; +our $input_allfunc; +# our $input_filename; + +our $allfuncinfo; # allfuncinfo option flag +our $showallfunc; # showallfunc option flag +our $no_percentage; # no_percentage option flag +our $donotfilter; # donotfilter option flag +our $objectdir; + +# Prototypes +sub print_usage(*); +sub read_gcov_function_file($); +sub get_PRJ_from_makefile_mk(); +# sub read_ExportedFunctionList(); +sub read_List($); + +# if (! ($tool_dir =~ /^\/(.*)$/)) +# { +# $tool_dir = "$cwd/$tool_dir"; +# } + +# Parse command line options +if (!GetOptions( "input-allfunc=s" => \$input_allfunc, + "allfuncinfo" => \$allfuncinfo, + "showallfunc" => \$showallfunc, + "no-percentage" => \$no_percentage, + "do-not-filter" => \$donotfilter, + "objectdir=s" => \$objectdir, + "help" => \$help, + "version" => \$version + )) +{ + print_usage(*STDERR); + exit(1); +} + +# Check for help option +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} + +# Check for version option +if ($version) +{ + print("$version_info\n"); + exit(0); +} + +# check if enough parameters +if ($#ARGV < 0) +{ + print("No input filename specified\n"); + print_usage(*STDERR); + exit(1); +} + +# special case: +# the filename contains a . or '/' at the beginning +my $startdir = $ARGV[0]; +if ( ($startdir =~ /^\.\./) || + ($startdir =~ /^\//) ) +{ + $startdir = dirname($startdir); + # print("start directory is $startdir\n"); + # chdir $startdir; +} +else +{ + $startdir = ""; +} + +# check for sal.map +if ( ! $input_allfunc ) +{ + # this is a try, to get the project directory form a found makefile.mk + # may work, but fails due to some disunderstandings may be problems in perl :-( + my $sDir = get_PRJ_from_makefile_mk(); + # chomp($sDir); + # HDW: print("PRJ is $dir\n"); + + # $sDir2 = "../.."; + my $sMapFile = "$sDir" . "/util/sal.map"; + # $sMapFile = "$sDir2" . "/util/sal.map"; + + if ( -e $sMapFile) + { + $input_allfunc = $sMapFile; + } + else + { + print("No input-allfunc filename specified\n"); + print_usage(*STDERR); + exit(1); + } +} +our @aDeprecatedList; +our @aExportedFunctionList; +# read_ExportedFunctionList(); +@aExportedFunctionList = read_List($input_allfunc); +@aDeprecatedList = read_List("deprecated.txt"); + +if ($allfuncinfo) +{ + print("Count of all functions: $#aExportedFunctionList\n"); + exit(0); +} + +if ($showallfunc) +{ + my $func; + foreach $func (@aExportedFunctionList) + { + print("$func\n"); + } + exit(0); +} + +# back to current directory +# this chdir was for a before chdir (in $startdir creation) but due to the fact, +# that the get_PRJ_from_makefile_mk works but the after concat of strings not, this +# chdir is also remarked. +# chdir $cwd; + +# HWD: print "count of param: \n"; +# $input_filename = $ARGV[0]; + +my $nCount = $#ARGV + 1; +my $nIdx; + +for ($nIdx = 0; $nIdx < $nCount ; ++$nIdx) +{ + my $file = $ARGV[$nIdx]; + # print("processing: $file\n"); + + # change directory, to the current file, due to the fact, that we may be need to call gcov + # and gcov will create some extra files, like *.gcov near the current file. + # if ( $startdir ne "" ) + # { + # chdir $startdir; + # $file = basename($file); + # } + + my $OBJECTS=""; + if ($objectdir) + { + $OBJECTS = "-o " . $objectdir; + } + + if (! ($file =~ /\.f$/ )) + { + my $filef = "$file.f"; + # if (! -e $filef ) + # { + # print "gcov $OBJECTS -l -f $file >$filef\n"; + my $blah = `gcov $OBJECTS -n -f $file >$filef`; + # } + $file = $filef; + } + read_gcov_function_file($file); + + # go back to old directory, because it's possible to change relative to an other directory. + if ( $startdir ne "" ) + { + chdir $cwd; + } +} + +# print "$tool_dir\n"; +# print "all is right\n"; +exit(0); + + +# -------------------------------------------------------------------------------- +# Read the map file, which should contain all exported functions. +sub read_List($) +{ + local *INPUT_HANDLE; + my $filename = $_[0]; + my @list; + my $line = ""; + open(INPUT_HANDLE, $filename); + # or die("ERROR: cannot open $filename!\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # reg exp: [spaces]functionname[semicolon][line end] + if ($line =~ /^\s+(\w*);$/) + { + # print("$1\n"); + push(@list, $1); + } + } + close(INPUT_HANDLE); + return @list; +} + +# -------------------------------------------------------------------------------- +# Helper function, test is a given value is found in the global exported function list. +# the given value format could be a simple function name +# or a prototype +# e.g. +# osl_getSystemPathFromFileURL +# or +# void getSystemPathFromFileURL( const char* rtl_...) +# +sub contain_in_List($$) +{ + my $func; + my $value = $_[0]; + my $list = $_[1]; + + if ($donotfilter) + { + return $value; + } + + foreach $func (@$list) # (@aExportedFunctionList) + { + # first try, direct check + if ($value eq $func) + { + # HWD: print("$value eq $func\n"); + return $value; + } + + # value not found, second try, may be we found it if we search word wise. + # helper, to insert a space after the word, before '(' + $value =~ s/\(/ \(/g; + # may be here we should replace all white spaces by ' ' + + # split by 'space' + my @list = split(' ', $value); + for(@list) + { + # HWD: print "$list[$n]\n"; + if ($_ eq $func) + { + # HWD: print ("found $func in $value\n"); + return $_; + } + } + } + # not found + return ""; +} +# -------------------------------------------------------------------------------- +# Read the gcov function (gcov -f) file +# and compare line by line with the export function list +# so we get a list of functions, which are only exported, and not all stuff. +# sample of output +# new gcov gcc 3.4 format +sub read_gcov_function_file($) +{ + local *INPUT_HANDLE; + my $file = $_[0]; + my $line = ""; + open(INPUT_HANDLE, $file) + or die("ERROR: cannot open $file!\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # sample line (for reg exp:) + # 100.00% of 3 source lines executed in function osl_thread_init_Impl + if ($line =~ /^Function \`(.*)\'$/ ) + { + my $sFunctionName = $1; + my $sPercentage; + $line = <INPUT_HANDLE>; + if ($line =~ /^Lines executed:(.*)% of/ ) + { + $sPercentage = $1; + } + my $value = contain_in_List( $sFunctionName, \@aExportedFunctionList ); + if ($value) + { + my $isDeprecated = contain_in_List( $sFunctionName, \@aDeprecatedList ); + if ($isDeprecated) + { + # Function is deprecated, do not export it. + } + else + { + if ($no_percentage) + { + print("$value\n"); + } + else + { + print("$sPercentage $value\n"); + } + } + } + # push(@aExportedFunctionList, $1); + } + } + close(INPUT_HANDLE); +} + +# gcov format since gcc 3.3.6 +# 100.00% von 3 Zeilen in function helloworld ausgeführt +# 100.00% von 5 Zeilen in function main ausgeführt +# 100.00% von 8 Zeilen in file tmp.c ausgeführt +sub read_gcov_function_file_old_gcc_3($) +{ + local *INPUT_HANDLE; + my $file = $_[0]; + my $line = ""; + open(INPUT_HANDLE, $file) + or die("ERROR: cannot open $file!\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # sample line (for reg exp:) + # 100.00% of 3 source lines executed in function osl_thread_init_Impl + if ($line =~ /^(.*)% of \d+ source lines executed in function (.*)$/ ) + { + my $value = contain_in_List( $2, \@aExportedFunctionList ); + if ($value) + { + my $isDeprecated = contain_in_List( $2, \@aDeprecatedList ); + if ($isDeprecated) + { + # Function is deprecated, do not export it. + } + else + { + if ($no_percentage) + { + print("$value\n"); + } + else + { + print("$1 $value\n"); + } + } + } + # push(@aExportedFunctionList, $1); + } + } + close(INPUT_HANDLE); +} + +# ------------------------------------------------------------------------------ +# helper, to read the PRJ value out of a makefile.mk file +sub get_PRJ_from_makefile_mk() +{ + local *INPUT_HANDLE; + # my $startdir = @_[0]; + my $line = ""; + my $value = ""; + open(INPUT_HANDLE, "makefile.mk") + or die("ERROR: cannot open makefile.mk\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # sample line + # PRJ= + # HWD: print("$line\n"); + if ($line =~ /^PRJ\s*=(.*)\s*$/) + { + # HWD: print("FOUND #####\n"); + $value = $1; + chomp($value); + $value =~ s/\$\//\//g; + } + } + close(INPUT_HANDLE); + return $value; +} + +# ---------------------------------------------------------------------------- +sub print_usage(*) +{ + local *HANDLE = $_[0]; + my $tool_name = basename($0); + + print(HANDLE <<END_OF_USAGE); + +Usage: $tool_name [OPTIONS] INPUTFILE + + -h, --help Print this help, then exit + -v, --version Print version number, then exit + -i, --input-allfunc FILENAME Map file, which contain all exported functions + -s, --showallfunc Shows all exported functions then exit + -a, --allfuncinfo Shows the count of all exported functions then quit + -n, --no-percentage Suppress the output of the percent value for tested functions + -d, --do-not-filter Show all functions, which gcov -f produce + +END_OF_USAGE + ; +} + diff --git a/sal/qa/helper/gcov/gcov_result.pl b/sal/qa/helper/gcov/gcov_result.pl new file mode 100644 index 000000000000..414eac2c828b --- /dev/null +++ b/sal/qa/helper/gcov/gcov_result.pl @@ -0,0 +1,232 @@ +#!/usr/bin/perl -w +# +# $Id: gcov_result.pl,v 1.2 2003-06-11 16:36:30 vg Exp $ +# + +# GCOV_RESULT +# +# Helper, to interpret the result and put the result via html in a database. +# Put into DB works via php. +# +# Q: Why perl? +# A: regexp ;-) +# + +use strict; +use File::Basename; +use Getopt::Long; +use Time::localtime; + +our $version_info = 'gcov helper $Revision: 1.2 $ '; + +our $help; # Help option flag +our $version; # Version option flag +# our $infile; + +our $usedFunctions; # name of all functions filename, which have a value > 0 +our $nonusedFunctions; # name of all functions filename, which have a value == 0 +our $complete; # name of all functions filename, which have a value == 100 +our $incomplete; # name of all functions filename, which have a value > 0 && < 100 + +our $environment; +our $major; +our $minor; +our $cwsname; +our $outputDir; + +# Prototypes +sub print_usage(*); +sub read_gcov_function_file($); +sub create2DigitNumber($); + +# Parse command line options +if (!GetOptions( + "help" => \$help, + "version" => \$version, + + "usedfunctions=s" => \$usedFunctions, + "nonusedfunctions=s" => \$nonusedFunctions, + "complete=s" => \$complete, + "incomplete=s" => \$incomplete, + "cwsname=s" => \$cwsname, + "major=s" => \$major, + "minor=s" => \$minor, + "environment=s" => \$environment, + "outputdir=s" => \$outputDir + )) +{ + print_usage(*STDERR); + exit(1); +} + +# Check for help option +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} + +# Check for version option +if ($version) +{ + print("$version_info\n"); + exit(0); +} + +# check if enough parameters +# if ($#ARGV < 0) +# { +# print("No input filename specified\n"); +# print_usage(*STDERR); +# exit(1); +# } + +# ------------------------------------------------------------------------------ + +my $sURL = "http://mahler.germany.sun.com/qadev/baselib/gcov_result_in_db_putter.php"; + +my $next = "?"; + +if ($complete) +{ + my $result = `cat $complete | wc -l`; + chomp($result); + $result =~ / *(\d+)/; + $sURL = $sURL . "$next" . "complete=$1"; + $next = "&"; +} + +if ($nonusedFunctions) +{ + my $result = `cat $nonusedFunctions | wc -l`; + chomp($result); + $result =~ / *(\d+)/; + $sURL = $sURL . "$next" . "notused=$1"; + $next = "&"; +} +if ($usedFunctions) +{ + my $result = `cat $usedFunctions | wc -l`; + chomp($result); + $result =~ / *(\d+)/; + $sURL = $sURL . "$next" . "used=$1"; + $next = "&"; +} +if ($incomplete) +{ + my $result = `cat $incomplete | wc -l`; + chomp($result); + $result =~ / *(\d+)/; + $sURL = $sURL . "$next" . "incomplete=$1"; + $next = "&"; +} + +if ($cwsname) +{ + # qadev8 + $sURL = $sURL . "$next" . "cwsname=$cwsname"; + $next = "&"; +} +if ($major) +{ + # srx645 + $sURL = $sURL . "$next" . "major=$major"; + $next = "&"; +} +if ($minor) +{ + # m3s1 + $sURL = $sURL . "$next" . "minor=$minor"; + $next = "&"; +} + +if ($environment) +{ + # unxlngi5 + $sURL = $sURL . "$next" . "environment=$environment"; + $next = "&"; +} + +my $year = localtime->year() + 1900; +my $month = create2DigitNumber(localtime->mon() + 1); +my $day = create2DigitNumber(localtime->mday()); +$sURL = $sURL . "$next" . "date=$year-$month-$day"; +$next = "&"; + +my $output; +if ($outputDir) +{ + chomp($outputDir); + $output = $outputDir; +} + +# check if output ends with "/" +if ( $output =~ /\/$/ ) +{ + print "Output name ends with '/'\n"; +} +else +{ + print "Output name does not end with '/'\n"; + $output = $output . "/"; +} +$output = $output . "php_result.txt"; + +my $result = `wget -O $output "$sURL"`; +print "$sURL\n"; + +print `cat $output`; + + +# ---------------------------------------------------------------------------- +sub print_usage(*) +{ + local *HANDLE = $_[0]; + my $tool_name = basename($0); + + print(HANDLE <<END_OF_USAGE); + +Usage: $tool_name [OPTIONS] + + -u, --usedfunctions count of all functions, which have a value > 0 + -n, --nonusedfunctions count of all functions, which have a value == 0 + -co, --complete count of all functions, which have a value == 100 + -i, --incomplete count of all functions, which have a value > 0 && < 100 + + -cw, --cwsname set cwsname + -ma, --major set major number + -mi, --minor set minor number + -e, --environment set environment + + -o, --outputdir set the directory, where to store the wget result + + -h, --help Print this help, then exit + -v, --version Print version number, then exit + +END_OF_USAGE + ; +} +# ------------------------------------------------------------------------------ +sub create2DigitNumber($) +{ + my $digit = $_[0]; + my $str; + my $nDigitLen = length $digit; + + if ($nDigitLen == 1) + { + $str = "0" . $digit; + } + else + { + if ($nDigitLen > 2) + { + $str = substr $digit, $nDigitLen - 2, 2; + } + else + { + $str = $digit; + } + } + return $str; +} diff --git a/sal/qa/helper/gcov/gcov_resultcompare.pl b/sal/qa/helper/gcov/gcov_resultcompare.pl new file mode 100644 index 000000000000..d52316fac0e7 --- /dev/null +++ b/sal/qa/helper/gcov/gcov_resultcompare.pl @@ -0,0 +1,151 @@ +#!/usr/bin/perl -w +# +# $Id: gcov_resultcompare.pl,v 1.2 2004-03-19 14:46:51 obo Exp $ +# + +# GCOV_RESULTCOMPARE +# +# Helper, to compare two different results +# +# Q: Why perl? +# A: regexp ;-) +# + +use strict; +use File::Basename; +use Getopt::Long; + +our $version_info = 'gcov_resultcompare $Revision: 1.2 $ '; + +our $help; # Help option flag +our $version; # Version option flag +# our $infile; + +our $orig; +our $compare; + +# Prototypes +sub print_usage(*); +sub read_gcov_function_file($); + +# Parse command line options +if (!GetOptions( + "o=s" => \$orig, + "c=s" => \$compare, + "help" => \$help, + "version" => \$version + )) +{ + print_usage(*STDERR); + exit(1); +} + +# Check for help option +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} + +# Check for version option +if ($version) +{ + print("$version_info\n"); + exit(0); +} + +# check if enough parameters +# if ($#ARGV < 1) +# { +# print("No input filenames specified\n"); +# print_usage(*STDERR); +# exit(1); +# } + +if (! $orig) +{ + print_usage(*STDOUT); + exit(0); +} +if (! $compare) +{ + print_usage(*STDOUT); + exit(0); +} + +# ------------------------------------------------------------------------------ + +my %origlist = read_gcov_function_file($orig); +my %cmplist = read_gcov_function_file($compare); + +my $key; +my $value; + +while (($key, $value) = each %origlist) +{ + my $cmpvalue = $cmplist{$key}; + + if ($cmpvalue != 0.00) + { + if ($value < 100.00) + { + if ($cmpvalue > $value && $value < 90.0) + { + print "$key, $value, CMP:$cmpvalue\n"; + } + } + } +} + +# -------------------------------------------------------------------------------- +# Read the gcov function (gcov -f) file +# and compare line by line with the export function list +# so we get a list of functions, which are only exported, and not all stuff. + +sub read_gcov_function_file($) +{ + local *INPUT_HANDLE; + my $file = shift; + my %list; + my $line = ""; + + open(INPUT_HANDLE, $file) + or die("ERROR: cannot open $file!\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # sample line (for reg exp:) + # 100.00 rtl_ustr_toDouble + if ($line =~ /^(.{6}) (\w+)$/ ) + { + my $percent = $1; + my $value = $2; + + $list{$value} = $percent; + } + } + close(INPUT_HANDLE); + return %list; +} + +# ---------------------------------------------------------------------------- +sub print_usage(*) +{ + local *HANDLE = $_[0]; + my $tool_name = basename($0); + + print(HANDLE <<END_OF_USAGE); + +Usage: $tool_name [OPTIONS] INPUTFILE + + -o Original File, which gives the main values + if here a value is smaller than in compare, the found value is a candidate for better check. + -c Compare file. + + -h, --help Print this help, then exit + -v, --version Print version number, then exit + +END_OF_USAGE + ; +} diff --git a/sal/qa/helper/gcov/gcov_resultinterpreter.pl b/sal/qa/helper/gcov/gcov_resultinterpreter.pl new file mode 100644 index 000000000000..b01506b20634 --- /dev/null +++ b/sal/qa/helper/gcov/gcov_resultinterpreter.pl @@ -0,0 +1,172 @@ +#!/usr/bin/perl -w +# +# $Id: gcov_resultinterpreter.pl,v 1.3 2005-11-02 17:24:12 kz Exp $ +# + +# GCOV_RESULTINTERPRETER +# +# Helper, to interpret the result +# +# Q: Why perl? +# A: regexp ;-) +# + +use strict; +use File::Basename; +use Getopt::Long; + +our $version_info = 'gcov helper $Revision: 1.3 $ '; + +our $help; # Help option flag +our $version; # Version option flag +# our $infile; + +our $usedFunctions; # show all functions, which have a value > 0 +our $nonusedFunctions; # show all functions, which have a value == 0 +our $nPercent; # show all functions, which have a value > $nPercent +our $complete; # show all functions, which have a value == 100 +our $incomplete; # show all functions, which have a value > 0 && < 100 + +# Prototypes +sub print_usage(*); +sub read_gcov_function_file($); + +# Parse command line options +if (!GetOptions( + "usedfunctions" => \$usedFunctions, + "nonusedfunctions" => \$nonusedFunctions, + "percent=s" => \$nPercent, + "complete" => \$complete, + "incomplete" => \$incomplete, + "help" => \$help, + "version" => \$version + )) +{ + print_usage(*STDERR); + exit(1); +} + +# Check for help option +if ($help) +{ + print_usage(*STDOUT); + exit(0); +} + +# Check for version option +if ($version) +{ + print("$version_info\n"); + exit(0); +} + +# check if enough parameters +if ($#ARGV < 0) +{ + print("No input filename specified\n"); + print_usage(*STDERR); + exit(1); +} + +if ($complete) +{ + $nPercent = 100.00; +} +# ------------------------------------------------------------------------------ + +my %list = read_gcov_function_file($ARGV[0]); + +my $key; +my $value; + +while (($key, $value) = each %list) +{ + # print "function: $key = $value\n"; + if ($nonusedFunctions) + { + if ($value <= 0.00) + { + print "$key\n"; + } + } + elsif ($usedFunctions) + { + if ($value != 0.00) + { + print "$key, $value\n"; + } + } + elsif ($nPercent) + { + if ($value >= $nPercent) + { + print "$key, $value\n"; + } + } + elsif ($incomplete) + { + if ($value > 0.00 && $value < 100.00) + { + print "$key, $value\n"; + } + } + else + { + print "$key, $value\n"; + } +} + +# -------------------------------------------------------------------------------- +# Read the gcov function (gcov -f) file +# and compare line by line with the export function list +# so we get a list of functions, which are only exported, and not all stuff. + +sub read_gcov_function_file($) +{ + local *INPUT_HANDLE; + my $file = $_[0]; + my %list; + my $line = ""; + + open(INPUT_HANDLE, $file) + or die("ERROR: cannot open $file!\n"); + + while ($line = <INPUT_HANDLE>) + { + chomp($line); + # sample line (for reg exp:) + # 100.00 rtl_ustr_toDouble + if ($line =~ /^(.*) (\w+)$/ ) + { + my $percent = $1; + my $value = $2; + + $list{$value} = $percent; + } + } + close(INPUT_HANDLE); + return %list; +} + +# ---------------------------------------------------------------------------- +sub print_usage(*) +{ + local *HANDLE = $_[0]; + my $tool_name = basename($0); + + print(HANDLE <<END_OF_USAGE); + +Usage: $tool_name [OPTIONS] INPUTFILE + + -u, --usedFunctions show all functions, which have a value > 0 + -n, --nonusedFunctions show all functions, which have a value == 0 + -p, --percent show all functions, which have a value > percent + -c, --complete show all functions, which have a value == 100 + -i, --incomplete show all functions, which have a value > 0 && < 100 + + -h, --help Print this help, then exit + -v, --version Print version number, then exit + +END_OF_USAGE + ; +} diff --git a/sal/qa/helper/gcov/gcov_run.sh b/sal/qa/helper/gcov/gcov_run.sh new file mode 100755 index 000000000000..31a4c4e44dec --- /dev/null +++ b/sal/qa/helper/gcov/gcov_run.sh @@ -0,0 +1,64 @@ +#!/bin/tcsh -f + +# This is a helper file, to start a coverage test by hand + +# ----- INIT ENVIRONMENT ----- +# setup a complete build environment, copy from our beanshell environment +setenv SHELL /bin/tcsh +source /net/margritte/usr/qaapi/workspace/qadev/scripts/init/staroffice.cshrc + +# do a setsolar + +setenv SOURCE_ROOT /cws/so-cwsserv06/qadev16 +setsolar -cwsname qadev16 -sourceroot -src680 -ver m25 -jdk14 unxlngi5 + + +# ----- CLEAN OLD COVERAGE INFOS ----- + +setenv SALDIR /cws/so-cwsserv06/qadev16/SRC680/src.m25/sal + +# this is a patch for sal, to see also "ustr" in string +cd $SALDIR/rtl/source + +# strtmpl.c contains code, which is used for strings and ustrings. This file contain lot of makros +# which unpacked at compile time. Due to the fact, gcov has some problems with such things, an idea is +# to copy strtmpl.c to ustrtmpl.c and replace the include command in ustring.c +# this is done be the follows lines. + +# cat ustring.c | sed -e "s/strtmpl.c/ustrtmpl.c/" > ustring.c.new ; mv -f ustring.c.new ustring.c +# cp strtmpl.c ustrtmpl.c + +cd $SALDIR + +rm -f `find . -type f -name '*.bb' -print` +rm -f `find . -type f -name '*.bbg' -print` +rm -f `find . -type f -name '*.f' -print` +rm -f `find . -type f -name '*.da' -print` +rm -f `find . -type f -name '*.gcov' -print` + +rm -rf unxlngi5 + +# ----- START A NEW BUILD WITH COVERAGE ----- +setenv ENVCFLAGS "-O0 -ftest-coverage -fprofile-arcs" +build TESTCOVERAGE=t +deliver + + +# ----- START THE TESTS ----- + +# unsetenv ENVCFLAGS +cd cd $SALDIR/qa +# cd qa/osl/file +dmake test + + +# ----- BUILD GCOV (coverage) FILES ----- +cd cd $SALDIR/qa/helper/gcov +statistics + +# the statistics file create some *.txt files, the most interesting one is realallchecked.txt, +# which contain only the interface functions and it's run through in percent. +# the gcov_resultcompare.pl use two of these files to give out a compare. + +# usage: gcov_resultcompare.pl -o realallchecked.txt -c <other>/realallchecked.txt + diff --git a/sal/qa/helper/gcov/readme.txt b/sal/qa/helper/gcov/readme.txt new file mode 100644 index 000000000000..6c9f46b225cb --- /dev/null +++ b/sal/qa/helper/gcov/readme.txt @@ -0,0 +1,13 @@ +GCOV Coverage information helper functions + +# Files: +deprecated.txt +gcov_all +gcov_filter.pl +gcov_result.pl +gcov_resultinterpreter.pl +statistics + +\\mahler\automat\docs\qadev\baselib\gcov_result_in_db_putter.php + + diff --git a/sal/qa/helper/gcov/statistics b/sal/qa/helper/gcov/statistics new file mode 100755 index 000000000000..cbb374c172d2 --- /dev/null +++ b/sal/qa/helper/gcov/statistics @@ -0,0 +1,20 @@ +#!/bin/bash +# $Id: statistics,v 1.3 2003-06-11 16:38:03 vg Exp $ + +./gcov_filter.pl -i ../../../util/sal.map --showallfunc FOO | sort | uniq >exportedfunctions.txt + +# gives the number off all files. +./gcov_filter.pl -i ../../../util/sal.map --allfuncinfo FOO + +./gcov_all --no-percentage | sort | uniq >allchecked.txt + +# gives the number of all testable functions +echo -n " testable functions: " +cat allchecked.txt | wc -l + +# gives a list of all checked functions within gcov. +./gcov_all | sort +1 | uniq >realallchecked.txt + +# output all functions, which are not tested by gcov -f, due to the fact, that they where not found +comm -3 exportedfunctions.txt allchecked.txt >notfound.txt + |