summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/memory.c14
-rw-r--r--tests/mpfr-test.h3
-rw-r--r--tests/tversion.c5
3 files changed, 16 insertions, 6 deletions
diff --git a/tests/memory.c b/tests/memory.c
index 0a52b7799..640b2b5d9 100644
--- a/tests/memory.c
+++ b/tests/memory.c
@@ -40,9 +40,16 @@ struct header {
struct header *next;
};
+/* The memory limit can be changed with the MPFR_TESTS_MEMORY_LIMIT
+ environment variable. This is normally not necessary (a failure
+ would mean a bug), thus not recommended, for "make check". But
+ some test programs can take arguments for particular tests, which
+ may need more memory. This variable is exported, so that such
+ programs may also change the memory limit. */
+size_t tests_memory_limit = DEFAULT_MEMORY_LIMIT;
+
static struct header *tests_memory_list;
static size_t tests_total_size = 0;
-static size_t tests_memory_limit = 1UL << 22; /* default memory limit */
MPFR_LOCK_DECL(mpfr_lock_memory)
static void *
@@ -247,11 +254,6 @@ tests_memory_start (void)
tests_memory_list = NULL;
mp_set_memory_functions (tests_allocate, tests_reallocate, tests_free);
- /* The memory limit can be changed with the MPFR_TESTS_MEMORY_LIMIT
- environment variable. This is normally not necessary (a failure
- would mean a bug), thus not recommended, for "make check". But
- some test programs can take arguments for particular tests, which
- may need more memory. */
p = getenv ("MPFR_TESTS_MEMORY_LIMIT");
if (p != NULL)
{
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h
index 221375386..616ef4119 100644
--- a/tests/mpfr-test.h
+++ b/tests/mpfr-test.h
@@ -79,6 +79,9 @@ extern "C" {
int test_version (void);
+/* Memory handling */
+#define DEFAULT_MEMORY_LIMIT (1UL << 22)
+extern size_t tests_memory_limit;
void tests_memory_start (void);
void tests_memory_end (void);
diff --git a/tests/tversion.c b/tests/tversion.c
index b49eba0cd..6bd87d47b 100644
--- a/tests/tversion.c
+++ b/tests/tversion.c
@@ -219,6 +219,11 @@ main (void)
tests_start_mpfr ();
if (locale != NULL)
printf ("[tversion] Locale: %s\n", locale);
+ /* The memory limit should not be changed for "make check".
+ The warning below signals a possible user mistake. */
+ if (tests_memory_limit != DEFAULT_MEMORY_LIMIT)
+ printf ("[tversion] Warning! Memory limit changed to %zu\n",
+ tests_memory_limit);
tests_end_mpfr ();
return err;