1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 // Note: This file is essentially a copy of
8 // xpcom/tests/gtest/TestDeadlockDetector.cpp, but all mutexes were turned into
9 // SQLiteMutexes. We use #include and some macros to avoid actual source code
12 #include "mozilla/CondVar.h"
13 #include "mozilla/RecursiveMutex.h"
14 #include "mozilla/ReentrantMonitor.h"
15 #include "SQLiteMutex.h"
17 // We need this one so _gdb_sleep_duration is also in "storage" namespace
18 #include "mozilla/gtest/MozHelpers.h"
20 #include "gtest/gtest.h"
22 using namespace mozilla
;
25 * Helper class to allocate a sqlite3_mutex for our SQLiteMutex.
27 class TestMutex
: public mozilla::storage::SQLiteMutex
{
29 explicit TestMutex(const char* aName
)
30 : mozilla::storage::SQLiteMutex(aName
),
31 mInner(sqlite3_mutex_alloc(SQLITE_MUTEX_FAST
)) {
32 NS_ASSERTION(mInner
, "could not allocate a sqlite3_mutex");
33 initWithMutex(mInner
);
36 ~TestMutex() { sqlite3_mutex_free(mInner
); }
38 void Lock() { lock(); }
40 void Unlock() { unlock(); }
43 sqlite3_mutex
* mInner
;
46 // These are the two macros that differentiate this file from the XPCOM one.
47 #define MUTEX TestMutex
48 #define TESTNAME(name) storage_##name
50 // Bug 1473531: the test storage_DeadlockDetectorTest.storage_Sanity5DeathTest
51 // times out on macosx ccov builds
52 #if defined(XP_MACOSX) && defined(MOZ_CODE_COVERAGE)
53 # define DISABLE_STORAGE_SANITY5_DEATH_TEST
56 #include "../../../xpcom/tests/gtest/TestDeadlockDetector.cpp"