Add basic cconv test
authorJens Axboe <axboe@kernel.dk>
Thu, 8 Mar 2012 20:34:18 +0000 (21:34 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 8 Mar 2012 20:34:18 +0000 (21:34 +0100)
Signed-off-by: Jens Axboe <axboe@kernel.dk>
cconv.c
init.c
thread_options.h

diff --git a/cconv.c b/cconv.c
index f16e0d6a90b80dc7c5cabde2f1baeab03fee68e4..3a1c6a201704d6a26ef0cccea43919f267905873 100644 (file)
--- a/cconv.c
+++ b/cconv.c
@@ -1,3 +1,5 @@
+#include <string.h>
+
 #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 0b57a9c238565e27be1cd0d3454732a3c1b0f135..e3d373803931fbe5c5554bb4b32784223c907884 100644 (file)
--- 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);
 
index d46da31b706e31dbd7a131ec2da372e4a060ce10..1193abeb9f48065ccae7e0cabde6f30dae41de4a 100644 (file)
@@ -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