test: Remove CDList memory limit test. (#7777)
authorMathias Preiner <mathias.preiner@gmail.com>
Thu, 9 Dec 2021 03:20:28 +0000 (19:20 -0800)
committerGitHub <noreply@github.com>
Thu, 9 Dec 2021 03:20:28 +0000 (03:20 +0000)
This test is of little usefulness and has issues with different platforms (mac) and architectures (arm64).

test/unit/context/cdlist_black.cpp
test/unit/memory.h [deleted file]

index a8d9f952b1fe0169a184b534094ea4450a4b0d6c..6bc48f9d036d6101034610857b43dd87abffb901 100644 (file)
@@ -20,7 +20,6 @@
 
 #include "base/exception.h"
 #include "context/cdlist.h"
-#include "memory.h"
 #include "test_context.h"
 
 namespace cvc5 {
@@ -135,25 +134,6 @@ TEST_F(TestContextBlackCDList, empty_iterator)
   list->deleteSelf();
 }
 
-TEST_F(TestContextBlackCDList, out_of_memory)
-{
-#ifndef CVC5_MEMORY_LIMITING_DISABLED
-  CDList<uint32_t> list(d_context.get());
-  test::WithLimitedMemory wlm(1);
-
-  ASSERT_THROW(
-      {
-        // We cap it at UINT32_MAX, preferring to terminate with a
-        // failure than run indefinitely.
-        for (uint32_t i = 0; i < UINT32_MAX; ++i)
-        {
-          list.push_back(i);
-        }
-      },
-      std::bad_alloc);
-#endif
-}
-
 TEST_F(TestContextBlackCDList, pop_below_level_created)
 {
   d_context->push();
diff --git a/test/unit/memory.h b/test/unit/memory.h
deleted file mode 100644 (file)
index 574488e..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/******************************************************************************
- * Top contributors (to current version):
- *   Tim King, Morgan Deters, Aina Niemetz
- *
- * This file is part of the cvc5 project.
- *
- * Copyright (c) 2009-2021 by the authors listed in the file AUTHORS
- * in the top-level source directory and their institutional affiliations.
- * All rights reserved.  See the file COPYING in the top-level source
- * directory for licensing information.
- * ****************************************************************************
- *
- * Utility class to help testing out-of-memory conditions.
- *
- * Use it like this (for example):
- *
- *   cvc5::test::WithLimitedMemory wlm(amount);
- *   ASSERT_THROW( foo(), bad_alloc );
- *
- * The WithLimitedMemory destructor will re-establish the previous limit.
- *
- * This class does not exist in CVC5_MEMORY_LIMITING_DISABLED is defined.
- * This can be disabled for a variety of reasons.
- */
-
-#include "test.h"
-
-#ifndef __CVC5__TEST__UNIT__MEMORY_H
-#define __CVC5__TEST__UNIT__MEMORY_H
-
-#include <string>
-#include <sys/resource.h>
-#include <sys/time.h>
-
-#include "base/check.h"
-#include "base/configuration_private.h"
-
-// Conditionally define CVC5_MEMORY_LIMITING_DISABLED.
-#ifdef __APPLE__
-#define CVC5_MEMORY_LIMITING_DISABLED 1
-#define CVC5_MEMORY_LIMITING_DISABLED_REASON "setrlimit() is broken on Mac."
-#else /* __APPLE__ */
-
-// Tests cannot expect bad_alloc to be thrown due to limit memory using
-// setrlimit when ASAN is enable. ASAN instead aborts on mmap failures.
-#  if IS_ASAN_BUILD
-#define CVC5_MEMORY_LIMITING_DISABLED 1
-#define CVC5_MEMORY_LIMITING_DISABLED_REASON "ASAN's mmap failures abort."
-#  endif
-#endif
-
-namespace cvc5 {
-namespace test {
-
-#ifndef CVC5_MEMORY_LIMITING_DISABLED
-class WithLimitedMemory {
- public:
-  WithLimitedMemory() { remember(); }
-
-  WithLimitedMemory(rlim_t amount) {
-    remember();
-    set(amount);
-  }
-
-  ~WithLimitedMemory() { set(d_prevAmount); }
-
-  void set(rlim_t amount) {
-    struct rlimit rlim;
-    rlim.rlim_cur = amount;
-    rlim.rlim_max = RLIM_INFINITY;
-    ASSERT_EQ(setrlimit(RLIMIT_AS, &rlim), 0);
-  }
-
- private:
-  void remember() {
-    struct rlimit rlim;
-    ASSERT_EQ(getrlimit(RLIMIT_AS, &rlim), 0);
-    d_prevAmount = rlim.rlim_cur;
-  }
-
-  rlim_t d_prevAmount;
-}; /* class WithLimitedMemory */
-#endif
-
-}  // namespace test
-}  // namespace cvc5
-
-// Remove CVC5_MEMORY_LIMITING_DISABLED_REASON if it is defined.
-#ifdef CVC5_MEMORY_LIMITING_DISABLED_REASON
-#undef CVC5_MEMORY_LIMITING_DISABLED_REASON
-#endif /* CVC5_MEMORY_LIMITING_DISABLED_REASON */
-
-#endif /* __CVC5__TEST__MEMORY_H */