Bug 1891332 - Replace debug MOZ_ASSERT with MOZ_RELEASE_ASSERT in MFBT tests. r=xpcom-reviewers,emilio

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

Depends on D207373

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

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

@ -66,11 +66,11 @@ void TestDocumentationExample() {
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))
#define CHECK_BOOL(aIndex) \
MOZ_ASSERT(val.LoadFlag##aIndex() == false); \
MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == false); \
val.StoreFlag##aIndex(true); \
MOZ_ASSERT(val.LoadFlag##aIndex() == true); \
MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == true); \
val.StoreFlag##aIndex(false); \
MOZ_ASSERT(val.LoadFlag##aIndex() == false);
MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == false);
#define GENERATE_TEST_JAMMED_WITH_FLAGS(aSize) \
void TestJammedWithFlags##aSize() { \
@ -85,28 +85,28 @@ void TestDocumentationExample() {
#define GENERATE_TEST_LOPSIDED_FUNC(aSide, aSize) \
void TestLopsided##aSide##aSize() { \
Lopsided##aSide##aSize val; \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
val.StoreHappyLittleBit(true); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
val.StoreLargeAndInCharge(1); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 1); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 1); \
val.StoreLargeAndInCharge(0); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
uint##aSize##_t size = aSize; \
uint##aSize##_t int_max = (~(1ull << (size - 1))) - 1; \
val.StoreLargeAndInCharge(int_max); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
val.StoreHappyLittleBit(false); \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
val.StoreLargeAndInCharge(int_max); \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \
MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
}
#define GENERATE_TEST_LOPSIDED(aSize) \

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

@ -134,7 +134,7 @@ void TestFitForTypes() {
template <typename T, typename U>
static constexpr void AssertSameTypeAndValue(T a, U b) {
static_assert(std::is_same_v<T, U>);
MOZ_ASSERT(a == b);
MOZ_RELEASE_ASSERT(a == b);
}
void TestUnderlyingValue() {

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

@ -267,15 +267,15 @@ template <typename T>
static void TestEqualsIsForInt32(T aVal) {
int32_t i32;
A(NumberIsInt32(aVal, &i32));
MOZ_ASSERT(i32 == aVal);
MOZ_RELEASE_ASSERT(i32 == aVal);
A(NumberEqualsInt32(aVal, &i32));
MOZ_ASSERT(i32 == aVal);
MOZ_RELEASE_ASSERT(i32 == aVal);
int64_t i64;
A(NumberIsInt64(aVal, &i64));
MOZ_ASSERT(i64 == aVal);
MOZ_RELEASE_ASSERT(i64 == aVal);
A(NumberEqualsInt64(aVal, &i64));
MOZ_ASSERT(i64 == aVal);
MOZ_RELEASE_ASSERT(i64 == aVal);
};
// Used to test Number{Is,Equals}{Int32,Int64} for values that fit in int64 but
@ -288,9 +288,9 @@ static void TestEqualsIsForInt64(T aVal) {
int64_t i64;
A(NumberIsInt64(aVal, &i64));
MOZ_ASSERT(i64 == aVal);
MOZ_RELEASE_ASSERT(i64 == aVal);
A(NumberEqualsInt64(aVal, &i64));
MOZ_ASSERT(i64 == aVal);
MOZ_RELEASE_ASSERT(i64 == aVal);
};
// Used to test Number{Is,Equals}{Int32,Int64} for values that aren't equal to

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -20,10 +20,10 @@ using mozilla::ToMaybeRef;
#define RUN_TEST(t) \
do { \
bool cond = (t()); \
if (!cond) return 1; \
MOZ_RELEASE_ASSERT(cond, "Unexpectedly returned false during test: " #t); \
cond = AllDestructorsWereCalled(); \
MOZ_ASSERT(cond, "Failed to destroy all objects during test: " #t); \
if (!cond) return 1; \
MOZ_RELEASE_ASSERT(cond, \
"Failed to destroy all objects during test: " #t); \
} while (false)
enum Status {

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

@ -20,7 +20,7 @@ class Foo : public RefCounted<Foo> {
static int sNumDestroyed;
~Foo() {
MOZ_ASSERT(!mDead);
MOZ_RELEASE_ASSERT(!mDead);
mDead = true;
sNumDestroyed++;
}

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

@ -24,10 +24,7 @@ using mozilla::Vector;
#define CHECK(c) \
do { \
bool cond = !!(c); \
MOZ_ASSERT(cond, "Failed assertion: " #c); \
if (!cond) { \
return false; \
} \
MOZ_RELEASE_ASSERT(cond, "Test failed: " #c); \
} while (false)
typedef UniquePtr<int> NewInt;

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

@ -350,28 +350,28 @@ void mozilla::detail::VectorTesting::testReplaceRawBuffer() {
MOZ_RELEASE_ASSERT(v.reserve(4));
v.infallibleEmplaceBack(1, 2);
v.infallibleEmplaceBack(3, 4);
MOZ_ASSERT(S::constructCount == 2);
MOZ_RELEASE_ASSERT(S::constructCount == 2);
s = v.extractRawBuffer();
}
MOZ_ASSERT(S::constructCount == 2);
MOZ_ASSERT(S::moveCount == 0);
MOZ_ASSERT(S::destructCount == 0);
MOZ_RELEASE_ASSERT(S::constructCount == 2);
MOZ_RELEASE_ASSERT(S::moveCount == 0);
MOZ_RELEASE_ASSERT(S::destructCount == 0);
{
Vector<S, 10> v;
v.replaceRawBuffer(s, 2);
MOZ_ASSERT(v.length() == 2);
MOZ_ASSERT(v.reserved() == 2);
MOZ_ASSERT(v.capacity() == 10);
MOZ_ASSERT(v[0].j == 1);
MOZ_ASSERT(v[1].j == 3);
MOZ_ASSERT(S::destructCount == 2);
MOZ_RELEASE_ASSERT(v.length() == 2);
MOZ_RELEASE_ASSERT(v.capacity() == 10);
MOZ_RELEASE_ASSERT(v[0].j == 1);
MOZ_RELEASE_ASSERT(v[1].j == 3);
MOZ_RELEASE_ASSERT(S::destructCount == 2);
}
MOZ_ASSERT(S::constructCount == 2);
MOZ_ASSERT(S::moveCount == 2);
MOZ_ASSERT(S::destructCount == 4);
MOZ_RELEASE_ASSERT(S::constructCount == 2);
MOZ_RELEASE_ASSERT(S::moveCount == 2);
MOZ_RELEASE_ASSERT(S::destructCount == 4);
S::resetCounts();
@ -379,30 +379,30 @@ void mozilla::detail::VectorTesting::testReplaceRawBuffer() {
Vector<S, 2> v;
MOZ_RELEASE_ASSERT(v.reserve(4));
v.infallibleEmplaceBack(9, 10);
MOZ_ASSERT(S::constructCount == 1);
MOZ_RELEASE_ASSERT(S::constructCount == 1);
s = v.extractRawBuffer();
MOZ_ASSERT(S::constructCount == 1);
MOZ_ASSERT(S::moveCount == 0);
MOZ_RELEASE_ASSERT(S::constructCount == 1);
MOZ_RELEASE_ASSERT(S::moveCount == 0);
}
MOZ_ASSERT(S::destructCount == 0);
MOZ_RELEASE_ASSERT(S::destructCount == 0);
{
Vector<S> v;
v.replaceRawBuffer(s, 1, 4);
MOZ_ASSERT(v.length() == 1);
MOZ_ASSERT(v.reserved() == 4);
MOZ_ASSERT(v.capacity() == 4);
MOZ_ASSERT(v[0].j == 9);
MOZ_RELEASE_ASSERT(v.length() == 1);
MOZ_RELEASE_ASSERT(v.capacity() == 4);
MOZ_RELEASE_ASSERT(v[0].j == 9);
for (size_t i = 0; i < 5; i++) MOZ_RELEASE_ASSERT(v.emplaceBack(i, i));
MOZ_ASSERT(v.length() == 6);
MOZ_ASSERT(v.reserved() == 6);
MOZ_ASSERT(S::constructCount == 6);
MOZ_ASSERT(S::moveCount == 4);
MOZ_ASSERT(S::destructCount == 4);
MOZ_RELEASE_ASSERT(v.length() == 6);
MOZ_RELEASE_ASSERT(S::constructCount == 6);
MOZ_RELEASE_ASSERT(S::moveCount == 4);
MOZ_RELEASE_ASSERT(S::destructCount == 4);
}
MOZ_ASSERT(S::destructCount == 10);
MOZ_RELEASE_ASSERT(S::destructCount == 10);
}
void mozilla::detail::VectorTesting::testInsert() {
@ -541,13 +541,13 @@ void mozilla::detail::VectorTesting::testShrinkStorageToFit() {
Vector<int, 0> v1;
MOZ_RELEASE_ASSERT(v1.reserve(10));
v1.infallibleAppend(1);
MOZ_ASSERT(v1.length() == 1);
MOZ_ASSERT(v1.reserved() == 10);
MOZ_ASSERT(v1.capacity() >= 10);
MOZ_RELEASE_ASSERT(v1.length() == 1);
MOZ_RELEASE_ASSERT(v1.capacity() >= 10);
v1.shrinkStorageToFit();
MOZ_ASSERT(v1.length() == 1);
MOZ_ASSERT(v1.reserved() == 1);
MOZ_ASSERT(v1.capacity() == 1);
MOZ_RELEASE_ASSERT(v1.length() == 1);
MOZ_RELEASE_ASSERT(v1.capacity() == 1);
}
// Vectors using inline storage do nothing.
@ -555,13 +555,13 @@ void mozilla::detail::VectorTesting::testShrinkStorageToFit() {
Vector<int, 2> v2;
MOZ_RELEASE_ASSERT(v2.reserve(2));
v2.infallibleAppend(1);
MOZ_ASSERT(v2.length() == 1);
MOZ_ASSERT(v2.reserved() == 2);
MOZ_ASSERT(v2.capacity() == 2);
MOZ_RELEASE_ASSERT(v2.length() == 1);
MOZ_RELEASE_ASSERT(v2.capacity() == 2);
v2.shrinkStorageToFit();
MOZ_ASSERT(v2.length() == 1);
MOZ_ASSERT(v2.reserved() == 2);
MOZ_ASSERT(v2.capacity() == 2);
MOZ_RELEASE_ASSERT(v2.length() == 1);
MOZ_RELEASE_ASSERT(v2.capacity() == 2);
}
// shrinkStorageToFit uses inline storage if possible.
@ -569,13 +569,13 @@ void mozilla::detail::VectorTesting::testShrinkStorageToFit() {
Vector<int, 2> v;
MOZ_RELEASE_ASSERT(v.reserve(4));
v.infallibleAppend(1);
MOZ_ASSERT(v.length() == 1);
MOZ_ASSERT(v.reserved() == 4);
MOZ_ASSERT(v.capacity() >= 4);
MOZ_RELEASE_ASSERT(v.length() == 1);
MOZ_RELEASE_ASSERT(v.capacity() >= 4);
v.shrinkStorageToFit();
MOZ_ASSERT(v.length() == 1);
MOZ_ASSERT(v.reserved() == 1);
MOZ_ASSERT(v.capacity() == 2);
MOZ_RELEASE_ASSERT(v.length() == 1);
MOZ_RELEASE_ASSERT(v.capacity() == 2);
}
// Non-pod shrinking to non-inline storage.