• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

realm / realm-core / 1853

20 Nov 2023 07:46PM UTC coverage: 91.683% (-0.02%) from 91.699%
1853

push

Evergreen

web-flow
Fix client reset cycle detection for PBS recovery errors (#7149)

Tracking that a client reset was in progress was done in the same write
transaction as the recovery operation, so if recovery failed the tracking was
rolled back too. This worked for FLX due to that codepath committing before
beginning recovery.

92262 of 169120 branches covered (0.0%)

31 of 31 new or added lines in 3 files covered. (100.0%)

143 existing lines in 15 files now uncovered.

231277 of 252257 relevant lines covered (91.68%)

6495482.01 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.1
/src/realm/util/assert.hpp
1
/*************************************************************************
2
 *
3
 * Copyright 2016 Realm Inc.
4
 *
5
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 * you may not use this file except in compliance with the License.
7
 * You may obtain a copy of the License at
8
 *
9
 * http://www.apache.org/licenses/LICENSE-2.0
10
 *
11
 * Unless required by applicable law or agreed to in writing, software
12
 * distributed under the License is distributed on an "AS IS" BASIS,
13
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
 * See the License for the specific language governing permissions and
15
 * limitations under the License.
16
 *
17
 **************************************************************************/
18

19
#ifndef REALM_UTIL_ASSERT_HPP
20
#define REALM_UTIL_ASSERT_HPP
21

22
#include <realm/util/features.h>
23
#include <realm/util/terminate.hpp>
24

25
#if REALM_ENABLE_ASSERTIONS || defined(REALM_DEBUG)
26
#define REALM_ASSERTIONS_ENABLED 1
27
#else
28
#define REALM_ASSERTIONS_ENABLED 0
29
#endif
30

31
#define REALM_ASSERT_RELEASE(condition)                                                                              \
32
    (REALM_LIKELY(condition) ? static_cast<void>(0)                                                                  \
4,294,967,294✔
33
                             : realm::util::terminate("Assertion failed: " #condition, __FILE__, __LINE__))
4,294,967,294✔
34

35
#if REALM_ASSERTIONS_ENABLED
36
#define REALM_ASSERT(condition) REALM_ASSERT_RELEASE(condition)
4,294,967,294✔
37
#else
38
#define REALM_ASSERT(condition) static_cast<void>(sizeof bool(condition))
456✔
39
#endif
40

41
#ifdef REALM_DEBUG
42
#define REALM_ASSERT_DEBUG(condition) REALM_ASSERT_RELEASE(condition)
4,294,967,294✔
43
#else
44
#define REALM_ASSERT_DEBUG(condition) static_cast<void>(sizeof bool(condition))
342,096✔
45
#endif
46

47
#define REALM_STRINGIFY(X) #X
2,166,790,009✔
48

49
#define REALM_ASSERT_RELEASE_EX(condition, ...)                                                                      \
50
    (REALM_LIKELY(condition) ? static_cast<void>(0)                                                                  \
4,294,967,294✔
51
                             : realm::util::terminate_with_info("Assertion failed: " #condition, __LINE__, __FILE__, \
2,166,790,009✔
52
                                                                REALM_STRINGIFY((__VA_ARGS__)), __VA_ARGS__))
2,166,790,009✔
53

54
#ifdef REALM_DEBUG
55
#define REALM_ASSERT_DEBUG_EX REALM_ASSERT_RELEASE_EX
4,224,657,949✔
56
#else
57
#define REALM_ASSERT_DEBUG_EX(condition, ...) static_cast<void>(sizeof bool(condition))
135,066✔
58
#endif
59

60
// Becase the assert is used in noexcept methods, it's a bad idea to allocate
61
// buffer space for the message so therefore we must pass it to terminate which
62
// will 'cerr' it for us without needing any buffer
63
#if REALM_ENABLE_ASSERTIONS || defined(REALM_DEBUG)
64

65
#define REALM_ASSERT_EX REALM_ASSERT_RELEASE_EX
405,792,219✔
66

67
#define REALM_ASSERT_3(left, cmp, right)                                                                             \
68
    (REALM_LIKELY((left)cmp(right)) ? static_cast<void>(0)                                                           \
4,294,967,294✔
69
                                    : realm::util::terminate("Assertion failed: "                                    \
2,159,074,575✔
70
                                                             "" #left " " #cmp " " #right,                           \
21,329,575✔
71
                                                             __FILE__, __LINE__, left, right))
21,329,575✔
72

73
#define REALM_ASSERT_7(left1, cmp1, right1, logical, left2, cmp2, right2)                                            \
74
    (REALM_LIKELY(((left1)cmp1(right1))logical((left2)cmp2(right2)))                                                 \
98,654,640✔
75
         ? static_cast<void>(0)                                                                                      \
98,650,515✔
76
         : realm::util::terminate("Assertion failed: "                                                               \
49,212,723✔
77
                                  "" #left1 " " #cmp1 " " #right1 " " #logical " "                                   \
16,500✔
78
                                  "" #left2 " " #cmp2 " " #right2,                                                   \
16,500✔
79
                                  __FILE__, __LINE__, left1, right1, left2, right2))
16,500✔
80

81
#define REALM_ASSERT_11(left1, cmp1, right1, logical1, left2, cmp2, right2, logical2, left3, cmp3, right3)           \
82
    (REALM_LIKELY(((left1)cmp1(right1))logical1((left2)cmp2(right2)) logical2((left3)cmp3(right3)))                  \
361,086✔
83
         ? static_cast<void>(0)                                                                                      \
361,086✔
84
         : realm::util::terminate("Assertion failed: "                                                               \
191,829✔
UNCOV
85
                                  "" #left1 " " #cmp1 " " #right1 " " #logical1 " "                                  \
×
UNCOV
86
                                  "" #left2 " " #cmp2 " " #right2 " " #logical2 " "                                  \
×
UNCOV
87
                                  "" #left3 " " #cmp3 " " #right3,                                                   \
×
UNCOV
88
                                  __FILE__, __LINE__, left1, right1, left2, right2, left3, right3))
×
89
#else
90
#define REALM_ASSERT_EX(condition, ...) static_cast<void>(sizeof bool(condition))
91
#define REALM_ASSERT_3(left, cmp, right) static_cast<void>(sizeof bool((left)cmp(right)))
92
#define REALM_ASSERT_7(left1, cmp1, right1, logical, left2, cmp2, right2)                                            \
93
    static_cast<void>(sizeof bool(((left1)cmp1(right1))logical((left2)cmp2(right2))))
94
#define REALM_ASSERT_11(left1, cmp1, right1, logical1, left2, cmp2, right2, logical2, left3, cmp3, right3)           \
95
    static_cast<void>(sizeof bool(((left1)cmp1(right1))logical1((left2)cmp2(right2)) logical2((left3)cmp3(right3))))
96
#endif
97

98
#define REALM_UNREACHABLE() realm::util::terminate("Unreachable code", __FILE__, __LINE__)
99
#ifdef REALM_COVER
100
#define REALM_COVER_NEVER(x) false
101
#define REALM_COVER_ALWAYS(x) true
102
#else
103
#define REALM_COVER_NEVER(x) (x)
118,628,199✔
104
#define REALM_COVER_ALWAYS(x) (x)
105
#endif
106

107
#endif // REALM_UTIL_ASSERT_HPP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc