]>
git.proxmox.com Git - ceph.git/blob - ceph/src/test/common/test_mutex.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
8 #include <common/Mutex.h>
9 #include "gtest/gtest.h"
10 #include "common/ceph_context.h"
11 #include "common/config.h"
12 #include "include/coredumpctl.h"
15 * Override normal ceph assert.
16 * It is needed to prevent hang when we assert() and THEN still wait on lock().
20 void __ceph_assert_fail(const char *assertion
, const char *file
, int line
,
27 static CephContext
* cct
;
29 static void do_init() {
31 cct
= new CephContext(0);
32 lockdep_register_ceph_context(cct
);
36 static void disable_lockdep() {
38 lockdep_unregister_ceph_context(cct
);
44 TEST(Mutex
, NormalAsserts
) {
45 Mutex
* m
= new Mutex("Normal",false);
47 EXPECT_THROW(m
->Lock(), int);
50 TEST(Mutex
, RecursiveWithLockdep
) {
52 Mutex
* m
= new Mutex("Recursive1",true);
60 TEST(Mutex
, RecursiveWithoutLockdep
) {
62 Mutex
* m
= new Mutex("Recursive2",true);
70 TEST(Mutex
, DeleteLocked
) {
71 Mutex
* m
= new Mutex("Recursive3",false);
74 EXPECT_DEATH(delete m
,".*");