assert bugs through common interface
[c11tester.git] / common.cc
index b274989f48bc4d885f6976b596139b1e5bde42ed..8b5c99717137d1d3f6a95b423fb6c8bf6fc2b08f 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,13 @@ 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) {
+               char msg[100];
+               sprintf(msg, "Program has hit assertion in file %s at line %d\n",
+                               file, line);
+               model->assert_bug(msg, true);
+       }
+}