Add --parse-only command line option
authorJens Axboe <axboe@kernel.dk>
Thu, 7 Mar 2013 10:31:20 +0000 (11:31 +0100)
committerJens Axboe <axboe@kernel.dk>
Thu, 7 Mar 2013 10:31:20 +0000 (11:31 +0100)
Sometimes it's useful just being able to verify whether a job
config is valid or not, without actually starting any jobs.

Signed-off-by: Jens Axboe <axboe@kernel.dk>
README
init.c

diff --git a/README b/README
index b662e714d62bb6f88f3880c5b5607c52a31556b6..317ddec668ab7cba185cd75ce5a15878c4896c0d 100644 (file)
--- a/README
+++ b/README
@@ -134,6 +134,7 @@ Command line
 
 $ fio
        --debug                 Enable some debugging options (see below)
 
 $ fio
        --debug                 Enable some debugging options (see below)
+       --parse-only            Parse options only, don't start any IO
        --output                Write output to file
        --runtime               Runtime in seconds
        --latency-log           Generate per-job latency logs
        --output                Write output to file
        --runtime               Runtime in seconds
        --latency-log           Generate per-job latency logs
diff --git a/init.c b/init.c
index 32da42c5d8e4ba2ab86dbf4e2888cb7af05eb5ff..c7226887210363b9dbeb637420ae683458409c92 100644 (file)
--- a/init.c
+++ b/init.c
@@ -34,6 +34,7 @@ static char **ini_file;
 static int max_jobs = FIO_MAX_JOBS;
 static int dump_cmdline;
 static int def_timeout;
 static int max_jobs = FIO_MAX_JOBS;
 static int dump_cmdline;
 static int def_timeout;
+static int parse_only;
 
 static struct thread_data def_thread;
 struct thread_data *threads = NULL;
 
 static struct thread_data def_thread;
 struct thread_data *threads = NULL;
@@ -150,6 +151,11 @@ static struct option l_opts[FIO_NR_OPTIONS] = {
                .has_arg        = required_argument,
                .val            = 'd' | FIO_CLIENT_FLAG,
        },
                .has_arg        = required_argument,
                .val            = 'd' | FIO_CLIENT_FLAG,
        },
+       {
+               .name           = (char *) "parse-only",
+               .has_arg        = no_argument,
+               .val            = 'P' | FIO_CLIENT_FLAG,
+       },
        {
                .name           = (char *) "section",
                .has_arg        = required_argument,
        {
                .name           = (char *) "section",
                .has_arg        = required_argument,
@@ -817,7 +823,7 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
        /*
         * if we are just dumping the output command line, don't add the job
         */
        /*
         * if we are just dumping the output command line, don't add the job
         */
-       if (dump_cmdline) {
+       if (dump_cmdline || parse_only) {
                put_job(td);
                return 0;
        }
                put_job(td);
                return 0;
        }
@@ -1251,6 +1257,7 @@ static void usage(const char *name)
        printf("  --debug=options\tEnable debug logging. May be one/more of:\n"
                "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n"
                "\t\t\tdiskutil,job,mutex,profile,time,net\n");
        printf("  --debug=options\tEnable debug logging. May be one/more of:\n"
                "\t\t\tprocess,file,io,mem,blktrace,verify,random,parse,\n"
                "\t\t\tdiskutil,job,mutex,profile,time,net\n");
+       printf("  --parse-only\t\tParse options only, don't start any IO\n");
        printf("  --output\t\tWrite output to file\n");
        printf("  --runtime\t\tRuntime in seconds\n");
        printf("  --latency-log\t\tGenerate per-job latency logs\n");
        printf("  --output\t\tWrite output to file\n");
        printf("  --runtime\t\tRuntime in seconds\n");
        printf("  --latency-log\t\tGenerate per-job latency logs\n");
@@ -1528,6 +1535,9 @@ int parse_cmd_line(int argc, char *argv[])
                        if (set_debug(optarg))
                                do_exit++;
                        break;
                        if (set_debug(optarg))
                                do_exit++;
                        break;
+               case 'P':
+                       parse_only = 1;
+                       break;
                case 'x': {
                        size_t new_size;
 
                case 'x': {
                        size_t new_size;
 
@@ -1738,7 +1748,7 @@ int parse_options(int argc, char *argv[])
        fio_options_free(&def_thread);
 
        if (!thread_number) {
        fio_options_free(&def_thread);
 
        if (!thread_number) {
-               if (dump_cmdline)
+               if (dump_cmdline || parse_only)
                        return 0;
                if (exec_profile)
                        return 0;
                        return 0;
                if (exec_profile)
                        return 0;