From 05c1e1c04090ec5121bd37213d9be7fc92c26f71 Mon Sep 17 00:00:00 2001 From: Matthieu Schaller <matthieu.schaller@durham.ac.uk> Date: Wed, 11 Oct 2017 14:37:14 +0200 Subject: [PATCH] Make the unit tests ignore FPEs if we can't activate them on this platform. Do not run the dump and logger tests if the file allocation POSIX functions don't exist. --- tests/test125cells.c | 4 +++- tests/test27cells.c | 4 +++- tests/testActivePair.c | 4 +++- tests/testDump.c | 8 ++++++++ tests/testLogger.c | 8 ++++++++ tests/testPeriodicBC.c | 4 +++- tests/testSymmetry.c | 4 +++- 7 files changed, 31 insertions(+), 5 deletions(-) diff --git a/tests/test125cells.c b/tests/test125cells.c index dbb3a7c3f5..7a9f02d1b2 100644 --- a/tests/test125cells.c +++ b/tests/test125cells.c @@ -469,8 +469,10 @@ int main(int argc, char *argv[]) { unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); - /* Choke on FP-exceptions */ +/* Choke on FP-exceptions */ +#ifdef HAVE_FE_ENABLE_EXCEPT feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif /* Get some randomness going */ srand(0); diff --git a/tests/test27cells.c b/tests/test27cells.c index 7ba1eec9ad..884c9f5c6b 100644 --- a/tests/test27cells.c +++ b/tests/test27cells.c @@ -316,8 +316,10 @@ int main(int argc, char *argv[]) { unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); - /* Choke on FP-exceptions */ +/* Choke on FP-exceptions */ +#ifdef HAVE_FE_ENABLE_EXCEPT feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif /* Get some randomness going */ srand(0); diff --git a/tests/testActivePair.c b/tests/testActivePair.c index 1e0111b4f0..1fb6b43481 100644 --- a/tests/testActivePair.c +++ b/tests/testActivePair.c @@ -393,8 +393,10 @@ int main(int argc, char *argv[]) { unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); - /* Choke on FP-exceptions */ +/* Choke on FP-exceptions */ +#ifdef HAVE_FE_ENABLE_EXCEPT feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif /* Generate a RNG seed from time. */ unsigned int seed = time(NULL); diff --git a/tests/testDump.c b/tests/testDump.c index 7343af49f6..ba85d41e60 100644 --- a/tests/testDump.c +++ b/tests/testDump.c @@ -20,6 +20,8 @@ /* Config parameters. */ #include "../config.h" +#ifdef HAVE_POSIX_FALLOCATE /* Are we on a sensible platform? */ + /* Some standard headers. */ #include <errno.h> #include <fcntl.h> @@ -85,3 +87,9 @@ int main(int argc, char *argv[]) { /* Return a happy number. */ return 0; } + +#else + +int main() { return 0; } + +#endif /* HAVE_POSIX_FALLOCATE */ diff --git a/tests/testLogger.c b/tests/testLogger.c index ec3b33b6a9..4c83f92180 100644 --- a/tests/testLogger.c +++ b/tests/testLogger.c @@ -20,6 +20,8 @@ /* Config parameters. */ #include "../config.h" +#ifdef HAVE_POSIX_FALLOCATE /* Are we on a sensible platform? */ + /* Some standard headers. */ #include <stdio.h> #include <stdlib.h> @@ -245,3 +247,9 @@ int main(int argc, char *argv[]) { printf("PASS\n"); return 0; } + +#else + +int main() { return 0; } + +#endif /* HAVE_POSIX_FALLOCATE */ diff --git a/tests/testPeriodicBC.c b/tests/testPeriodicBC.c index 1afe829ce7..ded767c5d6 100644 --- a/tests/testPeriodicBC.c +++ b/tests/testPeriodicBC.c @@ -391,8 +391,10 @@ int main(int argc, char *argv[]) { unsigned long long cpufreq = 0; clocks_set_cpufreq(cpufreq); - /* Choke on FP-exceptions */ +/* Choke on FP-exceptions */ +#ifdef HAVE_FE_ENABLE_EXCEPT feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif /* Get some randomness going */ srand(0); diff --git a/tests/testSymmetry.c b/tests/testSymmetry.c index 73c5708a6a..68a878b05c 100644 --- a/tests/testSymmetry.c +++ b/tests/testSymmetry.c @@ -28,8 +28,10 @@ int main(int argc, char *argv[]) { - /* Choke if need be */ +/* Choke on FPEs */ +#ifdef HAVE_FE_ENABLE_EXCEPT feenableexcept(FE_DIVBYZERO | FE_INVALID | FE_OVERFLOW); +#endif #if defined(SHADOWFAX_SPH) /* Initialize the Voronoi simulation box */ -- GitLab