[PATCH] Add option for terse parseable output
[fio.git] / init.c
diff --git a/init.c b/init.c
index de9cb4983a57d151ce444c03823b0beab7cfc6f3..40fcf1c35f61a5426648ee19dcfa9f680147bcf1 100644 (file)
--- a/init.c
+++ b/init.c
 #define DEF_RWMIX_READ         (50)
 #define DEF_NICE               (0)
 
-static int def_sequential = DEF_SEQUENTIAL;
-static int def_bs = DEF_BS;
 static int def_timeout = DEF_TIMEOUT;
-static int def_repeatable = DEF_RAND_REPEAT;
-static int def_odirect = DEF_ODIRECT;
 
 static char fio_version_string[] = "fio 1.4";
 
@@ -58,6 +54,7 @@ int rate_quit = 0;
 int write_lat_log = 0;
 int write_bw_log = 0;
 int exitall_on_terminate = 0;
+int terse_output = 0;
 unsigned long long mlock_size = 0;
 FILE *f_out = NULL;
 FILE *f_err = NULL;
@@ -137,9 +134,9 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
                char tmp[PATH_MAX];
 
                if (td->directory && td->directory[0] != '\0')
-                       sprintf(tmp, "%s/%s.%d", td->directory, jobname, td->jobnum);
+                       sprintf(tmp, "%s/%s.%d", td->directory, jobname, td->thread_number);
                else
-                       sprintf(tmp, "%s.%d", jobname, td->jobnum);
+                       sprintf(tmp, "%s.%d", jobname, td->thread_number);
                td->file_name = strdup(tmp);
        } else
                td->file_name = strdup(jobname);
@@ -177,10 +174,12 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
 
        ddir = td->ddir + (!td->sequential << 1) + (td->iomix << 2);
 
-       if (!job_add_num)
-               fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
-       else if (job_add_num == 1)
-               fprintf(f_out, "...\n");
+       if (!terse_output) {
+               if (!job_add_num)
+                       fprintf(f_out, "%s: (g=%d): rw=%s, odir=%d, bs=%d-%d, rate=%d, ioengine=%s, iodepth=%d\n", td->name, td->groupid, ddir_str[ddir], td->odirect, td->min_bs, td->max_bs, td->rate, td->io_engine_name, td->iodepth);
+               else if (job_add_num == 1)
+                       fprintf(f_out, "...\n");
+       }
 
        /*
         * recurse add identical jobs, clear numjobs and stonewall options
@@ -195,7 +194,6 @@ static int add_job(struct thread_data *td, const char *jobname, int job_add_num)
 
                td_new->numjobs = 1;
                td_new->stonewall = 0;
-               td_new->jobnum = numjobs;
                job_add_num = numjobs - 1;
 
                if (add_job(td_new, jobname, job_add_num))
@@ -233,7 +231,7 @@ int init_random_state(struct thread_data *td)
        if (td->sequential)
                return 0;
 
-       if (def_repeatable)
+       if (td->rand_repeatable)
                seeds[3] = DEF_RANDSEED;
 
        blocks = (td->io_size + td->min_bs - 1) / td->min_bs;
@@ -616,7 +614,7 @@ int parse_jobs_ini(char *file)
                /*
                 * Seperate multiple job files by a stonewall
                 */
-               if (stonewall) {
+               if (!global && stonewall) {
                        td->stonewall = stonewall;
                        stonewall = 0;
                }
@@ -656,6 +654,11 @@ int parse_jobs_ini(char *file)
                                fgetpos(f, &off);
                                continue;
                        }
+                       if (!check_int(p, "rand_repeatable", &il)) {
+                               td->rand_repeatable = il;
+                               fgetpos(f, &off);
+                               continue;
+                       }
                        if (!check_int(p, "rate", &td->rate)) {
                                fgetpos(f, &off);
                                continue;
@@ -925,14 +928,14 @@ static int fill_def_thread(void)
         */
        def_thread.ddir = DDIR_READ;
        def_thread.iomix = 0;
-       def_thread.bs = def_bs;
+       def_thread.bs = DEF_BS;
        def_thread.min_bs = -1;
        def_thread.max_bs = -1;
        def_thread.io_engine = DEF_IO_ENGINE;
        strcpy(def_thread.io_engine_name, DEF_IO_ENGINE_NAME);
-       def_thread.odirect = def_odirect;
+       def_thread.odirect = DEF_ODIRECT;
        def_thread.ratecycle = DEF_RATE_CYCLE;
-       def_thread.sequential = def_sequential;
+       def_thread.sequential = DEF_SEQUENTIAL;
        def_thread.timeout = def_timeout;
        def_thread.create_file = DEF_CREATE;
        def_thread.overwrite = DEF_OVERWRITE;
@@ -950,6 +953,7 @@ static int fill_def_thread(void)
        def_thread.rwmixcycle = DEF_RWMIX_CYCLE;
        def_thread.rwmixread = DEF_RWMIX_READ;
        def_thread.nice = DEF_NICE;
+       def_thread.rand_repeatable = DEF_RAND_REPEAT;
 #ifdef FIO_HAVE_DISK_UTIL
        def_thread.do_disk_util = 1;
 #endif
@@ -960,13 +964,11 @@ static int fill_def_thread(void)
 static void usage(char *name)
 {
        printf("%s\n", fio_version_string);
-       printf("\t-s IO is sequential\n");
-       printf("\t-b Block size in KiB for each IO\n");
+       printf("\t-o Write output to file\n");
        printf("\t-t Runtime in seconds\n");
-       printf("\t-R Exit all threads on failure to meet rate goal\n");
-       printf("\t-o Use O_DIRECT\n");
        printf("\t-l Generate per-job latency logs\n");
        printf("\t-w Generate per-job bandwidth logs\n");
+       printf("\t-m Minimal (terse) output\n");
        printf("\t-f Job file (Required)\n");
        printf("\t-v Print version info and exit\n");
 }
@@ -975,37 +977,12 @@ static int parse_cmd_line(int argc, char *argv[])
 {
        int c, idx = 1, ini_idx = 0;
 
-       while ((c = getopt(argc, argv, "s:b:t:r:R:o:f:lwvhO:")) != EOF) {
+       while ((c = getopt(argc, argv, "t:o:f:lwvhm")) != EOF) {
                switch (c) {
-                       case 's':
-                               def_sequential = !!atoi(optarg);
-                               idx++;
-                               break;
-                       case 'b':
-                               def_bs = atoi(optarg);
-                               def_bs <<= 10;
-                               if (!def_bs) {
-                                       printf("bad block size\n");
-                                       def_bs = DEF_BS;
-                               }
-                               idx++;
-                               break;
                        case 't':
                                def_timeout = atoi(optarg);
                                idx++;
                                break;
-                       case 'r':
-                               def_repeatable = !!atoi(optarg);
-                               idx++;
-                               break;
-                       case 'R':
-                               rate_quit = !!atoi(optarg);
-                               idx++;
-                               break;
-                       case 'o':
-                               def_odirect = !!atoi(optarg);
-                               idx++;
-                               break;
                        case 'f':
                                ini_idx++;
                                ini_file = realloc(ini_file, ini_idx * sizeof(char *));
@@ -1020,7 +997,7 @@ static int parse_cmd_line(int argc, char *argv[])
                                write_bw_log = 1;
                                idx++;
                                break;
-                       case 'O':
+                       case 'o':
                                f_out = fopen(optarg, "w+");
                                if (!f_out) {
                                        perror("fopen output");
@@ -1029,6 +1006,10 @@ static int parse_cmd_line(int argc, char *argv[])
                                f_err = f_out;
                                idx++;
                                break;
+                       case 'm':
+                               terse_output = 1;
+                               idx++;
+                               break;
                        case 'h':
                                usage(argv[0]);
                                exit(0);
@@ -1118,7 +1099,9 @@ int parse_options(int argc, char *argv[])
                        return 1;
                if (parse_jobs_ini(ini_file[i]))
                        return 1;
+               free(ini_file[i]);
        }
 
+       free(ini_file);
        return 0;
 }