[PATCH] Add fio_assert()
[fio.git] / fio.h
diff --git a/fio.h b/fio.h
index ddf66945d1b0e4cbbf84e6d5be7f830a73a93cfe..c0b92a6c6671b3afda65b5fca4499dd6eea71b6c 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -670,4 +670,12 @@ extern void close_ioengine(struct thread_data *);
 #define for_each_file(td, f, i)        \
        for ((i) = 0, (f) = &(td)->files[0]; (i) < (int) (td)->nr_files; (i)++, (f)++)
 
 #define for_each_file(td, f, i)        \
        for ((i) = 0, (f) = &(td)->files[0]; (i) < (int) (td)->nr_files; (i)++, (f)++)
 
+#define fio_assert(td, cond)   do {    \
+       if (!(cond)) {                  \
+               fprintf(stderr, "file:%s:%d, assert %s failed\n", __FILE__, __LINE__, #cond);   \
+               (td)->runstate = TD_EXITED;     \
+               exit(0);                        \
+       }       \
+} while (0)
+
 #endif
 #endif