From 05a54ba38745d7130141e2d606ca5068b18d90fd Mon Sep 17 00:00:00 2001 From: svn_bwardell Date: Sun, 7 Aug 2011 12:40:58 +0000 Subject: Add code to test vectorisation macros. This is conditionally run dependent on the "tests" parameter which can take the values "report", "abort" or "skip". The default is "skip" which causes the tests not to run. git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/Vectors/trunk@18 105869f7-3296-0410-a4ea-f4349344b45a --- param.ccl | 7 +++++ schedule.ccl | 8 ++++++ src/make.code.defn | 2 +- src/test.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 src/test.c diff --git a/param.ccl b/param.ccl index dc5d37e..f785af9 100644 --- a/param.ccl +++ b/param.ccl @@ -1 +1,8 @@ # Parameter definitions for thorn Vectors + +KEYWORD tests "Whether to run correctness tests on startup." +{ + "report" :: "Run tests and report any which fail." + "abort" :: "Run tests and abort if any fail." + "skip" :: "Don't run tests." +} "skip" \ No newline at end of file diff --git a/schedule.ccl b/schedule.ccl index 7da984f..d6c06a9 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -4,3 +4,11 @@ schedule Vectors_Startup at CCTK_STARTUP { LANG: C } "Print startup message" + +if (CCTK_EQUALS(tests, "report") || CCTK_EQUALS(tests, "abort")) +{ + schedule Vectors_Test at CCTK_PARAMCHECK + { + LANG: C + } "Run correctness tests." +} diff --git a/src/make.code.defn b/src/make.code.defn index 15ba9a9..dea6494 100644 --- a/src/make.code.defn +++ b/src/make.code.defn @@ -1,7 +1,7 @@ # Main make.code.defn file for thorn Vectors # Source files in this directory -SRCS = vectors.c +SRCS = vectors.c test.c # Subdirectories containing source files SUBDIRS = diff --git a/src/test.c b/src/test.c new file mode 100644 index 0000000..6b95516 --- /dev/null +++ b/src/test.c @@ -0,0 +1,84 @@ +#include "cctk.h" +#include "cctk_Arguments.h" +#include "cctk_Parameters.h" +#include "vectors.h" +#include + +#define VECTEST(testname, vecexpr, scalarexpr) \ +{ \ + CCTK_REAL_VEC rv = vecexpr; \ + for(int i=0; i