fix the tools/test_coverage.sh script

This commit is contained in:
arvidn 2019-09-14 19:31:31 +02:00 committed by Arvid Norberg
parent 08b6a112c0
commit 3168de21f9
3 changed files with 103 additions and 30 deletions

View File

@ -425,6 +425,9 @@ feature sanitize : off rtc on : composite propagated link-incompatible ;
# RTC (runtime check) is an msvc feature
feature.compose <sanitize>rtc : <cflags>/RTCc <cflags>/RTCsu ;
feature test-coverage : off on : composite propagated link-incompatible ;
feature.compose <test-coverage>on : <cflags>--coverage <linkflags>--coverage ;
feature i2p : on off : composite propagated ;
feature.compose <i2p>on : <define>TORRENT_USE_I2P=1 ;
feature.compose <i2p>off : <define>TORRENT_USE_I2P=0 ;

View File

@ -29,8 +29,9 @@ def clean():
'*.cpp.rej',
'*.hpp.orig',
'*.hpp.rej',
'*.hpp.gcov',
'*.cpp.gcov',
'*.gcov',
'*.gcno',
'*.gcda',
'Makefile.in',
'Makefile',
'lib*.a',

View File

@ -1,45 +1,81 @@
#!/bin/bash
OBJECT_PATH=bin/gcc-4.8/debug/asserts-off/boost-source/deprecated-functions-off/export-extra-on/invariant-checks-off/link-static/test-coverage-on/threading-multi/src
# $1 = test_name
# $2 = filename pattern for tested source files
# $3 = optional bjam arguments
function run_test {
set +e
rm $OBJECT_PATH/*.gcda
set -e
if [[ ! -f test-coverage/coverage_$1_full ]]; then
cd test
B2_ARGS='sanitize=off asserts=off invariant-checks=off link=static deprecated-functions=off debug-iterators=off test-coverage=on picker-debugging=off -j4'
bjam $B2_ARGS $1 testing.execute=off
EXE_PATH=$(ls -d bin/$1.test/*/debug/debug-iterators-off/deprecated-functions-off/export-extra-on/link-static/test-coverage-on/threading-multi)
cd test
# force running the test
rm -f $EXE_PATH/$1.output
rm -f $EXE_PATH/$1.run
rm -f $EXE_PATH/$1.test
cd ..
# expand the pattern to find the path to the object files
OBJECT_PATH=$(ls -d bin/*/debug/debug-iterators-off/deprecated-functions-off/export-extra-on/link-static/test-coverage-on/threading-multi)
# clear counters from last run
rm -f $OBJECT_PATH/src/*.gcda
rm -f $OBJECT_PATH/e25519/src/*.gcda
rm -f test/$EXE_PATH/*.gcda
cd test
# now run the test
bjam $B2_ARGS $1 -l250
cd ..
set +e
bjam asserts=off invariant-checks=off link=static deprecated-functions=off debug-iterators=off test-coverage=on picker-debugging=off -j4 $1
set -e
cd ..
lcov --base-directory test -d test/$EXE_PATH -d $OBJECT_PATH/src -d $OBJECT_PATH/ed25519/src -c -o test-coverage/coverage_$1_full --exclude "/usr/*" --exclude "/Applications/Xcode.app/*" --exclude "*/boost/*"
fi
lcov --extract test-coverage/coverage_$1_full "$2" -o test-coverage/coverage_$1
lcov -d $OBJECT_PATH/ -c -o coverage_$1_full
lcov --extract coverage_$1_full "$2" -o test-coverage/coverage_$1
if [ ! -f test-coverage/coverage_all ]; then
cp test-coverage/coverage_$1 test-coverage/coverage_all
else
lcov --add-tracefile test-coverage/coverage_$1 --add-tracefile test-coverage/coverage_all -o test-coverage/coverage_all
fi
rm coverage_$1_full
if [[ $# > 2 ]]; then
lcov --extract test-coverage/coverage_$1_full "$3" -o test-coverage/coverage_$1
lcov --add-tracefile test-coverage/coverage_$1 --add-tracefile test-coverage/coverage_all -o test-coverage/coverage_all
fi
if [[ $# > 3 ]]; then
lcov --extract test-coverage/coverage_$1_full "$4" -o test-coverage/coverage_$1
lcov --add-tracefile test-coverage/coverage_$1 --add-tracefile test-coverage/coverage_all -o test-coverage/coverage_all
fi
set +e
}
# force rebuilding and rerunning the unit tests
cd test
set +e
rm -rf bin
set -e
cd ..
mkdir -p test-coverage
rm -f test-coverage/coverage_all
set +e
mkdir test-coverage
rm test-coverage/coverage_all
set -e
run_test test_bloom_filter "*/bloom_filter.*" -a
run_test test_create_torrent "*/create_torrent.*"
run_test test_bandwidth_limiter "*/bandwidth_*.*"
run_test test_alloca "*/alloca.hpp"
run_test test_generate_peer_id "*/generate_peer_id.*"
run_test test_file_progress "*/file_progress.*"
run_test test_stack_allocator "*/stack_allocator.*"
run_test test_linked_list "*/linked_list.*"
run_test test_enum_net "*/broadcast_socket.*"
run_test test_stat_cache "*/stat_cache.*"
run_test test_dos_blocker "*/dos_blocker.*"
run_test test_fence "*/disk_job_fence.*"
run_test test_settings_pack "*/settings_pack.*"
run_test test_timestamp_history "*/timestamp_history.*"
run_test test_merkle "*/merkle.*"
run_test test_resolve_links "*/resolve_links.*"
run_test test_heterogeneous_queue "*/heterogeneous_queue.*"
run_test test_socket_io "*/socket_io.*"
run_test test_peer_priority "*/torrent_peer.*"
run_test test_tailqueue "*/tailqueue.*"
run_test test_bencoding "*/entry.*" "*/bencode.*" "*/bdecode.*"
run_test test_bdecode "*/bdecode.*"
run_test test_io "*/io.hpp"
run_test test_block_cache "*/block_cache.*"
run_test test_peer_classes "*/peer_class*.*"
run_test test_bloom_filter "*/bloom_filter.*"
run_test test_sha1_hash "*/sha1_hash.*"
run_test test_identify_client "*/identify_client.*"
run_test test_packet_buffer "*/packet_buffer.*"
@ -48,7 +84,6 @@ run_test test_bitfield "*/bitfield.*"
run_test test_alert_manager "*/alert_manager.*"
run_test test_alert_types "*/alert_types.*"
run_test test_dht "*/kademlia/*"
run_test test_bdecode "*/bdecode.*"
run_test test_piece_picker "*/piece_picker.*"
run_test test_torrent_info "*/torrent_info.*"
run_test test_part_file "*/part_file.*"
@ -61,8 +96,42 @@ run_test test_file_storage "*/file_storage.*"
run_test test_storage "*/storage.*"
run_test test_xml "*/xml_parse.*"
run_test test_sliding_average "*/sliding_average.*"
run_test test_string "*/escape_string.*"
run_test test_string "*/escape_string.*" "*/string_util.*"
run_test test_utf8 "*/ConvertUTF.*"
run_test test_hasher "*/hasher.*"
run_test test_hasher512 "*/hasher512.*"
run_test test_span "*/span.hpp"
run_test test_crc32 "*/crc32c.*"
run_test test_ffs "*/ffs.cpp"
run_test test_ed25519 "*/ed25519/src/*"
run_test test_receive_buffer "*/receive_buffer.*"
run_test test_magnet "*/magnet_uri.*"
run_test test_session "*/session_impl.*" "*/session.*"
run_test test_remove_torrent "*/session_impl.*"
run_test test_read_piece "*/torrent.*"
run_test test_session_params "*/session.*"
run_test test_buffer "*/buffer.*"
run_test test_file "*/file.*"
run_test test_read_resume "*/read_resume_data.*" "*/write_resume_data.*"
run_test test_resume "*/torrent.*"
run_test test_checking "*/torrent.*"
run_test test_pe_crypto "*/pe_crypto.*"
run_test test_remap_files "*/file_storage.*" "*/torrent.*"
run_test test_time_critical "*/torrent.*" "*/peer_connection.*" "*/bt_peer_connection.*"
run_test test_pex "*/ut_pex.*"
run_test test_checking "*/torrent.*" "*/disk_io_thread.*"
run_test test_url_seed "*/web_peer_connection.*"
run_test test_web_seed "*/web_peer_connection.*"
run_test test_web_seed_redirect "*/web_peer_connection.*"
run_test test_web_seed_socks4 "*/web_peer_connection.*"
run_test test_web_seed_socks5 "*/web_peer_connection.*"
run_test test_web_seed_socks5_pw "*/web_peer_connection.*"
run_test test_web_seed_http "*/web_peer_connection.*"
run_test test_web_seed_http_pw "*/web_peer_connection.*"
run_test test_web_seed_chunked "*/web_peer_connection.*"
run_test test_web_seed_ban "*/web_peer_connection.*"
run_test test_torrent "*/torrent.*"
run_test test_auto_unchoke "*/session_impl.*"
genhtml -o test-coverage/ -t $1 --num-spaces=4 test-coverage/coverage_all
genhtml -o test-coverage/ -t libtorrent-unit-tests --num-spaces=4 test-coverage/coverage_all