2525
2626#include " encoding.h"
2727
28+ /* strict_mode_assert is a standard ceph_assert() in product code. Some tests
29+ * (specifically test_interval_set.cc) can override this macro with an
30+ * exception.
31+ */
32+ #ifndef strict_mode_assert
33+ #define strict_mode_assert (expr ) ceph_assert(expr)
34+ #endif
35+
2836/*
2937 * *** NOTE ***
3038 *
@@ -362,7 +370,7 @@ class interval_set {
362370
363371 auto start = std::max<T>(ps->first , pl->first );
364372 auto en = std::min<T>(ps->first + ps->second , offset);
365- ceph_assert (en > start);
373+ strict_mode_assert (en > start);
366374 mi = m.emplace_hint (mi, start, en - start);
367375 _size += mi->second ;
368376 if (ps->first + ps->second <= offset) {
@@ -556,7 +564,7 @@ class interval_set {
556564
557565 if (p->first + p->second != start) {
558566 // cout << "p is " << p->first << "~" << p->second << ", start is " << start << ", len is " << len << endl;
559- ceph_abort ( );
567+ strict_mode_assert ( false );
560568 }
561569
562570 p->second += len; // append to end
@@ -572,7 +580,7 @@ class interval_set {
572580 *plen = p->second ;
573581 m.erase (n);
574582 } else {
575- ceph_assert (n == m.end () || start + len < n->first );
583+ strict_mode_assert (n == m.end () || start + len < n->first );
576584 if (plen)
577585 *plen = p->second ;
578586 }
@@ -586,7 +594,7 @@ class interval_set {
586594 m.erase (p);
587595 m[start] = len + psecond; // append to front
588596 } else {
589- ceph_assert (p->first > start+len);
597+ strict_mode_assert (p->first > start+len);
590598 if (pstart)
591599 *pstart = start;
592600 if (plen)
@@ -677,11 +685,11 @@ class interval_set {
677685
678686 _size -= len;
679687
680- ceph_assert (p != m.end ());
681- ceph_assert (p->first <= start);
688+ strict_mode_assert (p != m.end ());
689+ strict_mode_assert (p->first <= start);
682690
683691 T before = start - p->first ;
684- ceph_assert (p->second >= before+len);
692+ strict_mode_assert (p->second >= before+len);
685693 T after = p->second - before - len;
686694 if (before) {
687695 if (claim && claim (p->first , before)) {
@@ -999,4 +1007,5 @@ struct denc_traits<interval_set<T, C>> {
9991007template <typename T, template <typename , typename , typename ...> class C , bool strict>
10001008struct fmt ::is_range<interval_set<T, C, strict>, char > : std::false_type {};
10011009
1010+ #undef strict_mode_assert
10021011#endif
0 commit comments