summaryrefslogtreecommitdiffstats
path: root/xpcom/tests/gtest
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-12 05:43:14 +0000
commit8dd16259287f58f9273002717ec4d27e97127719 (patch)
tree3863e62a53829a84037444beab3abd4ed9dfc7d0 /xpcom/tests/gtest
parentReleasing progress-linux version 126.0.1-1~progress7.99u1. (diff)
downloadfirefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz
firefox-8dd16259287f58f9273002717ec4d27e97127719.zip
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'xpcom/tests/gtest')
-rw-r--r--xpcom/tests/gtest/TestFile.cpp2
-rw-r--r--xpcom/tests/gtest/TestHandleWatcher.cpp11
-rw-r--r--xpcom/tests/gtest/TestMozPromise.cpp2
-rw-r--r--xpcom/tests/gtest/TestStrings.cpp33
-rw-r--r--xpcom/tests/gtest/TestTimers.cpp2
-rw-r--r--xpcom/tests/gtest/TestTokenizer.cpp60
-rw-r--r--xpcom/tests/gtest/moz.build16
7 files changed, 103 insertions, 23 deletions
diff --git a/xpcom/tests/gtest/TestFile.cpp b/xpcom/tests/gtest/TestFile.cpp
index 6e95366584..fc7650ccbc 100644
--- a/xpcom/tests/gtest/TestFile.cpp
+++ b/xpcom/tests/gtest/TestFile.cpp
@@ -36,7 +36,7 @@ static void SetUseDOSDevicePathSyntax(nsIFile* aFile) {
nsCOMPtr<nsILocalFileWin> winFile = do_QueryInterface(aFile, &rv);
VerifyResult(rv, "Querying nsILocalFileWin");
- MOZ_ASSERT(winFile);
+ MOZ_RELEASE_ASSERT(winFile);
winFile->SetUseDOSDevicePathSyntax(true);
}
}
diff --git a/xpcom/tests/gtest/TestHandleWatcher.cpp b/xpcom/tests/gtest/TestHandleWatcher.cpp
index c003a026a1..b3997140d1 100644
--- a/xpcom/tests/gtest/TestHandleWatcher.cpp
+++ b/xpcom/tests/gtest/TestHandleWatcher.cpp
@@ -101,8 +101,9 @@ class TestHandleWatcher : public testing::Test {
private:
static bool sIsLive; // just for confirmation
static void AssertIsLive() {
- MOZ_ASSERT(sIsLive,
- "attempted to use `class TestHandleWatcher` outside test group");
+ MOZ_RELEASE_ASSERT(
+ sIsLive,
+ "attempted to use `class TestHandleWatcher` outside test group");
}
static RefPtr<mozilla::SharedThreadPool> sPool;
@@ -339,7 +340,7 @@ struct ActivationTestSetup {
private:
nsIEventTarget* GetQueue(TargetType targetTyoe) {
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_RELEASE_ASSERT(NS_IsMainThread());
switch (targetTyoe) {
case TargetType::Main:
return NS_GetCurrentThread();
@@ -378,9 +379,9 @@ struct ActivationTestSetup {
}
bool Execute() {
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_RELEASE_ASSERT(NS_IsMainThread());
bool const spin = SpinEventLoopUntil([this] {
- MOZ_ASSERT(NS_IsMainThread());
+ MOZ_RELEASE_ASSERT(NS_IsMainThread());
return run.load();
}).ok();
return spin && watcher.IsStopped();
diff --git a/xpcom/tests/gtest/TestMozPromise.cpp b/xpcom/tests/gtest/TestMozPromise.cpp
index 9b06304139..02dbef7114 100644
--- a/xpcom/tests/gtest/TestMozPromise.cpp
+++ b/xpcom/tests/gtest/TestMozPromise.cpp
@@ -45,7 +45,7 @@ class DelayedResolveOrReject : public Runnable {
mIterations(aIterations) {}
NS_IMETHOD Run() override {
- MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
+ MOZ_RELEASE_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (!mPromise) {
// Canceled.
return NS_OK;
diff --git a/xpcom/tests/gtest/TestStrings.cpp b/xpcom/tests/gtest/TestStrings.cpp
index b1458ec6ce..450befc20d 100644
--- a/xpcom/tests/gtest/TestStrings.cpp
+++ b/xpcom/tests/gtest/TestStrings.cpp
@@ -1183,11 +1183,9 @@ TEST_F(Strings, stringbuffer) {
memcpy(data, kData, sizeof(kData));
nsCString str;
- buf->ToString(sizeof(kData) - 1, str);
-
- nsStringBuffer* buf2;
- buf2 = nsStringBuffer::FromString(str);
+ str.Assign(buf, sizeof(kData) - 1);
+ nsStringBuffer* buf2 = str.GetStringBuffer();
EXPECT_EQ(buf, buf2);
}
@@ -1283,9 +1281,6 @@ TEST_F(Strings, string_tointeger) {
int32_t result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
EXPECT_EQ(rv, t->rv);
EXPECT_EQ(result, t->result);
- result = nsAutoCString(t->str).ToInteger(&rv, t->radix);
- EXPECT_EQ(rv, t->rv);
- EXPECT_EQ(result, t->result);
}
}
@@ -2288,6 +2283,30 @@ TEST_F(Strings, printf) {
create_printf_strings(format, (char*)anotherString);
verify_printf_strings(expectedOutput);
}
+ {
+ const char* format = "RightJustify %8s";
+ const char* expectedOutput = "RightJustify foo";
+ create_printf_strings(format, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "LeftJustify %-8s";
+ const char* expectedOutput = "LeftJustify foo ";
+ create_printf_strings(format, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "RightJustify2 %*s";
+ const char* expectedOutput = "RightJustify2 foo";
+ create_printf_strings(format, 8, "foo");
+ verify_printf_strings(expectedOutput);
+ }
+ {
+ const char* format = "LeftJustify2 %-*s";
+ const char* expectedOutput = "LeftJustify2 foo ";
+ create_printf_strings(format, 8, "foo");
+ verify_printf_strings(expectedOutput);
+ }
}
// We don't need these macros following the printf test.
diff --git a/xpcom/tests/gtest/TestTimers.cpp b/xpcom/tests/gtest/TestTimers.cpp
index ea8792e273..7bd4cb1a14 100644
--- a/xpcom/tests/gtest/TestTimers.cpp
+++ b/xpcom/tests/gtest/TestTimers.cpp
@@ -308,7 +308,7 @@ class FindExpirationTimeState final {
// Create timers, with aNumLowPriority low priority timers first in the queue
void InitTimers(uint32_t aNumLowPriority, uint32_t aType) {
// aType is just for readability.
- MOZ_ASSERT(aType == nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY);
+ MOZ_RELEASE_ASSERT(aType == nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY);
InitTimers(aNumLowPriority, nsITimer::TYPE_ONE_SHOT_LOW_PRIORITY, nullptr);
}
diff --git a/xpcom/tests/gtest/TestTokenizer.cpp b/xpcom/tests/gtest/TestTokenizer.cpp
index 1457b82fff..3c1043a92a 100644
--- a/xpcom/tests/gtest/TestTokenizer.cpp
+++ b/xpcom/tests/gtest/TestTokenizer.cpp
@@ -1421,6 +1421,66 @@ TEST(Tokenizer, ReadIntegers)
EXPECT_TRUE(t.CheckEOF());
}
+TEST(Tokenizer, ReadHexadecimals)
+{
+ Tokenizer t("0x100,0x0a,0xFe02dXXX,0a,0xX,0xffffffff,0x7fffffff,0x100000000");
+
+ uint32_t value32;
+ int32_t signed_value32;
+ uint64_t value64;
+
+ // "0x100,"
+ EXPECT_TRUE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(value32 == 0x100);
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0x0a,"
+ EXPECT_TRUE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(value32 == 0xa);
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0xFe02dX,"
+ EXPECT_TRUE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(value32 == 0xfe02d);
+ EXPECT_TRUE(t.CheckWord("XXX"));
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0a,"
+ EXPECT_FALSE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(t.ReadHexadecimal(&value32, /* aPrefixed = */ false));
+ EXPECT_TRUE(value32 == 0xa);
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0xX,"
+ EXPECT_FALSE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(t.Check(Tokenizer::Token::Number(0)));
+ EXPECT_TRUE(t.CheckWord("xX"));
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0xffffffff,"
+ // there is a case to be made that maybe this should be parsed as -1,
+ // but for now, this is not supported.
+ EXPECT_FALSE(t.ReadHexadecimal(&signed_value32));
+ EXPECT_FALSE(t.CheckChar(','));
+
+ EXPECT_TRUE(t.ReadHexadecimal(&value32));
+ EXPECT_TRUE(value32 == std::numeric_limits<uint32_t>::max());
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0x7fffffff,"
+ EXPECT_TRUE(t.ReadHexadecimal(&signed_value32));
+ EXPECT_TRUE(signed_value32 == std::numeric_limits<int32_t>::max());
+ EXPECT_TRUE(t.CheckChar(','));
+
+ // "0x100000000,"
+ EXPECT_FALSE(t.ReadHexadecimal(&value32));
+ EXPECT_FALSE(t.CheckEOF());
+ EXPECT_FALSE(t.CheckChar(','));
+
+ EXPECT_TRUE(t.ReadHexadecimal(&value64));
+ EXPECT_TRUE(t.CheckEOF());
+}
+
TEST(Tokenizer, CheckPhrase)
{
Tokenizer t("foo bar baz");
diff --git a/xpcom/tests/gtest/moz.build b/xpcom/tests/gtest/moz.build
index 4d8d38e89a..22a5b1751d 100644
--- a/xpcom/tests/gtest/moz.build
+++ b/xpcom/tests/gtest/moz.build
@@ -66,8 +66,8 @@ UNIFIED_SOURCES += [
"TestTaskQueue.cpp",
"TestTextFormatter.cpp",
"TestThreadManager.cpp",
- "TestThreadPool.cpp",
"TestThreadPoolListener.cpp",
+ "TestThreadUtils.cpp",
"TestThrottledEventQueue.cpp",
"TestTimeStamp.cpp",
"TestTokenizer.cpp",
@@ -75,24 +75,24 @@ UNIFIED_SOURCES += [
"TestVariant.cpp",
]
+# Bug 1894540 - Fails under TSAN
+if not CONFIG["MOZ_TSAN"]:
+ UNIFIED_SOURCES += [
+ "TestThreadPool.cpp",
+ ]
+
if CONFIG["OS_TARGET"] != "Android":
UNIFIED_SOURCES += [
"TestPipes.cpp",
"TestThreads.cpp",
]
-# skip the test on windows10-aarch64 due to perma-fail, bug 1422219
-if not (CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64"):
- UNIFIED_SOURCES += ["TestThreadUtils.cpp"]
-
# skip the test on OSX due to frequent failures (bug 1571186)
if CONFIG["OS_TARGET"] != "Darwin":
UNIFIED_SOURCES += ["TestExpirationTracker.cpp"]
# skip the test on windows10-aarch64 and Android, aarch64 due to bug 1545670
-if CONFIG["OS_TARGET"] != "Android" and not (
- CONFIG["OS_TARGET"] == "WINNT" and CONFIG["TARGET_CPU"] == "aarch64"
-):
+if CONFIG["OS_TARGET"] != "Android":
UNIFIED_SOURCES += ["TestTimers.cpp"]