From 51167799022df58d45a99bbd7aa9cf81a47c46c9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Thu, 8 Mar 2012 21:34:18 +0100 Subject: [PATCH] Add basic cconv test Signed-off-by: Jens Axboe --- cconv.c | 22 ++++++++++++++++++++++ init.c | 4 ++++ thread_options.h | 1 + 3 files changed, 27 insertions(+) diff --git a/cconv.c b/cconv.c index f16e0d6a..3a1c6a20 100644 --- a/cconv.c +++ b/cconv.c @@ -1,3 +1,5 @@ +#include + #include "thread_options.h" static void string_to_cpu(char **dst, const uint8_t *src) @@ -372,3 +374,23 @@ void convert_thread_options_to_net(struct thread_options_pack *top, } +/* + * Basic conversion test. We'd really need to fill in more of the options + * to have a thorough test. Even better, we should auto-generate the + * converter functions... + */ +int fio_test_cconv(struct thread_options *__o) +{ + struct thread_options o; + struct thread_options_pack top1, top2; + + memset(&top1, 0, sizeof(top1)); + memset(&top2, 0, sizeof(top2)); + + convert_thread_options_to_net(&top1, __o); + memset(&o, 0, sizeof(o)); + convert_thread_options_to_cpu(&o, &top1); + convert_thread_options_to_net(&top2, &o); + + return memcmp(&top1, &top2, sizeof(top1)); +} diff --git a/init.c b/init.c index 0b57a9c2..e3d37380 100644 --- a/init.c +++ b/init.c @@ -1630,12 +1630,16 @@ int fio_init_options(void) return 0; } +extern int fio_check_options(struct thread_options *); + int parse_options(int argc, char *argv[]) { int job_files, i; if (fio_init_options()) return 1; + if (fio_test_cconv(&def_thread.o)) + log_err("fio: failed internal cconv test\n"); job_files = parse_cmd_line(argc, argv); diff --git a/thread_options.h b/thread_options.h index d46da31b..1193abeb 100644 --- a/thread_options.h +++ b/thread_options.h @@ -406,5 +406,6 @@ struct thread_options_pack { extern void convert_thread_options_to_cpu(struct thread_options *o, struct thread_options_pack *top); extern void convert_thread_options_to_net(struct thread_options_pack *top, struct thread_options *); +extern int fio_test_cconv(struct thread_options *); #endif -- 2.25.1