genfio: Don't use cat EOF for small prints
[fio.git] / tools / genfio
index 3f9ab283840a54bef1c1ae2ef70bf2e1ccc7d759..0bc24cb1d475e43d413b50c3c488cd6ae14c6865 100755 (executable)
@@ -65,6 +65,8 @@ show_help() {
 -x prefix                      : Add a prefix to the fio filename
                                        Useful to let a context associated with the file
                                        If the prefix features a / (slash), prefix will be considered as a directory
+-A cmd_to_run                  : System command to run after each job (exec_postrun in fio)
+-B cmd_to_run                  : System command to run before each job (exec_prerun in fio)
 
 Example:
 
@@ -90,21 +92,15 @@ EOF
 }
 
 finish_template() {
-cat >>$TEMPLATE <<EOF
-iodepth=$IODEPTH
-EOF
+echo "iodepth=$IODEPTH" >> $TEMPLATE
 
 if [ "$RUNTIME" != "0" ]; then
-cat >>$TEMPLATE << EOF
-runtime=$RUNTIME
-time_based
-EOF
+       echo "runtime=$RUNTIME" >> $TEMPLATE
+       echo "time_based" >> $TEMPLATE
 fi
 
 if [ "$CACHED_IO" = "FALSE" ]; then
-cat >>$TEMPLATE << EOF
-direct=1
-EOF
+       echo "direct=1" >> $TEMPLATE
 fi
 }
 
@@ -189,7 +185,7 @@ esac
 }
 
 parse_cmdline() {
-while getopts "hacpsd:b:r:m:x:D:" opt; do
+while getopts "hacpsd:b:r:m:x:D:A:B:" opt; do
   case $opt in
     h)
        show_help
@@ -239,6 +235,12 @@ while getopts "hacpsd:b:r:m:x:D:" opt; do
     a)
        SEQ=2
       ;;
+    B)
+       echo "exec_prerun=$OPTARG" >> $TEMPLATE
+      ;;
+    A)
+       echo "exec_postrun=$OPTARG" >> $TEMPLATE
+      ;;
     \?)
       echo "Invalid option: -$OPTARG" >&2
       ;;