From 5e7492abdffa6bc2f24d586673b1597080c6fe46 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Tue, 6 Feb 2018 23:37:20 -0600 Subject: [PATCH] Allow mutability if in testing --- src/vm_di.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/vm_di.c b/src/vm_di.c index 3201935..99d6ba0 100644 --- a/src/vm_di.c +++ b/src/vm_di.c @@ -10,6 +10,7 @@ * a value for a DI entry, it cannot be changed. */ +#include #include #include "log.h" @@ -22,15 +23,25 @@ */ static void *di_table[VM_DI_SIZE]; +#ifdef TESTING +static bool di_mutable = true; +#else +static bool di_mutable = false; +#endif + /* * Set the di table entry `ent` to `val`. If there is a _previous_ * value assigned to ent, then this returns ERR_INVALID, and no - * further assignment is allowed. + * further assignment is allowed. + * + * NOTE: in testing, we _do_ allow multiple assignments to entries, so + * as to make it easier to tear down and rebuild machines/cpus/etc. + * between tests. */ int vm_di_set(int ent, void *val) { - if (di_table[ent] != NULL) { + if (di_table[ent] != NULL && !di_mutable) { return ERR_INVALID; }