From 402dc016408ac87fb53118e63f95196a4319efbf Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 15 Jun 2015 16:31:41 +0300 Subject: [PATCH 1/6] Coverage info --- cmake/EthCompilerSettings.cmake | 7 ++++ getcoverage.sh | 33 +++++++++++++++++++ ...reCompiledContractsTransactionFiller.json} | 0 test/libethereum/state.cpp | 4 +-- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100755 getcoverage.sh rename test/libethereum/StateTestsFiller/{stPrecompiledContractsTransactionFiller.json => stPreCompiledContractsTransactionFiller.json} (100%) diff --git a/cmake/EthCompilerSettings.cmake b/cmake/EthCompilerSettings.cmake index 53535a489..4009b22a6 100644 --- a/cmake/EthCompilerSettings.cmake +++ b/cmake/EthCompilerSettings.cmake @@ -64,6 +64,13 @@ if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_C set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lprofiler") endif () +if (PROFILING AND (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU"))) + set(CMAKE_CXX_FLAGS "-g --coverage ${CMAKE_CXX_FLAGS}") + set(CMAKE_C_FLAGS "-g --coverage ${CMAKE_C_FLAGS}") + set(CMAKE_SHARED_LINKER_FLAGS "--coverage ${CMAKE_SHARED_LINKER_FLAGS} -lprofiler") + set(CMAKE_EXE_LINKER_FLAGS "--coverage ${CMAKE_EXE_LINKER_FLAGS} -lprofiler") +endif () + if (("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU") OR ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")) option(USE_LD_GOLD "Use GNU gold linker" ON) if (USE_LD_GOLD) diff --git a/getcoverage.sh b/getcoverage.sh new file mode 100755 index 000000000..a04ab78fe --- /dev/null +++ b/getcoverage.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +CPP_ETHEREUM_PATH=$(pwd) + +if [ ! -d "$CPP_ETHEREUM_PATH/build/test" ]; then + echo "You need to compile and build ethereum with cmake -DPROFILING option to the build dir!" + exit; +fi + +if which lcov >/dev/null; then + if which genhtml >/dev/null; then + echo Running testeth... + $($CPP_ETHEREUM_PATH/build/test/testeth) + echo Prepearing coverage info... + else + echo genhtml not found + exit; + fi +else + echo lcov not found + exit; +fi + +OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" + +TESTETH=$CPP_ETHEREUM_PATH/build/test/CMakeFiles/testeth.dir +lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/coverage.info +genhtml $OUTPUT_DIR/coverage.info --output-directory $OUTPUT_DIR/testeth + +echo "Coverage info should be located at: $CPP_ETHEREUM_PATH/build/test/coverage/testeth" +echo "Opening index..." + +xdg-open $CPP_ETHEREUM_PATH/build/test/coverage/testeth/index.html diff --git a/test/libethereum/StateTestsFiller/stPrecompiledContractsTransactionFiller.json b/test/libethereum/StateTestsFiller/stPreCompiledContractsTransactionFiller.json similarity index 100% rename from test/libethereum/StateTestsFiller/stPrecompiledContractsTransactionFiller.json rename to test/libethereum/StateTestsFiller/stPreCompiledContractsTransactionFiller.json diff --git a/test/libethereum/state.cpp b/test/libethereum/state.cpp index 5eb3c76c3..632e7982b 100644 --- a/test/libethereum/state.cpp +++ b/test/libethereum/state.cpp @@ -129,9 +129,9 @@ BOOST_AUTO_TEST_CASE(stPreCompiledContracts) dev::test::executeTests("stPreCompiledContracts", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } -BOOST_AUTO_TEST_CASE(stPrecompiledContractsTransaction) +BOOST_AUTO_TEST_CASE(stPreCompiledContractsTransaction) { - dev::test::executeTests("stPrecompiledContractsTransaction", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); + dev::test::executeTests("stPreCompiledContractsTransaction", "/StateTests",dev::test::getFolder(__FILE__) + "/StateTestsFiller", dev::test::doStateTests); } BOOST_AUTO_TEST_CASE(stLogTests) From 1959b140f9a628ec48fae59f195392465b0415fa Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 15 Jun 2015 18:27:00 +0300 Subject: [PATCH 2/6] Coverage script --- getcoverage.sh | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/getcoverage.sh b/getcoverage.sh index a04ab78fe..4c01bad46 100755 --- a/getcoverage.sh +++ b/getcoverage.sh @@ -7,8 +7,12 @@ if [ ! -d "$CPP_ETHEREUM_PATH/build/test" ]; then exit; fi +OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" +TESTETH=$CPP_ETHEREUM_PATH/build #/test/CMakeFiles/testeth.dir + if which lcov >/dev/null; then if which genhtml >/dev/null; then + lcov --directory $TESTETH --zerocounters echo Running testeth... $($CPP_ETHEREUM_PATH/build/test/testeth) echo Prepearing coverage info... @@ -21,13 +25,15 @@ else exit; fi -OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" - -TESTETH=$CPP_ETHEREUM_PATH/build/test/CMakeFiles/testeth.dir -lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/coverage.info -genhtml $OUTPUT_DIR/coverage.info --output-directory $OUTPUT_DIR/testeth +echo Cleaning previous report... +rm -r $OUTPUT_DIR/testeth +rm $OUTPUT_DIR/full_coverage.info +rm $OUTPUT_DIR/testeth_coverage.info +lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/full_coverage.info +lcov --extract $OUTPUT_DIR/full_coverage.info *cpp-ethereum/* --output-file $OUTPUT_DIR/testeth_coverage.info +genhtml $OUTPUT_DIR/testeth_coverage.info --output-directory $OUTPUT_DIR/testeth echo "Coverage info should be located at: $CPP_ETHEREUM_PATH/build/test/coverage/testeth" echo "Opening index..." -xdg-open $CPP_ETHEREUM_PATH/build/test/coverage/testeth/index.html +xdg-open $CPP_ETHEREUM_PATH/build/test/coverage/testeth/index.html & From b6ca0d7856818d4ec43e4a1e21fceb8b5d7a5838 Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 15 Jun 2015 20:07:11 +0300 Subject: [PATCH 3/6] Coerage Script --- getcoverage.sh | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/getcoverage.sh b/getcoverage.sh index 4c01bad46..446d584e6 100755 --- a/getcoverage.sh +++ b/getcoverage.sh @@ -2,38 +2,44 @@ CPP_ETHEREUM_PATH=$(pwd) -if [ ! -d "$CPP_ETHEREUM_PATH/build/test" ]; then - echo "You need to compile and build ethereum with cmake -DPROFILING option to the build dir!" - exit; +which $CPP_ETHEREUM_PATH/build/test/testeth >/dev/null 2>&1 +if [ $? != 0 ] +then + echo "You need to compile and build ethereum with cmake -DPROFILING option to the build dir!" + exit; fi OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" TESTETH=$CPP_ETHEREUM_PATH/build #/test/CMakeFiles/testeth.dir if which lcov >/dev/null; then - if which genhtml >/dev/null; then + if which genhtml >/dev/null; then lcov --directory $TESTETH --zerocounters echo Running testeth... - $($CPP_ETHEREUM_PATH/build/test/testeth) + $($CPP_ETHEREUM_PATH/build/test/testeth --all) + $($CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all) + $($CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all) echo Prepearing coverage info... - else + else echo genhtml not found exit; - fi + fi else - echo lcov not found - exit; + echo lcov not found + exit; +fi + +if [ -d "$OUTPUT_DIR" ]; then + echo Cleaning previous report... + rm -r $OUTPUT_DIR fi -echo Cleaning previous report... -rm -r $OUTPUT_DIR/testeth -rm $OUTPUT_DIR/full_coverage.info -rm $OUTPUT_DIR/testeth_coverage.info +mkdir $OUTPUT_DIR lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/full_coverage.info lcov --extract $OUTPUT_DIR/full_coverage.info *cpp-ethereum/* --output-file $OUTPUT_DIR/testeth_coverage.info genhtml $OUTPUT_DIR/testeth_coverage.info --output-directory $OUTPUT_DIR/testeth -echo "Coverage info should be located at: $CPP_ETHEREUM_PATH/build/test/coverage/testeth" +echo "Coverage info should be located at: $OUTPUT_DIR/testeth" echo "Opening index..." -xdg-open $CPP_ETHEREUM_PATH/build/test/coverage/testeth/index.html & +xdg-open $OUTPUT_DIR/testeth/index.html & From be45d62b6144c5ee8f0061bb5e0065ca93cbf33e Mon Sep 17 00:00:00 2001 From: Dimitry Date: Mon, 15 Jun 2015 21:08:22 +0300 Subject: [PATCH 4/6] Code Coverage: bash syntax --- getcoverage.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/getcoverage.sh b/getcoverage.sh index 446d584e6..ac50bf94b 100755 --- a/getcoverage.sh +++ b/getcoverage.sh @@ -16,9 +16,9 @@ if which lcov >/dev/null; then if which genhtml >/dev/null; then lcov --directory $TESTETH --zerocounters echo Running testeth... - $($CPP_ETHEREUM_PATH/build/test/testeth --all) - $($CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all) - $($CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all) + $CPP_ETHEREUM_PATH/build/test/testeth -t --all + $CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all + $CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all echo Prepearing coverage info... else echo genhtml not found From b381bc6f489b76b9986161f14fea0948a67b8769 Mon Sep 17 00:00:00 2001 From: Dimitry Date: Tue, 16 Jun 2015 01:26:11 +0300 Subject: [PATCH 5/6] Script Coverage --- getcoverage.sh | 40 +++++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/getcoverage.sh b/getcoverage.sh index ac50bf94b..8d34d733c 100755 --- a/getcoverage.sh +++ b/getcoverage.sh @@ -10,35 +10,37 @@ then fi OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" -TESTETH=$CPP_ETHEREUM_PATH/build #/test/CMakeFiles/testeth.dir +TESTETH=$CPP_ETHEREUM_PATH/build if which lcov >/dev/null; then if which genhtml >/dev/null; then - lcov --directory $TESTETH --zerocounters - echo Running testeth... - $CPP_ETHEREUM_PATH/build/test/testeth -t --all - $CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all - $CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all - echo Prepearing coverage info... + echo Cleaning previous report... + if [ -d "$OUTPUT_DIR" ]; then + rm -r $OUTPUT_DIR + fi + mkdir $OUTPUT_DIR + lcov --directory $TESTETH --zerocounters + lcov --capture --initial --directory $TESTETH --output-file $OUTPUT_DIR/coverage_base.info + + echo Running testeth... + $CPP_ETHEREUM_PATH/build/test/testeth --all + $CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all + $CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all + + echo Prepearing coverage info... + lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/coverage_test.info + lcov --add-tracefile $OUTPUT_DIR/coverage_base.info --add-tracefile $OUTPUT_DIR/coverage_test.info --output-file $OUTPUT_DIR/coverage_all.info + lcov --extract $OUTPUT_DIR/coverage_all.info *cpp-ethereum/* --output-file $OUTPUT_DIR/coverage_export.info + genhtml $OUTPUT_DIR/coverage_export.info --output-directory $OUTPUT_DIR/testeth else - echo genhtml not found - exit; + echo genhtml not found + exit; fi else echo lcov not found exit; fi -if [ -d "$OUTPUT_DIR" ]; then - echo Cleaning previous report... - rm -r $OUTPUT_DIR -fi - -mkdir $OUTPUT_DIR -lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/full_coverage.info -lcov --extract $OUTPUT_DIR/full_coverage.info *cpp-ethereum/* --output-file $OUTPUT_DIR/testeth_coverage.info -genhtml $OUTPUT_DIR/testeth_coverage.info --output-directory $OUTPUT_DIR/testeth - echo "Coverage info should be located at: $OUTPUT_DIR/testeth" echo "Opening index..." From be2ed88d2f6bc265906fee8a4f9589d92bb7d686 Mon Sep 17 00:00:00 2001 From: Dimitry Date: Tue, 16 Jun 2015 15:25:29 +0300 Subject: [PATCH 6/6] Coverage script --- getcoverage.sh | 38 +++++++++++++++++++++++++++----------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/getcoverage.sh b/getcoverage.sh index 8d34d733c..196629170 100755 --- a/getcoverage.sh +++ b/getcoverage.sh @@ -1,17 +1,33 @@ #!/bin/bash CPP_ETHEREUM_PATH=$(pwd) - -which $CPP_ETHEREUM_PATH/build/test/testeth >/dev/null 2>&1 +BUILD_DIR=$CPP_ETHEREUM_PATH/build +TEST_MODE="" + +for i in "$@" +do +case $i in + -builddir) + shift + ((i++)) + BUILD_DIR=${!i} + shift + ;; + --all) + TEST_MODE="--all" + shift + ;; +esac +done + +which $BUILD_DIR/test/testeth >/dev/null 2>&1 if [ $? != 0 ] then echo "You need to compile and build ethereum with cmake -DPROFILING option to the build dir!" exit; fi -OUTPUT_DIR="$CPP_ETHEREUM_PATH/build/test/coverage" -TESTETH=$CPP_ETHEREUM_PATH/build - +OUTPUT_DIR=$BUILD_DIR/test/coverage if which lcov >/dev/null; then if which genhtml >/dev/null; then echo Cleaning previous report... @@ -19,16 +35,16 @@ if which lcov >/dev/null; then rm -r $OUTPUT_DIR fi mkdir $OUTPUT_DIR - lcov --directory $TESTETH --zerocounters - lcov --capture --initial --directory $TESTETH --output-file $OUTPUT_DIR/coverage_base.info + lcov --directory $BUILD_DIR --zerocounters + lcov --capture --initial --directory $BUILD_DIR --output-file $OUTPUT_DIR/coverage_base.info echo Running testeth... - $CPP_ETHEREUM_PATH/build/test/testeth --all - $CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit --all - $CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit --all + $CPP_ETHEREUM_PATH/build/test/testeth $TEST_MODE + $CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit $TEST_MODE + $CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit $TEST_MODE echo Prepearing coverage info... - lcov --capture --directory $TESTETH --output-file $OUTPUT_DIR/coverage_test.info + lcov --capture --directory $BUILD_DIR --output-file $OUTPUT_DIR/coverage_test.info lcov --add-tracefile $OUTPUT_DIR/coverage_base.info --add-tracefile $OUTPUT_DIR/coverage_test.info --output-file $OUTPUT_DIR/coverage_all.info lcov --extract $OUTPUT_DIR/coverage_all.info *cpp-ethereum/* --output-file $OUTPUT_DIR/coverage_export.info genhtml $OUTPUT_DIR/coverage_export.info --output-directory $OUTPUT_DIR/testeth