diff -U8 b/test/test_duplex.cpp b/test/test_duplex.cpp --- b/test/test_duplex.cpp +++ b/test/test_duplex.cpp @@ -13,16 +13,18 @@ #endif #include "cubeb/cubeb.h" #include #include #include #include #include +#include "mozilla/gtest/MozHelpers.h" + // #define ENABLE_NORMAL_LOG // #define ENABLE_VERBOSE_LOG #include "common.h" #define SAMPLE_FREQUENCY 48000 #define STREAM_FORMAT CUBEB_SAMPLE_FLOAT32LE #define INPUT_CHANNELS 1 #define INPUT_LAYOUT CUBEB_LAYOUT_MONO @@ -196,16 +198,21 @@ TEST(cubeb, duplex_collection_change) duplex_collection_change_impl(ctx); r = cubeb_register_device_collection_changed( ctx, static_cast(CUBEB_DEVICE_TYPE_INPUT), nullptr, nullptr); ASSERT_EQ(r, CUBEB_OK); } +void CauseDeath(cubeb * p) { + mozilla::gtest::DisableCrashReporter(); + cubeb_destroy(p); +} + #ifdef GTEST_HAS_DEATH_TEST TEST(cubeb, duplex_collection_change_no_unregister) { cubeb * ctx; int r; r = common_init(&ctx, "Cubeb duplex example with collection change"); ASSERT_EQ(r, CUBEB_OK) << "Error initializing cubeb library"; @@ -213,19 +220,27 @@ TEST(cubeb, duplex_collection_change_no_ /* This test needs an available input device, skip it if this host does not * have one. */ if (!can_run_audio_input_test(ctx)) { cubeb_destroy(ctx); return; } std::unique_ptr cleanup_cubeb_at_exit( - ctx, [](cubeb * p) noexcept { EXPECT_DEATH(cubeb_destroy(p), ""); }); + ctx, [](cubeb * p) noexcept { EXPECT_DEATH(CauseDeath(p), ""); }); duplex_collection_change_impl(ctx); + +# if defined(XP_MACOSX) && !defined(MOZ_DEBUG) + // For some reason this test hangs on macOS in non-debug builds when the child + // process (death test fork) crashes and the crash reporter is enabled in the + // parent process. There is not much left to do that can cause a crash in the + // parent process anyway, so disable the crash reporter where needed to pass. + mozilla::gtest::DisableCrashReporter(); +# endif } #endif long data_cb_input(cubeb_stream * stream, void * user, const void * inputbuffer, void * outputbuffer, long nframes) { if (stream == NULL || inputbuffer == NULL || outputbuffer != NULL) {