Bug 1891332 - Replace debug MOZ_ASSERT with MOZ_RELEASE_ASSERT in media tests. r=media-playback-reviewers,padenot

MOZ_ASSERT, MOZ_ASSERT_UNREACHABLE, and NS_ASSERTION are only checked in debug builds, so release builds' tests are not checking these assertions.

Depends on D207372

Differential Revision: https://phabricator.services.mozilla.com/D207373
This commit is contained in:
Chris Peterson 2024-04-17 03:26:29 +00:00
Родитель 05289b2c2d
Коммит c02295d34e
13 изменённых файлов: 83 добавлений и 85 удалений

Просмотреть файл

@ -329,9 +329,9 @@ TEST(TestAudioDriftCorrection, DynamicInputBufferSizeChanges)
if (((receivedFramesStart - transmittedFramesStart + i) /
aTransmitterBlockSize) > numBlocksTransmitted) {
tone.Generate(inSegment, aTransmitterBlockSize);
MOZ_ASSERT(!inSegment.IsNull());
MOZ_RELEASE_ASSERT(!inSegment.IsNull());
inToneVerifier.AppendData(inSegment);
MOZ_ASSERT(!inSegment.IsNull());
MOZ_RELEASE_ASSERT(!inSegment.IsNull());
++numBlocksTransmitted;
totalFramesTransmitted += aTransmitterBlockSize;
}

Просмотреть файл

@ -99,7 +99,7 @@ class AudioVerifier {
void CountZeroCrossing(Sample aCurrentSample) {
if (mPrevious > 0 && aCurrentSample <= 0) {
if (mZeroCrossCount++) {
MOZ_ASSERT(mZeroCrossCount > 1);
MOZ_RELEASE_ASSERT(mZeroCrossCount > 1);
mSumPeriodInSamples += mTotalFramesSoFar - mLastZeroCrossPosition;
}
mLastZeroCrossPosition = mTotalFramesSoFar;
@ -120,7 +120,7 @@ class AudioVerifier {
return;
}
MOZ_ASSERT(mCurrentDiscontinuityFrameCount == 0);
MOZ_RELEASE_ASSERT(mCurrentDiscontinuityFrameCount == 0);
if (!discontinuity) {
return;
}

Просмотреть файл

@ -15,7 +15,7 @@ class GMPTestMonitor {
GMPTestMonitor() : mFinished(false) {}
void AwaitFinished() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
mozilla::SpinEventLoopUntil("GMPTestMonitor::AwaitFinished"_ns,
[&]() { return mFinished; });
mFinished = false;
@ -23,7 +23,7 @@ class GMPTestMonitor {
private:
void MarkFinished() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
mFinished = true;
}

Просмотреть файл

@ -168,15 +168,17 @@ MockCubebStream::MockCubebStream(
mAudioVerifier(aInputStreamParams ? aInputStreamParams->rate
: aOutputStreamParams->rate,
100 /* aFrequency */) {
MOZ_ASSERT(mAudioGenerator.ChannelCount() <= MAX_INPUT_CHANNELS,
MOZ_RELEASE_ASSERT(mAudioGenerator.ChannelCount() <= MAX_INPUT_CHANNELS,
"mInputBuffer has no enough space to hold generated data");
MOZ_ASSERT_IF(mFrozenStart, mRunningMode == RunningMode::Automatic);
if (mFrozenStart) {
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
}
if (aInputStreamParams) {
mInputParams = *aInputStreamParams;
}
if (aOutputStreamParams) {
mOutputParams = *aOutputStreamParams;
MOZ_ASSERT(SampleRate() == mOutputParams.rate);
MOZ_RELEASE_ASSERT(SampleRate() == mOutputParams.rate);
}
}
@ -268,13 +270,13 @@ int MockCubebStream::RegisterDeviceChangedCallback(
}
cubeb_stream* MockCubebStream::AsCubebStream() {
MOZ_ASSERT(!mDestroyed);
MOZ_RELEASE_ASSERT(!mDestroyed);
return reinterpret_cast<cubeb_stream*>(this);
}
MockCubebStream* MockCubebStream::AsMock(cubeb_stream* aStream) {
auto* mockStream = reinterpret_cast<MockCubebStream*>(aStream);
MOZ_ASSERT(!mockStream->mDestroyed);
MOZ_RELEASE_ASSERT(!mockStream->mDestroyed);
return mockStream;
}
@ -309,24 +311,24 @@ nsTArray<AudioDataValue>&& MockCubebStream::TakeRecordedInput() {
}
void MockCubebStream::SetDriftFactor(float aDriftFactor) {
MOZ_ASSERT(mRunningMode == MockCubeb::RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == MockCubeb::RunningMode::Automatic);
mDriftFactor = aDriftFactor;
}
void MockCubebStream::ForceError() { mForceErrorState = true; }
void MockCubebStream::ForceDeviceChanged() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
mForceDeviceChanged = true;
};
void MockCubebStream::NotifyDeviceChangedNow() {
MOZ_ASSERT(mRunningMode == RunningMode::Manual);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Manual);
NotifyDeviceChanged();
}
void MockCubebStream::Thaw() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
MonitorAutoLock l(mFrozenStartMonitor);
mFrozenStart = false;
mFrozenStartMonitor.Notify();
@ -370,8 +372,8 @@ MediaEventSource<void>& MockCubebStream::DeviceChangeForcedEvent() {
}
KeepProcessing MockCubebStream::ManualDataCallback(long aNrFrames) {
MOZ_ASSERT(mRunningMode == RunningMode::Manual);
MOZ_ASSERT(aNrFrames <= kMaxNrFrames);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Manual);
MOZ_RELEASE_ASSERT(aNrFrames <= kMaxNrFrames);
return Process(aNrFrames);
}
@ -422,7 +424,7 @@ KeepProcessing MockCubebStream::Process(long aNrFrames) {
}
KeepProcessing MockCubebStream::Process10Ms() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
uint32_t rate = SampleRate();
const long nrFrames =
static_cast<long>(static_cast<float>(rate * 10) * mDriftFactor) /
@ -445,20 +447,20 @@ MockCubeb::MockCubeb() : MockCubeb(MockCubeb::RunningMode::Automatic) {}
MockCubeb::MockCubeb(RunningMode aRunningMode)
: ops(&mock_ops), mRunningMode(aRunningMode) {}
MockCubeb::~MockCubeb() { MOZ_ASSERT(!mFakeAudioThread); };
MockCubeb::~MockCubeb() { MOZ_RELEASE_ASSERT(!mFakeAudioThread); };
void MockCubeb::Destroy() {
MOZ_ASSERT(mHasCubebContext);
MOZ_RELEASE_ASSERT(mHasCubebContext);
{
auto streams = mLiveStreams.Lock();
MOZ_ASSERT(streams->IsEmpty());
MOZ_RELEASE_ASSERT(streams->IsEmpty());
}
mDestroyed = true;
Release();
}
cubeb* MockCubeb::AsCubebContext() {
MOZ_ASSERT(!mDestroyed);
MOZ_RELEASE_ASSERT(!mDestroyed);
if (mHasCubebContext.compareExchange(false, true)) {
AddRef();
}
@ -467,7 +469,7 @@ cubeb* MockCubeb::AsCubebContext() {
MockCubeb* MockCubeb::AsMock(cubeb* aContext) {
auto* mockCubeb = reinterpret_cast<MockCubeb*>(aContext);
MOZ_ASSERT(!mockCubeb->mDestroyed);
MOZ_RELEASE_ASSERT(!mockCubeb->mDestroyed);
return mockCubeb;
}
@ -613,12 +615,12 @@ void MockCubeb::SetSupportDeviceChangeCallback(bool aSupports) {
void MockCubeb::ForceStreamInitError() { mStreamInitErrorState = true; }
void MockCubeb::SetStreamStartFreezeEnabled(bool aEnabled) {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
mStreamStartFreezeEnabled = aEnabled;
}
auto MockCubeb::ForceAudioThread() -> RefPtr<ForcedAudioThreadPromise> {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
RefPtr<ForcedAudioThreadPromise> p =
mForcedAudioThreadPromise.Ensure(__func__);
mForcedAudioThread = true;
@ -627,7 +629,7 @@ auto MockCubeb::ForceAudioThread() -> RefPtr<ForcedAudioThreadPromise> {
}
void MockCubeb::UnforceAudioThread() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
mForcedAudioThread = false;
}
@ -660,12 +662,12 @@ void MockCubeb::StreamDestroy(MockCubebStream* aStream) {
}
void MockCubeb::GoFaster() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
mFastMode = true;
}
void MockCubeb::DontGoFaster() {
MOZ_ASSERT(mRunningMode == RunningMode::Automatic);
MOZ_RELEASE_ASSERT(mRunningMode == RunningMode::Automatic);
mFastMode = false;
}
@ -680,12 +682,13 @@ MockCubeb::StreamDestroyEvent() {
void MockCubeb::StartStream(MockCubebStream* aStream) {
auto streams = mLiveStreams.Lock();
MOZ_ASSERT_IF(!aStream, mForcedAudioThread);
// Forcing an audio thread must happen before starting streams
MOZ_ASSERT_IF(!aStream, streams->IsEmpty());
if (aStream) {
MOZ_ASSERT(!streams->Contains(aStream->mSelf));
MOZ_RELEASE_ASSERT(!streams->Contains(aStream->mSelf));
streams->AppendElement(aStream->mSelf);
} else {
MOZ_RELEASE_ASSERT(mForcedAudioThread);
// Forcing an audio thread must happen before starting streams
MOZ_RELEASE_ASSERT(streams->IsEmpty());
}
if (!mFakeAudioThread && mRunningMode == RunningMode::Automatic) {
AddRef(); // released when the thread exits
@ -719,7 +722,7 @@ void MockCubeb::ThreadFunction() {
}
}
streams->RemoveElementsBy([](const auto& stream) { return !stream; });
MOZ_ASSERT(mFakeAudioThread);
MOZ_RELEASE_ASSERT(mFakeAudioThread);
if (streams->IsEmpty() && !mForcedAudioThread) {
// This leaks the std::thread if Gecko's main thread has already been
// shut down.

Просмотреть файл

@ -81,7 +81,7 @@ class MockGraphInterface : public GraphInterface {
RefPtr<Runnable> aSwitchedRunnable = NS_NewRunnableFunction(
"DefaultNoopSwitchedRunnable", [] {})) {
auto guard = mNextDriver.Lock();
MOZ_ASSERT(guard->isNothing());
MOZ_RELEASE_ASSERT(guard->isNothing());
*guard =
Some(std::make_tuple(std::move(aDriver), std::move(aSwitchedRunnable)));
}
@ -252,7 +252,7 @@ class MOZ_STACK_CLASS AutoSetter {
: mVal(aVal), mNew(aNew), mOld(mVal.exchange(aNew)) {}
~AutoSetter() {
DebugOnly<T> oldNew = mVal.exchange(mOld);
MOZ_ASSERT(oldNew == mNew);
MOZ_RELEASE_ASSERT(oldNew == mNew);
}
};
#endif

Просмотреть файл

@ -522,7 +522,7 @@ TEST(TestAudioTrackGraph, NonNativeInputTrackErrorCallback)
class TestDeviceInputConsumerTrack : public DeviceInputConsumerTrack {
public:
static TestDeviceInputConsumerTrack* Create(MediaTrackGraph* aGraph) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
TestDeviceInputConsumerTrack* track =
new TestDeviceInputConsumerTrack(aGraph->GraphRate());
aGraph->AddTrack(track);
@ -530,7 +530,7 @@ class TestDeviceInputConsumerTrack : public DeviceInputConsumerTrack {
}
void Destroy() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
DisconnectDeviceInput();
DeviceInputConsumerTrack::Destroy();
}
@ -543,7 +543,7 @@ class TestDeviceInputConsumerTrack : public DeviceInputConsumerTrack {
if (mInputs.IsEmpty()) {
GetData<AudioSegment>()->AppendNullData(aTo - aFrom);
} else {
MOZ_ASSERT(mInputs.Length() == 1);
MOZ_RELEASE_ASSERT(mInputs.Length() == 1);
AudioSegment data;
DeviceInputConsumerTrack::GetInputSourceData(data, aFrom, aTo);
GetData<AudioSegment>()->AppendFrom(&data);
@ -555,7 +555,7 @@ class TestDeviceInputConsumerTrack : public DeviceInputConsumerTrack {
return 0;
}
DeviceInputTrack* t = mInputs[0]->GetSource()->AsDeviceInputTrack();
MOZ_ASSERT(t);
MOZ_RELEASE_ASSERT(t);
return t->NumberOfChannels();
}
@ -700,7 +700,7 @@ TEST(TestAudioTrackGraph, RestartAudioIfMaxChannelCountChanged)
void SetInputChannelCount(MediaTrackGraph* aGraph,
CubebUtils::AudioDeviceID aDevice,
uint32_t aChannelCount) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
struct Message : public ControlMessage {
MediaTrackGraph* mGraph;

Просмотреть файл

@ -58,7 +58,7 @@ template <typename T>
static nsresult EnumerateCDMStorageDir(const nsACString& aDir, T&& aDirIter) {
RefPtr<GeckoMediaPluginServiceParent> service =
GeckoMediaPluginServiceParent::GetSingleton();
MOZ_ASSERT(service);
MOZ_RELEASE_ASSERT(service);
// $profileDir/gmp/$platform/
nsCOMPtr<nsIFile> path;
@ -94,7 +94,7 @@ class GMPShutdownObserver : public nsIRunnable, public nsIObserver {
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
EXPECT_TRUE(observerService);
@ -133,7 +133,7 @@ class NotifyObserversTask : public Runnable {
explicit NotifyObserversTask(const char* aTopic)
: mozilla::Runnable("NotifyObserversTask"), mTopic(aTopic) {}
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
if (observerService) {
@ -153,7 +153,7 @@ class ClearCDMStorageTask : public nsIRunnable, public nsIObserver {
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD Run() override {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
nsCOMPtr<nsIObserverService> observerService =
mozilla::services::GetObserverService();
EXPECT_TRUE(observerService);
@ -272,7 +272,7 @@ static nsCString GetNodeId(const nsAString& aOrigin,
static bool IsCDMStorageIsEmpty() {
RefPtr<GeckoMediaPluginServiceParent> service =
GeckoMediaPluginServiceParent::GetSingleton();
MOZ_ASSERT(service);
MOZ_RELEASE_ASSERT(service);
nsCOMPtr<nsIFile> storage;
nsresult rv = service->GetStorageDir(getter_AddRefs(storage));
EXPECT_NS_SUCCEEDED(rv);
@ -286,14 +286,14 @@ static bool IsCDMStorageIsEmpty() {
static void AssertIsOnGMPThread() {
RefPtr<GeckoMediaPluginService> service =
GeckoMediaPluginService::GetGeckoMediaPluginService();
MOZ_ASSERT(service);
MOZ_RELEASE_ASSERT(service);
nsCOMPtr<nsIThread> thread;
service->GetThread(getter_AddRefs(thread));
MOZ_ASSERT(thread);
MOZ_RELEASE_ASSERT(thread);
nsCOMPtr<nsIThread> currentThread;
DebugOnly<nsresult> rv = NS_GetCurrentThread(getter_AddRefs(currentThread));
MOZ_ASSERT(NS_SUCCEEDED(rv));
MOZ_ASSERT(currentThread == thread);
nsresult rv = NS_GetCurrentThread(getter_AddRefs(currentThread));
MOZ_RELEASE_ASSERT(NS_SUCCEEDED(rv));
MOZ_RELEASE_ASSERT(currentThread == thread);
}
class CDMStorageTest {
@ -1049,8 +1049,8 @@ class CDMStorageTest {
constexpr auto data = "Just_some_arbitrary_data."_ns;
MOZ_ASSERT(longRecordName.Length() < GMP_MAX_RECORD_NAME_SIZE);
MOZ_ASSERT(longRecordName.Length() > 260); // Windows MAX_PATH
MOZ_RELEASE_ASSERT(longRecordName.Length() < GMP_MAX_RECORD_NAME_SIZE);
MOZ_RELEASE_ASSERT(longRecordName.Length() > 260); // Windows MAX_PATH
nsCString response("stored ");
response.Append(longRecordName);

Просмотреть файл

@ -87,7 +87,7 @@ TEST_F(TestDeviceInputTrack, DeviceInputConsumerTrack) {
class TestDeviceInputConsumerTrack : public DeviceInputConsumerTrack {
public:
static TestDeviceInputConsumerTrack* Create(MediaTrackGraph* aGraph) {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
TestDeviceInputConsumerTrack* track =
new TestDeviceInputConsumerTrack(aGraph->GraphRate());
aGraph->AddTrack(track);
@ -95,7 +95,7 @@ TEST_F(TestDeviceInputTrack, DeviceInputConsumerTrack) {
}
void Destroy() {
MOZ_ASSERT(NS_IsMainThread());
MOZ_RELEASE_ASSERT(NS_IsMainThread());
DisconnectDeviceInput();
DeviceInputConsumerTrack::Destroy();
}
@ -108,7 +108,7 @@ TEST_F(TestDeviceInputTrack, DeviceInputConsumerTrack) {
return 0;
}
DeviceInputTrack* t = mInputs[0]->GetSource()->AsDeviceInputTrack();
MOZ_ASSERT(t);
MOZ_RELEASE_ASSERT(t);
return t->NumberOfChannels();
}

Просмотреть файл

@ -56,7 +56,7 @@ class MP4DemuxerBinding {
}
RefPtr<GenericPromise> CheckTrackKeyFrame(MediaTrackDemuxer* aTrackDemuxer) {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_RELEASE_ASSERT(mTaskQueue->IsCurrentThreadIn());
RefPtr<MediaTrackDemuxer> track = aTrackDemuxer;
RefPtr<MP4DemuxerBinding> binding = this;
@ -97,7 +97,7 @@ class MP4DemuxerBinding {
}
RefPtr<GenericPromise> CheckTrackSamples(MediaTrackDemuxer* aTrackDemuxer) {
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
MOZ_RELEASE_ASSERT(mTaskQueue->IsCurrentThreadIn());
RefPtr<MediaTrackDemuxer> track = aTrackDemuxer;
RefPtr<MP4DemuxerBinding> binding = this;

Просмотреть файл

@ -193,7 +193,7 @@ static already_AddRefed<MediaDataEncoder> CreateH264Encoder(
}
void WaitForShutdown(const RefPtr<MediaDataEncoder>& aEncoder) {
MOZ_ASSERT(aEncoder);
MOZ_RELEASE_ASSERT(aEncoder);
Maybe<bool> result;
// media::Await() supports exclusive promises only, but ShutdownPromise is

Просмотреть файл

@ -223,7 +223,7 @@ struct WebMioData {
};
static int webm_read(void* aBuffer, size_t aLength, void* aUserData) {
NS_ASSERTION(aUserData, "aUserData must point to a valid WebMioData");
MOZ_RELEASE_ASSERT(aUserData, "aUserData must point to a valid WebMioData");
WebMioData* ioData = static_cast<WebMioData*>(aUserData);
// Check the read length.
@ -247,7 +247,7 @@ static int webm_read(void* aBuffer, size_t aLength, void* aUserData) {
}
static int webm_seek(int64_t aOffset, int aWhence, void* aUserData) {
NS_ASSERTION(aUserData, "aUserData must point to a valid WebMioData");
MOZ_RELEASE_ASSERT(aUserData, "aUserData must point to a valid WebMioData");
WebMioData* ioData = static_cast<WebMioData*>(aUserData);
if (Abs(aOffset) > ioData->data.Length()) {
@ -281,7 +281,7 @@ static int webm_seek(int64_t aOffset, int aWhence, void* aUserData) {
}
static int64_t webm_tell(void* aUserData) {
NS_ASSERTION(aUserData, "aUserData must point to a valid WebMioData");
MOZ_RELEASE_ASSERT(aUserData, "aUserData must point to a valid WebMioData");
WebMioData* ioData = static_cast<WebMioData*>(aUserData);
return ioData->offset.isValid() ? ioData->offset.value() : -1;
}

Просмотреть файл

@ -49,8 +49,7 @@ RddProcessTest::TestTelemetryProbes(JSContext* aCx,
promise->MaybeResolve((int32_t)rddProc->RDDProcessPid());
},
[promise](nsresult aError) {
MOZ_ASSERT_UNREACHABLE("RddProcessTest; failure to get RDD child");
promise->MaybeReject(aError);
MOZ_CRASH("RddProcessTest; failure to get RDD child");
});
promise.forget(aOutPromise);

Просмотреть файл

@ -141,8 +141,7 @@ TestNat::NatBehavior TestNat::ToNatBehavior(const std::string& type) {
return TestNat::PORT_DEPENDENT;
}
MOZ_ASSERT(false, "Invalid NAT behavior");
return TestNat::ENDPOINT_INDEPENDENT;
MOZ_CRASH("Invalid NAT behavior");
}
bool TestNat::has_port_mappings() const {
@ -202,8 +201,8 @@ TestNrSocket::~TestNrSocket() { nat_->erase_socket(this); }
RefPtr<NrSocketBase> TestNrSocket::create_external_socket(
const nr_transport_addr& dest_addr) const {
MOZ_ASSERT(nat_->enabled_);
MOZ_ASSERT(!nat_->is_an_internal_tuple(dest_addr));
MOZ_RELEASE_ASSERT(nat_->enabled_);
MOZ_RELEASE_ASSERT(!nat_->is_an_internal_tuple(dest_addr));
int r;
nr_transport_addr nat_external_addr;
@ -261,7 +260,7 @@ void TestNrSocket::close() {
}
int TestNrSocket::listen(int backlog) {
MOZ_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP);
MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP);
r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s listening", this,
internal_socket_->my_addr().as_string);
@ -269,7 +268,7 @@ int TestNrSocket::listen(int backlog) {
}
int TestNrSocket::accept(nr_transport_addr* addrp, nr_socket** sockp) {
MOZ_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP);
MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol == IPPROTO_TCP);
int r = internal_socket_->accept(addrp, sockp);
if (r) {
return r;
@ -296,7 +295,7 @@ void TestNrSocket::process_delayed_cb(NR_SOCKET s, int how, void* cb_arg) {
int TestNrSocket::sendto(const void* msg, size_t len, int flags,
const nr_transport_addr* to) {
MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s %s", this, __FUNCTION__,
to->as_string);
@ -347,10 +346,7 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags,
external_socket = similar_port_mapping->external_socket_;
} else {
external_socket = create_external_socket(*to);
if (!external_socket) {
MOZ_ASSERT(false);
return R_INTERNAL;
}
MOZ_RELEASE_ASSERT(external_socket);
}
port_mapping = create_port_mapping(*to, external_socket);
@ -371,7 +367,7 @@ int TestNrSocket::sendto(const void* msg, size_t len, int flags,
int TestNrSocket::recvfrom(void* buf, size_t maxlen, size_t* len, int flags,
nr_transport_addr* from) {
MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
if (!read_buffer_.empty()) {
UdpPacket& packet = read_buffer_.front();
@ -441,8 +437,8 @@ bool TestNrSocket::allow_ingress(const nr_transport_addr& to,
const nr_transport_addr& from,
PortMapping** port_mapping_used) const {
// This is only called for traffic arriving at a port mapping
MOZ_ASSERT(nat_->enabled_);
MOZ_ASSERT(!nat_->is_an_internal_tuple(from));
MOZ_RELEASE_ASSERT(nat_->enabled_);
MOZ_RELEASE_ASSERT(!nat_->is_an_internal_tuple(from));
// Find the port mapping (if any) that this packet landed on
*port_mapping_used = nullptr;
@ -603,7 +599,7 @@ int TestNrSocket::write(const void* msg, size_t len, size_t* written) {
return R_INTERNAL;
}
// This is TCP only
MOZ_ASSERT(port_mappings_.size() == 1);
MOZ_RELEASE_ASSERT(port_mappings_.size() == 1);
r_log(LOG_GENERIC, LOG_DEBUG, "PortMapping %s -> %s writing",
port_mappings_.front()->external_socket_->my_addr().as_string,
port_mappings_.front()->remote_address_.as_string);
@ -641,7 +637,7 @@ int TestNrSocket::read(void* buf, size_t maxlen, size_t* len) {
if (port_mappings_.empty()) {
r = internal_socket_->read(buf, maxlen, len);
} else {
MOZ_ASSERT(port_mappings_.size() == 1);
MOZ_RELEASE_ASSERT(port_mappings_.size() == 1);
r = port_mappings_.front()->external_socket_->read(buf, maxlen, len);
if (!r && nat_->refresh_on_ingress_) {
port_mappings_.front()->last_used_ = PR_IntervalNow();
@ -722,7 +718,7 @@ int TestNrSocket::async_wait(int how, NR_async_cb cb, void* cb_arg,
if (internal_socket_->my_addr().protocol == IPPROTO_TCP) {
// For a TCP connection through a simulated NAT, these signals are
// just passed through.
MOZ_ASSERT(port_mappings_.size() == 1);
MOZ_RELEASE_ASSERT(port_mappings_.size() == 1);
return port_mappings_.front()->async_wait(
how, port_mapping_tcp_passthrough_callback, this, function, line);
@ -834,7 +830,7 @@ void TestNrSocket::on_socket_readable(NrSocketBase* real_socket) {
}
void TestNrSocket::fire_readable_callback() {
MOZ_ASSERT(poll_flags() & PR_POLL_READ);
MOZ_RELEASE_ASSERT(poll_flags() & PR_POLL_READ);
r_log(LOG_GENERIC, LOG_DEBUG, "TestNrSocket %p %s ready for read", this,
internal_socket_->my_addr().as_string);
fire_callback(NR_ASYNC_WAIT_READ);
@ -849,7 +845,7 @@ void TestNrSocket::port_mapping_writeable_callback(void* ext_sock_v, int how,
}
void TestNrSocket::write_to_port_mapping(NrSocketBase* external_socket) {
MOZ_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
MOZ_RELEASE_ASSERT(internal_socket_->my_addr().protocol != IPPROTO_TCP);
int r = 0;
for (PortMapping* port_mapping : port_mappings_) {
@ -935,7 +931,7 @@ TestNrSocket::PortMapping::PortMapping(
}
int TestNrSocket::PortMapping::send_from_queue() {
MOZ_ASSERT(remote_address_.protocol != IPPROTO_TCP);
MOZ_RELEASE_ASSERT(remote_address_.protocol != IPPROTO_TCP);
int r = 0;
while (!send_queue_.empty()) {
@ -967,7 +963,7 @@ int TestNrSocket::PortMapping::send_from_queue() {
int TestNrSocket::PortMapping::sendto(const void* msg, size_t len,
const nr_transport_addr& to) {
MOZ_ASSERT(remote_address_.protocol != IPPROTO_TCP);
MOZ_RELEASE_ASSERT(remote_address_.protocol != IPPROTO_TCP);
r_log(LOG_GENERIC, LOG_DEBUG, "PortMapping %s -> %s sending to %s",
external_socket_->my_addr().as_string, remote_address_.as_string,
to.as_string);