Add debug helper stub for t/ programs
authorJens Axboe <axboe@fb.com>
Fri, 26 Sep 2014 15:58:29 +0000 (09:58 -0600)
committerJens Axboe <axboe@fb.com>
Fri, 26 Sep 2014 15:58:29 +0000 (09:58 -0600)
Signed-off-by: Jens Axboe <axboe@fb.com>
Makefile
t/debug.c [new file with mode: 0644]
t/debug.h [new file with mode: 0644]
t/dedupe.c
t/lfsr-test.c
t/stest.c

index ee7f05a6802742b018e4b4a391bab160952a3c1b..d93ce7809af6f7d8fc477c8ac4e49317541556fc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -164,7 +164,7 @@ GFIO_OBJS = $(OBJS) gfio.o graph.o tickmarks.o ghelpers.o goptions.o gerror.o \
 -include $(OBJS:.o=.d)
 
 T_SMALLOC_OBJS = t/stest.o
-T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o
+T_SMALLOC_OBJS += gettime.o mutex.o smalloc.o t/log.o t/debug.o
 T_SMALLOC_PROGS = t/stest
 
 T_IEEE_OBJS = t/ieee754.o
@@ -180,7 +180,7 @@ T_AXMAP_OBJS += lib/lfsr.o lib/axmap.o
 T_AXMAP_PROGS = t/axmap
 
 T_LFSR_TEST_OBJS = t/lfsr-test.o
-T_LFSR_TEST_OBJS += lib/lfsr.o
+T_LFSR_TEST_OBJS += lib/lfsr.o gettime.o t/log.o t/debug.o
 T_LFSR_TEST_PROGS = t/lfsr-test
 
 ifeq ($(CONFIG_TARGET_OS), Linux)
@@ -192,7 +192,7 @@ endif
 ifeq ($(CONFIG_TARGET_OS), Linux)
 T_DEDUPE_OBJS = t/dedupe.o
 T_DEDUPE_OBJS += lib/rbtree.o t/log.o mutex.o smalloc.o gettime.o crc/md5.o \
-               memalign.o lib/bloom.o
+               memalign.o lib/bloom.o t/debug.o
 T_DEDUPE_PROGS = t/dedupe
 endif
 
diff --git a/t/debug.c b/t/debug.c
new file mode 100644 (file)
index 0000000..c297d61
--- /dev/null
+++ b/t/debug.c
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+FILE *f_err;
+struct timeval *fio_tv = NULL;
+unsigned int fio_debug = 0;
+
+void __dprint(int type, const char *str, ...)
+{
+}
+
+void debug_init(void)
+{
+       f_err = stderr;
+}
diff --git a/t/debug.h b/t/debug.h
new file mode 100644 (file)
index 0000000..9d1d415
--- /dev/null
+++ b/t/debug.h
@@ -0,0 +1,6 @@
+#ifndef FIO_DEBUG_INC_H
+#define FIO_DEBUG_INC_H
+
+extern void debug_init(void);
+
+#endif
index ac5d7f2d4b3a42975f43e1eaabd143f661480b74..3ae17242f4a741bf2ccefd818f4fc8aeea3e6bc4 100644 (file)
 #include "../fio_time.h"
 
 #include "../lib/bloom.h"
-
-FILE *f_err;
-struct timeval *fio_tv = NULL;
-unsigned int fio_debug = 0;
-
-void __dprint(int type, const char *str, ...)
-{
-}
+#include "debug.h"
 
 struct worker_thread {
        pthread_t thread;
@@ -518,6 +511,8 @@ int main(int argc, char *argv[])
        uint64_t nextents, nchunks;
        int c, ret;
 
+       debug_init();
+
        while ((c = getopt(argc, argv, "b:t:d:o:c:p:B:")) != -1) {
                switch (c) {
                case 'b':
index 481f37e8ddf640322764f66ff9d549d665803bcb..2eee0c648e50aad5b3264f7407bc858dd4ad70cc 100644 (file)
@@ -86,12 +86,12 @@ int main(int argc, char *argv[])
         * negligible overhead.
         */
        fprintf(stderr, "\nTest initiated... ");
-       clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &start);
+       fio_gettime(&start, NULL);
        while (!lfsr_next(fl, &i, fl->max_val)) {
                if (verify)
                        *(uint8_t *)(v + i) += 1;
        }
-       clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &end);
+       fio_gettime(&end, NULL);
        fprintf(stderr, "finished.\n");
 
 
index 0da8f2cf8670aad2cef31de9b0abedd5e86f1f93..efb256efa92d106fe1902de36a5bcdfcf4e1adf7 100644 (file)
--- a/t/stest.c
+++ b/t/stest.c
@@ -4,10 +4,7 @@
 
 #include "../smalloc.h"
 #include "../flist.h"
-
-FILE *f_err;
-struct timeval *fio_tv = NULL;
-unsigned int fio_debug = 0;
+#include "debug.h"
 
 #define MAGIC1 0xa9b1c8d2
 #define MAGIC2 0xf0a1e9b3
@@ -72,9 +69,8 @@ static int do_specific_alloc(unsigned long size)
 
 int main(int argc, char *argv[])
 {
-       f_err = stderr;
-
        sinit();
+       debug_init();
 
        do_rand_allocs();
 
@@ -84,7 +80,3 @@ int main(int argc, char *argv[])
        scleanup();
        return 0;
 }
-
-void __dprint(int type, const char *str, ...)
-{
-}