From daaf1d291363cdb19e17f296d0a52bba3ea88d3d Mon Sep 17 00:00:00 2001
From: Josh Borrow <joshua.borrow@durham.ac.uk>
Date: Mon, 15 Oct 2018 20:24:43 +0100
Subject: [PATCH] Initialised artificial viscosity variables in the  cell tests

---
 src/cache.h          |  1 +
 tests/test125cells.c | 10 +++++++---
 tests/test27cells.c  |  4 ++++
 tests/testCbrt.c     |  1 +
 4 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/cache.h b/src/cache.h
index 77f933cc54..5dd8164b1d 100644
--- a/src/cache.h
+++ b/src/cache.h
@@ -834,6 +834,7 @@ static INLINE void cache_clean(struct cache *c) {
     free(c->balsara);
     free(c->soundspeed);
   }
+  c->count = 0;
 }
 
 #endif /* WITH_VECTORIZATION */
diff --git a/tests/test125cells.c b/tests/test125cells.c
index 0b52bf6873..3d7d5458f1 100644
--- a/tests/test125cells.c
+++ b/tests/test125cells.c
@@ -590,6 +590,7 @@ int main(int argc, char *argv[]) {
   prog_const.const_newton_G = 1.f;
 
   struct hydro_props hp;
+  hydro_props_init_no_hydro(&hp);
   hp.eta_neighbours = h;
   hp.h_tolerance = 1e0;
   hp.h_max = FLT_MAX;
@@ -675,8 +676,8 @@ int main(int argc, char *argv[]) {
 /* Initialise the particle cache. */
 #ifdef WITH_VECTORIZATION
     runner.ci_cache.count = 0;
-    cache_init(&runner.ci_cache, 512);
     runner.cj_cache.count = 0;
+    cache_init(&runner.ci_cache, 512);
     cache_init(&runner.cj_cache, 512);
 #endif
 
@@ -724,8 +725,8 @@ int main(int argc, char *argv[]) {
 
 #ifdef WITH_VECTORIZATION
     /* Initialise the cache. */
-    runner.ci_cache.count = 0;
-    runner.cj_cache.count = 0;
+    cache_clean(&runner.ci_cache);
+    cache_clean(&runner.cj_cache);
     cache_init(&runner.ci_cache, 512);
     cache_init(&runner.cj_cache, 512);
 #endif
@@ -890,5 +891,8 @@ int main(int argc, char *argv[]) {
   for (int i = 0; i < 125; ++i) clean_up(cells[i]);
   free(solution);
 
+  cache_clean(&runner.ci_cache);
+  cache_clean(&runner.cj_cache);
+
   return 0;
 }
diff --git a/tests/test27cells.c b/tests/test27cells.c
index 0ba724c7da..92a36d7dcd 100644
--- a/tests/test27cells.c
+++ b/tests/test27cells.c
@@ -456,6 +456,7 @@ int main(int argc, char *argv[]) {
   space.dim[2] = 3.;
 
   struct hydro_props hp;
+  hydro_props_init_no_hydro(&hp);
   hp.eta_neighbours = h;
   hp.h_tolerance = 1e0;
   hp.h_max = FLT_MAX;
@@ -615,5 +616,8 @@ int main(int argc, char *argv[]) {
   /* Clean things to make the sanitizer happy ... */
   for (int i = 0; i < 27; ++i) clean_up(cells[i]);
 
+  cache_clean(&runner.ci_cache);
+  cache_clean(&runner.cj_cache);
+
   return 0;
 }
diff --git a/tests/testCbrt.c b/tests/testCbrt.c
index b608f9a00d..3663e0e19a 100644
--- a/tests/testCbrt.c
+++ b/tests/testCbrt.c
@@ -125,5 +125,6 @@ int main(int argc, char *argv[]) {
   message("x * icbrtf   took %9.3f %s (acc = %18.11e).",
           clocks_from_ticks(getticks() - tic_ours), clocks_getunit(), acc_ours);
 
+  free(data);
   return 0;
 }
-- 
GitLab