diff options
author | Tim King <taking@google.com> | 2016-11-07 13:38:53 -0800 |
---|---|---|
committer | Tim King <taking@google.com> | 2016-11-07 13:38:53 -0800 |
commit | edcaaa68d802f2c58eedee94d494737b12c11acc (patch) | |
tree | fbe3f6e91e29024a4c9287c432c896e31d5a3d82 /test/unit/context | |
parent | d9608e29789960cd50704689d39e9a35d01be321 (diff) |
Disabling out of memory tests unit tests when ASAN is enabled. ASAN failures are too hard for the unit testing framework.
Diffstat (limited to 'test/unit/context')
-rw-r--r-- | test/unit/context/cdlist_black.h | 60 | ||||
-rw-r--r-- | test/unit/context/cdlist_context_memory_black.h | 78 | ||||
-rw-r--r-- | test/unit/context/cdvector_black.h | 3 |
3 files changed, 63 insertions, 78 deletions
diff --git a/test/unit/context/cdlist_black.h b/test/unit/context/cdlist_black.h index 8929e8fb4..f4231ac91 100644 --- a/test/unit/context/cdlist_black.h +++ b/test/unit/context/cdlist_black.h @@ -16,18 +16,17 @@ #include <cxxtest/TestSuite.h> -#include <iostream> #include <limits.h> +#include <iostream> #include <vector> #include "base/exception.h" -#include "context/context.h" #include "context/cdlist.h" +#include "context/context.h" #include "memory.h" using namespace std; using namespace CVC4::context; -using namespace CVC4::test; using namespace CVC4; struct DtorSensitiveObject { @@ -37,19 +36,13 @@ struct DtorSensitiveObject { }; class CDListBlack : public CxxTest::TestSuite { -private: - + private: Context* d_context; -public: + public: + void setUp() { d_context = new Context(); } - void setUp() { - d_context = new Context(); - } - - void tearDown() { - delete d_context; - } + void tearDown() { delete d_context; } // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 @@ -69,21 +62,19 @@ public: CDList<int> list(d_context, callDestructor); TS_ASSERT(list.empty()); - for(int i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) { TS_ASSERT_EQUALS(list.size(), unsigned(i)); list.push_back(i); TS_ASSERT(!list.empty()); TS_ASSERT_EQUALS(list.back(), i); int i2 = 0; - for(CDList<int>::const_iterator j = list.begin(); - j != list.end(); - ++j) { + for (CDList<int>::const_iterator j = list.begin(); j != list.end(); ++j) { TS_ASSERT_EQUALS(*j, i2++); } } TS_ASSERT_EQUALS(list.size(), unsigned(N)); - for(int i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) { TS_ASSERT_EQUALS(list[i], i); } } @@ -132,30 +123,31 @@ public: } void testEmptyIterator() { - CDList<int>* list = new(true) CDList<int>(d_context); + CDList<int>* list = new (true) CDList<int>(d_context); TS_ASSERT_EQUALS(list->begin(), list->end()); list->deleteSelf(); } - /* setrlimit() totally broken on Mac OS X */ void testOutOfMemory() { -#ifdef __APPLE__ +#ifdef CVC4_MEMORY_LIMITING_DISABLED - TS_WARN("can't run memory tests on Mac OS X"); + test::WarnWithLimitedMemoryDisabledReason(); -#else /* __APPLE__ */ +#else /* CVC4_MEMORY_LIMITING_DISABLED */ CDList<unsigned> list(d_context); - WithLimitedMemory wlm(1); - - TS_ASSERT_THROWS({ - // We cap it at UINT_MAX, preferring to terminate with a - // failure than run indefinitely. - for(unsigned i = 0; i < UINT_MAX; ++i) { - list.push_back(i); - } - }, bad_alloc); - -#endif /* __APPLE__ */ + test::WithLimitedMemory wlm(1); + + TS_ASSERT_THROWS( + { + // We cap it at UINT_MAX, preferring to terminate with a + // failure than run indefinitely. + for (unsigned i = 0; i < UINT_MAX; ++i) { + list.push_back(i); + } + }, + bad_alloc); + +#endif /* CVC4_MEMORY_LIMITING_DISABLED */ } }; diff --git a/test/unit/context/cdlist_context_memory_black.h b/test/unit/context/cdlist_context_memory_black.h index a43d34b00..dccdd528e 100644 --- a/test/unit/context/cdlist_context_memory_black.h +++ b/test/unit/context/cdlist_context_memory_black.h @@ -16,19 +16,18 @@ #include <cxxtest/TestSuite.h> -#include <vector> #include <iostream> +#include <vector> #include <limits.h> #include "memory.h" -#include "context/context.h" #include "context/cdchunk_list.h" +#include "context/context.h" using namespace std; using namespace CVC4::context; -using namespace CVC4::test; struct DtorSensitiveObject { bool& d_dtorCalled; @@ -37,19 +36,13 @@ struct DtorSensitiveObject { }; class CDListContextMemoryBlack : public CxxTest::TestSuite { -private: - + private: Context* d_context; -public: + public: + void setUp() { d_context = new Context(); } - void setUp() { - d_context = new Context(); - } - - void tearDown() { - delete d_context; - } + void tearDown() { delete d_context; } // test at different sizes. this triggers grow() behavior differently. // grow() was completely broken in revision 256 @@ -66,34 +59,32 @@ public: } void listTest(int N, bool callDestructor) { - CDChunkList<int> - list(d_context, callDestructor, ContextMemoryAllocator<int>(d_context->getCMM())); + CDChunkList<int> list(d_context, callDestructor, + ContextMemoryAllocator<int>(d_context->getCMM())); TS_ASSERT(list.empty()); - for(int i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) { TS_ASSERT_EQUALS(list.size(), unsigned(i)); list.push_back(i); TS_ASSERT(!list.empty()); TS_ASSERT_EQUALS(list.back(), i); int i2 = 0; - for(CDChunkList<int>::const_iterator j = list.begin(); - j != list.end(); - ++j) { + for (CDChunkList<int>::const_iterator j = list.begin(); j != list.end(); + ++j) { TS_ASSERT_EQUALS(*j, i2++); } } TS_ASSERT_EQUALS(list.size(), unsigned(N)); - for(int i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) { TS_ASSERT_EQUALS(list[i], i); } } void testEmptyIterator() { - CDChunkList< int>* list = - new(d_context->getCMM()) - CDChunkList< int >(true, d_context, false, - ContextMemoryAllocator<int>(d_context->getCMM())); + CDChunkList<int>* list = new (d_context->getCMM()) + CDChunkList<int>(true, d_context, false, + ContextMemoryAllocator<int>(d_context->getCMM())); TS_ASSERT_EQUALS(list->begin(), list->end()); } @@ -104,8 +95,12 @@ public: bool shouldAlsoRemainFalse = false; bool aThirdFalse = false; - CDChunkList<DtorSensitiveObject> listT(d_context, true, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); - CDChunkList<DtorSensitiveObject> listF(d_context, false, ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); + CDChunkList<DtorSensitiveObject> listT( + d_context, true, + ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); + CDChunkList<DtorSensitiveObject> listF( + d_context, false, + ContextMemoryAllocator<DtorSensitiveObject>(d_context->getCMM())); DtorSensitiveObject shouldRemainFalseDSO(shouldRemainFalse); DtorSensitiveObject shouldFlipToTrueDSO(shouldFlipToTrue); @@ -140,25 +135,26 @@ public: TS_ASSERT_EQUALS(aThirdFalse, false); } - /* setrlimit() totally broken on Mac OS X */ void testOutOfMemory() { -#ifdef __APPLE__ +#ifdef CVC4_MEMORY_LIMITING_DISABLED - TS_WARN("can't run memory tests on Mac OS X"); + CVC4::test::WarnWithLimitedMemoryDisabledReason(); -#else /* __APPLE__ */ +#else /* CVC4_MEMORY_LIMITING_DISABLED */ CDChunkList<unsigned> list(d_context); - WithLimitedMemory wlm(1); - - TS_ASSERT_THROWS({ - // We cap it at UINT_MAX, preferring to terminate with a - // failure than run indefinitely. - for(unsigned i = 0; i < UINT_MAX; ++i) { - list.push_back(i); - } - }, bad_alloc); - -#endif /* __APPLE__ */ + CVC4::test::WithLimitedMemory wlm(1); + + TS_ASSERT_THROWS( + { + // We cap it at UINT_MAX, preferring to terminate with a + // failure than run indefinitely. + for (unsigned i = 0; i < UINT_MAX; ++i) { + list.push_back(i); + } + }, + bad_alloc); + +#endif /* CVC4_MEMORY_LIMITING_DISABLED */ } }; diff --git a/test/unit/context/cdvector_black.h b/test/unit/context/cdvector_black.h index 4b47c0660..e806ca712 100644 --- a/test/unit/context/cdvector_black.h +++ b/test/unit/context/cdvector_black.h @@ -22,14 +22,11 @@ #include <limits.h> -#include "memory.h" - #include "context/context.h" #include "context/cdvector.h" using namespace std; using namespace CVC4::context; -using namespace CVC4::test; struct DtorSensitiveObject { bool& d_dtorCalled; |