The fewer lines added the better, and narrow down the use of DisableCrashReporter in the parent process to a minimum. Differential Revision: https://phabricator.services.mozilla.com/D233658
74 lines
2.3 KiB
Diff
74 lines
2.3 KiB
Diff
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 <atomic>
|
|
#include <math.h>
|
|
#include <memory>
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
+#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>(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<cubeb, decltype(&cubeb_destroy)> 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) {
|