summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorvlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2008-01-23 16:51:02 +0000
committervlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4>2008-01-23 16:51:02 +0000
commitd51026fa23e79fd7062795d794ac21dcd0eaaa0f (patch)
treee72d115acfd759fbe9a1d9682752cdc445f4510e /tests
parent372bab0d95b3dbf02db0a8ccc98efb4d3ecc4f17 (diff)
downloadmpfr-d51026fa23e79fd7062795d794ac21dcd0eaaa0f.tar.gz
Test that the MPFR library version matches the mpfr.h version in any
test file (this should avoid some bug reports that don't mention the real problem). git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@5224 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tests')
-rw-r--r--tests/mpfr-test.h2
-rw-r--r--tests/tests.c28
-rw-r--r--tests/tversion.c32
3 files changed, 39 insertions, 23 deletions
diff --git a/tests/mpfr-test.h b/tests/mpfr-test.h
index 089e4aaa9..f76cd3dbb 100644
--- a/tests/mpfr-test.h
+++ b/tests/mpfr-test.h
@@ -58,6 +58,8 @@ MA 02110-1301, USA. */
extern "C" {
#endif
+void test_version _MPFR_PROTO ((void));
+
void tests_memory_start _MPFR_PROTO ((void));
void tests_memory_end _MPFR_PROTO ((void));
diff --git a/tests/tests.c b/tests/tests.c
index 3dab5d5b2..fc64fb94e 100644
--- a/tests/tests.c
+++ b/tests/tests.c
@@ -100,8 +100,36 @@ void (*dummy_func)(mpfr_srcptr) = mpfr_dump;
#endif
void
+test_version (void)
+{
+ const char *version;
+
+ /* VL: I get the following error on an OpenSUSE machine, and changing
+ the value of shlibpath_overrides_runpath in the libtool file from
+ 'no' to 'yes' fixes the problem. */
+
+ version = mpfr_get_version ();
+ if (strcmp (MPFR_VERSION_STRING, version) == 0)
+ return;
+
+ printf ("Incorrect MPFR version! (%s header vs %s library)\n\n"
+ "Nothing else has been tested since for this reason,\n"
+ "any other test may fail. Please fix this one first.\n\n"
+ "You can try to avoid this problem by changing the value of\n"
+ "shlibpath_overrides_runpath in the libtool file and rebuild\n"
+ "MPFR (make clean && make && make check).\n"
+ "Otherwise this error may be due to a corrupted mpfr.h, an\n"
+ "incomplete build (try to rebuild MPFR from scratch and/or\n"
+ "use 'make clean'), or something wrong in the system.\n",
+ MPFR_VERSION_STRING, version);
+ exit (1);
+}
+
+void
tests_start_mpfr (void)
{
+ test_version ();
+
/* don't buffer, so output is not lost if a test causes a segv etc */
setbuf (stdout, NULL);
diff --git a/tests/tversion.c b/tests/tversion.c
index 1120d1957..9bc5d7b0b 100644
--- a/tests/tversion.c
+++ b/tests/tversion.c
@@ -26,31 +26,14 @@ MA 02110-1301, USA. */
#include "mpfr-test.h"
-static void
-err (int d, const char *shdr, const char *slib)
-{
- /* VL: I get the following error on an OpenSUSE machine, and changing
- the value of shlibpath_overrides_runpath in the libtool file from
- 'no' to 'yes' fixes the problem. */
- printf ("Incorrect MPFR version [%d] (%s header vs %s library)!\n"
- "For this reason, other tests may fail. "
- "Please fix this one first.\n\n"
- "You can try to avoid this problem by changing the value of\n"
- "shlibpath_overrides_runpath in the libtool file and rebuild\n"
- "MPFR (make clean && make && make check).\n"
- "Otherwise this error may be due to a corrupted mpfr.h, an\n"
- "incomplete build (try to rebuild MPFR from scratch and/or\n"
- "use 'make clean'), or something wrong in the system.\n",
- d, shdr, slib);
- exit (1);
-}
-
int
main (void)
{
char buffer[256];
const char *version;
+ test_version ();
+
version = mpfr_get_version ();
/* This test is disabled when a suffix (e.g. -dev) has been defined. */
@@ -58,12 +41,15 @@ main (void)
sprintf (buffer, "%d.%d.%d", MPFR_VERSION_MAJOR, MPFR_VERSION_MINOR,
MPFR_VERSION_PATCHLEVEL);
if (strcmp (buffer, version) != 0)
- err (1, buffer, version);
+ {
+ /* All the other problems should have been detected by test_version. */
+ printf ("Incorrect MPFR version! (%s header vs %s library)\n"
+ "This error should have never occurred and may be due "
+ "to a corrupted 'mpfr.h'.\n", buffer, version);
+ exit (1);
+ }
#endif
- if (strcmp (MPFR_VERSION_STRING, version) != 0)
- err (2, MPFR_VERSION_STRING, version);
-
if (__GNU_MP_VERSION_PATCHLEVEL != 0)
sprintf (buffer, "%d.%d.%d", __GNU_MP_VERSION, __GNU_MP_VERSION_MINOR,
__GNU_MP_VERSION_PATCHLEVEL);