From b46de5d23cdad135a87eaa3bd1564e795cd8523d Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 29 Mar 2023 13:56:07 +0000 Subject: [PATCH 1/3] Use gcovr to process code coverage data for better coverage reporting, including branch coverage --- .github/workflows/sonar-scan.yml | 21 +++++---------------- sonar-project.properties | 7 ++++++- 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/.github/workflows/sonar-scan.yml b/.github/workflows/sonar-scan.yml index 230a275c4..14bd6508e 100644 --- a/.github/workflows/sonar-scan.yml +++ b/.github/workflows/sonar-scan.yml @@ -50,6 +50,7 @@ jobs: sudo apt-get install -y --allow-downgrades openssl=${openssl_ver} libssl-dev=${libssl_ver} sudo apt-get install -y \ ccache \ + gcovr \ parallel \ libboost-thread-dev \ libboost-iostreams-dev \ @@ -184,23 +185,11 @@ jobs: df -h - name: Prepare for scanning with SonarScanner run: | - find _build/libraries/[acdenptuw]*/CMakeFiles/*.dir \ - _build/libraries/plugins/*/CMakeFiles/*.dir \ - -type d -print \ - | while read d; do \ - tmpd="${d:7}"; \ - srcd="${tmpd/CMakeFiles*.dir/.}"; \ - gcov -o "$d" "${srcd}"/*.[ch][px][px] \ - "${srcd}"/include/graphene/*/*.[ch][px][px] ; \ - done >/dev/null - find _build/programs/[cdgjsw]*/CMakeFiles/*.dir \ - -type d -print \ - | while read d; do \ - tmpd="${d:7}"; \ - srcd="${tmpd/CMakeFiles*.dir/.}"; \ - gcov -o "$d" "${srcd}"/*.[ch][px][px] ; \ - done >/dev/null programs/build_helpers/set_sonar_branch_for_github_actions sonar-project.properties + pushd _build + gcovr --version + gcovr --exclude-unreachable-branches --sonarqube ../coverage.xml -r .. + popd - name: Scan with SonarScanner env: # to get access to secrets.SONAR_TOKEN, provide GITHUB_TOKEN diff --git a/sonar-project.properties b/sonar-project.properties index 8796e257e..c6b9acde7 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -20,7 +20,12 @@ sonar.tests=tests sonar.exclusions=programs/build_helper/**/*,libraries/fc/**/*,libraries/egenesis/egenesis_full.cpp sonar.sources=libraries,programs sonar.cfamily.build-wrapper-output=bw-output -sonar.cfamily.gcov.reportsPath=. + +# Note: +# It is hard to get the gcov sensor working, but gcovr works. +# See https://community.sonarsource.com/t/code-coverage-incorrect-for-c-gcov-project/41837/5 +#sonar.cfamily.gcov.reportsPath=. +sonar.coverageReportPaths=coverage.xml # Decide which tree the current build belongs to in SonarCloud. # Managed by the `set_sonar_branch*` script(s) when building with CI. From 11b2a81dfb1b2f2a6e80a10075067eed25ac8e9c Mon Sep 17 00:00:00 2001 From: abitmore Date: Wed, 29 Mar 2023 19:43:10 +0000 Subject: [PATCH 2/3] Bump FC --- libraries/fc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/fc b/libraries/fc index 4d024a83b..2405393e4 160000 --- a/libraries/fc +++ b/libraries/fc @@ -1 +1 @@ -Subproject commit 4d024a83b774da0e186c0c6c070e695f563da373 +Subproject commit 2405393e40219b8ff3a87ccbcc3de14e32886dda From f927efc45a9b7fcb12eeb500595754663797d8f5 Mon Sep 17 00:00:00 2001 From: abitmore Date: Thu, 30 Mar 2023 09:41:47 +0000 Subject: [PATCH 3/3] Fix macOS build Type "long" is not reflected in macOS, so avoid using it implicitly in tests --- tests/cli/main.cpp | 4 ++-- tests/tests/settle_tests.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/cli/main.cpp b/tests/cli/main.cpp index 41b3b632c..585b2dd41 100644 --- a/tests/cli/main.cpp +++ b/tests/cli/main.cpp @@ -1246,8 +1246,8 @@ BOOST_FIXTURE_TEST_CASE( cli_confidential_tx_test, cli_fixture ) // then confirm that balances are received, and then analyze the range // prooofs to make sure the mantissa length does not reveal approximate // balance (issue #480). - std::map to_list = {{"alice",100000000000}, - {"bob", 1000000000}}; + std::map to_list = {{"alice",100000000000LL}, + {"bob", 1000000000LL}}; vector bconfs; auto core_asset = W.get_asset("1.3.0"); BOOST_TEST_MESSAGE("Sending blind transactions to alice and bob"); diff --git a/tests/tests/settle_tests.cpp b/tests/tests/settle_tests.cpp index 5fef6aeed..2d879f135 100644 --- a/tests/tests/settle_tests.cpp +++ b/tests/tests/settle_tests.cpp @@ -1551,7 +1551,7 @@ BOOST_AUTO_TEST_CASE( create_bitassets ) transfer( committee_account, rachelregistrar_id, asset( 10000000 ) ); transfer( committee_account, rachelreferrer_id, asset( 10000000 ) ); transfer( committee_account, rachel.get_id(), asset( 10000000) ); - transfer( committee_account, paul_id, asset( 10000000000 ) ); + transfer( committee_account, paul_id, asset( 10000000000LL ) ); asset_update_operation op; op.issuer = biteur.issuer;