summaryrefslogtreecommitdiffstats
path: root/storage/test/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 /storage/test/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 'storage/test/gtest')
-rw-r--r--storage/test/gtest/test_interruptSynchronousConnection.cpp33
1 files changed, 19 insertions, 14 deletions
diff --git a/storage/test/gtest/test_interruptSynchronousConnection.cpp b/storage/test/gtest/test_interruptSynchronousConnection.cpp
index dfa19bc86e..b29337e720 100644
--- a/storage/test/gtest/test_interruptSynchronousConnection.cpp
+++ b/storage/test/gtest/test_interruptSynchronousConnection.cpp
@@ -8,6 +8,7 @@
#include "storage_test_harness.h"
+#include "mozilla/Atomics.h"
#include "mozilla/SpinEventLoopUntil.h"
class SynchronousConnectionInterruptionTest : public ::testing::Test {
@@ -31,7 +32,9 @@ class SynchronousConnectionInterruptionTest : public ::testing::Test {
nsCOMPtr<nsIThread> mThread;
- bool mDone = false;
+ mozilla::Atomic<nsresult> mRv = mozilla::Atomic<nsresult>(NS_ERROR_FAILURE);
+
+ mozilla::Atomic<bool> mDone{false};
};
TEST_F(SynchronousConnectionInterruptionTest,
@@ -41,12 +44,11 @@ TEST_F(SynchronousConnectionInterruptionTest,
const uint32_t delayMs = 500;
ASSERT_EQ(NS_OK, mThread->DelayedDispatch(
- NS_NewRunnableFunction(
- "InterruptRunnable",
- [this]() {
- ASSERT_EQ(NS_OK, mConnection->Interrupt());
- mDone = true;
- }),
+ NS_NewRunnableFunction("InterruptRunnable",
+ [this]() {
+ mRv = mConnection->Interrupt();
+ mDone = true;
+ }),
delayMs));
const nsCString infiniteQuery =
@@ -56,10 +58,12 @@ TEST_F(SynchronousConnectionInterruptionTest,
nsCOMPtr<mozIStorageStatement> stmt;
ASSERT_EQ(NS_OK,
mConnection->CreateStatement(infiniteQuery, getter_AddRefs(stmt)));
+
ASSERT_EQ(NS_ERROR_ABORT, stmt->Execute());
ASSERT_EQ(NS_OK, stmt->Finalize());
ASSERT_TRUE(mDone);
+ ASSERT_EQ(NS_OK, mRv);
ASSERT_EQ(NS_OK, mConnection->Close());
}
@@ -67,15 +71,16 @@ TEST_F(SynchronousConnectionInterruptionTest,
TEST_F(SynchronousConnectionInterruptionTest, interruptAfterCloseWillFail) {
ASSERT_EQ(NS_OK, mConnection->Close());
- ASSERT_EQ(
- NS_OK,
- mThread->Dispatch(NS_NewRunnableFunction("InterruptRunnable", [this]() {
- ASSERT_EQ(NS_ERROR_NOT_INITIALIZED, mConnection->Interrupt());
- mDone = true;
- })));
+ ASSERT_EQ(NS_OK, mThread->Dispatch(
+ NS_NewRunnableFunction("InterruptRunnable", [this]() {
+ mRv = mConnection->Interrupt();
+ mDone = true;
+ })));
ASSERT_TRUE(mozilla::SpinEventLoopUntil("interruptAfterCloseWillFail"_ns,
- [this]() { return mDone; }));
+ [this]() -> bool { return mDone; }));
+
+ ASSERT_EQ(NS_ERROR_NOT_INITIALIZED, mRv);
ASSERT_EQ(NS_ERROR_NOT_INITIALIZED, mConnection->Close());
}