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 удалений

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

@ -65,12 +65,12 @@ void TestDocumentationExample() {
(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \ (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, \
21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32)) 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32))
#define CHECK_BOOL(aIndex) \ #define CHECK_BOOL(aIndex) \
MOZ_ASSERT(val.LoadFlag##aIndex() == false); \ MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == false); \
val.StoreFlag##aIndex(true); \ val.StoreFlag##aIndex(true); \
MOZ_ASSERT(val.LoadFlag##aIndex() == true); \ MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == true); \
val.StoreFlag##aIndex(false); \ val.StoreFlag##aIndex(false); \
MOZ_ASSERT(val.LoadFlag##aIndex() == false); MOZ_RELEASE_ASSERT(val.LoadFlag##aIndex() == false);
#define GENERATE_TEST_JAMMED_WITH_FLAGS(aSize) \ #define GENERATE_TEST_JAMMED_WITH_FLAGS(aSize) \
void TestJammedWithFlags##aSize() { \ void TestJammedWithFlags##aSize() { \
@ -82,31 +82,31 @@ void TestDocumentationExample() {
// ========================= TestLopsided =========================== // ========================= TestLopsided ===========================
#define GENERATE_TEST_LOPSIDED_FUNC(aSide, aSize) \ #define GENERATE_TEST_LOPSIDED_FUNC(aSide, aSize) \
void TestLopsided##aSide##aSize() { \ void TestLopsided##aSide##aSize() { \
Lopsided##aSide##aSize val; \ Lopsided##aSide##aSize val; \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
val.StoreHappyLittleBit(true); \ val.StoreHappyLittleBit(true); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
val.StoreLargeAndInCharge(1); \ val.StoreLargeAndInCharge(1); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 1); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 1); \
val.StoreLargeAndInCharge(0); \ val.StoreLargeAndInCharge(0); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == 0); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == 0); \
uint##aSize##_t size = aSize; \ uint##aSize##_t size = aSize; \
uint##aSize##_t int_max = (~(1ull << (size - 1))) - 1; \ uint##aSize##_t int_max = (~(1ull << (size - 1))) - 1; \
val.StoreLargeAndInCharge(int_max); \ val.StoreLargeAndInCharge(int_max); \
MOZ_ASSERT(val.LoadHappyLittleBit() == true); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == true); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
val.StoreHappyLittleBit(false); \ val.StoreHappyLittleBit(false); \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
val.StoreLargeAndInCharge(int_max); \ val.StoreLargeAndInCharge(int_max); \
MOZ_ASSERT(val.LoadHappyLittleBit() == false); \ MOZ_RELEASE_ASSERT(val.LoadHappyLittleBit() == false); \
MOZ_ASSERT(val.LoadLargeAndInCharge() == int_max); \ MOZ_RELEASE_ASSERT(val.LoadLargeAndInCharge() == int_max); \
} }
#define GENERATE_TEST_LOPSIDED(aSize) \ #define GENERATE_TEST_LOPSIDED(aSize) \

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

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

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

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

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

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

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

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

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

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

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

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

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