Enabling code coverage does not work #308

Open
opened 11 months ago by duke · 2 comments
duke commented 11 months ago
Owner

The ./build.sh --enable-lcov command should enable code coverage files to be generated which can be used with make cov but it doesn't work :

 .~~~~~~~~~~~~~~~~.
{{ Building Hush!! }}
 `~~~~~~~~~~~~~~~~`
        \   ^__^
         \  (@@)\_______            
            (__)\ HUSH  )\/\      $
    z        zz ||----w |      z  |
zz  zz  z       || z   ||xxx   z z|z zz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz
+ LCOV_ARG=
+ HARDENING_ARG=--enable-hardening
+ TEST_ARG=
+ '[' x--disable-tests = x--enable-lcov ']'
+ '[' x--disable-tests = x--disable-tests ']'
+ TEST_ARG=--enable-tests=no
+ shift
+ MINING_ARG=
+ '[' x--enable-lcov = x--disable-mining ']'
+ eval make --version
++ make --version
+ head -n2
GNU Make 4.2.1
Built for x86_64-pc-linux-gnu
+ as --version
+ head -n1
GNU assembler (GNU Binutils for Ubuntu) 2.32
+ as --version
+ tail -n1
This assembler was configured for a target of `x86_64-linux-gnu'.
+ ld -v
GNU ld (GNU Binutils for Ubuntu) 2.32
+ HOST=x86_64-unknown-linux-gnu
+ BUILD=x86_64-unknown-linux-gnu
+ make --enable-lcov -C ./depends/ V=1
make: unrecognized option '--enable-lcov'
Usage: make [options] [target] ...

From this comment in util/build.sh :

# If --enable-lcov is the first argument, enable lcov coverage support:
LCOV_ARG=''
HARDENING_ARG='--enable-hardening'
TEST_ARG=''
if [ "x${1:-}" = 'x--enable-lcov' ]
then
    LCOV_ARG='--enable-lcov'
    HARDENING_ARG='--disable-hardening'
    shift
elif [ "x${1:-}" = 'x--disable-tests' ]
then
    TEST_ARG='--enable-tests=no'
    shift
fi

# If --disable-mining is the next argument, disable mining code:
MINING_ARG=''
if [ "x${1:-}" = 'x--disable-mining' ]
then
    MINING_ARG='--enable-mining=no'
    shift
fi

it seems that --enable-lcov must be the first argument, but we always pass in --disable-tests as the first argument, so the code to detect code coverage doesn't work. The way it fails seems to be it passes the argument to make instead of the compiler, and make does not know anything about --enable-lcov and fails.

The `./build.sh --enable-lcov` command should enable code coverage files to be generated which can be used with `make cov` but it doesn't work : ``` .~~~~~~~~~~~~~~~~. {{ Building Hush!! }} `~~~~~~~~~~~~~~~~` \ ^__^ \ (@@)\_______ (__)\ HUSH )\/\ $ z zz ||----w | z | zz zz z || z ||xxx z z|z zz zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz + LCOV_ARG= + HARDENING_ARG=--enable-hardening + TEST_ARG= + '[' x--disable-tests = x--enable-lcov ']' + '[' x--disable-tests = x--disable-tests ']' + TEST_ARG=--enable-tests=no + shift + MINING_ARG= + '[' x--enable-lcov = x--disable-mining ']' + eval make --version ++ make --version + head -n2 GNU Make 4.2.1 Built for x86_64-pc-linux-gnu + as --version + head -n1 GNU assembler (GNU Binutils for Ubuntu) 2.32 + as --version + tail -n1 This assembler was configured for a target of `x86_64-linux-gnu'. + ld -v GNU ld (GNU Binutils for Ubuntu) 2.32 + HOST=x86_64-unknown-linux-gnu + BUILD=x86_64-unknown-linux-gnu + make --enable-lcov -C ./depends/ V=1 make: unrecognized option '--enable-lcov' Usage: make [options] [target] ... ``` From this comment in util/build.sh : ``` # If --enable-lcov is the first argument, enable lcov coverage support: LCOV_ARG='' HARDENING_ARG='--enable-hardening' TEST_ARG='' if [ "x${1:-}" = 'x--enable-lcov' ] then LCOV_ARG='--enable-lcov' HARDENING_ARG='--disable-hardening' shift elif [ "x${1:-}" = 'x--disable-tests' ] then TEST_ARG='--enable-tests=no' shift fi # If --disable-mining is the next argument, disable mining code: MINING_ARG='' if [ "x${1:-}" = 'x--disable-mining' ] then MINING_ARG='--enable-mining=no' shift fi ``` it seems that --enable-lcov must be the first argument, but we always pass in --disable-tests as the first argument, so the code to detect code coverage doesn't work. The way it fails seems to be it passes the argument to `make` instead of the compiler, and `make` does not know anything about `--enable-lcov` and fails.
duke added the
build
bug
labels 11 months ago
Poster
Owner

This diff allowed me to build with coverage :

diff --git a/build.sh b/build.sh
index 7bdf5f93d..0d2ba773a 100755
--- a/build.sh
+++ b/build.sh
@@ -7,7 +7,8 @@ set -eu -o pipefail
 
 # run correct build script for detected OS
 if [[ "$OSTYPE" == "linux-gnu"* ]]; then
-    ./util/build.sh --disable-tests $@
+    # ./util/build.sh --enable-lcov --disable-tests $@
+    ./util/build.sh --enable-lcov $@
 elif [[ "$OSTYPE" == "darwin"* ]]; then
     ./util/build-mac.sh --disable-tests $@
 elif [[ "$OSTYPE" == "msys"* ]]; then

so we need to improve build.sh to look at $1 and if it's --enable-lcov then don't pass in --disable-tests . Using both --enable-lcov and --disable-tests is not supported.

apt install lcov was also needed.

This diff allowed me to build with coverage : ``` diff --git a/build.sh b/build.sh index 7bdf5f93d..0d2ba773a 100755 --- a/build.sh +++ b/build.sh @@ -7,7 +7,8 @@ set -eu -o pipefail # run correct build script for detected OS if [[ "$OSTYPE" == "linux-gnu"* ]]; then - ./util/build.sh --disable-tests $@ + # ./util/build.sh --enable-lcov --disable-tests $@ + ./util/build.sh --enable-lcov $@ elif [[ "$OSTYPE" == "darwin"* ]]; then ./util/build-mac.sh --disable-tests $@ elif [[ "$OSTYPE" == "msys"* ]]; then ``` so we need to improve build.sh to look at `$1` and if it's --enable-lcov then don't pass in --disable-tests . Using both --enable-lcov and --disable-tests is not supported. `apt install lcov` was also needed.
Poster
Owner

make cov runs for a bit and does stuff but ends with this error :

Reading tracefile leveldb_baseline.info
lcov: ERROR: no valid records found in tracefile leveldb_baseline.info
make: *** [Makefile:1123: leveldb_baseline_filtered.info] Error 255

`make cov` runs for a bit and does stuff but ends with this error : ``` Reading tracefile leveldb_baseline.info lcov: ERROR: no valid records found in tracefile leveldb_baseline.info make: *** [Makefile:1123: leveldb_baseline_filtered.info] Error 255 ```
duke added the
medium priority
label 11 months ago
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date

No due date set.

Dependencies

This issue currently doesn't have any dependencies.

Loading…
There is no content yet.