From eda8227d80b3d1f00a346974e7a52c2327602a75 Mon Sep 17 00:00:00 2001 From: arvidn Date: Wed, 14 Nov 2018 14:48:05 +0100 Subject: [PATCH] simplify test Jamfile by making each test its own target. Make test_lsd explicit and don't run it on travis OSX, since it can't get the socket there --- .travis.yml | 6 +- test/Jamfile | 221 +++++++++++++++++++++---------------------- test/Makefile.am | 1 - test/test_random.cpp | 66 ------------- 4 files changed, 114 insertions(+), 180 deletions(-) delete mode 100644 test/test_random.cpp diff --git a/.travis.yml b/.travis.yml index e41164d79..588951c87 100644 --- a/.travis.yml +++ b/.travis.yml @@ -220,7 +220,11 @@ script: # libtorrent is the name of the test suite target - cd test - 'if [ "$tests" == "1" ]; then - travis_retry bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant libtorrent test_natpmp enum_if -l300 && + travis_retry bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant -l300 && + travis_retry bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant test_natpmp enum_if -l300 && + if [[ $TRAVIS_OS_NAME != "osx" ]]; then + travis_retry bjam -j3 warnings-as-errors=on warnings=all crypto=$crypto debug-iterators=on picker-debugging=on asserts=on invariant-checks=full $toolset variant=$variant test_lsd -l300; + fi && if [ "$coverage" == "1" ]; then codecov --root .. --gcov-exec gcov-5; fi; diff --git a/test/Jamfile b/test/Jamfile index b1bb8dfb1..f6765f480 100644 --- a/test/Jamfile +++ b/test/Jamfile @@ -101,128 +101,124 @@ explicit test_natpmp ; explicit enum_if ; explicit stage_enum_if ; -test-suite libtorrent : - [ run - test_primitives.cpp - test_io.cpp - test_create_torrent.cpp - test_packet_buffer.cpp - test_timestamp_history.cpp - test_bloom_filter.cpp - test_identify_client.cpp - test_merkle.cpp - test_resolve_links.cpp - test_heterogeneous_queue.cpp - test_ip_voter.cpp - test_sliding_average.cpp - test_socket_io.cpp -# test_random.cpp - test_part_file.cpp - test_peer_list.cpp - test_torrent_info.cpp - test_time.cpp - test_file_storage.cpp - test_peer_priority.cpp - test_threads.cpp - test_tailqueue.cpp - test_bandwidth_limiter.cpp - test_buffer.cpp - test_bencoding.cpp - test_bdecode.cpp - test_http_parser.cpp - test_xml.cpp - test_ip_filter.cpp - test_hasher.cpp - test_block_cache.cpp - test_peer_classes.cpp - test_settings_pack.cpp - test_fence.cpp - test_dos_blocker.cpp - test_stat_cache.cpp - test_enum_net.cpp - test_linked_list.cpp - test_stack_allocator.cpp - test_file_progress.cpp - test_generate_peer_id.cpp - test_alloca.cpp ] +run + test_primitives.cpp + test_io.cpp + test_create_torrent.cpp + test_packet_buffer.cpp + test_timestamp_history.cpp + test_bloom_filter.cpp + test_identify_client.cpp + test_merkle.cpp + test_resolve_links.cpp + test_heterogeneous_queue.cpp + test_ip_voter.cpp + test_sliding_average.cpp + test_socket_io.cpp + test_part_file.cpp + test_peer_list.cpp + test_torrent_info.cpp + test_time.cpp + test_file_storage.cpp + test_peer_priority.cpp + test_threads.cpp + test_tailqueue.cpp + test_bandwidth_limiter.cpp + test_buffer.cpp + test_bencoding.cpp + test_bdecode.cpp + test_http_parser.cpp + test_xml.cpp + test_ip_filter.cpp + test_hasher.cpp + test_block_cache.cpp + test_peer_classes.cpp + test_settings_pack.cpp + test_fence.cpp + test_dos_blocker.cpp + test_stat_cache.cpp + test_enum_net.cpp + test_linked_list.cpp + test_stack_allocator.cpp + test_file_progress.cpp + test_generate_peer_id.cpp + test_alloca.cpp ; - [ run test_listen_socket.cpp - : : : openssl:/torrent//ssl - openssl:/torrent//crypto - ] +run test_listen_socket.cpp + : : : openssl:/torrent//ssl + openssl:/torrent//crypto ; - [ run test_piece_picker.cpp ] +run test_piece_picker.cpp ; - [ run test_dht.cpp - test_dht_storage.cpp - test_direct_dht.cpp - test_hasher512.cpp - : : : openssl:/torrent//ssl - openssl:/torrent//crypto - ] +run test_dht.cpp + test_dht_storage.cpp + test_direct_dht.cpp + test_hasher512.cpp + : : : openssl:/torrent//ssl + openssl:/torrent//crypto ; - [ run test_string.cpp test_utf8.cpp ] +run test_string.cpp test_utf8.cpp ; - [ run test_sha1_hash.cpp ] - [ run test_span.cpp ] - [ run test_bitfield.cpp ] - [ run test_crc32.cpp ] - [ run test_ffs.cpp ] - [ run test_ed25519.cpp ] - [ run test_gzip.cpp ] - [ run test_receive_buffer.cpp ] - [ run test_alert_manager.cpp ] - [ run test_alert_types.cpp ] - [ run test_magnet.cpp ] - [ run test_storage.cpp ] - [ run test_session.cpp ] - [ run test_session_params.cpp ] - [ run test_read_piece.cpp ] - [ run test_remove_torrent.cpp ] - [ run test_flags.cpp ] +run test_sha1_hash.cpp ; +run test_span.cpp ; +run test_bitfield.cpp ; +run test_crc32.cpp ; +run test_ffs.cpp ; +run test_ed25519.cpp ; +run test_gzip.cpp ; +run test_receive_buffer.cpp ; +run test_alert_manager.cpp ; +run test_alert_types.cpp ; +run test_magnet.cpp ; +run test_storage.cpp ; +run test_session.cpp ; +run test_session_params.cpp ; +run test_read_piece.cpp ; +run test_remove_torrent.cpp ; +run test_flags.cpp ; - [ run test_file.cpp ] - [ run test_fast_extension.cpp ] - [ run test_privacy.cpp ] - [ run test_recheck.cpp ] - [ run test_read_resume.cpp ] - [ run test_resume.cpp ] - [ run test_ssl.cpp : : +run test_file.cpp ; +run test_fast_extension.cpp ; +run test_privacy.cpp ; +run test_recheck.cpp ; +run test_read_resume.cpp ; +run test_resume.cpp ; +run test_ssl.cpp : : + : openssl:/torrent//ssl + openssl:/torrent//crypto ; +run test_tracker.cpp ; +run test_checking.cpp ; +run test_url_seed.cpp ; +run test_web_seed.cpp ; +run test_web_seed_redirect.cpp ; +run test_web_seed_socks4.cpp ; +run test_web_seed_socks5.cpp ; +run test_web_seed_socks5_no_peers.cpp ; +run test_web_seed_socks5_pw.cpp ; +run test_web_seed_http.cpp ; +run test_web_seed_http_pw.cpp ; +run test_web_seed_chunked.cpp ; +run test_web_seed_ban.cpp ; +run test_pe_crypto.cpp ; + +run test_remap_files.cpp ; +run test_utp.cpp ; +run test_auto_unchoke.cpp ; +run test_http_connection.cpp : : : openssl:/torrent//ssl openssl:/torrent//crypto - ] - [ run test_tracker.cpp ] - [ run test_checking.cpp ] - [ run test_url_seed.cpp ] - [ run test_web_seed.cpp ] - [ run test_web_seed_redirect.cpp ] - [ run test_web_seed_socks4.cpp ] - [ run test_web_seed_socks5.cpp ] - [ run test_web_seed_socks5_no_peers.cpp ] - [ run test_web_seed_socks5_pw.cpp ] - [ run test_web_seed_http.cpp ] - [ run test_web_seed_http_pw.cpp ] - [ run test_web_seed_chunked.cpp ] - [ run test_web_seed_ban.cpp ] - [ run test_pe_crypto.cpp ] - - [ run test_remap_files.cpp ] - [ run test_utp.cpp ] - [ run test_auto_unchoke.cpp ] - [ run test_http_connection.cpp : : - : openssl:/torrent//ssl - openssl:/torrent//crypto - ] - [ run test_torrent.cpp ] - [ run test_transfer.cpp ] - [ run test_time_critical.cpp ] - [ run test_pex.cpp ] - [ run test_priority.cpp ] + ; +run test_torrent.cpp ; +run test_transfer.cpp ; +run test_time_critical.cpp ; +run test_pex.cpp ; +run test_priority.cpp ; # turn these tests into simulations - [ run test_upnp.cpp ] - [ run test_lsd.cpp ] - ; +run test_upnp.cpp ; + +run test_lsd.cpp ; +explicit test_lsd ; # these are the tests run on appveyor, while the flapping ones are being # transitioned into simulations @@ -231,6 +227,7 @@ alias win-tests : test_string test_dht test_sha1_hash + test_span test_bitfield test_crc32 test_pe_crypto diff --git a/test/Makefile.am b/test/Makefile.am index f91a65645..ec5149757 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -190,7 +190,6 @@ test_primitives_SOURCES = \ test_ip_voter.cpp \ test_sliding_average.cpp \ test_socket_io.cpp \ - test_random.cpp \ test_utf8.cpp \ test_gzip.cpp \ test_bitfield.cpp \ diff --git a/test/test_random.cpp b/test/test_random.cpp deleted file mode 100644 index cced2cebc..000000000 --- a/test/test_random.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - -Copyright (c) 2014, Arvid Norberg -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions -are met: - - * Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in - the documentation and/or other materials provided with the distribution. - * Neither the name of the author nor the names of its - contributors may be used to endorse or promote products derived - from this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -*/ - -#include "test.hpp" -#include "setup_transfer.hpp" -#include "libtorrent/random.hpp" - -#include - -using namespace lt; - -TORRENT_TEST(random) -{ - - const int repetitions = 200000; - - for (int byte = 0; byte < 4; ++byte) - { - std::array buckets; - buckets.fill(0); - - for (int i = 0; i < repetitions; ++i) - { - std::uint32_t val = lt::random(0xffffffff); - val >>= byte * 8; - ++buckets[val & 0xff]; - } - - for (std::size_t i = 0; i < 256; ++i) - { - const int expected = repetitions / 256; - // expect each bucket to be within 15% of the expected value - std::printf("%d: %f\n", int(i), double(buckets[i] - expected) * 100.0 / expected); - TEST_CHECK(std::abs(buckets[i] - expected) < expected / 6); - } - } -}