diff --git a/.ignore b/.ignore index 2328a66e6..d5fb93c96 100644 --- a/.ignore +++ b/.ignore @@ -2,7 +2,6 @@ !.justfile !.projectile !.unisonignore -!TODO.org 3rdparty/_distfiles 3rdparty/dr_wav 3rdparty/hedley diff --git a/scripts/scons_helpers/format-header.py b/scripts/scons_helpers/format-header.py index 554a7392f..00392065f 100644 --- a/scripts/scons_helpers/format-header.py +++ b/scripts/scons_helpers/format-header.py @@ -1,4 +1,5 @@ import datetime +import filecmp import fnmatch import os import re @@ -42,6 +43,8 @@ def make_guard(path): arr = ['roc', 'public_api', dirname, basename] else: arr = ['roc', 'public_api', basename] + elif dirname == '.': + arr = ['roc', basename] else: arr = [dirname, basename] while not arr[0].startswith('roc_') and arr[0] != 'roc': @@ -201,4 +204,5 @@ def walk_dir(directory, patterns): with tempfile.NamedTemporaryFile('w+') as fp: format_file(fp, path) fp.flush() - shutil.copy(fp.name, path) + if not filecmp.cmp(path, fp.name): + shutil.copy(fp.name, path) diff --git a/src/SConscript b/src/SConscript index 7eb112e80..32c9d51a8 100644 --- a/src/SConscript +++ b/src/SConscript @@ -267,10 +267,14 @@ if GetOption('enable_tests') or GetOption('enable_benchmarks'): common_test_env.Prepend(LIBS=[all_modules_libs]) if GetOption('enable_tests'): - test_main_object = common_test_env.Object('tests/test_main.cpp') + test_main_objects = [] + for src in common_test_env.Glob('tests/test_*.cpp'): + test_main_objects += common_test_env.Object(src) if GetOption('enable_benchmarks'): - bench_main_object = common_test_env.Object('tests/bench_main.cpp') + bench_main_objects = [] + for src in common_test_env.Glob('tests/bench_*.cpp'): + bench_main_objects += common_test_env.Object(src) test_targets = [] @@ -278,7 +282,8 @@ if GetOption('enable_tests') or GetOption('enable_benchmarks'): test_dir = 'tests/' + test_name test_env = common_test_env.DeepClone() - test_env.Append(CPPPATH=['#src/' + test_dir]) + test_env.Append(CPPPATH=['#src/tests']) + test_env.Append(CPPPATH=['#src/tests/' + test_name]) if test_name == 'public_api': if GetOption('disable_shared') and not GetOption('enable_static'): @@ -288,12 +293,12 @@ if GetOption('enable_tests') or GetOption('enable_benchmarks'): for kind in ['test', 'bench']: if kind == 'test': if GetOption('enable_tests'): - main_object = test_main_object + main_objects = test_main_objects else: continue else: if GetOption('enable_benchmarks'): - main_object = bench_main_object + main_objects = bench_main_objects else: continue @@ -310,7 +315,7 @@ if GetOption('enable_tests') or GetOption('enable_benchmarks'): if not sources: continue - sources_and_objects = sources + main_object + sanitizer_objects + sources_and_objects = sources + main_objects + sanitizer_objects if test_name == 'public_api': sources_and_objects += public_api_objects diff --git a/src/tests/public_api/test_context.cpp b/src/tests/public_api/test_context.cpp index 6addd8188..e182d23e7 100644 --- a/src/tests/public_api/test_context.cpp +++ b/src/tests/public_api/test_context.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_endpoint.cpp b/src/tests/public_api/test_endpoint.cpp index 4d123ebeb..a2497df7b 100644 --- a/src/tests/public_api/test_endpoint.cpp +++ b/src/tests/public_api/test_endpoint.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_loopback_encoder_2_decoder.cpp b/src/tests/public_api/test_loopback_encoder_2_decoder.cpp index a2ebd433d..241fc3839 100644 --- a/src/tests/public_api/test_loopback_encoder_2_decoder.cpp +++ b/src/tests/public_api/test_loopback_encoder_2_decoder.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/utils.h" #include "roc_core/macro_helpers.h" @@ -408,7 +407,7 @@ TEST(loopback_encoder_2_decoder, source_control) { TEST(loopback_encoder_2_decoder, source_repair) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } sender_conf.fec_encoding = ROC_FEC_ENCODING_RS8M; @@ -452,7 +451,7 @@ TEST(loopback_encoder_2_decoder, source_repair) { TEST(loopback_encoder_2_decoder, source_repair_losses) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } sender_conf.fec_encoding = ROC_FEC_ENCODING_RS8M; @@ -496,7 +495,7 @@ TEST(loopback_encoder_2_decoder, source_repair_losses) { TEST(loopback_encoder_2_decoder, source_repair_control) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } sender_conf.fec_encoding = ROC_FEC_ENCODING_RS8M; diff --git a/src/tests/public_api/test_loopback_sender_2_receiver.cpp b/src/tests/public_api/test_loopback_sender_2_receiver.cpp index 14247f8ad..277ff7ae3 100644 --- a/src/tests/public_api/test_loopback_sender_2_receiver.cpp +++ b/src/tests/public_api/test_loopback_sender_2_receiver.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/context.h" #include "test_helpers/proxy.h" #include "test_helpers/receiver.h" @@ -166,7 +165,7 @@ TEST(loopback_sender_2_receiver, rtp_rtcp) { TEST(loopback_sender_2_receiver, rs8m_without_losses) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } enum { Flags = test::FlagRS8M, SampleRate = 44100, FrameChans = 2, PacketChans = 2 }; @@ -192,7 +191,7 @@ TEST(loopback_sender_2_receiver, rs8m_without_losses) { TEST(loopback_sender_2_receiver, rs8m_with_losses) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } enum { @@ -232,7 +231,7 @@ TEST(loopback_sender_2_receiver, rs8m_with_losses) { TEST(loopback_sender_2_receiver, ldpc_without_losses) { if (!is_ldpc_supported()) { - return; + TEST_SKIP(); } enum { Flags = test::FlagLDPC, SampleRate = 44100, FrameChans = 2, PacketChans = 2 }; @@ -258,7 +257,7 @@ TEST(loopback_sender_2_receiver, ldpc_without_losses) { TEST(loopback_sender_2_receiver, ldpc_with_losses) { if (!is_ldpc_supported()) { - return; + TEST_SKIP(); } enum { @@ -632,7 +631,7 @@ TEST(loopback_sender_2_receiver, multitrack_separate_contexts) { // Smoke test for various counters, durations, etc. TEST(loopback_sender_2_receiver, metrics_measurements) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } enum { diff --git a/src/tests/public_api/test_plugin_plc.cpp b/src/tests/public_api/test_plugin_plc.cpp index 077744cf7..cae9ab713 100644 --- a/src/tests/public_api/test_plugin_plc.cpp +++ b/src/tests/public_api/test_plugin_plc.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/context.h" #include "test_helpers/proxy.h" #include "test_helpers/receiver.h" @@ -231,7 +230,7 @@ TEST_GROUP(plugin_plc) { // Check that all all packets were restored by FEC and not by PLC. TEST(plugin_plc, losses_restored_by_fec) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } enum { Flags = test::FlagRS8M | test::FlagLoseSomePkts }; @@ -284,7 +283,7 @@ TEST(plugin_plc, losses_restored_by_fec) { // Check that PLC was used to restore packets. TEST(plugin_plc, losses_restored_by_plc) { if (!is_rs8m_supported()) { - return; + TEST_SKIP(); } enum { diff --git a/src/tests/public_api/test_receiver.cpp b/src/tests/public_api/test_receiver.cpp index c2ae860d5..1895f854c 100644 --- a/src/tests/public_api/test_receiver.cpp +++ b/src/tests/public_api/test_receiver.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/macro_helpers.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_receiver_decoder.cpp b/src/tests/public_api/test_receiver_decoder.cpp index ce7b39e4b..caa8c129b 100644 --- a/src/tests/public_api/test_receiver_decoder.cpp +++ b/src/tests/public_api/test_receiver_decoder.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/macro_helpers.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_sender.cpp b/src/tests/public_api/test_sender.cpp index f6c7af9ee..8405a95e6 100644 --- a/src/tests/public_api/test_sender.cpp +++ b/src/tests/public_api/test_sender.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/macro_helpers.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_sender_encoder.cpp b/src/tests/public_api/test_sender_encoder.cpp index 1bedddda3..ef0aefe17 100644 --- a/src/tests/public_api/test_sender_encoder.cpp +++ b/src/tests/public_api/test_sender_encoder.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/macro_helpers.h" #include "roc_core/stddefs.h" diff --git a/src/tests/public_api/test_version.cpp b/src/tests/public_api/test_version.cpp index 77ac0994f..35fe88935 100644 --- a/src/tests/public_api/test_version.cpp +++ b/src/tests/public_api/test_version.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc/version.h" diff --git a/src/tests/roc_fec/test_block_encoder_decoder.cpp b/src/tests/roc_fec/test_block_encoder_decoder.cpp index 26f8d2d7a..69ee55da6 100644 --- a/src/tests/roc_fec/test_block_encoder_decoder.cpp +++ b/src/tests/roc_fec/test_block_encoder_decoder.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/mock_arena.h" #include "roc_core/array.h" diff --git a/src/tests/roc_fec/test_block_writer_reader.cpp b/src/tests/roc_fec/test_block_writer_reader.cpp index 73c134f4e..3304138d6 100644 --- a/src/tests/roc_fec/test_block_writer_reader.cpp +++ b/src/tests/roc_fec/test_block_writer_reader.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/packet_dispatcher.h" #include "roc_core/heap_arena.h" @@ -2592,7 +2591,7 @@ TEST(block_writer_reader, reader_oversized_repair_block) { TEST(block_writer_reader, reader_invalid_fec_scheme_source_packet) { if (CodecMap::instance().num_schemes() == 1) { - return; + TEST_SKIP(); } for (size_t n_scheme = 0; n_scheme < CodecMap::instance().num_schemes(); ++n_scheme) { @@ -2665,7 +2664,7 @@ TEST(block_writer_reader, reader_invalid_fec_scheme_source_packet) { TEST(block_writer_reader, reader_invalid_fec_scheme_repair_packet) { if (CodecMap::instance().num_schemes() == 1) { - return; + TEST_SKIP(); } for (size_t n_scheme = 0; n_scheme < CodecMap::instance().num_schemes(); ++n_scheme) { diff --git a/src/tests/roc_fec/test_block_writer_reader_duration.cpp b/src/tests/roc_fec/test_block_writer_reader_duration.cpp index 7682e1e4f..4e9e6da2c 100644 --- a/src/tests/roc_fec/test_block_writer_reader_duration.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_duration.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/packet_dispatcher.h" #include "roc_core/heap_arena.h" @@ -113,7 +112,7 @@ TEST_GROUP(block_writer_reader_duration) { TEST(block_writer_reader_duration, no_losses) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -155,7 +154,7 @@ TEST(block_writer_reader_duration, no_losses) { TEST(block_writer_reader_duration, lost_first_packet_in_first_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -202,7 +201,7 @@ TEST(block_writer_reader_duration, lost_first_packet_in_first_block) { TEST(block_writer_reader_duration, lost_first_packet_in_third_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -249,7 +248,7 @@ TEST(block_writer_reader_duration, lost_first_packet_in_third_block) { TEST(block_writer_reader_duration, lost_almost_every_packet) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -297,7 +296,7 @@ TEST(block_writer_reader_duration, lost_almost_every_packet) { TEST(block_writer_reader_duration, lost_single_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -349,7 +348,7 @@ TEST(block_writer_reader_duration, lost_single_block) { TEST(block_writer_reader_duration, resize_block_middle) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, diff --git a/src/tests/roc_fec/test_block_writer_reader_errors.cpp b/src/tests/roc_fec/test_block_writer_reader_errors.cpp index 2e3876fa3..0333aa6ab 100644 --- a/src/tests/roc_fec/test_block_writer_reader_errors.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_errors.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/mock_arena.h" #include "test_helpers/packet_dispatcher.h" #include "test_helpers/status_reader.h" @@ -134,12 +133,12 @@ TEST_GROUP(block_writer_reader_errors) { }; TEST(block_writer_reader_errors, writer_cant_resize_block) { - enum { BlockSize1 = 50, BlockSize2 = 60 }; - if (!fec_supported()) { - return; + TEST_SKIP(); } + enum { BlockSize1 = 50, BlockSize2 = 60 }; + core::ScopedPtr encoder( CodecMap::instance().new_block_encoder(codec_config, packet_factory, arena)); CHECK(encoder); @@ -178,12 +177,12 @@ TEST(block_writer_reader_errors, writer_cant_resize_block) { } TEST(block_writer_reader_errors, writer_cant_encode_packet) { - enum { BlockSize1 = 50, BlockSize2 = 60 }; - if (!fec_supported()) { - return; + TEST_SKIP(); } + enum { BlockSize1 = 50, BlockSize2 = 60 }; + test::MockArena mock_arena; core::ScopedPtr encoder( @@ -218,12 +217,12 @@ TEST(block_writer_reader_errors, writer_cant_encode_packet) { } TEST(block_writer_reader_errors, reader_cant_resize_block) { - enum { BlockSize1 = 50, BlockSize2 = 60 }; - if (!fec_supported()) { - return; + TEST_SKIP(); } + enum { BlockSize1 = 50, BlockSize2 = 60 }; + core::ScopedPtr encoder( CodecMap::instance().new_block_encoder(codec_config, packet_factory, arena)); @@ -288,12 +287,12 @@ TEST(block_writer_reader_errors, reader_cant_resize_block) { } TEST(block_writer_reader_errors, reader_cant_decode_packet) { - enum { BlockSize1 = 50, BlockSize2 = 60 }; - if (!fec_supported()) { - return; + TEST_SKIP(); } + enum { BlockSize1 = 50, BlockSize2 = 60 }; + core::ScopedPtr encoder( CodecMap::instance().new_block_encoder(codec_config, packet_factory, arena)); CHECK(encoder); @@ -371,7 +370,7 @@ TEST(block_writer_reader_errors, reader_cant_decode_packet) { TEST(block_writer_reader_errors, reader_cant_read_source_packet) { if (!fec_supported()) { - return; + TEST_SKIP(); } core::ScopedPtr encoder( @@ -418,7 +417,7 @@ TEST(block_writer_reader_errors, reader_cant_read_source_packet) { TEST(block_writer_reader_errors, reader_cant_read_repair_packet) { if (!fec_supported()) { - return; + TEST_SKIP(); } core::ScopedPtr encoder( @@ -465,7 +464,7 @@ TEST(block_writer_reader_errors, reader_cant_read_repair_packet) { TEST(block_writer_reader_errors, reader_cant_read_source_and_repair_packets) { if (!fec_supported()) { - return; + TEST_SKIP(); } core::ScopedPtr decoder( diff --git a/src/tests/roc_fec/test_block_writer_reader_peek.cpp b/src/tests/roc_fec/test_block_writer_reader_peek.cpp index 4f35e8eb7..fc47958f0 100644 --- a/src/tests/roc_fec/test_block_writer_reader_peek.cpp +++ b/src/tests/roc_fec/test_block_writer_reader_peek.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/packet_dispatcher.h" #include "roc_core/heap_arena.h" @@ -145,7 +144,7 @@ TEST_GROUP(block_writer_reader_peek) { // Check how peek works when there are no losses. TEST(block_writer_reader_peek, no_losses) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -183,7 +182,7 @@ TEST(block_writer_reader_peek, no_losses) { // Check that peek works with repaired packets. TEST(block_writer_reader_peek, repairs_in_the_middle_of_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -225,7 +224,7 @@ TEST(block_writer_reader_peek, repairs_in_the_middle_of_block) { // Check that peek skips lost packets in the middle of the block. TEST(block_writer_reader_peek, losses_in_the_middle_of_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -278,7 +277,7 @@ TEST(block_writer_reader_peek, losses_in_the_middle_of_block) { // Check that peek skips lost packets in the beginning of the block. TEST(block_writer_reader_peek, losses_in_the_beginning_of_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -334,7 +333,7 @@ TEST(block_writer_reader_peek, losses_in_the_beginning_of_block) { // the end of the block, but instead returns StatusDrain. TEST(block_writer_reader_peek, losses_in_the_end_of_block) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -391,7 +390,7 @@ TEST(block_writer_reader_peek, losses_in_the_end_of_block) { // Peek packet when there is loss, then deliver lost packet and peek again. TEST(block_writer_reader_peek, late_source_packets) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, @@ -464,7 +463,7 @@ TEST(block_writer_reader_peek, late_source_packets) { // and then peek again. TEST(block_writer_reader_peek, late_repair_packets) { if (!fec_supported()) { - return; + TEST_SKIP(); } test::PacketDispatcher dispatcher(source_parser, repair_parser, packet_factory, diff --git a/src/tests/roc_fec/test_composer.cpp b/src/tests/roc_fec/test_composer.cpp index f4735e6c5..a4bfa9b08 100644 --- a/src/tests/roc_fec/test_composer.cpp +++ b/src/tests/roc_fec/test_composer.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/heap_arena.h" #include "roc_fec/composer.h" diff --git a/src/tests/roc_fec/test_composer_parser.cpp b/src/tests/roc_fec/test_composer_parser.cpp index 48e9393fa..2694a49ec 100644 --- a/src/tests/roc_fec/test_composer_parser.cpp +++ b/src/tests/roc_fec/test_composer_parser.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/heap_arena.h" #include "roc_fec/composer.h" diff --git a/src/tests/roc_node/test_context.cpp b/src/tests/roc_node/test_context.cpp index 482175ea2..a29e97051 100644 --- a/src/tests/roc_node/test_context.cpp +++ b/src/tests/roc_node/test_context.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/heap_arena.h" #include "roc_node/context.h" diff --git a/src/tests/roc_node/test_receiver.cpp b/src/tests/roc_node/test_receiver.cpp index d82091513..055ea9145 100644 --- a/src/tests/roc_node/test_receiver.cpp +++ b/src/tests/roc_node/test_receiver.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_address/protocol.h" #include "roc_core/heap_arena.h" diff --git a/src/tests/roc_node/test_receiver_decoder.cpp b/src/tests/roc_node/test_receiver_decoder.cpp index a2c07485f..8a67f0a22 100644 --- a/src/tests/roc_node/test_receiver_decoder.cpp +++ b/src/tests/roc_node/test_receiver_decoder.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_address/interface.h" #include "roc_address/protocol.h" diff --git a/src/tests/roc_node/test_sender.cpp b/src/tests/roc_node/test_sender.cpp index 8eca8cda3..4dd04b3d8 100644 --- a/src/tests/roc_node/test_sender.cpp +++ b/src/tests/roc_node/test_sender.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_core/heap_arena.h" #include "roc_fec/codec_map.h" @@ -429,13 +429,13 @@ TEST(sender, endpoints_fec) { } TEST(sender, endpoints_fec_multiple_slots) { - Context context(context_config, arena); - LONGS_EQUAL(status::StatusOK, context.init_status()); - if (!fec::CodecMap::instance().has_scheme(packet::FEC_ReedSolomon_M8)) { - return; + TEST_SKIP(); } + Context context(context_config, arena); + LONGS_EQUAL(status::StatusOK, context.init_status()); + sender_config.fec_encoder.scheme = packet::FEC_ReedSolomon_M8; Sender sender(context, sender_config); @@ -707,7 +707,7 @@ TEST(sender, configure_errors) { LONGS_EQUAL(0, context.network_loop().num_ports()); } - { // multicast group: IP familty mismatch + { // multicast group: IP family mismatch Context context(context_config, arena); LONGS_EQUAL(status::StatusOK, context.init_status()); @@ -905,15 +905,15 @@ TEST(sender, recover) { } TEST(sender, port_sharing) { + if (!fec::CodecMap::instance().has_scheme(packet::FEC_ReedSolomon_M8)) { + TEST_SKIP(); + } + Context context(context_config, arena); LONGS_EQUAL(status::StatusOK, context.init_status()); LONGS_EQUAL(0, context.network_loop().num_ports()); - if (!fec::CodecMap::instance().has_scheme(packet::FEC_ReedSolomon_M8)) { - return; - } - sender_config.fec_encoder.scheme = packet::FEC_ReedSolomon_M8; { // source and repair shared: same empty config diff --git a/src/tests/roc_node/test_sender_encoder.cpp b/src/tests/roc_node/test_sender_encoder.cpp index 17b8c2bd8..bcd0f6ed5 100644 --- a/src/tests/roc_node/test_sender_encoder.cpp +++ b/src/tests/roc_node/test_sender_encoder.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_address/interface.h" #include "roc_address/protocol.h" diff --git a/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp index 9bd72f86e..f00410eda 100644 --- a/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp +++ b/src/tests/roc_pipeline/test_loopback_sink_2_source.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/frame_reader.h" #include "test_helpers/frame_writer.h" diff --git a/src/tests/roc_pipeline/test_pipeline_loop.cpp b/src/tests/roc_pipeline/test_pipeline_loop.cpp index 3a070a0c5..dd3c4ddd5 100644 --- a/src/tests/roc_pipeline/test_pipeline_loop.cpp +++ b/src/tests/roc_pipeline/test_pipeline_loop.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_audio/frame.h" #include "roc_core/cond.h" diff --git a/src/tests/roc_pipeline/test_receiver_endpoint.cpp b/src/tests/roc_pipeline/test_receiver_endpoint.cpp index 736ed6d87..0e41fb2ed 100644 --- a/src/tests/roc_pipeline/test_receiver_endpoint.cpp +++ b/src/tests/roc_pipeline/test_receiver_endpoint.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_address/protocol.h" #include "roc_audio/mixer.h" diff --git a/src/tests/roc_pipeline/test_receiver_loop.cpp b/src/tests/roc_pipeline/test_receiver_loop.cpp index 0149b6705..a5d67b5e0 100644 --- a/src/tests/roc_pipeline/test_receiver_loop.cpp +++ b/src/tests/roc_pipeline/test_receiver_loop.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/mock_scheduler.h" #include "roc_core/heap_arena.h" diff --git a/src/tests/roc_pipeline/test_receiver_source.cpp b/src/tests/roc_pipeline/test_receiver_source.cpp index 5186fa901..b54485cbd 100644 --- a/src/tests/roc_pipeline/test_receiver_source.cpp +++ b/src/tests/roc_pipeline/test_receiver_source.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/control_reader.h" #include "test_helpers/control_writer.h" #include "test_helpers/frame_reader.h" @@ -2084,7 +2083,7 @@ TEST(receiver_source, fec_no_losses) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2130,7 +2129,7 @@ TEST(receiver_source, fec_lose_source_packets) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2190,7 +2189,7 @@ TEST(receiver_source, fec_lose_repair_packets) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2238,7 +2237,7 @@ TEST(receiver_source, fec_delay_source_packets) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2355,7 +2354,7 @@ TEST(receiver_source, fec_delay_repair_packets) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2647,7 +2646,7 @@ TEST(receiver_source, soft_read_fec) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, @@ -2781,7 +2780,7 @@ TEST(receiver_source, soft_read_delays_fec) { init_with_defaults(); if (!fec_supported()) { - return; + TEST_SKIP(); } ReceiverSource receiver(make_default_config(), processor_map, encoding_map, diff --git a/src/tests/roc_pipeline/test_sender_endpoint.cpp b/src/tests/roc_pipeline/test_sender_endpoint.cpp index 8191e47c8..bfab515b5 100644 --- a/src/tests/roc_pipeline/test_sender_endpoint.cpp +++ b/src/tests/roc_pipeline/test_sender_endpoint.cpp @@ -6,7 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include +#include "test_harness.h" #include "roc_address/protocol.h" #include "roc_core/heap_arena.h" diff --git a/src/tests/roc_pipeline/test_sender_loop.cpp b/src/tests/roc_pipeline/test_sender_loop.cpp index a3270e9dc..c2e34c176 100644 --- a/src/tests/roc_pipeline/test_sender_loop.cpp +++ b/src/tests/roc_pipeline/test_sender_loop.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/mock_scheduler.h" #include "roc_core/heap_arena.h" diff --git a/src/tests/roc_pipeline/test_sender_sink.cpp b/src/tests/roc_pipeline/test_sender_sink.cpp index ef53f6679..2199b9adb 100644 --- a/src/tests/roc_pipeline/test_sender_sink.cpp +++ b/src/tests/roc_pipeline/test_sender_sink.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/control_reader.h" #include "test_helpers/control_writer.h" #include "test_helpers/frame_writer.h" diff --git a/src/tests/roc_pipeline/test_session_router.cpp b/src/tests/roc_pipeline/test_session_router.cpp index d1a29ec9d..0f1ce7d77 100644 --- a/src/tests/roc_pipeline/test_session_router.cpp +++ b/src/tests/roc_pipeline/test_session_router.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/utils.h" #include "roc_core/heap_arena.h" diff --git a/src/tests/roc_pipeline/test_transcoder_sink.cpp b/src/tests/roc_pipeline/test_transcoder_sink.cpp index 889274114..cc784f13d 100644 --- a/src/tests/roc_pipeline/test_transcoder_sink.cpp +++ b/src/tests/roc_pipeline/test_transcoder_sink.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/frame_writer.h" #include "test_helpers/mock_sink.h" diff --git a/src/tests/roc_pipeline/test_transcoder_source.cpp b/src/tests/roc_pipeline/test_transcoder_source.cpp index 3d90358fa..163b5e65a 100644 --- a/src/tests/roc_pipeline/test_transcoder_source.cpp +++ b/src/tests/roc_pipeline/test_transcoder_source.cpp @@ -6,8 +6,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include - +#include "test_harness.h" #include "test_helpers/frame_reader.h" #include "test_helpers/mock_source.h" diff --git a/src/tests/test_harness.cpp b/src/tests/test_harness.cpp new file mode 100644 index 000000000..abb0eb478 --- /dev/null +++ b/src/tests/test_harness.cpp @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2024 Roc Streaming authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#include "test_harness.h" + +ExtTestOutput::ExtTestOutput() + : ConsoleTestOutput() { +} + +void ExtTestOutput::printCurrentTestStarted(const UtestShell& test) { + ExtTestRunner::getCurrent()->markTestStarted(); + + ConsoleTestOutput::printCurrentTestStarted(test); +} + +void ExtTestOutput::printCurrentTestEnded(const TestResult& res) { + if (ExtTestRunner::getCurrent()->isTestSkipped()) { + setProgressIndicator("s"); + } + + ConsoleTestOutput::printCurrentTestEnded(res); + + ExtTestRunner::getCurrent()->markTestEnded(); +} + +ExtTestRunner* ExtTestRunner::current_runner_ = NULL; + +ExtTestRunner* ExtTestRunner::getCurrent() { + return current_runner_; +} + +ExtTestRunner::ExtTestRunner(int argc, const char* const* argv) + : CommandLineTestRunner(argc, argv, TestRegistry::getCurrentRegistry()) + , test_skipped_(false) { + current_runner_ = this; +} + +void ExtTestRunner::markTestStarted() { + test_skipped_ = false; +} + +void ExtTestRunner::markTestSkipped() { + test_skipped_ = true; +} + +void ExtTestRunner::markTestEnded() { + test_skipped_ = false; +} + +bool ExtTestRunner::isTestSkipped() const { + return test_skipped_; +} + +TestOutput* ExtTestRunner::createConsoleOutput() { + return new ExtTestOutput; +} diff --git a/src/tests/test_harness.h b/src/tests/test_harness.h new file mode 100644 index 000000000..a66c459f5 --- /dev/null +++ b/src/tests/test_harness.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2024 Roc Streaming authors + * + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. + */ + +#ifndef ROC_TEST_HARNESS_H_ +#define ROC_TEST_HARNESS_H_ + +#include +#include +#include +#include + +#define TEST_SKIP() \ + do { \ + ExtTestRunner::getCurrent()->markTestSkipped(); \ + TEST_EXIT; \ + } while (0) + +class ExtTestOutput : public ConsoleTestOutput { +public: + ExtTestOutput(); + + virtual void printCurrentTestStarted(const UtestShell& test); + virtual void printCurrentTestEnded(const TestResult& res); +}; + +class ExtTestRunner : public CommandLineTestRunner { +public: + static ExtTestRunner* getCurrent(); + + ExtTestRunner(int argc, const char* const* argv); + + void markTestStarted(); + void markTestSkipped(); + void markTestEnded(); + + bool isTestSkipped() const; + +protected: + virtual TestOutput* createConsoleOutput(); + +private: + static ExtTestRunner* current_runner_; + bool test_skipped_; +}; + +#endif // ROC_TEST_HARNESS_H_ diff --git a/src/tests/test_main.cpp b/src/tests/test_main.cpp index 23546bf6a..c24103c37 100644 --- a/src/tests/test_main.cpp +++ b/src/tests/test_main.cpp @@ -6,15 +6,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -#include -#include - #include "roc_core/crash_handler.h" #include "roc_core/die.h" #include "roc_core/heap_arena.h" #include "roc_core/log.h" #include "roc_core/stddefs.h" +#include "test_harness.h" + using namespace roc; int main(int argc, const char** argv) { @@ -53,7 +52,9 @@ int main(int argc, const char** argv) { MemoryLeakWarningPlugin::turnOffNewDeleteOverloads(); - const int code = CommandLineTestRunner::RunAllTests(argc, argv); + ExtTestRunner runner(argc, argv); + + const int code = runner.runAllTestsMain(); if (code != 0) { /* Terminate without destructors and exit handlers. * If a test was failed, chances are that there are leaks or other errors