From f02ccb2663070e74d780bb2e01b0df502bdad8b5 Mon Sep 17 00:00:00 2001 From: svn_bwardell Date: Sun, 7 Aug 2011 12:43:08 +0000 Subject: Unconditionally run tests and abort if any fail. git-svn-id: https://svn.cct.lsu.edu/repos/numrel/LSUThorns/Vectors/trunk@23 105869f7-3296-0410-a4ea-f4349344b45a --- param.ccl | 7 ------- schedule.ccl | 9 +++------ src/test.c | 15 +++++++-------- 3 files changed, 10 insertions(+), 21 deletions(-) diff --git a/param.ccl b/param.ccl index f785af9..dc5d37e 100644 --- a/param.ccl +++ b/param.ccl @@ -1,8 +1 @@ # 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 d6c06a9..54e71b6 100644 --- a/schedule.ccl +++ b/schedule.ccl @@ -5,10 +5,7 @@ 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 { - schedule Vectors_Test at CCTK_PARAMCHECK - { - LANG: C - } "Run correctness tests." -} + LANG: C +} "Run correctness tests." diff --git a/src/test.c b/src/test.c index 6b95516..7360a60 100644 --- a/src/test.c +++ b/src/test.c @@ -13,7 +13,7 @@ if(vecres == res) \ passed++; \ else \ - CCTK_VWarn(warnlevel, __LINE__, __FILE__, \ + CCTK_VWarn(CCTK_WARN_ALERT, __LINE__, __FILE__, \ CCTK_THORNSTRING, "Failed test %s", testname); \ numtests++; \ } \ @@ -24,12 +24,6 @@ void Vectors_Test(CCTK_ARGUMENTS) DECLARE_CCTK_ARGUMENTS; DECLARE_CCTK_PARAMETERS; - int warnlevel; - if (CCTK_EQUALS(tests, "abort")) - warnlevel = CCTK_WARN_ABORT; - else - warnlevel = CCTK_WARN_ALERT; - CCTK_INT passed = 0, numtests=0; CCTK_REAL a[CCTK_REAL_VEC_SIZE]; @@ -79,6 +73,11 @@ void Vectors_Test(CCTK_ARGUMENTS) VECTEST("kifthen 0", kifthen(ToReal(0.),bv,cv), signbit(0.)?c[i]:b[i]); VECTEST("kifthen -0", kifthen(ToReal(-0.),bv,cv), signbit(-0.)?c[i]:b[i]); - CCTK_VInfo(CCTK_THORNSTRING, "%d/%d tests passed ", passed, numtests); + if (passed != numtests) + CCTK_VWarn(CCTK_WARN_ABORT, __LINE__, __FILE__, CCTK_THORNSTRING, + "Failed %d correctness tests", numtests - passed); + else + CCTK_VInfo(CCTK_THORNSTRING, "%d/%d tests passed ", passed, numtests); + return; } -- cgit v1.2.3