model-assert: add MODEL_ASSERT() for user programs
[c11tester.git] / common.cc
index b274989f48bc4d885f6976b596139b1e5bde42ed..20102b0bba76ecee78f3491302b5768967c482a2 100644 (file)
--- a/common.cc
+++ b/common.cc
@@ -2,6 +2,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 
+#include <model-assert.h>
+
 #include "common.h"
 #include "model.h"
 #include "stacktrace.h"
@@ -40,3 +42,12 @@ void assert_hook(void)
 {
        printf("Add breakpoint to line %u in file %s.\n",__LINE__,__FILE__);
 }
+
+void model_assert(bool expr, const char *file, int line)
+{
+       if (!expr) {
+               printf("  [BUG] Program has hit assertion in file %s at line %d\n",
+                               file, line);
+               model->set_assert();
+       }
+}