From 9077ee4ae85d3a4519f99372b884ec7d9fd3e781 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 26 Sep 2014 09:58:29 -0600 Subject: [PATCH] Add debug helper stub for t/ programs Signed-off-by: Jens Axboe --- Makefile | 6 +++--- t/debug.c | 14 ++++++++++++++ t/debug.h | 6 ++++++ t/dedupe.c | 11 +++-------- t/lfsr-test.c | 4 ++-- t/stest.c | 12 ++---------- 6 files changed, 30 insertions(+), 23 deletions(-) create mode 100644 t/debug.c create mode 100644 t/debug.h diff --git a/Makefile b/Makefile index ee7f05a6..d93ce780 100644 --- 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 index 00000000..c297d615 --- /dev/null +++ b/t/debug.c @@ -0,0 +1,14 @@ +#include + +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 index 00000000..9d1d4150 --- /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 diff --git a/t/dedupe.c b/t/dedupe.c index ac5d7f2d..3ae17242 100644 --- a/t/dedupe.c +++ b/t/dedupe.c @@ -28,14 +28,7 @@ #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': diff --git a/t/lfsr-test.c b/t/lfsr-test.c index 481f37e8..2eee0c64 100644 --- a/t/lfsr-test.c +++ b/t/lfsr-test.c @@ -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"); diff --git a/t/stest.c b/t/stest.c index 0da8f2cf..efb256ef 100644 --- 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, ...) -{ -} -- 2.25.1