[PATCH] Add fio_assert()
authorJens Axboe <jens.axboe@oracle.com>
Tue, 13 Feb 2007 16:39:56 +0000 (17:39 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Tue, 13 Feb 2007 16:39:56 +0000 (17:39 +0100)
A job must not call assert(), as it wont exit and set thread
state properly.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.h
io_u.c

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
diff --git a/io_u.c b/io_u.c
index 29c23f6f0a44a48abf2fb4ea1367b75ac4964f68..ae92df5d1a4d2559fe5d6c47be5d017529181f8f 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -3,7 +3,6 @@
 #include <string.h>
 #include <signal.h>
 #include <time.h>
 #include <string.h>
 #include <signal.h>
 #include <time.h>
-#include <assert.h>
 
 #include "fio.h"
 #include "os.h"
 
 #include "fio.h"
 #include "os.h"
@@ -45,7 +44,8 @@ static void mark_random_map(struct thread_data *td, struct fio_file *f,
                idx = RAND_MAP_IDX(td, f, block);
                bit = RAND_MAP_BIT(td, f, block);
 
                idx = RAND_MAP_IDX(td, f, block);
                bit = RAND_MAP_BIT(td, f, block);
 
-               assert(idx < f->num_maps);
+               idx = f->num_maps;
+               fio_assert(td, idx < f->num_maps);
 
                f->file_map[idx] |= (1UL << bit);
                block++;
 
                f->file_map[idx] |= (1UL << bit);
                block++;