diff options
author | Anel Husakovic <anel@mariadb.org> | 2019-11-18 19:01:20 +0100 |
---|---|---|
committer | Anel Husakovic <anel@mariadb.org> | 2019-11-19 15:00:48 +0100 |
commit | 00f9df29224ada9cdbb796c99f4c2ae3f227db73 (patch) | |
tree | bc4e87ee7566dbe6382d1cf79456e3ff7adf2321 | |
parent | 6718d3bc3241f72e07504133371cf3813d2e6fe9 (diff) | |
download | mariadb-git-bb-10.2-anel-MDEV-20787.tar.gz |
MDEV-20787: Script dgcov.pl does not workbb-10.2-anel-MDEV-20787
Let's change CMakeList with `--coverage` flag as an alias for
`-fprofile-arcs -ftest-coverage -lgcov` in addition.
When the server is compiled with `-DENABLE_GCOV=ON`, from object files are generated
`.gcno` and `.gcda` files.
`./mtr --gcov is_check_constraint` is invoking the script calls
`./dgcov.pl --purge`, `./mtr is_check_constraint`,
`./dgcov.pl --generate>/var/last_changes.dgcov`.
The `purge` flag is clearing `.gcda` files (and others extensions),
while running the test new `.gcda` files are obtained.
With `generate` flag, `gcov -i` (`intermediate format`) is called
on obtained `<object-files-name>.gcda` files (`dbug.c.gcda` e.g.).
The patch is tested on `gcov 6.3` and `gcov 7.4` versions
and can be seen that resulting `.gcov` file for `6.3` creates
`<full path>.gcov` (`dbug.c.gcda.gcov` e.g.) file,
where `gcov 7.4` is still creating `object-file-names.gcov`(`dbug.c.gcov`) files
as `gcov` in general is doing.
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rwxr-xr-x | mysql-test/dgcov.pl | 16 |
2 files changed, 15 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 0dcc2a75587..af025a0312f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -249,7 +249,7 @@ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC") OPTION(ENABLE_GCOV "Enable gcov (debug, Linux builds only)" OFF) IF (ENABLE_GCOV) - MY_CHECK_AND_SET_COMPILER_FLAG("-fprofile-arcs -ftest-coverage -lgcov" DEBUG) + MY_CHECK_AND_SET_COMPILER_FLAG("--coverage" DEBUG) ENDIF() MY_CHECK_AND_SET_COMPILER_FLAG(-ggdb3 DEBUG) diff --git a/mysql-test/dgcov.pl b/mysql-test/dgcov.pl index fbc5540e697..47ffaca04ef 100755 --- a/mysql-test/dgcov.pl +++ b/mysql-test/dgcov.pl @@ -68,8 +68,11 @@ if ($opt_purge) system($cmd)==0 or die "system($cmd): $? $!"; exit 0; } - +my $gcov_vers= `gcov -v`; +$gcov_vers=~ s/\D//g; +$gcov_vers= substr($gcov_vers, 0, 1); find(\&gcov_one_file, $root); +undef $gcov_vers; find(\&write_coverage, $root) if $opt_generate; exit 0 if $opt_only_gcov; @@ -162,7 +165,16 @@ sub gcov_one_file { } # now, read the generated file - open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!"; + if($gcov_vers<7) + { + open FH, '<', "$_.gcov" or die "open(<$_.gcov): $!"; + } + else + { + my $f=substr $_, 0, -5; + open FH, '<', "$f.gcov" or die "open(<$f.gcov): $!"; + undef $f; + } my $fname; while (<FH>) { chomp; |