aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPjotr Prins2018-07-26 23:36:18 +0000
committerPjotr Prins2018-07-26 23:36:18 +0000
commit15cf2344547bcd4d300aba22a96e9897153e50e1 (patch)
tree7f0b29d823f56cadebd99247ea7a8e4f97f5874b
parentd42329ed84e99f9ab351af291c42dbd06ca9cb59 (diff)
downloadpangemma-15cf2344547bcd4d300aba22a96e9897153e50e1.tar.gz
Unittest: added test for forcing and catching floating point errors (this works)
-rw-r--r--INSTALL.md2
-rw-r--r--src/gemma.cpp2
-rw-r--r--test/src/unittests-math.cpp31
3 files changed, 33 insertions, 2 deletions
diff --git a/INSTALL.md b/INSTALL.md
index 84ee942..f4cc046 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -66,7 +66,7 @@ Guix will make it easier in the future to deal with shared
graphs. Contact Pjotr Prins if you are really interested.
The following two links capture and provide the reproducible build
-system that we use for development of GEMMA:
+system that we use for development of GEMMA to generate /gnu/store/9ahrb1swr06kjm2gr2zg0fsyvps3xqgz-profile
1. https://gitlab.com/genenetwork/guix-bioinformatics/tree/99718d253ec9ed8ed836f0a348381a7cd83d4b9f
2. https://gitlab.com/genenetwork/guix/tree/686f5b9a8cdb66e81140b03a42644579e7eb1f9a
diff --git a/src/gemma.cpp b/src/gemma.cpp
index 4c7799a..809cd8e 100644
--- a/src/gemma.cpp
+++ b/src/gemma.cpp
@@ -2,7 +2,7 @@
Genome-wide Efficient Mixed Model Association (GEMMA)
Copyright © 2011-2017, Xiang Zhou
Copyright © 2017, Peter Carbonetto
- Copyright © 2017, Pjotr Prins
+ Copyright © 2017-2018, Pjotr Prins
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
diff --git a/test/src/unittests-math.cpp b/test/src/unittests-math.cpp
index 757c2dc..18e00f6 100644
--- a/test/src/unittests-math.cpp
+++ b/test/src/unittests-math.cpp
@@ -1,5 +1,6 @@
#include <catch.hpp>
#include <iostream>
+#include <fenv.h>
#include "gsl/gsl_matrix.h"
#include <cblas.h>
@@ -166,3 +167,33 @@ TEST_CASE("fast_dgemm", "[math]") {
REQUIRE(trunc(C[2003]) == -10627000400.0 );
}
+
+// The following code is normally disabled as it stops the unit tests!
+
+#ifdef TEST_SIGFPE
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <signal.h>
+
+void sighandler(int signum)
+{
+ printf("Process %d got signal %d\n", getpid(), signum);
+ signal(signum, SIG_DFL);
+ kill(getpid(), signum);
+}
+
+TEST_CASE("NaN handlers", "[math]") {
+
+ signal(SIGFPE, sighandler);
+ feenableexcept(FE_INVALID |
+ FE_DIVBYZERO |
+ FE_OVERFLOW |
+ FE_UNDERFLOW);
+ double dirty = 0.0;
+ double nanval= 0.0/dirty;
+ printf("Succeeded! dirty=%lf, nanval=%lf\n",dirty,nanval);
+}
+
+#endif // TEST_SIGFPE